diff options
-rw-r--r-- | .emacs.d/init.el | 127 | ||||
-rw-r--r-- | .emacs.d/rul-emacs.org | 143 |
2 files changed, 167 insertions, 103 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 2fc32fb..c708afb 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -4,35 +4,24 @@ (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) -;; Do not persist customizations -(setq custom-file (make-temp-file "emacs-custom-")) - -;; Place backups in ~/.backups/ directory, like a civilized program. -;; ------ (if (file-directory-p "~/.backup") (setq backup-directory-alist '(("." . "~/.backup"))) (message "Directory does not exist: ~/.backup")) -(filesets-init) +(setq + backup-by-copying t ; Don't delink hardlinks + delete-old-versions t ; Clean up the backups + kept-new-versions 3 ; keep some new versions + kept-old-versions 2 ; and some old ones, too + version-control t) ; Use version numbers on backups -(setq backup-by-copying t ; Don't delink hardlinks - delete-old-versions t ; Clean up the backups - version-control t ; Use version numbers on backups, - kept-new-versions 3 ; keep some new versions - kept-old-versions 2) ; and some old ones, too +;; Do not persist customizations +(setq custom-file (make-temp-file "emacs-custom-")) -;; --------- -;; Generic keybindings -;; --------- -(global-set-key (kbd "C-c d") 'diff-buffer-with-file) +;; Global keybindings (global-set-key (kbd "C-c R") 'revert-buffer) (global-set-key (kbd "C-c w") 'whitespace-cleanup) -(global-set-key (kbd "C-c b s") 'bookmark-set) -(global-set-key (kbd "C-c b j") 'bookmark-jump) - -(global-set-key (kbd "<f12>") 'compile) - (defun help/insert-em-dash () "Inserts an EM-DASH (not a HYPEN, not an N-DASH)" (interactive) @@ -40,77 +29,16 @@ (global-set-key (kbd "C--") #'help/insert-em-dash) -;; ------ -;; General config -;; ------ - -(setq fill-column 79) +(setq fill-column 79) ; Wrap lines +(setq mouse-yank-at-point t) ; Do not follow mouse curors when mouse-yanking -;; Make sure that pressing middle mouse button pastes right at point, -;; not where the mouse cursor is. -(setq mouse-yank-at-point t) - -(setq column-number-mode 1) -(setq line-number-mode 1) -(setq-default indent-tabs-mode nil) -(setq-default tab-width 4) - -(setq-default c-basic-offset 4) - -;; ------ -;; Initialize environment -;; ------ - -(require 'server) -(setq server-client-instructions nil) -(unless (server-running-p) - (server-start)) +(setq-default indent-tabs-mode nil) ; No tabs when indenting +(setq-default tab-width 4) ; How many spaces a tab represents -;; Load themes early in the bootstrap process. -(load-file "~/.emacs.d/rul-init.d/themes.el") - -;; ------ -;; Helper for compilation. -;; ------ -;; Close the compilation window if there was no error at all. -(defun compilation-exit-autoclose (status code msg) - ;; If M-x compile exists with a 0 - (when (and (eq status 'exit) (zerop code)) - ;; then bury the *compilation* buffer, so that C-x b doesn't go there - (bury-buffer) - ;; and delete the *compilation* window - (delete-window (get-buffer-window (get-buffer "*compilation*")))) - ;; Always return the anticipated result of compilation-exit-message-function - (cons msg code)) - -;; Specify my function (maybe I should have done a lambda function) -(setq compilation-exit-message-function 'compilation-exit-autoclose) -(setq compilation-read-command nil) - -;; Themes -(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") - -;; Remove scratch message (setq initial-scratch-message "") -;; Ask y or n instead of yes or no (defalias 'yes-or-no-p 'y-or-n-p) -;; Fancier buffer selection -(global-set-key (kbd "C-x C-b") 'bs-show) - -;;; Stefan Monnier <foo at acm.org>. It is the opposite of fill-paragraph -(defun unfill-paragraph (&optional region) - "Takes a multi-line paragraph and makes it into a single line of text." - (interactive (progn (barf-if-buffer-read-only) '(t))) - (let ((fill-column (point-max)) - ;; This would override `fill-column' if it's an integer. - (emacs-lisp-docstring-fill-column t)) - (fill-paragraph nil region))) - -;; Handy key definition -(define-key global-map "\M-Q" 'unfill-paragraph) - ;; Only flash the mode line (setq ring-bell-function (lambda () @@ -124,29 +52,24 @@ (setq show-paren-delay 0) (show-paren-mode 1) -;; Save what you enter into minibuffer prompts -(setq history-length 25) -(savehist-mode 1) +(savehist-mode 1) ; Save histories, including minibuffer + +(save-place-mode 1) ; Remember and restore cursor information -;; Remember and restore cursor information -(save-place-mode 1) +(setq auto-save-no-message t) ; Do not print a message when auto-saving -;; Do not print a message when auto-saving -(setq auto-save-no-message t) +(pixel-scroll-precision-mode 1) ; Precision scrolling -;;;; Desktop -;; (setq desktop-path `(,user-emacs-directory)) -;; (setq desktop-base-file-name "desktop") -;; (desktop-save-mode 1) +;; Server +(require 'server) +(setq server-client-instructions nil) ; Keep it quiet when opening an ec -;; It's easier to get to magit if symlinks are followed. -(setq vc-follow-symlinks t) ;; drop +(unless (server-running-p) + (server-start)) (dolist (path '("~/.emacs.d/rul-lisp/config" "~/.emacs.d/rul-lisp/packages")) (add-to-list 'load-path path)) -(pixel-scroll-precision-mode 1) - (require 'rul-completion) (require 'rul-fm) (require 'rul-prog) @@ -157,12 +80,12 @@ (require 'rul-wm) (require 'rul-write) -(load-file "~/.emacs.d/rul-init.d/fonts.el") - ;; Init parts (will be deprecated in favor of packages) +(load-file "~/.emacs.d/rul-init.d/themes.el") (load-file "~/.emacs.d/rul-init.d/auto-fill.el") (load-file "~/.emacs.d/rul-init.d/flycheck.el") (load-file "~/.emacs.d/rul-init.d/flyspell.el") +(load-file "~/.emacs.d/rul-init.d/fonts.el") (load-file "~/.emacs.d/rul-init.d/go-lang.el") (load-file "~/.emacs.d/rul-init.d/hydra.el") (load-file "~/.emacs.d/rul-init.d/ibuffer.el") diff --git a/.emacs.d/rul-emacs.org b/.emacs.d/rul-emacs.org index 7dd47c1..44e7465 100644 --- a/.emacs.d/rul-emacs.org +++ b/.emacs.d/rul-emacs.org @@ -30,7 +30,6 @@ this file, and *not* at load time, as that would be too slow. - =rul-emacs.org=: this file. It (will) generate the rest of the structure. * The early init - ** Graphical aspects Customization of graphical aspects of Emacs, such as size, panels, etc. @@ -83,3 +82,145 @@ environment. (setq inhibit-startup-screen t) (setq inhibit-startup-echo-area-message user-login-name) #+end_src + +* The init.el file +** Package matters + +I use package from both stable and bleeding-edge Melpa. + +#+begin_src emacs-lisp :tangle "init.el" +(add-to-list 'package-archives + '("melpa-stable" . "https://stable.melpa.org/packages/") t) + +(add-to-list 'package-archives + '("melpa" . "https://melpa.org/packages/") t) +#+end_src +** Backups +Emacs tends to clutter the filesystem with backup files. A backup file is normally the filename with a =~= suffix. I rather have my filesystem clean, and centralize all backups in a single directory. + +#+begin_src emacs-lisp :tangle "init.el" +(if (file-directory-p "~/.backup") + (setq backup-directory-alist '(("." . "~/.backup"))) + (message "Directory does not exist: ~/.backup")) + +(setq + backup-by-copying t ; Don't delink hardlinks + delete-old-versions t ; Clean up the backups + kept-new-versions 3 ; keep some new versions + kept-old-versions 2 ; and some old ones, too + version-control t) ; Use version numbers on backups +#+end_src +** Customizations +Customizations don't place nicely with version control, so I do them in a random file that won't get persisted. + +Configurations that need persisting will be added to =custom-set-variables= and =custom-set-faces=. + +#+begin_src emacs-lisp :tangle "init.el" +;; Do not persist customizations +(setq custom-file (make-temp-file "emacs-custom-")) +#+end_src +** Global keybindings +This section defines keybindings common across all modes. + +#+begin_src emacs-lisp :tangle "init.el" +;; Global keybindings +(global-set-key (kbd "C-c R") 'revert-buffer) +(global-set-key (kbd "C-c w") 'whitespace-cleanup) + +(defun help/insert-em-dash () + "Inserts an EM-DASH (not a HYPEN, not an N-DASH)" + (interactive) + (insert "—")) + +(global-set-key (kbd "C--") #'help/insert-em-dash) +#+end_src +** Editor interface +General configurations related to text editing across all modes. + +#+begin_src emacs-lisp :tangle "init.el" +(setq fill-column 79) ; Wrap lines +(setq mouse-yank-at-point t) ; Do not follow mouse curors when mouse-yanking + +(setq-default indent-tabs-mode nil) ; No tabs when indenting +(setq-default tab-width 4) ; How many spaces a tab represents + +(setq initial-scratch-message "") + +(defalias 'yes-or-no-p 'y-or-n-p) + +;; Only flash the mode line +(setq ring-bell-function + (lambda () + (let ((orig-fg (face-foreground 'mode-line))) + (set-face-foreground 'mode-line "#F2804F") + (run-with-idle-timer 0.1 nil + (lambda (fg) (set-face-foreground 'mode-line fg)) + orig-fg)))) + +;; Highlight parens +(setq show-paren-delay 0) +(show-paren-mode 1) + +(savehist-mode 1) ; Save histories, including minibuffer + +(save-place-mode 1) ; Remember and restore cursor information + +(setq auto-save-no-message t) ; Do not print a message when auto-saving + +(pixel-scroll-precision-mode 1) ; Precision scrolling +#+end_src +** Emacs server +I used to run Emacs as a systemd daemon, but it was not too deterministic as sometimes it would break. + + https://rbenencia.name/blog/emacs-daemon-as-a-systemd-service/ + +Now, I simply start it from Emacs itself. This approach works well for me. + +#+begin_src emacs-lisp :tangle "init.el" +;; Server +(require 'server) +(setq server-client-instructions nil) ; Keep it quiet when opening an ec + +(unless (server-running-p) + (server-start)) +#+end_src +** Modules machinery +#+begin_src emacs-lisp :tangle "init.el" +(dolist (path '("~/.emacs.d/rul-lisp/config" "~/.emacs.d/rul-lisp/packages")) + (add-to-list 'load-path path)) + +(require 'rul-completion) +(require 'rul-fm) +(require 'rul-prog) +(require 'rul-elfeed) +(require 'rul-modeline) +(require 'rul-media) +(require 'rul-org) +(require 'rul-wm) +(require 'rul-write) + +;; Init parts (will be deprecated in favor of packages) +(load-file "~/.emacs.d/rul-init.d/themes.el") +(load-file "~/.emacs.d/rul-init.d/auto-fill.el") +(load-file "~/.emacs.d/rul-init.d/flycheck.el") +(load-file "~/.emacs.d/rul-init.d/flyspell.el") +(load-file "~/.emacs.d/rul-init.d/fonts.el") +(load-file "~/.emacs.d/rul-init.d/go-lang.el") +(load-file "~/.emacs.d/rul-init.d/hydra.el") +(load-file "~/.emacs.d/rul-init.d/ibuffer.el") +(load-file "~/.emacs.d/rul-init.d/imenu.el") +(load-file "~/.emacs.d/rul-init.d/latex.el") +(load-file "~/.emacs.d/rul-init.d/logos.el") +(load-file "~/.emacs.d/rul-init.d/magit.el") +(load-file "~/.emacs.d/rul-init.d/mail-mode.el") +(load-file "~/.emacs.d/rul-init.d/markdown.el") +(load-file "~/.emacs.d/rul-init.d/notmuch.el") +(load-file "~/.emacs.d/rul-init.d/vterm.el") +(load-file "~/.emacs.d/rul-init.d/which-key.el") + +(when-let* ((file (locate-user-emacs-file "rul-post-init.el")) + ((file-exists-p file))) + (load-file file)) + +;; init.el ends here +#+end_src |