diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-08 17:16:29 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-08 17:16:29 -0500 |
| commit | a55a5248bd2dae5f849476d0f7b5dcd8d91cf929 (patch) | |
| tree | 834a7b012f6823b53ee2f516384b7bc4c4ec819b /modules/system-utils.el | |
| parent | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (diff) | |
fit and finish work
- gptel: added gptel-send-region with global keybinding
- projectile: made project-switch-actions more efficient with regexp
- prog-go: removed disabled code
- mu4e: capture template captures region if selected
- system utils: merged bury alive with other killing buffer code
- org-capture: renamed *website-clipper to org-webpage-clipper
- rg: auto switch to ripgrep-results window when ripgrep search completes
- dashboard: remove dashboard banner custom face
General
- moved abbrev_defs to assets
- removed gitmodules file
- updated packages
- fixed docstring and formatting throughout
Custom-Functions
- move cj/merge-list-to-list to custom-functions
- add remove leading trailing whitespace function
- corrected arrayify prompt
Font-Config
- added font point sizes in fontaine menu
- make default font point size 11
Python
- adding back python poetry support
- added cj/python-setup method
- merge python and python-mode configurations
(they are the same built-in package)
Show-Kill-Ring
- show-kill-ring displays in another read-only buffer
- show-kill-ring exits with q
Elfeed
- moved elfeed-feeds.org to assets
- removed Wired from elfeed feeds
- moved ElfeedDB to user-emacs-directory/.elfeed-db
- moved elfeed-dashboard.org to assets
Diffstat (limited to 'modules/system-utils.el')
| -rw-r--r-- | modules/system-utils.el | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/modules/system-utils.el b/modules/system-utils.el index bab4f01a..f5967520 100644 --- a/modules/system-utils.el +++ b/modules/system-utils.el @@ -18,27 +18,61 @@ (setq nerd-icons-ibuffer-color-icon t) (setq nerd-icons-ibuffer-human-readable-size t)) -;; ------------------------------ Bury Alive List ------------------------------ -;; buries buffers on the 'cj/bury-alive-list' list rather than killing them. The -;; keybinding for kill-buffer is remapped to this function. - -(defvar cj/bury-alive-list '("*dashboard*" "*scratch*" "*Messages*") +;; ------------------------ Killing Buffers And Windows ------------------------ +;; Accidentally killing buffers can lose data. these functions override common +;; buffer killing functions and buries buffers on the 'cj/buffer-bury-alive-list' list +;; rather than killing them. Allows for interactive adding to the +;; 'cj/buffer-bury-alive-list' via 'C-u C-x k' + +;; BUFFER BURY ALIVE LIST +(defvar cj/buffer-bury-alive-list '("*dashboard*" "*scratch*" "*Messages*") "Buffers that shouldn't be killed, but buried instead.") -(defun cj/kill-or-bury-alive (target-buffer) +;; KILL BUFFER AND WINDOW +(defun cj/kill-buffer-and-window () + "Kill current buffer and window. +Buries buffers instead if they are on the cj/buffer-bury-alive-list." + (interactive) + (let ((target-buffer (current-buffer))) + (delete-window) + (cj/kill-buffer-or-bury-alive target-buffer))) +(global-set-key (kbd "M-C") 'cj/kill-buffer-and-window) + +;; KILL OTHER WINDOW +(defun cj/kill-other-window () + "Close the next window and kill any buffer in it. +Buries buffers instead if they are on the cj/buffer-bury-alive-list." + (interactive) + (other-window 1) + (let ((target-buffer (current-buffer))) + (if (not (one-window-p)) (delete-window)) + (cj/kill-buffer-or-bury-alive target-buffer))) +(global-set-key (kbd "M-O") 'cj/kill-other-window) + +;; KILL ALL OTHER BUFFERS AND WINDOWS +(defun cj/kill-all-other-buffers-and-windows () + "Save buffers, then kill all other buffers and windows. +Buries buffers instead if they are on the cj/buffer-bury-alive-list." + (interactive) + (save-some-buffers) + (delete-other-windows) + (mapc 'cj/kill-buffer-or-bury-alive (delq (current-buffer) (buffer-list)))) +(global-set-key (kbd "M-M") 'cj/kill-all-other-buffers-and-windows) + +;; KILL BUFFER OR BURY ALIVE +(defun cj/kill-buffer-or-bury-alive (target-buffer) "Bury buffers on the bury-instead-list rather than killing them. -With a prefix argument, add the TARGET-BUFFER to \='cj/bury-alive-list\='." +With a prefix argument, add the TARGET-BUFFER to \='cj/buffer-bury-alive-list\='." (interactive "bKill or Add to bury (don't kill) buffer list: ") (with-current-buffer target-buffer (if current-prefix-arg (progn - (add-to-list 'cj/bury-alive-list (buffer-name (current-buffer))) + (add-to-list 'cj/buffer-bury-alive-list (buffer-name (current-buffer))) (message "Added %s to bury-alive-list" (buffer-name (current-buffer)))) - (if (member (buffer-name (current-buffer)) cj/bury-alive-list) + (if (member (buffer-name (current-buffer)) cj/buffer-bury-alive-list) (bury-buffer) (kill-buffer (current-buffer)))))) - -(global-set-key [remap kill-buffer] #'cj/kill-or-bury-alive) +(global-set-key [remap kill-buffer] #'cj/kill-buffer-or-bury-alive) ;; --------------------------- Emacs Server Shutdown --------------------------- ;; shuts down the Emacs server. useful with emacsclient. @@ -243,14 +277,16 @@ The function offers the option to open the `macros-file' for editing when called (write-region ";;; -*- lexical-binding: t -*-\n" nil macros-file) (message "Saved macros file not found, so created: %s" macros-file))) -;; ----------------------------- Merge List To List ---------------------------- -;; Convenience method for merging two lists together -;; https://emacs.stackexchange.com/questions/38008/adding-many-items-to-a-list/68048#68048 +;; -------------------------------- Abbrev Mode -------------------------------- +;; word abbreviations mode. used to auto-correct spelling (see flyspell-config) -(defun cj/merge-list-to-list (dst src) - "Merge content of the 2nd list SRC with the 1st one DST." - (set dst - (append (eval dst) src))) +(use-package abbrev-mode + :ensure nil ;; built-in + :defer .5 + :custom + (abbrev-file-name (concat user-emacs-directory "assets/abbrev_defs")) ;; keep project root clean + :config + (abbrev-mode)) ;; use abbrev mode everywhere ;; -------------------------------- Log Silently ------------------------------- ;; utility function to log silently to the Messages buffer (for debugging/warning) |
