Commit c1286376 authored by Noah Friedman's avatar Noah Friedman
Browse files

(eldoc-message-commands): Move docstring into comments, since this isn't

a user variable.

(eldoc-message-commands-table-size, eldoc-use-idle-timer-p,
eldoc-function-argstring-from-docstring-method-table): Use defvar,
not defconst.

(eldoc-last-data): Use cons explicitly; don't rely on dotted pair read
syntax.  I'm worried the latter might get compiled as read-only data someday.

(eldoc-docstring-message): If truncating symbol name, show ending of name
rather than beginning.  The former is generally more unique.

(eldoc-function-argstring-from-docstring-method-table): Handle
pathological `save-restriction' case.

[top level]: Add `indent-for-tab-command' to eldoc-message-commands.
parent 2a7d4505
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;; Keywords: extensions ;; Keywords: extensions
;; Created: 1995-10-06 ;; Created: 1995-10-06
;; $Id: eldoc.el,v 1.11 1997/03/27 10:44:56 friedman Exp rms $ ;; $Id: eldoc.el,v 1.12 1997/04/14 07:33:28 rms Exp $
;; This file is part of GNU Emacs. ;; This file is part of GNU Emacs.
...@@ -106,31 +106,31 @@ returns another string is acceptable." ...@@ -106,31 +106,31 @@ returns another string is acceptable."
;; No user options below here. ;; No user options below here.
(defvar eldoc-message-commands nil ;; Commands after which it is appropriate to print in the echo area.
"Commands after which it is appropriate to print in the echo area. ;; Eldoc does not try to print function arglists, etc. after just any command,
;; because some commands print their own messages in the echo area and these
Eldoc does not try to print function arglists, etc. after just any command, ;; functions would instantly overwrite them. But self-insert-command as well
because some commands print their own messages in the echo area and these ;; as most motion commands are good candidates.
functions would instantly overwrite them. But self-insert-command as well ;; This variable contains an obarray of symbols; do not manipulate it
as most motion commands are good candidates. ;; directly. Instead, use `eldoc-add-command' and `eldoc-remove-command'.
(defvar eldoc-message-commands nil)
This variable contains an obarray of symbols; do not manipulate it
directly. Instead, use the functions `eldoc-add-command' and
`eldoc-remove-command'.")
;; This is used by eldoc-add-command to initialize eldoc-message-commands ;; This is used by eldoc-add-command to initialize eldoc-message-commands
;; as an obarray. ;; as an obarray.
;; If you increase the number of buckets, keep it a prime number. ;; It should probably never be necessary to do so, but if you
(defconst eldoc-message-commands-table-size 31) ;; choose to increase the number of buckets, you must do so before loading
;; this file since the obarray is initialized at load time.
;; Remember to keep it a prime number to improve hash performance.
(defvar eldoc-message-commands-table-size 31)
;; Bookkeeping; the car contains the last symbol read from the buffer. ;; Bookkeeping; the car contains the last symbol read from the buffer.
;; The cdr contains the string last displayed in the echo area, so it can ;; The cdr contains the string last displayed in the echo area, so it can
;; be printed again if necessary without reconsing. ;; be printed again if necessary without reconsing.
(defvar eldoc-last-data '(nil . nil)) (defvar eldoc-last-data (cons nil nil))
(defvar eldoc-last-message nil) (defvar eldoc-last-message nil)
;; Idle timers are supported in Emacs 19.31 and later. ;; Idle timers are supported in Emacs 19.31 and later.
(defconst eldoc-use-idle-timer-p (fboundp 'run-with-idle-timer)) (defvar eldoc-use-idle-timer-p (fboundp 'run-with-idle-timer))
;; eldoc's timer object, if using idle timers ;; eldoc's timer object, if using idle timers
(defvar eldoc-timer nil) (defvar eldoc-timer nil)
...@@ -394,7 +394,13 @@ the mode, respectively." ...@@ -394,7 +394,13 @@ the mode, respectively."
(cond ((>= strip len) (cond ((>= strip len)
(format "%s" doc)) (format "%s" doc))
(t (t
(setq name (substring name 0 (- len strip))) ;;(setq name (substring name 0 (- len strip)))
;;
;; Show the end of the partial variable name,
;; rather than the beginning, since the former
;; is more likely to be unique given package
;; namespace conventions.
(setq name (substring name strip))
(format "%s: %s" name doc))))) (format "%s: %s" name doc)))))
(t (t
(format "%s: %s" symbol doc)))))))) (format "%s: %s" symbol doc))))))))
...@@ -417,11 +423,11 @@ the mode, respectively." ...@@ -417,11 +423,11 @@ the mode, respectively."
;; The order in this table is significant, since later predicates may be ;; The order in this table is significant, since later predicates may be
;; more general than earlier ones. ;; more general than earlier ones.
;; ;;
;; Compiler note for Emacs 19.29 and later: these functions will be ;; Compiler note for Emacs/XEmacs versions which support dynamic loading:
;; compiled to bytecode, but can't be lazy-loaded even if you set ;; these functions will be compiled to bytecode, but can't be lazy-loaded
;; byte-compile-dynamic; to do that would require making them named ;; even if you set byte-compile-dynamic; to do that would require making
;; top-level defuns, and that's not particularly desirable either. ;; them named top-level defuns, which is not particularly desirable either.
(defconst eldoc-function-argstring-from-docstring-method-table (defvar eldoc-function-argstring-from-docstring-method-table
(list (list
;; Try first searching for args starting with symbol name. ;; Try first searching for args starting with symbol name.
;; This is to avoid matching parenthetical remarks in e.g. sit-for. ;; This is to avoid matching parenthetical remarks in e.g. sit-for.
...@@ -437,7 +443,10 @@ the mode, respectively." ...@@ -437,7 +443,10 @@ the mode, respectively."
;; Try again not requiring this symbol name in the docstring. ;; Try again not requiring this symbol name in the docstring.
;; This will be the case when looking up aliases. ;; This will be the case when looking up aliases.
(list (function (lambda (doc fn) (list (function (lambda (doc fn)
(string-match "^([^\n)]+)$" doc))) ;; save-restriction has a pathological docstring in
;; Emacs/XEmacs 19.
(and (not (eq fn 'save-restriction))
(string-match "^([^\n)]+)$" doc))))
(function (lambda (doc) (function (lambda (doc)
;; end does not include trailing ")" sequence. ;; end does not include trailing ")" sequence.
(let ((end (- (match-end 0) 1))) (let ((end (- (match-end 0) 1)))
...@@ -490,8 +499,7 @@ the mode, respectively." ...@@ -490,8 +499,7 @@ the mode, respectively."
(function (lambda (doc) (function (lambda (doc)
(substring doc (match-beginning 1) (match-end 1))))) (substring doc (match-beginning 1) (match-end 1)))))
;; These subrs don't have arglists in their docstrings. ;; These common subrs don't have arglists in their docstrings. So cheat.
;; This is cheating.
(list (function (lambda (doc fn) (list (function (lambda (doc fn)
(memq fn '(and or list + -)))) (memq fn '(and or list + -))))
(function (lambda (doc) (function (lambda (doc)
...@@ -593,8 +601,9 @@ the mode, respectively." ...@@ -593,8 +601,9 @@ the mode, respectively."
;; Prime the command list. ;; Prime the command list.
(eldoc-add-command-completions (eldoc-add-command-completions
"backward-" "beginning-of-" "delete-other-windows" "delete-window" "backward-" "beginning-of-" "delete-other-windows" "delete-window"
"end-of-" "forward-" "goto-" "mouse-set-point" "next-" "other-window" "end-of-" "forward-" "indent-for-tab-command" "goto-" "mouse-set-point"
"previous-" "recenter" "scroll-" "self-insert-command" "split-window-") "next-" "other-window" "previous-" "recenter" "scroll-"
"self-insert-command" "split-window-")
(provide 'eldoc) (provide 'eldoc)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment