From 7649176669fbe49260ec2a0cee1865c3f4cf5f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Wed, 24 Aug 2022 23:34:18 +0200 Subject: [PATCH] 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. --- lisp/progmodes/elisp-mode.el | 8 ++++++-- test/lisp/progmodes/elisp-mode-tests.el | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 0c4a9bfdbe..bc8833a693 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1643,7 +1643,10 @@ elisp--eval-defun ;; FIXME: the print-length/level bindings should only be applied while ;; printing, not while evaluating. (defvar elisp--eval-defun-result) + ;; FIXME: This Edebug dependency is undesirable. See bug#50245 + (defvar edebug-all-defs) (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. @@ -1668,8 +1671,9 @@ elisp--eval-defun (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. diff --git a/test/lisp/progmodes/elisp-mode-tests.el b/test/lisp/progmodes/elisp-mode-tests.el index 8e4dfa8bb8..345e8880c8 100644 --- a/test/lisp/progmodes/elisp-mode-tests.el +++ b/test/lisp/progmodes/elisp-mode-tests.el @@ -183,6 +183,16 @@ eval-last-sexp-print-format-large-int-echo (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) -- 2.34.1