Subject: 29.0.50; Eval region or buffer

From: Juri Linkov <[email-masked]>
Date: Fri, 18 Nov 2022 09:44:39 +0200

'elisp-eval-buffer' is a nice new command that evaluates the current buffer
with a convenient keybinding 'C-c C-e'.  It would be nicer also to react on
the currently active region:

```
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 6bdaa7a37a..9b8a66c243 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -2213,10 +2213,14 @@ elisp-flymake--batch-compile-for-flymake
     (pp collected)))
 
 (defun elisp-eval-buffer ()
-  "Evaluate the forms in the current buffer."
+  "Evaluate the forms in the active region or the whole current 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.
```