diff options
| author | Stefan Monnier | 2014-09-04 11:23:37 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-09-04 11:23:37 -0400 |
| commit | 1f69089d359f5c2c04bffc352b16810d40f79a36 (patch) | |
| tree | aa00fc1ddfe3da53dc67b37a3518460f3b7b7530 | |
| parent | e77bcfa34d3dfd0efb6ffb40e4035374e22143fc (diff) | |
| download | emacs-1f69089d359f5c2c04bffc352b16810d40f79a36.tar.gz emacs-1f69089d359f5c2c04bffc352b16810d40f79a36.zip | |
* lisp/emacs-lisp/eldoc.el (eldoc-function-argstring): Don't strip
terminating paren.
(eldoc-last-data-store): Return cached data.
(eldoc-get-var-docstring): Avoid setq.
(eldoc-get-fnsym-args-string): Clarify data flow.
Fixes: debbugs:18352
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eldoc.el | 68 |
2 files changed, 43 insertions, 33 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 78d3cf56321..24adcdc13c9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2014-09-04 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/eldoc.el (eldoc-function-argstring): Don't strip | ||
| 4 | terminating paren (bug#18352). | ||
| 5 | (eldoc-last-data-store): Return cached data. | ||
| 6 | (eldoc-get-var-docstring): Avoid setq. | ||
| 7 | (eldoc-get-fnsym-args-string): Clarify data flow. | ||
| 8 | |||
| 1 | 2014-09-04 Thierry Volpiatto <thierry.volpiatto@gmail.com> | 9 | 2014-09-04 Thierry Volpiatto <thierry.volpiatto@gmail.com> |
| 2 | 10 | ||
| 3 | * emacs-lisp/eldoc.el (eldoc-highlight-function-argument): Handle the | 11 | * emacs-lisp/eldoc.el (eldoc-highlight-function-argument): Handle the |
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index acb1bdc32e8..6f933268e52 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 -*- lexical-binding: t; -*- | 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 | ||
| @@ -344,27 +344,29 @@ Emacs Lisp mode) that support ElDoc.") | |||
| 344 | "Return a string containing the parameter list of the function SYM. | 344 | "Return a string containing the parameter list of the function SYM. |
| 345 | If SYM is a subr and no arglist is obtainable from the docstring | 345 | If SYM is a subr and no arglist is obtainable from the docstring |
| 346 | or elsewhere, return a 1-line docstring." | 346 | or elsewhere, return a 1-line docstring." |
| 347 | (let (args doc advertised) | 347 | (let ((argstring |
| 348 | (cond ((not (and sym (symbolp sym) (fboundp sym)))) | 348 | (cond |
| 349 | ((not (and sym (symbolp sym) (fboundp sym))) nil) | ||
| 349 | ((and (eq sym (aref eldoc-last-data 0)) | 350 | ((and (eq sym (aref eldoc-last-data 0)) |
| 350 | (eq 'function (aref eldoc-last-data 2))) | 351 | (eq 'function (aref eldoc-last-data 2))) |
| 351 | (setq doc (aref eldoc-last-data 1))) | 352 | (aref eldoc-last-data 1)) |
| 352 | ((listp (setq advertised (gethash (indirect-function sym) | ||
| 353 | advertised-signature-table t))) | ||
| 354 | (setq args advertised)) | ||
| 355 | ((setq doc (help-split-fundoc (documentation sym t) sym)) | ||
| 356 | (setq args (car doc))) | ||
| 357 | (t | 353 | (t |
| 358 | (setq args (help-function-arglist sym)))) | 354 | (let* ((advertised (gethash (indirect-function sym) |
| 359 | (if args | 355 | advertised-signature-table t)) |
| 360 | ;; Stringify, and store before highlighting, downcasing, etc. | 356 | doc |
| 361 | ;; FIXME should truncate before storing. | 357 | (args |
| 362 | (eldoc-last-data-store sym (setq args (eldoc-function-argstring args)) | 358 | (cond |
| 363 | 'function) | 359 | ((listp advertised) advertised) |
| 364 | (setq args doc)) ; use stored value | 360 | ((setq doc (help-split-fundoc (documentation sym t) sym)) |
| 365 | ;; Change case, highlight, truncate. | 361 | (car doc)) |
| 366 | (if args | 362 | (t (help-function-arglist sym))))) |
| 367 | (eldoc-highlight-function-argument sym args index)))) | 363 | ;; Stringify, and store before highlighting, downcasing, etc. |
| 364 | ;; FIXME should truncate before storing. | ||
| 365 | (eldoc-last-data-store sym (eldoc-function-argstring args) | ||
| 366 | 'function)))))) | ||
| 367 | ;; Highlight, truncate. | ||
| 368 | (if argstring | ||
| 369 | (eldoc-highlight-function-argument sym argstring index)))) | ||
| 368 | 370 | ||
| 369 | (defun eldoc-highlight-function-argument (sym args index) | 371 | (defun eldoc-highlight-function-argument (sym args index) |
| 370 | "Highlight argument INDEX in ARGS list for function SYM. | 372 | "Highlight argument INDEX in ARGS list for function SYM. |
| @@ -478,23 +480,23 @@ In the absence of INDEX, just call `eldoc-docstring-format-sym-doc'." | |||
| 478 | ;; Return a string containing a brief (one-line) documentation string for | 480 | ;; Return a string containing a brief (one-line) documentation string for |
| 479 | ;; the variable. | 481 | ;; the variable. |
| 480 | (defun eldoc-get-var-docstring (sym) | 482 | (defun eldoc-get-var-docstring (sym) |
| 481 | (when sym | 483 | (cond ((not sym) nil) |
| 482 | (cond ((and (eq sym (aref eldoc-last-data 0)) | 484 | ((and (eq sym (aref eldoc-last-data 0)) |
| 483 | (eq 'variable (aref eldoc-last-data 2))) | 485 | (eq 'variable (aref eldoc-last-data 2))) |
| 484 | (aref eldoc-last-data 1)) | 486 | (aref eldoc-last-data 1)) |
| 485 | (t | 487 | (t |
| 486 | (let ((doc (documentation-property sym 'variable-documentation t))) | 488 | (let ((doc (documentation-property sym 'variable-documentation t))) |
| 487 | (cond (doc | 489 | (when doc |
| 488 | (setq doc (eldoc-docstring-format-sym-doc | 490 | (let ((doc (eldoc-docstring-format-sym-doc |
| 489 | sym (eldoc-docstring-first-line doc) | 491 | sym (eldoc-docstring-first-line doc) |
| 490 | 'font-lock-variable-name-face)) | 492 | 'font-lock-variable-name-face))) |
| 491 | (eldoc-last-data-store sym doc 'variable))) | 493 | (eldoc-last-data-store sym doc 'variable))))))) |
| 492 | doc))))) | ||
| 493 | 494 | ||
| 494 | (defun eldoc-last-data-store (symbol doc type) | 495 | (defun eldoc-last-data-store (symbol doc type) |
| 495 | (aset eldoc-last-data 0 symbol) | 496 | (aset eldoc-last-data 0 symbol) |
| 496 | (aset eldoc-last-data 1 doc) | 497 | (aset eldoc-last-data 1 doc) |
| 497 | (aset eldoc-last-data 2 type)) | 498 | (aset eldoc-last-data 2 type) |
| 499 | doc) | ||
| 498 | 500 | ||
| 499 | ;; Note that any leading `*' in the docstring (which indicates the variable | 501 | ;; Note that any leading `*' in the docstring (which indicates the variable |
| 500 | ;; is a user option) is removed. | 502 | ;; is a user option) is removed. |
| @@ -596,7 +598,7 @@ ARGLIST is either a string, or a list of strings or symbols." | |||
| 596 | (let ((str (cond ((stringp arglist) arglist) | 598 | (let ((str (cond ((stringp arglist) arglist) |
| 597 | ((not (listp arglist)) nil) | 599 | ((not (listp arglist)) nil) |
| 598 | (t (format "%S" (help-make-usage 'toto arglist)))))) | 600 | (t (format "%S" (help-make-usage 'toto arglist)))))) |
| 599 | (if (and str (string-match "\\`([^ ]+ ?" str)) | 601 | (if (and str (string-match "\\`([^ )]+ ?" str)) |
| 600 | (replace-match "(" t t str) | 602 | (replace-match "(" t t str) |
| 601 | str))) | 603 | str))) |
| 602 | 604 | ||