From: rearman Date: Wed, 16 Apr 2025 15:31:24 +0000 (-0400) Subject: Add defuns and bindings to safely kill and restart emacs X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=5cf7d8c17aafb4558bc2bae2a9b30023aa9060ad;p=emacsinit.git Add defuns and bindings to safely kill and restart emacs --- diff --git a/re/re-bindings.el b/re/re-bindings.el index 10c4bb3..e0e562c 100644 --- a/re/re-bindings.el +++ b/re/re-bindings.el @@ -3,6 +3,10 @@ ;;; Code: +;; Stopping Emacs +(keymap-global-set "C-x M-c" #'re/kill-emacs) +(keymap-global-set "C-x M-r" #'re/restart-emacs) + ;; Editing Bindings (keymap-global-set "" nil) ; I keep toggliŋ overwrite-mode haply (keymap-global-set "C-\\" #'undo-redo) diff --git a/re/re-editing-defuns.el b/re/re-editing-defuns.el index c57c614..fbdaa75 100644 --- a/re/re-editing-defuns.el +++ b/re/re-editing-defuns.el @@ -104,12 +104,14 @@ If in org-mode, call `org-end-of-line' first." (display-line-numbers-mode -1)) (defun re/other-window-or-split-window (&optional window) + "Go to other window or split sensibly." (interactive) (if (= (count-windows) 1) (funcall split-window-preferred-function window) (other-window 1))) (defun re/isearch-forward-use-region () + "Search text in region if active, otherwise normal forward search." (interactive) (when (use-region-p) (add-to-history 'search-ring @@ -118,6 +120,7 @@ If in org-mode, call `org-end-of-line' first." (call-interactively 'isearch-forward)) (defun re/isearch-backward-use-region () + "Search text in region if active, otherwise normal backward search." (interactive) (when (use-region-p) (add-to-history 'search-ring @@ -130,5 +133,17 @@ If in org-mode, call `org-end-of-line' first." (interactive) (setq-local tab-width width)) +(defun re/kill-emacs () + "Save all open files and kill emacs." + (interactive) + (save-some-buffers t) + (kill-emacs)) + +(defun re/restart-emacs () + "Save all open files and restart emacs." + (interactive) + (save-some-buffers t) + (kill-emacs nil t)) + (provide 're-editing-defuns) ;;; re-editing-defuns.el ends here