diff --git a/config/backup.el b/config/backup.el new file mode 100644 index 0000000..4d6400c --- /dev/null +++ b/config/backup.el @@ -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) + diff --git a/config/clipboard.el b/config/clipboard.el new file mode 100644 index 0000000..20b0c23 --- /dev/null +++ b/config/clipboard.el @@ -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."))))) diff --git a/config/editor.el b/config/editor.el new file mode 100644 index 0000000..bfe4a5a --- /dev/null +++ b/config/editor.el @@ -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 diff --git a/config/keybinding.el b/config/keybinding.el new file mode 100644 index 0000000..6ed694b --- /dev/null +++ b/config/keybinding.el @@ -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 " ) 'mc/mark-next-like-this ) +(global-set-key (kbd "C-c " ) '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 ) diff --git a/lisp/setup-packages.el b/config/packages.el similarity index 54% rename from lisp/setup-packages.el rename to config/packages.el index 9352ce7..1e6222b 100644 --- a/lisp/setup-packages.el +++ b/config/packages.el @@ -17,25 +17,9 @@ (treemacs-follow-mode t) ;; Enable follow mode (setq treemacs-show-hidden-files t) ;; Show hidden files (optional) (treemacs-fringe-indicator-mode t) ;; Show fringe indicators - (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 ) - ) + (treemacs-git-mode 'deferred)) ;; Enable Git integration -(use-package multiple-cursors - :ensure t - :config - ;(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) - (global-set-key (kbd "C-c ") 'mc/mark-next-like-this) - (global-set-key (kbd "C-c ") 'mc/mark-previous-like-this) - ;(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this) - ;(global-set-key (kbd "C-S-") 'mc/add-cursor-on-click) - ) +(use-package multiple-cursors :ensure t) (use-package highlight-indent-guides :ensure t @@ -51,3 +35,4 @@ :ensure t :config (global-company-mode t)) + diff --git a/config/ui.el b/config/ui.el new file mode 100644 index 0000000..b9d178f --- /dev/null +++ b/config/ui.el @@ -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 diff --git a/init.el b/init.el index b998f93..745ae40 100644 --- a/init.el +++ b/init.el @@ -1,14 +1,17 @@ -(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"))) -(load-file (expand-file-name "setup-ui.el" (concat user-emacs-directory "lisp"))) +(add-to-list 'load-path (expand-file-name "config" user-emacs-directory)) +(load-file (expand-file-name "packages.el" (concat user-emacs-directory "config"))) +(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 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) ) + '(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. @@ -16,76 +19,3 @@ ;; 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 diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..40e61a9 --- /dev/null +++ b/install.sh @@ -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 diff --git a/lisp/setup-ui.el b/lisp/setup-ui.el deleted file mode 100644 index d5736ee..0000000 --- a/lisp/setup-ui.el +++ /dev/null @@ -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