84 lines
3.2 KiB
EmacsLisp
84 lines
3.2 KiB
EmacsLisp
(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory))
|
|
(load-file (expand-file-name "setup-packages.el" (concat user-emacs-directory "lisp")))
|
|
|
|
|
|
(custom-set-variables
|
|
;; custom-set-variables was added by Custom.
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
;; Your init file should contain only one such instance.
|
|
;; If there is more than one, they won't work right.
|
|
;; '(custom-enabled-themes '(tango-dark)) ;; Use a themes that available by emacs
|
|
'(package-selected-packages nil) )
|
|
(custom-set-faces
|
|
;; custom-set-faces was added by Custom.
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
;; Your init file should contain only one such instance.
|
|
;; If there is more than one, they won't work right.
|
|
)
|
|
|
|
; Custom themes that I download from internet
|
|
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
|
|
(load-theme 'dracula t)
|
|
(add-to-list 'default-frame-alist '(background-color . "unspecified-bg"))
|
|
|
|
; make backup to a designated dir, mirroring the full path
|
|
(defun xah-backup-nested-dir-file-path (Fpath)
|
|
"Return a new file path and create dirs.
|
|
If the new path's directories does not exist, create them.
|
|
version 2022-06-09"
|
|
(let* ($backupRoot $backupFilePath)
|
|
(setq $backupRoot "~/.emacs.d/backup/")
|
|
;; remove Windows driver letter in path, e.g. C:
|
|
(setq $backupFilePath
|
|
(format "%s%s~" $backupRoot (replace-regexp-in-string "^[A-Za-z]:/" "" Fpath)))
|
|
(make-directory
|
|
(file-name-directory $backupFilePath)
|
|
(file-name-directory $backupFilePath))
|
|
$backupFilePath
|
|
))
|
|
(setq make-backup-file-name-function 'xah-backup-nested-dir-file-path)
|
|
|
|
; disable backup
|
|
; (setq backup-inhibited t)
|
|
|
|
; disable auto save
|
|
(setq auto-save-default nil)
|
|
|
|
;; Enable line numbers globally
|
|
(global-display-line-numbers-mode t)
|
|
;; Disable line numbers for Treemacs
|
|
(add-hook 'treemacs-mode-hook (lambda () (display-line-numbers-mode 0)))
|
|
|
|
;; Clipboard integration (Not work in terminal)
|
|
(setq select-enable-clipboard t)
|
|
(setq select-enable-primary t)
|
|
|
|
;; Clipboard integration for terminal (Need xclip)
|
|
(when (not (display-graphic-p)) ;; Check if Emacs is running in the terminal
|
|
(defun my-copy-to-clipboard ()
|
|
"Copy region to clipboard using xclip."
|
|
(interactive)
|
|
(if (use-region-p)
|
|
(let ((text (buffer-substring-no-properties (region-beginning) (region-end))))
|
|
(with-temp-buffer
|
|
(insert text)
|
|
(call-process-region (point-min) (point-max) "xclip" nil 0 nil "-selection" "clipboard"))
|
|
(message "Copied to clipboard"))
|
|
(message "No region selected.")))
|
|
|
|
(global-set-key (kbd "C-c M-w") 'my-copy-to-clipboard))
|
|
|
|
|
|
;; For example, set the default tab width to 4 spaces
|
|
(setq-default tab-width 4)
|
|
;; For Python mode, set the indentation style
|
|
(add-hook 'python-mode-hook
|
|
(lambda ()
|
|
(setq indent-tabs-mode nil) ; Use spaces instead of tabs
|
|
(setq python-indent-offset 4) )) ; Set the indentation offset
|
|
;; For JavaScript mode, set the indentation style
|
|
(add-hook 'js-mode-hook
|
|
(lambda ()
|
|
(setq indent-tabs-mode nil) ; Use spaces instead of tabs
|
|
(setq js-indent-level 4))) ; Set the indentation offset
|