aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Liu2014-01-12 12:00:03 +0800
committerLeo Liu2014-01-12 12:00:03 +0800
commit9b335362d0a968be76188b463512ee6b9c5ae901 (patch)
tree634f1f6997376455af68615b318d8e91f90384d5
parent4efa3f1e0e66a7d84b0807c7b5d263e32f54a4e3 (diff)
downloademacs-9b335362d0a968be76188b463512ee6b9c5ae901.tar.gz
emacs-9b335362d0a968be76188b463512ee6b9c5ae901.zip
Re-implement the feature of showing eldoc info after editing.
* emacs-lisp/eldoc.el (eldoc-post-insert-mode): Remove. (eldoc-edit-message-commands): New function. (eldoc-print-after-edit): New variable. (eldoc-pre-command-refresh-echo-area): Emit message only by eldoc-message-commands. (eldoc-mode): Restrict eldoc-message-commands to editing commands if eldoc-print-after-edit is set. * progmodes/octave.el (octave-mode-menu): Adapt to change in eldoc. Fixes: debbugs:16346
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/emacs-lisp/eldoc.el52
-rw-r--r--lisp/progmodes/octave.el8
-rw-r--r--lisp/simple.el1
4 files changed, 45 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 60aff3c7be0..786162d3e0a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12014-01-12 Leo Liu <sdl.web@gmail.com>
2
3 Re-implement the feature of showing eldoc info after editing.
4 * emacs-lisp/eldoc.el (eldoc-post-insert-mode): Remove.
5 (eldoc-edit-message-commands): New function.
6 (eldoc-print-after-edit): New variable.
7 (eldoc-pre-command-refresh-echo-area): Emit message only by
8 eldoc-message-commands.
9 (eldoc-mode): Restrict eldoc-message-commands to editing commands
10 if eldoc-print-after-edit is set. (Bug#16346)
11
12 * progmodes/octave.el (octave-mode-menu): Adapt to change in
13 eldoc.
14
12014-01-11 Eric S. Raymond <esr@thyrsus.com> 152014-01-11 Eric S. Raymond <esr@thyrsus.com>
2 16
3 * version.el (emacs-repository-get-version): Enhancee so the 17 * version.el (emacs-repository-get-version): Enhancee so the
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 8bd9ebc1e63..1c64e28c76b 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -1,4 +1,4 @@
1;;; eldoc.el --- show function arglist or variable docstring in echo area 1;;; eldoc.el --- show function arglist or variable docstring in echo area -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 1996-2014 Free Software Foundation, Inc. 3;; Copyright (C) 1996-2014 Free Software Foundation, Inc.
4 4
@@ -62,6 +62,12 @@ If this variable is set to 0, no idle time is required."
62 :type 'number 62 :type 'number
63 :group 'eldoc) 63 :group 'eldoc)
64 64
65(defcustom eldoc-print-after-edit nil
66 "If non-nil eldoc info is only shown when editing.
67Changing the value requires toggling `eldoc-mode'."
68 :type 'boolean
69 :group 'eldoc)
70
65;;;###autoload 71;;;###autoload
66(defcustom eldoc-minor-mode-string (purecopy " ElDoc") 72(defcustom eldoc-minor-mode-string (purecopy " ElDoc")
67 "String to display in mode line when ElDoc Mode is enabled; nil for none." 73 "String to display in mode line when ElDoc Mode is enabled; nil for none."
@@ -150,6 +156,16 @@ This is used to determine if `eldoc-idle-delay' is changed by the user.")
150 "The function used by `eldoc-message' to display messages. 156 "The function used by `eldoc-message' to display messages.
151It should receive the same arguments as `message'.") 157It should receive the same arguments as `message'.")
152 158
159(defun eldoc-edit-message-commands ()
160 (let ((cmds (make-vector 31 0))
161 (re (regexp-opt '("delete" "insert" "edit" "electric" "newline"))))
162 (mapatoms (lambda (s)
163 (and (commandp s)
164 (string-match-p re (symbol-name s))
165 (intern (symbol-name s) cmds)))
166 obarray)
167 cmds))
168
153 169
154;;;###autoload 170;;;###autoload
155(define-minor-mode eldoc-mode 171(define-minor-mode eldoc-mode
@@ -168,25 +184,13 @@ expression point is on."
168 (setq eldoc-last-message nil) 184 (setq eldoc-last-message nil)
169 (if eldoc-mode 185 (if eldoc-mode
170 (progn 186 (progn
187 (when eldoc-print-after-edit
188 (setq-local eldoc-message-commands (eldoc-edit-message-commands)))
171 (add-hook 'post-command-hook 'eldoc-schedule-timer nil t) 189 (add-hook 'post-command-hook 'eldoc-schedule-timer nil t)
172 (add-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area t)) 190 (add-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area t))
173 (remove-hook 'post-command-hook 'eldoc-schedule-timer) 191 (kill-local-variable 'eldoc-message-commands)
174 (remove-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area))) 192 (remove-hook 'post-command-hook 'eldoc-schedule-timer t)
175 193 (remove-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area t)))
176;;;###autoload
177(define-minor-mode eldoc-post-insert-mode nil
178 :group 'eldoc :lighter (:eval (if eldoc-mode ""
179 (concat eldoc-minor-mode-string "|i")))
180 (setq eldoc-last-message nil)
181 (let ((prn-info (lambda ()
182 (unless eldoc-mode
183 (eldoc-print-current-symbol-info)))))
184 (if eldoc-post-insert-mode
185 (add-hook 'post-self-insert-hook prn-info nil t)
186 (remove-hook 'post-self-insert-hook prn-info t))))
187
188;; FIXME: This changes Emacs's behavior when the file is loaded!
189(add-hook 'eval-expression-minibuffer-setup-hook 'eldoc-post-insert-mode)
190 194
191;;;###autoload 195;;;###autoload
192(defun turn-on-eldoc-mode () 196(defun turn-on-eldoc-mode ()
@@ -264,8 +268,10 @@ Otherwise work like `message'."
264;; This doesn't seem to be required for Emacs 19.28 and earlier. 268;; This doesn't seem to be required for Emacs 19.28 and earlier.
265(defun eldoc-pre-command-refresh-echo-area () 269(defun eldoc-pre-command-refresh-echo-area ()
266 (and eldoc-last-message 270 (and eldoc-last-message
267 (if (eldoc-display-message-no-interference-p) 271 (if (and (eldoc-display-message-no-interference-p)
268 (eldoc-message eldoc-last-message) 272 (symbolp this-command)
273 (intern-soft (symbol-name this-command) eldoc-message-commands))
274 (eldoc-message eldoc-last-message)
269 (setq eldoc-last-message nil)))) 275 (setq eldoc-last-message nil))))
270 276
271;; Decide whether now is a good time to display a message. 277;; Decide whether now is a good time to display a message.
@@ -283,9 +289,7 @@ Otherwise work like `message'."
283;; Check various conditions about the current environment that might make 289;; Check various conditions about the current environment that might make
284;; it undesirable to print eldoc messages right this instant. 290;; it undesirable to print eldoc messages right this instant.
285(defun eldoc-display-message-no-interference-p () 291(defun eldoc-display-message-no-interference-p ()
286 (and eldoc-mode 292 (not (or executing-kbd-macro (bound-and-true-p edebug-active))))
287 (not executing-kbd-macro)
288 (not (and (boundp 'edebug-active) edebug-active))))
289 293
290 294
291;;;###autoload 295;;;###autoload
@@ -309,7 +313,7 @@ Emacs Lisp mode) that support ElDoc.")
309 ;; This is run from post-command-hook or some idle timer thing, 313 ;; This is run from post-command-hook or some idle timer thing,
310 ;; so we need to be careful that errors aren't ignored. 314 ;; so we need to be careful that errors aren't ignored.
311 (with-demoted-errors "eldoc error: %s" 315 (with-demoted-errors "eldoc error: %s"
312 (and (or (eldoc-display-message-p) eldoc-post-insert-mode) 316 (and (eldoc-display-message-p)
313 (if eldoc-documentation-function 317 (if eldoc-documentation-function
314 (eldoc-message (funcall eldoc-documentation-function)) 318 (eldoc-message (funcall eldoc-documentation-function))
315 (let* ((current-symbol (eldoc-current-symbol)) 319 (let* ((current-symbol (eldoc-current-symbol))
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index e2ef492a9ad..1378e8fdb59 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -154,12 +154,8 @@ parenthetical grouping.")
154 ["Insert Function" octave-insert-defun t] 154 ["Insert Function" octave-insert-defun t]
155 ["Update Function File Comment" octave-update-function-file-comment t] 155 ["Update Function File Comment" octave-update-function-file-comment t]
156 "---" 156 "---"
157 ["Function Syntax Hints" (call-interactively 157 ["Function Syntax Hints" (eldoc-mode 'toggle)
158 (if (fboundp 'eldoc-post-insert-mode) 158 :style toggle :selected (bound-and-true-p eldoc-mode)
159 'eldoc-post-insert-mode
160 'eldoc-mode))
161 :style toggle :selected (or (bound-and-true-p eldoc-post-insert-mode)
162 (bound-and-true-p eldoc-mode))
163 :help "Display function signatures after typing `SPC' or `('"] 159 :help "Display function signatures after typing `SPC' or `('"]
164 ["Delimiter Matching" show-paren-mode 160 ["Delimiter Matching" show-paren-mode
165 :style toggle :selected show-paren-mode 161 :style toggle :selected show-paren-mode
diff --git a/lisp/simple.el b/lisp/simple.el
index 5c2f3c3db1d..ae18ae65fb5 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1387,6 +1387,7 @@ display the result of expression evaluation."
1387 (lambda () 1387 (lambda ()
1388 (add-hook 'completion-at-point-functions 1388 (add-hook 'completion-at-point-functions
1389 #'lisp-completion-at-point nil t) 1389 #'lisp-completion-at-point nil t)
1390 (eldoc-mode 1)
1390 (run-hooks 'eval-expression-minibuffer-setup-hook)) 1391 (run-hooks 'eval-expression-minibuffer-setup-hook))
1391 (read-from-minibuffer prompt initial-contents 1392 (read-from-minibuffer prompt initial-contents
1392 read-expression-map t 1393 read-expression-map t