Major change for tidy-up the config
This commit is contained in:
		
							parent
							
								
									1a1a42f4ec
								
							
						
					
					
						commit
						5e9486f011
					
				
							
								
								
									
										23
									
								
								config/backup.el
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								config/backup.el
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					; 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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										36
									
								
								config/clipboard.el
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								config/clipboard.el
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					;; 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-cut-to-clipboard ()
 | 
				
			||||||
 | 
					    "Cut 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"))
 | 
				
			||||||
 | 
					          (delete-region (region-beginning) (region-end))
 | 
				
			||||||
 | 
					          (message "Cut to clipboard"))
 | 
				
			||||||
 | 
					      (message "No region selected.")))
 | 
				
			||||||
 | 
					  (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.")))
 | 
				
			||||||
 | 
					  (defun my-paste-from-clipboard ()
 | 
				
			||||||
 | 
					  "Paste clipboard content using xclip."
 | 
				
			||||||
 | 
					  (interactive)
 | 
				
			||||||
 | 
					  (let ((clipboard-text (with-temp-buffer
 | 
				
			||||||
 | 
					                          (process-file "xclip" nil t nil "-selection" "clipboard" "-o")
 | 
				
			||||||
 | 
					                          (buffer-string))))
 | 
				
			||||||
 | 
					    (if clipboard-text
 | 
				
			||||||
 | 
					        (progn (insert clipboard-text) (message "Paste from clipboard") )
 | 
				
			||||||
 | 
					      (message "Clipboard is empty or xclip is not working.")))))
 | 
				
			||||||
							
								
								
									
										17
									
								
								config/editor.el
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								config/editor.el
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					;; 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
 | 
				
			||||||
 | 
					;; For HTML mode, set the indentation style
 | 
				
			||||||
 | 
					(add-hook 'html-mode-hook
 | 
				
			||||||
 | 
					          (lambda ()
 | 
				
			||||||
 | 
					            (setq indent-tabs-mode nil) ; Use spaces instead of tabs
 | 
				
			||||||
 | 
					            (setq js-indent-level 4))) ; Set the indentation offset
 | 
				
			||||||
							
								
								
									
										11
									
								
								config/keybinding.el
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								config/keybinding.el
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					(global-set-key (kbd "C-c \\"      ) 'treemacs                    ) ;; Tree Toggle
 | 
				
			||||||
 | 
					(global-set-key (kbd "C-c C-\\"    ) 'treemacs-select-window      ) ;; Tree Focus
 | 
				
			||||||
 | 
					(global-set-key (kbd "C-c M-`"     ) 'treemacs-edit-workspaces    )
 | 
				
			||||||
 | 
					(global-set-key (kbd "C-c TAB"     ) 'treemacs-next-workspace     )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(global-set-key (kbd "C-c <down>"  ) 'mc/mark-next-like-this      )
 | 
				
			||||||
 | 
					(global-set-key (kbd "C-c <up>"    ) 'mc/mark-previous-like-this  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(global-set-key (kbd "C-c C-w"     ) 'my-cut-to-clipboard         )
 | 
				
			||||||
 | 
					(global-set-key (kbd "C-c M-w"     ) 'my-copy-to-clipboard        )
 | 
				
			||||||
 | 
					(global-set-key (kbd "C-c C-y"     ) 'my-paste-from-clipboard     )
 | 
				
			||||||
@ -17,25 +17,9 @@
 | 
				
			|||||||
  (treemacs-follow-mode t)            ;; Enable follow mode
 | 
					  (treemacs-follow-mode t)            ;; Enable follow mode
 | 
				
			||||||
  (setq treemacs-show-hidden-files t) ;; Show hidden files (optional)
 | 
					  (setq treemacs-show-hidden-files t) ;; Show hidden files (optional)
 | 
				
			||||||
  (treemacs-fringe-indicator-mode t)  ;; Show fringe indicators
 | 
					  (treemacs-fringe-indicator-mode t)  ;; Show fringe indicators
 | 
				
			||||||
  (treemacs-git-mode 'deferred)       ;; Enable Git integration
 | 
					  (treemacs-git-mode 'deferred))      ;; Enable Git integration
 | 
				
			||||||
  (global-set-key (kbd "C-c \\"   ) 'treemacs                    ) ;; Tree Toggle
 | 
					 | 
				
			||||||
  (global-set-key (kbd "C-c C-\\" ) 'treemacs-select-window      ) ;; Tree Focus
 | 
					 | 
				
			||||||
  (global-set-key (kbd "C-c M-`"  ) 'treemacs-edit-workspaces    )
 | 
					 | 
				
			||||||
  (global-set-key (kbd "C-c TAB"  ) 'treemacs-next-workspace     )
 | 
					 | 
				
			||||||
  ;(global-set-key (kbd "M-`"      ) 'treemacs-switch-workspace   )
 | 
					 | 
				
			||||||
  ;(global-set-key (kbd "C-x w ."  ) 'treemacs-next-workspace     )
 | 
					 | 
				
			||||||
  ;(global-set-key (kbd "C-x w ,"  ) 'treemacs-previous-workspace )
 | 
					 | 
				
			||||||
  )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
(use-package multiple-cursors
 | 
					(use-package multiple-cursors :ensure t)
 | 
				
			||||||
  :ensure t
 | 
					 | 
				
			||||||
  :config
 | 
					 | 
				
			||||||
  ;(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
 | 
					 | 
				
			||||||
  (global-set-key (kbd "C-c <down>") 'mc/mark-next-like-this)
 | 
					 | 
				
			||||||
  (global-set-key (kbd "C-c <up>") 'mc/mark-previous-like-this)
 | 
					 | 
				
			||||||
  ;(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
 | 
					 | 
				
			||||||
  ;(global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click)
 | 
					 | 
				
			||||||
  )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
(use-package highlight-indent-guides
 | 
					(use-package highlight-indent-guides
 | 
				
			||||||
  :ensure t
 | 
					  :ensure t
 | 
				
			||||||
@ -51,3 +35,4 @@
 | 
				
			|||||||
  :ensure t
 | 
					  :ensure t
 | 
				
			||||||
  :config
 | 
					  :config
 | 
				
			||||||
  (global-company-mode t))
 | 
					  (global-company-mode t))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										8
									
								
								config/ui.el
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								config/ui.el
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					(setq tab-bar-show 1) ;; Show the tab bar only when more than one tab exists.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(global-display-line-numbers-mode t) ;; Display line numbers
 | 
				
			||||||
 | 
					(add-hook 'treemacs-mode-hook (lambda () (display-line-numbers-mode 0))) ;; Disable line numbers for Treemacs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") ;; Custom themes that I download from internet
 | 
				
			||||||
 | 
					(load-theme 'dracula t)
 | 
				
			||||||
 | 
					(add-to-list 'default-frame-alist '(background-color . "unspecified-bg")) ;; The background will follow the terminal background
 | 
				
			||||||
							
								
								
									
										84
									
								
								init.el
									
									
									
									
									
								
							
							
						
						
									
										84
									
								
								init.el
									
									
									
									
									
								
							@ -1,13 +1,16 @@
 | 
				
			|||||||
(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory))
 | 
					(add-to-list 'load-path (expand-file-name "config" user-emacs-directory))
 | 
				
			||||||
(load-file (expand-file-name "setup-packages.el" (concat user-emacs-directory "lisp")))
 | 
					(load-file (expand-file-name "packages.el"   (concat user-emacs-directory "config")))
 | 
				
			||||||
(load-file (expand-file-name "setup-ui.el"       (concat user-emacs-directory "lisp")))
 | 
					(load-file (expand-file-name "ui.el"         (concat user-emacs-directory "config")))
 | 
				
			||||||
 | 
					(load-file (expand-file-name "backup.el"     (concat user-emacs-directory "config")))
 | 
				
			||||||
 | 
					(load-file (expand-file-name "clipboard.el"  (concat user-emacs-directory "config")))
 | 
				
			||||||
 | 
					(load-file (expand-file-name "editor.el"     (concat user-emacs-directory "config")))
 | 
				
			||||||
 | 
					(load-file (expand-file-name "keybinding.el" (concat user-emacs-directory "config"))) ;; Always put keybinding at the end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(custom-set-variables
 | 
					(custom-set-variables
 | 
				
			||||||
 ;; custom-set-variables was added by Custom.
 | 
					 ;; custom-set-variables was added by Custom.
 | 
				
			||||||
 ;; If you edit it by hand, you could mess it up, so be careful.
 | 
					 ;; If you edit it by hand, you could mess it up, so be careful.
 | 
				
			||||||
 ;; Your init file should contain only one such instance.
 | 
					 ;; Your init file should contain only one such instance.
 | 
				
			||||||
 ;; If there is more than one, they won't work right.
 | 
					 ;; 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))
 | 
					 '(package-selected-packages nil))
 | 
				
			||||||
(custom-set-faces
 | 
					(custom-set-faces
 | 
				
			||||||
 ;; custom-set-faces was added by Custom.
 | 
					 ;; custom-set-faces was added by Custom.
 | 
				
			||||||
@ -16,76 +19,3 @@
 | 
				
			|||||||
 ;; If there is more than one, they won't work right.
 | 
					 ;; 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)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
;; 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-cut-to-clipboard ()
 | 
					 | 
				
			||||||
    "Cut 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"))
 | 
					 | 
				
			||||||
          (delete-region (region-beginning) (region-end))
 | 
					 | 
				
			||||||
          (message "Cut to clipboard"))
 | 
					 | 
				
			||||||
      (message "No region selected.")))
 | 
					 | 
				
			||||||
  (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 C-w") 'my-cut-to-clipboard)
 | 
					 | 
				
			||||||
  (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
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										23
									
								
								install.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								install.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					sudo apt-get update
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sudo apt-get install git
 | 
				
			||||||
 | 
					sudo apt-get install autoconf
 | 
				
			||||||
 | 
					sudo apt-get install texinfo # makeinfo >= 4.13
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# X development libraries and GTK+
 | 
				
			||||||
 | 
					sudo apt-get install libx11-dev libxpm-dev libxft-dev libxext-dev libxt-dev
 | 
				
			||||||
 | 
					# GTK+ and image libraries
 | 
				
			||||||
 | 
					sudo apt-get install libgtk-3-dev libtiff-dev libgif-dev libjpeg-dev libpng-dev libxpm-dev
 | 
				
			||||||
 | 
					# Additional Optional Packages
 | 
				
			||||||
 | 
					sudo apt-get install libncurses-dev libgnutls28-dev libxml2-dev
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Clipboard integration for terminal
 | 
				
			||||||
 | 
					sudo apt-get install xclip
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					git clone https://git.savannah.gnu.org/git/emacs.git
 | 
				
			||||||
 | 
					cd emacs
 | 
				
			||||||
 | 
					make
 | 
				
			||||||
 | 
					sudo make install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# .emacs.d
 | 
				
			||||||
 | 
					git clone https://gitea.ditaajipratama.net/aji/emacs.d.git ~/.emacs.d
 | 
				
			||||||
@ -1,4 +0,0 @@
 | 
				
			|||||||
(tab-bar-mode 1)
 | 
					 | 
				
			||||||
(setq tab-bar-show 1) ;; Show the tab bar only when more than one tab exists.
 | 
					 | 
				
			||||||
(global-display-line-numbers-mode t)
 | 
					 | 
				
			||||||
(add-hook 'treemacs-mode-hook (lambda () (display-line-numbers-mode 0))) ; Disable line numbers for Treemacs
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user