Fix instrumented eval-defun not printing "Edebug:" to the echo area

* 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.
This commit is contained in:
Daniel Martín 2022-08-25 14:37:36 +02:00 committed by Lars Ingebrigtsen
parent b947f80a62
commit dbec115948
2 changed files with 14 additions and 2 deletions

View 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.

View file

@ -183,6 +183,16 @@
(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)