Function: help-C-file-name
help-C-file-name is an autoloaded and byte-compiled function defined
in help-fns.el.gz.
Signature
(help-C-file-name SUBR-OR-VAR KIND)
Documentation
Return the name of the C file where SUBR-OR-VAR is defined.
KIND should be var for a variable or subr for a subroutine.
If we can't find the file name, nil is returned.
Source Code
;; Defined in /usr/src/emacs/lisp/help-fns.el.gz
;; Could be this, if we make symbol-file do the work below.
;; (defun help-C-file-name (subr-or-var kind)
;; "Return the name of the C file where SUBR-OR-VAR is defined.
;; KIND should be `var' for a variable or `subr' for a subroutine."
;; (symbol-file (if (symbolp subr-or-var) subr-or-var
;; (subr-name subr-or-var))
;; (if (eq kind 'var) 'defvar 'defun)))
;;;###autoload
(defun help-C-file-name (subr-or-var kind)
"Return the name of the C file where SUBR-OR-VAR is defined.
KIND should be `var' for a variable or `subr' for a subroutine.
If we can't find the file name, nil is returned."
(let ((docbuf (get-buffer-create " *DOC*"))
(name (if (eq 'var kind)
(concat "V" (symbol-name subr-or-var))
(concat "F" (if (symbolp subr-or-var)
(symbol-name subr-or-var)
(subr-name (advice--cd*r subr-or-var)))))))
(with-current-buffer docbuf
(goto-char (point-min))
(if (eobp)
(insert-file-contents-literally
(expand-file-name internal-doc-file-name doc-directory)))
(let ((file (catch 'loop
(while t
(let ((pnt (search-forward (concat "\^_" name "\n")
nil t)))
(if (not pnt)
(throw 'loop nil)
(re-search-backward "\^_S\\(.*\\)")
(let ((file (match-string 1)))
(if (member file build-files)
(throw 'loop file)
(goto-char pnt)))))))))
(if (not file)
nil
(if (string-match "^ns.*\\(\\.o\\|obj\\)\\'" file)
(setq file (replace-match ".m" t t file 1))
(if (string-match "\\.\\(o\\|obj\\)\\'" file)
(setq file (replace-match ".c" t t file))))
(if (string-match "\\.\\(c\\|m\\)\\'" file)
(concat "src/" file)
file))))))