diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-01-16 22:52:15 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-01-16 22:52:15 -0500 |
commit | 24b7f77581c7eefe484db6cbbd661c04460c66aa (patch) | |
tree | 59bf6bdfba55d0f5aeb73a755e2420ce19ac7c3a /lisp/help-fns.el | |
parent | a2cd6d90d20408a6265c8615697dbff94df3f098 (diff) | |
download | emacs-24b7f77581c7eefe484db6cbbd661c04460c66aa.tar.gz |
Improve handling of doc-strings and describe-function for cl-generic
* lisp/help-fns.el (find-lisp-object-file-name): Accept any `type' as long
as it's a symbol.
(help-fns-short-filename): New function.
(describe-function-1): Use it. Use autoload-do-load.
* lisp/help-mode.el (help-function-def): Add optional arg `type'.
* lisp/emacs-lisp/cl-generic.el (cl-generic-ensure-function): It's OK to
override an autoload.
(cl-generic-current-method-specializers): Replace dyn-bind variable
with a lexically-scoped macro.
(cl--generic-lambda): Update accordingly.
(cl-generic-define-method): Record manually in the load-history with
type `cl-defmethod'.
(cl--generic-get-dispatcher): Minor optimization.
(cl--generic-search-method): New function.
(find-function-regexp-alist): Add entry for `cl-defmethod' type.
(cl--generic-search-method): Add hyperlinks for methods. Merge the
specializers and the function's arguments.
* lisp/emacs-lisp/eieio-core.el (eieio--defalias): Move to eieio-generic.el.
(eieio-defclass-autoload): Don't record the superclasses any more.
(eieio-defclass-internal): Reuse the old class object if it was just an
autoload stub.
(eieio--class-precedence-list): Load the class if it's autoloaded.
* lisp/emacs-lisp/eieio-generic.el (eieio--defalias): Move from eieio-core.
(eieio--defgeneric-init-form): Don't throw away a previous docstring.
(eieio--method-optimize-primary): Don't mess with the docstring.
(defgeneric): Keep the `args' in the docstring.
(defmethod): Don't use the method's docstring for the generic
function's docstring.
* lisp/emacs-lisp/find-func.el: Use lexical-binding.
(find-function-regexp): Don't rule out `defgeneric'.
(find-function-regexp-alist): Document new possibility of including
a function instead of a regexp.
(find-function-search-for-symbol): Implement that new possibility.
(find-function-library): Don't assume that `function' is a symbol.
(find-function-do-it): Remove unused var `orig-buf'.
* test/automated/cl-generic-tests.el (cl-generic-test-8-after/before):
Rename from cl-generic-test-7-after/before.
(cl--generic-test-advice): New function.
(cl-generic-test-9-advice): New test.
* test/automated/eieio-test-methodinvoke.el (eieio-test-cl-generic-1): Reset
eieio-test--1.
Diffstat (limited to 'lisp/help-fns.el')
-rw-r--r-- | lisp/help-fns.el | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 10c040a246c..c0d63935035 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -183,8 +183,7 @@ OBJECT should be a symbol associated with a function, variable, or face; alternatively, it can be a function definition. If TYPE is `defvar', search for a variable definition. If TYPE is `defface', search for a face definition. -If TYPE is the value returned by `symbol-function' for a function symbol, - search for a function definition. +If TYPE is not a symbol, search for a function definition. The return value is the absolute name of a readable file where OBJECT is defined. If several such files exist, preference is given to a file @@ -194,9 +193,10 @@ suitable file is found, return nil." (let* ((autoloaded (autoloadp type)) (file-name (or (and autoloaded (nth 1 type)) (symbol-file - object (if (memq type (list 'defvar 'defface)) - type - 'defun))))) + ;; FIXME: Why do we have this weird "If TYPE is the + ;; value returned by `symbol-function' for a function + ;; symbol" exception? + object (or (if (symbolp type) type) 'defun))))) (cond (autoloaded ;; An autoloaded function: Locate the file since `symbol-function' @@ -452,6 +452,18 @@ FILE is the file where FUNCTION was probably defined." (t ".")) "\n"))))) +(defun help-fns-short-filename (filename) + (let* ((abbrev (abbreviate-file-name filename)) + (short abbrev)) + (dolist (dir load-path) + (let ((rel (file-relative-name filename dir))) + (if (< (length rel) (length short)) + (setq short rel))) + (let ((rel (file-relative-name abbrev dir))) + (if (< (length rel) (length short)) + (setq short rel)))) + short)) + ;;;###autoload (defun describe-function-1 (function) (let* ((advised (and (symbolp function) @@ -543,7 +555,7 @@ FILE is the file where FUNCTION was probably defined." ;; but that's completely wrong when the user used load-file. (princ (if (eq file-name 'C-source) "C source code" - (file-name-nondirectory file-name))) + (help-fns-short-filename file-name))) (princ "'") ;; Make a hyperlink to the library. (with-current-buffer standard-output @@ -564,7 +576,7 @@ FILE is the file where FUNCTION was probably defined." help-enable-auto-load (string-match "\\([^\\]=\\|[^=]\\|\\`\\)\\\\[[{<]" doc-raw) - (load (cadr real-def) t)) + (autoload-do-load real-def)) (substitute-command-keys doc-raw)))) (help-fns--key-bindings function) |