diff options
author | Leo Liu <sdl.web@gmail.com> | 2014-03-31 09:31:17 +0800 |
---|---|---|
committer | Leo Liu <sdl.web@gmail.com> | 2014-03-31 09:31:17 +0800 |
commit | 294b2b0928d7704915a480f43d1eb5c75fc35456 (patch) | |
tree | 8ac84ff9a5a99aa09564422b371cf261ea8e92b9 /lisp | |
parent | 1db854ccdd81811709b10b6793730e0dd1960021 (diff) |
* emacs-lisp/eldoc.el (eldoc-print-current-symbol-info): Refactor
out eldoc-documentation-function-default.
(eldoc-documentation-function-default): New function.
(eldoc-documentation-function): Change value.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 7 | ||||
-rw-r--r-- | lisp/emacs-lisp/eldoc.el | 34 |
2 files changed, 23 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index aae850d47a..52a974fa21 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-03-31 Leo Liu <sdl.web@gmail.com> + + * emacs-lisp/eldoc.el (eldoc-print-current-symbol-info): Refactor + out eldoc-documentation-function-default. + (eldoc-documentation-function-default): New function. + (eldoc-documentation-function): Change value. + 2014-03-31 Glenn Morris <rgm@gnu.org> * simple.el (cycle-spacing--context, cycle-spacing): Doc tweaks. diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index c64ec52dec..7102b5549e 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -298,8 +298,8 @@ Otherwise work like `message'." ;;;###autoload -(defvar eldoc-documentation-function nil - "If non-nil, function to call to return doc string. +(defvar eldoc-documentation-function #'eldoc-documentation-function-default + "Function to call to return doc string. The function of no args should return a one-line string for displaying doc about a function etc. appropriate to the context around point. It should return nil if there's no doc appropriate for the context. @@ -323,22 +323,20 @@ Emacs Lisp mode) that support ElDoc.") (when eldoc-last-message (eldoc-message nil) nil)) - (if eldoc-documentation-function - (eldoc-message (funcall eldoc-documentation-function)) - (let* ((current-symbol (eldoc-current-symbol)) - (current-fnsym (eldoc-fnsym-in-current-sexp)) - (doc (cond - ((null current-fnsym) - nil) - ((eq current-symbol (car current-fnsym)) - (or (apply 'eldoc-get-fnsym-args-string - current-fnsym) - (eldoc-get-var-docstring current-symbol))) - (t - (or (eldoc-get-var-docstring current-symbol) - (apply 'eldoc-get-fnsym-args-string - current-fnsym)))))) - (eldoc-message doc)))))) + (eldoc-message (funcall eldoc-documentation-function))))) + +(defun eldoc-documentation-function-default () + "Default value for `eldoc-documentation-function' (which see)." + (let ((current-symbol (eldoc-current-symbol)) + (current-fnsym (eldoc-fnsym-in-current-sexp))) + (cond ((null current-fnsym) + nil) + ((eq current-symbol (car current-fnsym)) + (or (apply #'eldoc-get-fnsym-args-string current-fnsym) + (eldoc-get-var-docstring current-symbol))) + (t + (or (eldoc-get-var-docstring current-symbol) + (apply #'eldoc-get-fnsym-args-string current-fnsym)))))) (defun eldoc-get-fnsym-args-string (sym &optional index) "Return a string containing the parameter list of the function SYM. |