]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix instrumented eval-defun not printing "Edebug:" to the echo area
authorDaniel Martín <mardani29@yahoo.es>
Thu, 25 Aug 2022 12:37:36 +0000 (14:37 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 25 Aug 2022 12:37:36 +0000 (14:37 +0200)
* lisp/progmodes/elisp-mode.el (elisp--eval-defun): Determine if we're
instrumenting a function and call eval-region with PRINTFLAG set to
nil if so (Bug#50245).

* test/lisp/progmodes/elisp-mode-tests.el
(eval-defun-prints-edebug-when-instrumented): Add a new test.

lisp/progmodes/elisp-mode.el
test/lisp/progmodes/elisp-mode-tests.el

index 9dc67010aa7f720effc011ca43983b29a6a4f48b..4ada27a1acae2952f7b0d98d8cce052df2e24e36 100644 (file)
@@ -1646,6 +1646,7 @@ Return the result of evaluation."
   ;; printing, not while evaluating.
   (defvar elisp--eval-defun-result)
   (let ((debug-on-error eval-expression-debug-on-error)
+        (edebugging edebug-all-defs)
         elisp--eval-defun-result)
     (save-excursion
       ;; Arrange for eval-region to "read" the (possibly) altered form.
@@ -1670,8 +1671,9 @@ Return the result of evaluation."
                          (elisp--eval-defun-1
                           (macroexpand form)))))
              (print-length eval-expression-print-length)
-             (print-level eval-expression-print-level))
-          (eval-region beg end standard-output
+             (print-level eval-expression-print-level)
+              (should-print (if (not edebugging) standard-output)))
+          (eval-region beg end should-print
                        (lambda (_ignore)
                          ;; Skipping to the end of the specified region
                          ;; will make eval-region return.
index 8074d8d70668180295f9ee01b62f7369b0d007f1..e73be0db50404e4d5990773f1c66753bb07ccd58 100644 (file)
         (call-interactively #'eval-last-sexp)
         (should (equal (current-message) "66 (#o102, #x42, ?B)"))))))
 
+;;; eval-defun
+
+(ert-deftest eval-defun-prints-edebug-when-instrumented ()
+  (skip-unless (not noninteractive))
+  (with-temp-buffer
+    (let ((current-prefix-arg '(4)))
+      (erase-buffer) (insert "(defun foo ())") (message nil)
+      (call-interactively #'eval-defun)
+      (should (equal (current-message) "Edebug: foo")))))
+
 ;;; eldoc
 
 (defun elisp-mode-tests--face-propertized-string (string)