]> git.earman.xyz Git - emacsinit.git/commitdiff
Add defuns and bindings to safely kill and restart emacs
authorrearman <rearman@r717.net>
Wed, 16 Apr 2025 15:31:24 +0000 (11:31 -0400)
committerrearman <rearman@r717.net>
Wed, 16 Apr 2025 15:31:24 +0000 (11:31 -0400)
re/re-bindings.el
re/re-editing-defuns.el

index 10c4bb3d2055b0a65b910f5c7618daa456f357bb..e0e562c04a09abb316989fcb39cc77eb972174d7 100644 (file)
@@ -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 "<insert>" nil) ; I keep toggliĊ‹ overwrite-mode haply
 (keymap-global-set "C-\\" #'undo-redo)
index c57c6144c5d696ffcec553c2461094a20e1b7929..fbdaa75732ec7f8de91b405240876dcbd52542c4 100644 (file)
@@ -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