aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-02-08 11:10:03 +0100
committerLars Ingebrigtsen2022-02-08 11:10:03 +0100
commitf788bb33e5ac4d4a482e88dedd89e5a64dd1f7d5 (patch)
treea8795bf1d0a10b7478c2cc06fcc91633db2ba88d
parenta512940daa046cc529c679942431435175cd6903 (diff)
downloademacs-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.el19
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.
401OBJECT should be a symbol associated with a function, variable, or face; 401OBJECT 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.
407The return value is the absolute name of a readable file where OBJECT is 407The return value is the absolute name of a readable file where OBJECT is
408defined. If several such files exist, preference is given to a file 408defined. If several such files exist, preference is given to a file
409found via `load-path'. The return value can also be `C-source', which 409found via `load-path'. The return value can also be `C-source', which
410means that OBJECT is a function or variable defined in C. If no 410means that OBJECT is a function or variable defined in C, but
411suitable file is found, return nil." 411it's currently unknown where. If no suitable file is found,
412return nil.
413
414If ALSO-C-SOURCE is non-nil, instead of returning `C-source',
415this function will attempt to locate the definition of OBJECT in
416the 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))