diff options
| author | Lars Ingebrigtsen | 2022-02-08 11:10:03 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-02-08 11:10:03 +0100 |
| commit | f788bb33e5ac4d4a482e88dedd89e5a64dd1f7d5 (patch) | |
| tree | a8795bf1d0a10b7478c2cc06fcc91633db2ba88d | |
| parent | a512940daa046cc529c679942431435175cd6903 (diff) | |
| download | emacs-f788bb33e5ac4d4a482e88dedd89e5a64dd1f7d5.tar.gz emacs-f788bb33e5ac4d4a482e88dedd89e5a64dd1f7d5.zip | |
Extend find-lisp-object-file-name
* lisp/help-fns.el (find-lisp-object-file-name): Add optional
parameter to always look in the DOC file (bug#17685).
| -rw-r--r-- | lisp/help-fns.el | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 5da575aa8d1..80d7d5cb028 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el | |||
| @@ -396,7 +396,7 @@ if the variable `help-downcase-arguments' is non-nil." | |||
| 396 | ;; `describe-face' (instead of `describe-simplify-lib-file-name'). | 396 | ;; `describe-face' (instead of `describe-simplify-lib-file-name'). |
| 397 | 397 | ||
| 398 | ;;;###autoload | 398 | ;;;###autoload |
| 399 | (defun find-lisp-object-file-name (object type) | 399 | (defun find-lisp-object-file-name (object type &optional also-c-source) |
| 400 | "Guess the file that defined the Lisp object OBJECT, of type TYPE. | 400 | "Guess the file that defined the Lisp object OBJECT, of type TYPE. |
| 401 | OBJECT should be a symbol associated with a function, variable, or face; | 401 | OBJECT should be a symbol associated with a function, variable, or face; |
| 402 | alternatively, it can be a function definition. | 402 | alternatively, it can be a function definition. |
| @@ -407,8 +407,13 @@ If TYPE is not a symbol, search for a function definition. | |||
| 407 | The return value is the absolute name of a readable file where OBJECT is | 407 | The return value is the absolute name of a readable file where OBJECT is |
| 408 | defined. If several such files exist, preference is given to a file | 408 | defined. If several such files exist, preference is given to a file |
| 409 | found via `load-path'. The return value can also be `C-source', which | 409 | found via `load-path'. The return value can also be `C-source', which |
| 410 | means that OBJECT is a function or variable defined in C. If no | 410 | means that OBJECT is a function or variable defined in C, but |
| 411 | suitable file is found, return nil." | 411 | it's currently unknown where. If no suitable file is found, |
| 412 | return nil. | ||
| 413 | |||
| 414 | If ALSO-C-SOURCE is non-nil, instead of returning `C-source', | ||
| 415 | this function will attempt to locate the definition of OBJECT in | ||
| 416 | the C sources, too." | ||
| 412 | (let* ((autoloaded (autoloadp type)) | 417 | (let* ((autoloaded (autoloadp type)) |
| 413 | (file-name (or (and autoloaded (nth 1 type)) | 418 | (file-name (or (and autoloaded (nth 1 type)) |
| 414 | (symbol-file | 419 | (symbol-file |
| @@ -445,14 +450,18 @@ suitable file is found, return nil." | |||
| 445 | (cond | 450 | (cond |
| 446 | ((and (not file-name) (subrp type)) | 451 | ((and (not file-name) (subrp type)) |
| 447 | ;; A built-in function. The form is from `describe-function-1'. | 452 | ;; A built-in function. The form is from `describe-function-1'. |
| 448 | (if (get-buffer " *DOC*") | 453 | (if (or (get-buffer " *DOC*") |
| 454 | (and also-c-source | ||
| 455 | (get-buffer-create " *DOC*"))) | ||
| 449 | (help-C-file-name type 'subr) | 456 | (help-C-file-name type 'subr) |
| 450 | 'C-source)) | 457 | 'C-source)) |
| 451 | ((and (not file-name) (symbolp object) | 458 | ((and (not file-name) (symbolp object) |
| 452 | (eq type 'defvar) | 459 | (eq type 'defvar) |
| 453 | (integerp (get object 'variable-documentation))) | 460 | (integerp (get object 'variable-documentation))) |
| 454 | ;; A variable defined in C. The form is from `describe-variable'. | 461 | ;; A variable defined in C. The form is from `describe-variable'. |
| 455 | (if (get-buffer " *DOC*") | 462 | (if (or (get-buffer " *DOC*") |
| 463 | (and also-c-source | ||
| 464 | (get-buffer-create " *DOC*"))) | ||
| 456 | (help-C-file-name object 'var) | 465 | (help-C-file-name object 'var) |
| 457 | 'C-source)) | 466 | 'C-source)) |
| 458 | ((not (stringp file-name)) | 467 | ((not (stringp file-name)) |