X-Git-Url: https://git.shemshak.org/gitweb.cgi/~bandali/configs/blobdiff_plain/63a849c3da1bd6eb3e0cc722ab0419b3d68c4f57..1446ab91e68b8e0d2d36ccccc5a3f7432c3e6937:/emacs/init.org?ds=inline diff --git a/emacs/init.org b/emacs/init.org index 5f96e69..454766c 100644 --- a/emacs/init.org +++ b/emacs/init.org @@ -59,6 +59,24 @@ file. ;; THIS FILE IS AUTO-GENERATED FROM `init.org'. #+end_src +** Naming conventions + +The conventions below were inspired by [[https://github.com/hlissner/doom-emacs][Doom]]'s conventions, found +[[https://github.com/hlissner/doom-emacs/blob/5dacbb7cb1c6ac246a9ccd15e6c4290def67757c/core/core.el#L3-L17][here]]. Naturally, I use my initials, =ab=, instead of =doom=. + +#+begin_src emacs-lisp :comments none +;; Naming conventions: +;; +;; ab-... public variables or non-interactive functions +;; ab--... private anything (non-interactive), not safe for direct use +;; ab/... an interactive function; safe for M-x or keybinding +;; ab:... an evil operator, motion, or command +;; ab|... a hook function +;; ab*... an advising function +;; ab@... a hydra command +;; ...! a macro +#+end_src + * Initial setup :PROPERTIES: :CUSTOM_ID: initial-setup @@ -101,9 +119,6 @@ Reset the variables back to default after init. ,load-file-name elapsed)))) #+end_src -Note that I'll be using my initials, =ab=, as a prefix for the -variables and functions I define throughout my init file. - ** Package management *** =straight.el= @@ -133,7 +148,7 @@ hacker. **** Useful helpers #+begin_src emacs-lisp -(defun straight-reload-init () +(defun ab/reload-init () "Reload init.el." (interactive) (straight-transaction @@ -142,7 +157,7 @@ hacker. (load user-init-file nil 'nomessage) (message "Reloading init.el... done."))) -(defun straight-eval-buffer () +(defun ab/eval-buffer () "Evaluate the current buffer as Elisp code." (interactive) (message "Evaluating %s..." (buffer-name)) @@ -204,6 +219,39 @@ it it's own file. (load custom-file)) #+end_src +** Better =$PATH= handling + +Let's use [[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]] to make Emacs use the =$PATH= as set up +in my shell. + +#+begin_src emacs-lisp +(use-package exec-path-from-shell + :defer 1 + :init + (setq exec-path-from-shell-check-startup-files nil) + :config + (exec-path-from-shell-initialize) + ;; while we're at it, let's fix access to our running ssh-agent + (exec-path-from-shell-copy-env "SSH_AGENT_PID") + (exec-path-from-shell-copy-env "SSH_AUTH_SOCK")) +#+end_src + +** Server + +Start server if not already running. Alternatively, can be done by +issuing =emacs --daemon= in the terminal, which can be automated with +a systemd service or using =brew services start emacs= on macOS. I use +Emacs as my window manager (via =exwm=), so I always start Emacs on +login; so starting the server from inside Emacs is good enough for me. + +See [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server][Using Emacs as a Server]]. + +#+begin_src emacs-lisp +(require 'server) +(unless (server-running-p) + (server-start)) +#+end_src + ** Backups Emacs' default backup settings aren't that great. Let's use more @@ -215,6 +263,78 @@ variable. version-control t) #+end_src +* Core +:PROPERTIES: +:CUSTOM_ID: core +:END: + +** Defaults + +*** Disable disabled commands + +Emacs disables some commands by default that could persumably be +confusing for novice users. Let's disable that. + +#+begin_src emacs-lisp +(setq disabled-command-function nil) +#+end_src + +*** Kill-ring + +Save what I copy into clipboard from other applications into Emacs' +kill-ring, which would allow me to still be able to easily access it +in case I kill (cut or copy) something else inside Emacs before +yanking (pasting) what I'd originally intended to. + +#+begin_src emacs-lisp +(setq save-interprogram-paste-before-kill t) +#+end_src + +*** Keep more =*Messages*= + +#+begin_src emacs-lisp +(setq message-log-max 10000) +#+end_src + +*** Lazy-person-friendly yes/no prompts + +Lazy people would prefer to type fewer keystrokes, especially for yes +or no questions. I'm lazy. + +#+begin_src emacs-lisp +(defalias 'yes-or-no-p #'y-or-n-p) +#+end_src + +*** =*scratch*= + +Let's customize the =*scratch*= buffer a bit. First off, I don't need +the default hint. + +#+begin_src emacs-lisp +(setq initial-scratch-message "") +#+end_src + +Also, let's use Text mode as the major mode, in case I want to +customize it (=*scratch*='s default major mode, Fundamental mode, +can't really be customized). + +#+begin_src emacs-lisp +(setq initial-major-mode 'text-mode) +#+end_src + +*** More useful frame titles + +Show either the file name or the buffer name (in case the buffer isn't +visiting a file). Borrowed from Emacs Prelude. + +#+begin_src emacs-lisp +(setq frame-title-format + '("" invocation-name " - " + (:eval (if (buffer-file-name) + (abbreviate-file-name (buffer-file-name)) + "%b")))) +#+end_src + * Config :PROPERTIES: :CUSTOM_ID: config