diff options
| author | Stefan Monnier | 2003-02-11 00:11:55 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-02-11 00:11:55 +0000 |
| commit | d16ba2e708d571f8a0ebc1203badca0b69bef6f4 (patch) | |
| tree | 48689412c8c9c7014514707d69a0b8760ab8ffeb | |
| parent | 9a0fc3da6fd595c3f95f856cdfadc9a6b0dfb2c4 (diff) | |
| download | emacs-d16ba2e708d571f8a0ebc1203badca0b69bef6f4.tar.gz emacs-d16ba2e708d571f8a0ebc1203badca0b69bef6f4.zip | |
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
(timer): Never require. It only works in current Emacs anyway.
(eldoc-mode, eldoc-message, eldoc-display-message-p)
(eldoc-docstring-format-sym-doc, eldoc-remove-command): Simplify.
| -rw-r--r-- | lisp/emacs-lisp/eldoc.el | 128 |
1 files changed, 35 insertions, 93 deletions
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 8f7fbb5493b..dda22a32139 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | ;; Keywords: extensions | 7 | ;; Keywords: extensions |
| 8 | ;; Created: 1995-10-06 | 8 | ;; Created: 1995-10-06 |
| 9 | 9 | ||
| 10 | ;; $Id: eldoc.el,v 1.22 2003/01/03 11:46:20 jpw Exp $ | 10 | ;; $Id: eldoc.el,v 1.23 2003/01/03 11:53:46 jpw Exp $ |
| 11 | 11 | ||
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| 13 | 13 | ||
| @@ -49,13 +49,6 @@ | |||
| 49 | 49 | ||
| 50 | (require 'help-fns) ;For fundoc-usage handling functions. | 50 | (require 'help-fns) ;For fundoc-usage handling functions. |
| 51 | 51 | ||
| 52 | ;; Use idle timers if available in the version of emacs running. | ||
| 53 | ;; Please don't change this to use `require'; this package works | ||
| 54 | ;; as-is in XEmacs 19.14 and later and I am striving to maintain | ||
| 55 | ;; compatibility between emacs variants. | ||
| 56 | (or (featurep 'timer) | ||
| 57 | (load "timer" t)) | ||
| 58 | |||
| 59 | (defgroup eldoc nil | 52 | (defgroup eldoc nil |
| 60 | "Show function arglist or variable docstring in echo area." | 53 | "Show function arglist or variable docstring in echo area." |
| 61 | :group 'lisp | 54 | :group 'lisp |
| @@ -99,10 +92,7 @@ former case. | |||
| 99 | 92 | ||
| 100 | If value is nil, messages are always truncated to fit in a single line of | 93 | If value is nil, messages are always truncated to fit in a single line of |
| 101 | display in the echo area. Function or variable symbol name may be | 94 | display in the echo area. Function or variable symbol name may be |
| 102 | truncated to make more of the arglist or documentation string visible. | 95 | truncated to make more of the arglist or documentation string visible." |
| 103 | |||
| 104 | Non-nil values for this variable have no effect unless | ||
| 105 | `eldoc-echo-area-multiline-supported-p' is non-nil." | ||
| 106 | :type '(radio (const :tag "Always" t) | 96 | :type '(radio (const :tag "Always" t) |
| 107 | (const :tag "Never" nil) | 97 | (const :tag "Never" nil) |
| 108 | (const :tag "Yes, but truncate symbol names if it will\ | 98 | (const :tag "Yes, but truncate symbol names if it will\ |
| @@ -111,12 +101,6 @@ Non-nil values for this variable have no effect unless | |||
| 111 | 101 | ||
| 112 | ;;; No user options below here. | 102 | ;;; No user options below here. |
| 113 | 103 | ||
| 114 | ;; Non-nil if this version of emacs supports dynamically resizable echo areas. | ||
| 115 | (defvar eldoc-echo-area-multiline-supported-p | ||
| 116 | (and (string-lessp "21" emacs-version) | ||
| 117 | (save-match-data | ||
| 118 | (numberp (string-match "^GNU Emacs" (emacs-version)))))) | ||
| 119 | |||
| 120 | ;; Commands after which it is appropriate to print in the echo area. | 104 | ;; Commands after which it is appropriate to print in the echo area. |
| 121 | ;; Eldoc does not try to print function arglists, etc. after just any command, | 105 | ;; Eldoc does not try to print function arglists, etc. after just any command, |
| 122 | ;; because some commands print their own messages in the echo area and these | 106 | ;; because some commands print their own messages in the echo area and these |
| @@ -142,10 +126,7 @@ Non-nil values for this variable have no effect unless | |||
| 142 | (defvar eldoc-last-data (make-vector 3 nil)) | 126 | (defvar eldoc-last-data (make-vector 3 nil)) |
| 143 | (defvar eldoc-last-message nil) | 127 | (defvar eldoc-last-message nil) |
| 144 | 128 | ||
| 145 | ;; Idle timers are supported in Emacs 19.31 and later. | 129 | ;; eldoc's timer object. |
| 146 | (defvar eldoc-use-idle-timer-p (fboundp 'run-with-idle-timer)) | ||
| 147 | |||
| 148 | ;; eldoc's timer object, if using idle timers | ||
| 149 | (defvar eldoc-timer nil) | 130 | (defvar eldoc-timer nil) |
| 150 | 131 | ||
| 151 | ;; idle time delay currently in use by timer. | 132 | ;; idle time delay currently in use by timer. |
| @@ -170,22 +151,12 @@ instead. | |||
| 170 | With prefix ARG, turn ElDoc mode on if and only if ARG is positive." | 151 | With prefix ARG, turn ElDoc mode on if and only if ARG is positive." |
| 171 | nil eldoc-minor-mode-string nil | 152 | nil eldoc-minor-mode-string nil |
| 172 | (setq eldoc-last-message nil) | 153 | (setq eldoc-last-message nil) |
| 173 | (cond (eldoc-use-idle-timer-p | 154 | (if eldoc-mode |
| 174 | (add-hook 'post-command-hook 'eldoc-schedule-timer) | 155 | (progn |
| 175 | (add-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area)) | 156 | (add-hook 'post-command-hook 'eldoc-schedule-timer nil t) |
| 176 | (t | 157 | (add-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area t)) |
| 177 | ;; Use post-command-idle-hook if defined, otherwise use | 158 | (remove-hook 'post-command-hook 'eldoc-schedule-timer) |
| 178 | ;; post-command-hook. The former is only proper to use in Emacs | 159 | (remove-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area))) |
| 179 | ;; 19.30; that is the first version in which it appeared, but it | ||
| 180 | ;; was obsolesced by idle timers in Emacs 19.31. | ||
| 181 | (add-hook (if (boundp 'post-command-idle-hook) | ||
| 182 | 'post-command-idle-hook | ||
| 183 | 'post-command-hook) | ||
| 184 | 'eldoc-print-current-symbol-info t t) | ||
| 185 | ;; quick and dirty hack for seeing if this is XEmacs | ||
| 186 | (and (fboundp 'display-message) | ||
| 187 | (add-hook 'pre-command-hook | ||
| 188 | 'eldoc-pre-command-refresh-echo-area t t))))) | ||
| 189 | 160 | ||
| 190 | ;;;###autoload | 161 | ;;;###autoload |
| 191 | (defun turn-on-eldoc-mode () | 162 | (defun turn-on-eldoc-mode () |
| @@ -209,33 +180,21 @@ With prefix ARG, turn ElDoc mode on if and only if ARG is positive." | |||
| 209 | 180 | ||
| 210 | (defun eldoc-message (&rest args) | 181 | (defun eldoc-message (&rest args) |
| 211 | (let ((omessage eldoc-last-message)) | 182 | (let ((omessage eldoc-last-message)) |
| 212 | (cond ((eq (car args) eldoc-last-message)) | 183 | (setq eldoc-last-message |
| 213 | ((or (null args) | 184 | (cond ((eq (car args) eldoc-last-message) eldoc-last-message) |
| 214 | (null (car args))) | 185 | ((null (car args)) nil) |
| 215 | (setq eldoc-last-message nil)) | 186 | ;; If only one arg, no formatting to do, so put it in |
| 216 | ;; If only one arg, no formatting to do so put it in | 187 | ;; eldoc-last-message so eq test above might succeed on |
| 217 | ;; eldoc-last-message so eq test above might succeed on | 188 | ;; subsequent calls. |
| 218 | ;; subsequent calls. | 189 | ((null (cdr args)) (car args)) |
| 219 | ((null (cdr args)) | 190 | (t (apply 'format args)))) |
| 220 | (setq eldoc-last-message (car args))) | ||
| 221 | (t | ||
| 222 | (setq eldoc-last-message (apply 'format args)))) | ||
| 223 | ;; In emacs 19.29 and later, and XEmacs 19.13 and later, all messages | 191 | ;; In emacs 19.29 and later, and XEmacs 19.13 and later, all messages |
| 224 | ;; are recorded in a log. Do not put eldoc messages in that log since | 192 | ;; are recorded in a log. Do not put eldoc messages in that log since |
| 225 | ;; they are Legion. | 193 | ;; they are Legion. |
| 226 | (cond ((fboundp 'display-message) | 194 | ;; Emacs way of preventing log messages. |
| 227 | ;; XEmacs 19.13 way of preventing log messages. | 195 | (let ((message-log-max nil)) |
| 228 | (cond (eldoc-last-message | 196 | (cond (eldoc-last-message (message "%s" eldoc-last-message)) |
| 229 | (display-message 'no-log eldoc-last-message)) | 197 | (omessage (message nil))))) |
| 230 | (omessage | ||
| 231 | (clear-message 'no-log)))) | ||
| 232 | (t | ||
| 233 | ;; Emacs way of preventing log messages. | ||
| 234 | (let ((message-log-max nil)) | ||
| 235 | (cond (eldoc-last-message | ||
| 236 | (message "%s" eldoc-last-message)) | ||
| 237 | (omessage | ||
| 238 | (message nil))))))) | ||
| 239 | eldoc-last-message) | 198 | eldoc-last-message) |
| 240 | 199 | ||
| 241 | ;; This function goes on pre-command-hook for XEmacs or when using idle | 200 | ;; This function goes on pre-command-hook for XEmacs or when using idle |
| @@ -253,24 +212,14 @@ With prefix ARG, turn ElDoc mode on if and only if ARG is positive." | |||
| 253 | ;; Decide whether now is a good time to display a message. | 212 | ;; Decide whether now is a good time to display a message. |
| 254 | (defun eldoc-display-message-p () | 213 | (defun eldoc-display-message-p () |
| 255 | (and (eldoc-display-message-no-interference-p) | 214 | (and (eldoc-display-message-no-interference-p) |
| 256 | (cond (eldoc-use-idle-timer-p | 215 | ;; If this-command is non-nil while running via an idle |
| 257 | ;; If this-command is non-nil while running via an idle | 216 | ;; timer, we're still in the middle of executing a command, |
| 258 | ;; timer, we're still in the middle of executing a command, | 217 | ;; e.g. a query-replace where it would be annoying to |
| 259 | ;; e.g. a query-replace where it would be annoying to | 218 | ;; overwrite the echo area. |
| 260 | ;; overwrite the echo area. | 219 | (and (not this-command) |
| 261 | (and (not this-command) | 220 | (symbolp last-command) |
| 262 | (symbolp last-command) | 221 | (intern-soft (symbol-name last-command) |
| 263 | (intern-soft (symbol-name last-command) | 222 | eldoc-message-commands)))) |
| 264 | eldoc-message-commands))) | ||
| 265 | (t | ||
| 266 | ;; If we don't have idle timers, this function is | ||
| 267 | ;; running on post-command-hook directly; that means the | ||
| 268 | ;; user's last command is still on `this-command', and we | ||
| 269 | ;; must wait briefly for input to see whether to do display. | ||
| 270 | (and (symbolp this-command) | ||
| 271 | (intern-soft (symbol-name this-command) | ||
| 272 | eldoc-message-commands) | ||
| 273 | (sit-for eldoc-idle-delay)))))) | ||
| 274 | 223 | ||
| 275 | ;; Check various conditions about the current environment that might make | 224 | ;; Check various conditions about the current environment that might make |
| 276 | ;; it undesirable to print eldoc messages right this instant. | 225 | ;; it undesirable to print eldoc messages right this instant. |
| @@ -307,9 +256,7 @@ With prefix ARG, turn ElDoc mode on if and only if ARG is positive." | |||
| 307 | (defun eldoc-get-fnsym-args-string (sym) | 256 | (defun eldoc-get-fnsym-args-string (sym) |
| 308 | (let ((args nil) | 257 | (let ((args nil) |
| 309 | (doc nil)) | 258 | (doc nil)) |
| 310 | (cond ((not (and sym | 259 | (cond ((not (and sym (symbolp sym) (fboundp sym)))) |
| 311 | (symbolp sym) | ||
| 312 | (fboundp sym)))) | ||
| 313 | ((and (eq sym (aref eldoc-last-data 0)) | 260 | ((and (eq sym (aref eldoc-last-data 0)) |
| 314 | (eq 'function (aref eldoc-last-data 2))) | 261 | (eq 'function (aref eldoc-last-data 2))) |
| 315 | (setq doc (aref eldoc-last-data 1))) | 262 | (setq doc (aref eldoc-last-data 1))) |
| @@ -362,8 +309,7 @@ With prefix ARG, turn ElDoc mode on if and only if ARG is positive." | |||
| 362 | (defun eldoc-docstring-format-sym-doc (sym doc) | 309 | (defun eldoc-docstring-format-sym-doc (sym doc) |
| 363 | (save-match-data | 310 | (save-match-data |
| 364 | (let* ((name (symbol-name sym)) | 311 | (let* ((name (symbol-name sym)) |
| 365 | (ea-multi (and eldoc-echo-area-multiline-supported-p | 312 | (ea-multi eldoc-echo-area-use-multiline-p) |
| 366 | eldoc-echo-area-use-multiline-p)) | ||
| 367 | ;; Subtract 1 from window width since emacs will not write | 313 | ;; Subtract 1 from window width since emacs will not write |
| 368 | ;; any chars to the last column, or in later versions, will | 314 | ;; any chars to the last column, or in later versions, will |
| 369 | ;; cause a wraparound and resize of the echo area. | 315 | ;; cause a wraparound and resize of the echo area. |
| @@ -473,9 +419,9 @@ With prefix ARG, turn ElDoc mode on if and only if ARG is positive." | |||
| 473 | 419 | ||
| 474 | (defun eldoc-add-command-completions (&rest names) | 420 | (defun eldoc-add-command-completions (&rest names) |
| 475 | (while names | 421 | (while names |
| 476 | (apply 'eldoc-add-command | 422 | (apply 'eldoc-add-command |
| 477 | (all-completions (car names) obarray 'fboundp)) | 423 | (all-completions (car names) obarray 'fboundp)) |
| 478 | (setq names (cdr names)))) | 424 | (setq names (cdr names)))) |
| 479 | 425 | ||
| 480 | (defun eldoc-remove-command (&rest cmds) | 426 | (defun eldoc-remove-command (&rest cmds) |
| 481 | (let (name) | 427 | (let (name) |
| @@ -486,11 +432,7 @@ With prefix ARG, turn ElDoc mode on if and only if ARG is positive." | |||
| 486 | (and (symbolp name) | 432 | (and (symbolp name) |
| 487 | (setq name (symbol-name name))) | 433 | (setq name (symbol-name name))) |
| 488 | 434 | ||
| 489 | (if (fboundp 'unintern) | 435 | (unintern name eldoc-message-commands)))) |
| 490 | (unintern name eldoc-message-commands) | ||
| 491 | (let ((s (intern-soft name eldoc-message-commands))) | ||
| 492 | (and s | ||
| 493 | (makunbound s))))))) | ||
| 494 | 436 | ||
| 495 | (defun eldoc-remove-command-completions (&rest names) | 437 | (defun eldoc-remove-command-completions (&rest names) |
| 496 | (while names | 438 | (while names |