aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/help-mode.el
diff options
context:
space:
mode:
authorStefan Monnier2015-07-07 02:14:16 -0400
committerStefan Monnier2015-07-07 02:14:16 -0400
commit59b5723c9b613f14cd60cd3239cfdbc0d2343b18 (patch)
tree923edc0b04619ab41af69078d8cd9e3f86df5038 /lisp/help-mode.el
parent287bce988895b104c33d53faacfffd91d8d8e0f1 (diff)
downloademacs-59b5723c9b613f14cd60cd3239cfdbc0d2343b18.tar.gz
emacs-59b5723c9b613f14cd60cd3239cfdbc0d2343b18.zip
Add online-help support to describe types
* lisp/help-fns.el (describe-symbol-backends): Move to help-mode.el. (describe-symbol): Improve the selection of default. * lisp/help-mode.el: Require cl-lib. (describe-symbol-backends): Move from help-fns.el. (help-make-xrefs): Use it. * lisp/emacs-lisp/cl-extra.el (describe-symbol-backends): Add entry for types. (cl--typedef-regexp): New const. (find-function-regexp-alist): Add entry for types. (cl-help-type, cl-type-definition): New buttons. (cl-find-class): New function. (cl-describe-type): New command. (cl--describe-class, cl--describe-class-slot) (cl--describe-class-slots): New functions, moved from eieio-opt.el. * lisp/emacs-lisp/cl-generic.el (cl--generic-method-documentation) (cl--generic-all-functions, cl--generic-specializers-apply-to-type-p): New functions. Moved from eieio-opt.el. (cl--generic-class-parents): New function, extracted from cl--generic-struct-specializers. (cl--generic-struct-specializers): Use it. * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Use pcase-dolist. Improve constructor's docstrings. (cl-struct-unknown-slot): New error. (cl-struct-slot-offset): Use it. * lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Record the type definition in current-load-list. * lisp/emacs-lisp/eieio-core.el (eieio--known-slot-names): New var. (eieio--add-new-slot): Set it. (eieio-defclass-internal): Use new name for current-load-list. (eieio-oref): Add compiler-macro to warn about unknown slots. * lisp/emacs-lisp/eieio.el (defclass): Update eieio--known-slot-names as compile-time as well. Improve constructor docstrings. * lisp/emacs-lisp/eieio-opt.el (eieio-help-class) (eieio--help-print-slot, eieio-help-class-slots): Move to cl-extra.el. (eieio-class-def): Remove button. (eieio-help-constructor): Use new name for load-history element. (eieio--specializers-apply-to-class-p, eieio-all-generic-functions) (eieio-method-documentation): Move to cl-generic.el. (eieio-display-method-list): Use new names. * lisp/emacs-lisp/lisp-mode.el (lisp-imenu-generic-expression): Add "define-linline". (lisp-fdefs): Remove "defsubst". (el-fdefs): Add "defsubst", "cl-defsubst", and "define-linline". * lisp/emacs-lisp/macroexp.el (macroexp--warned): New var. (macroexp--warn-and-return): Use it to avoid inf-loops. Add `compile-only' argument.
Diffstat (limited to 'lisp/help-mode.el')
-rw-r--r--lisp/help-mode.el38
1 files changed, 15 insertions, 23 deletions
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index cdddd542532..e1fc9fd1984 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -30,6 +30,7 @@
30;;; Code: 30;;; Code:
31 31
32(require 'button) 32(require 'button)
33(require 'cl-lib)
33(eval-when-compile (require 'easymenu)) 34(eval-when-compile (require 'easymenu))
34 35
35(defvar help-mode-map 36(defvar help-mode-map
@@ -216,7 +217,8 @@ The format is (FUNCTION ARGS...).")
216 (goto-char (point-min)) 217 (goto-char (point-min))
217 (if (re-search-forward 218 (if (re-search-forward
218 (format "^[ \t]*(\\(cl-\\)?define-compiler-macro[ \t]+%s" 219 (format "^[ \t]*(\\(cl-\\)?define-compiler-macro[ \t]+%s"
219 (regexp-quote (symbol-name fun))) nil t) 220 (regexp-quote (symbol-name fun)))
221 nil t)
220 (forward-line 0) 222 (forward-line 0)
221 (message "Unable to find location in file"))) 223 (message "Unable to find location in file")))
222 (message "Unable to find file"))) 224 (message "Unable to find file")))
@@ -385,6 +387,15 @@ it does not already exist."
385 (error "Current buffer is not in Help mode")) 387 (error "Current buffer is not in Help mode"))
386 (current-buffer)))) 388 (current-buffer))))
387 389
390(defvar describe-symbol-backends
391 `((nil ,#'fboundp ,(lambda (s _b _f) (describe-function s)))
392 ("face" ,#'facep ,(lambda (s _b _f) (describe-face s)))
393 (nil
394 ,(lambda (symbol)
395 (or (and (boundp symbol) (not (keywordp symbol)))
396 (get symbol 'variable-documentation)))
397 ,#'describe-variable)))
398
388;;;###autoload 399;;;###autoload
389(defun help-make-xrefs (&optional buffer) 400(defun help-make-xrefs (&optional buffer)
390 "Parse and hyperlink documentation cross-references in the given BUFFER. 401 "Parse and hyperlink documentation cross-references in the given BUFFER.
@@ -487,28 +498,9 @@ that."
487 ;; (pop-to-buffer (car location)) 498 ;; (pop-to-buffer (car location))
488 ;; (goto-char (cdr location)))) 499 ;; (goto-char (cdr location))))
489 (help-xref-button 8 'help-function-def sym)) 500 (help-xref-button 8 'help-function-def sym))
490 ((and 501 ((cl-some (lambda (x) (funcall (nth 1 x) sym))
491 (facep sym) 502 describe-symbol-backends)
492 (save-match-data (looking-at "[ \t\n]+face\\W"))) 503 (help-xref-button 8 'help-symbol sym)))))))
493 (help-xref-button 8 'help-face sym))
494 ((and (or (boundp sym)
495 (get sym 'variable-documentation))
496 (fboundp sym))
497 ;; We can't intuit whether to use the
498 ;; variable or function doc -- supply both.
499 (help-xref-button 8 'help-symbol sym))
500 ((and
501 (or (boundp sym)
502 (get sym 'variable-documentation))
503 (or
504 (documentation-property
505 sym 'variable-documentation)
506 (documentation-property
507 (indirect-variable sym)
508 'variable-documentation)))
509 (help-xref-button 8 'help-variable sym))
510 ((fboundp sym)
511 (help-xref-button 8 'help-function sym)))))))
512 ;; An obvious case of a key substitution: 504 ;; An obvious case of a key substitution:
513 (save-excursion 505 (save-excursion
514 (while (re-search-forward 506 (while (re-search-forward