]> git.eshelyaron.com Git - emacs.git/commitdiff
Rename 'elisp-eval-buffer' to 'elisp-eval-region-or-buffer' (bug#59350)
authorJuri Linkov <juri@linkov.net>
Sun, 20 Nov 2022 18:10:45 +0000 (20:10 +0200)
committerJuri Linkov <juri@linkov.net>
Sun, 20 Nov 2022 18:10:45 +0000 (20:10 +0200)
* lisp/progmodes/elisp-mode.el (elisp-eval-region-or-buffer):
Rename recently added command 'elisp-eval-buffer' to support active region.
(emacs-lisp-mode-map, lisp-interaction-mode-map): Rebind 'C-c C-e'
from elisp-eval-buffer to elisp-eval-region-or-buffer.

etc/NEWS
lisp/progmodes/elisp-mode.el

index 8a34afe8d291973a6e1ea2a0ddc50a465df9a744..9345cb06f5e3db4f3e93097b4e0759f8dd6b9b53 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1464,8 +1464,8 @@ This command visits the file on the current line with EWW.
 ** Elisp
 
 ---
-*** New command 'elisp-eval-buffer' (bound to 'C-c C-e').
-This command evals the forms in the current buffer.
+*** New command 'elisp-eval-region-or-buffer' (bound to 'C-c C-e').
+This command evals the forms in the active region or in the whole buffer.
 
 ---
 *** New commands 'elisp-byte-compile-file' and 'elisp-byte-compile-buffer'.
index 44c8ca7cb9de4a798aa6d2055c690326eb76a0d6..7c470de195f4984631660764430788edb0c2a752 100644 (file)
@@ -52,7 +52,7 @@ All commands in `lisp-mode-shared-map' are inherited by this map."
   :parent lisp-mode-shared-map
   "M-TAB" #'completion-at-point
   "C-M-x" #'eval-defun
-  "C-c C-e" #'elisp-eval-buffer
+  "C-c C-e" #'elisp-eval-region-or-buffer
   "C-c C-f" #'elisp-byte-compile-file
   "C-c C-b" #'elisp-byte-compile-buffer
   "C-M-q" #'indent-pp-sexp)
@@ -1234,7 +1234,7 @@ All commands in `lisp-mode-shared-map' are inherited by this map."
   :parent lisp-mode-shared-map
   "C-M-x" #'eval-defun
   "C-M-q" #'indent-pp-sexp
-  "C-c C-e" #'elisp-eval-buffer
+  "C-c C-e" #'elisp-eval-region-or-buffer
   "C-c C-b" #'elisp-byte-compile-buffer
   "M-TAB" #'completion-at-point
   "C-j"   #'eval-print-last-sexp)
@@ -2212,11 +2212,17 @@ Runs in a batch-mode Emacs.  Interactively use variable
     (terpri)
     (pp collected)))
 
-(defun elisp-eval-buffer ()
-  "Evaluate the forms in the current buffer."
+(defun elisp-eval-region-or-buffer ()
+  "Evaluate the forms in the active region or the whole current buffer.
+In Transient Mark mode when the mark is active, call `eval-region'.
+Otherwise, call `eval-buffer'."
   (interactive)
-  (eval-buffer)
-  (message "Evaluated the %s buffer" (buffer-name)))
+  (if (use-region-p)
+      (eval-region (region-beginning) (region-end))
+    (eval-buffer))
+  (message "Evaluated the %s%s buffer"
+           (if (use-region-p) "region in the " "")
+           (buffer-name)))
 
 (defun elisp-byte-compile-file (&optional load)
   "Byte compile the file the current buffer is visiting.