aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorAlan Mackenzie2017-01-23 19:00:49 +0000
committerAlan Mackenzie2017-01-23 19:00:49 +0000
commit0c31ff43b6880c84498fbe1f06e1e5809b55e838 (patch)
treed1a737ed59f7d58af3f7d5eda3fef8022291fd2e /lisp
parent03de82fe7ca09ab40fbcae394d4fcdfe3374496e (diff)
downloademacs-0c31ff43b6880c84498fbe1f06e1e5809b55e838.tar.gz
emacs-0c31ff43b6880c84498fbe1f06e1e5809b55e838.zip
Give , and .@ doc strings. Fixes bug #24561.
Also make *Help* links to ``' possible. Also make usable as such doc strings on the function-documentation property of a symbol. * lisp/emacs-lisp/backquote.el (top-level): Give , and '@ doc strings on the function-documentation property. Also give these symbols a reader-construct property. * lisp/help-fns.el (describe-function): Allow the function-documentation property to work. Use princ rather than prin1 to print the function's name when it has a reader-construct property. (help-fns-signature): Don't insert `high-usage' for a reader-construct. (describe-function-1): Adapt to process documentation on the function-documentation property. Print "a reader construct" when appropriate. * lisp/help-mode.el (help-xref-symbol-regexp): Amend this regexp also to match ``'.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/backquote.el10
-rw-r--r--lisp/help-fns.el38
-rw-r--r--lisp/help-mode.el2
3 files changed, 35 insertions, 15 deletions
diff --git a/lisp/emacs-lisp/backquote.el b/lisp/emacs-lisp/backquote.el
index 94c561cba0a..bb877dd2c97 100644
--- a/lisp/emacs-lisp/backquote.el
+++ b/lisp/emacs-lisp/backquote.el
@@ -247,4 +247,14 @@ LEVEL is only used internally and indicates the nesting level:
247 tail)) 247 tail))
248 (t (cons 'list heads))))) 248 (t (cons 'list heads)))))
249 249
250
251;; Give `,' and `,@' documentation strings which can be examined by C-h f.
252(put '\, 'function-documentation
253 "See `\\=`' (also `pcase') for the usage of `,'.")
254(put '\, 'reader-construct t)
255
256(put '\,@ 'function-documentation
257 "See `\\=`' for the usage of `,@'.")
258(put '\,@ 'reader-construct t)
259
250;;; backquote.el ends here 260;;; backquote.el ends here
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index fa16fa0bb67..edbcd9099d3 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -115,13 +115,15 @@ When called from lisp, FUNCTION may also be a function object."
115 (if fn 115 (if fn
116 (format "Describe function (default %s): " fn) 116 (format "Describe function (default %s): " fn)
117 "Describe function: ") 117 "Describe function: ")
118 #'help--symbol-completion-table #'fboundp t nil nil 118 #'help--symbol-completion-table
119 (lambda (f) (or (fboundp f) (get f 'function-documentation)))
120 t nil nil
119 (and fn (symbol-name fn))))) 121 (and fn (symbol-name fn)))))
120 (unless (equal val "") 122 (unless (equal val "")
121 (setq fn (intern val))) 123 (setq fn (intern val)))
122 (unless (and fn (symbolp fn)) 124 (unless (and fn (symbolp fn))
123 (user-error "You didn't specify a function symbol")) 125 (user-error "You didn't specify a function symbol"))
124 (unless (fboundp fn) 126 (unless (or (fboundp fn) (get fn 'function-documentation))
125 (user-error "Symbol's function definition is void: %s" fn)) 127 (user-error "Symbol's function definition is void: %s" fn))
126 (list fn))) 128 (list fn)))
127 129
@@ -144,7 +146,9 @@ When called from lisp, FUNCTION may also be a function object."
144 146
145 (save-excursion 147 (save-excursion
146 (with-help-window (help-buffer) 148 (with-help-window (help-buffer)
147 (prin1 function) 149 (if (get function 'reader-construct)
150 (princ function)
151 (prin1 function))
148 ;; Use " is " instead of a colon so that 152 ;; Use " is " instead of a colon so that
149 ;; it is easier to get out the function name using forward-sexp. 153 ;; it is easier to get out the function name using forward-sexp.
150 (princ " is ") 154 (princ " is ")
@@ -469,7 +473,8 @@ suitable file is found, return nil."
469 (let ((fill-begin (point)) 473 (let ((fill-begin (point))
470 (high-usage (car high)) 474 (high-usage (car high))
471 (high-doc (cdr high))) 475 (high-doc (cdr high)))
472 (insert high-usage "\n") 476 (unless (get function 'reader-construct)
477 (insert high-usage "\n"))
473 (fill-region fill-begin (point)) 478 (fill-region fill-begin (point))
474 high-doc))))) 479 high-doc)))))
475 480
@@ -565,18 +570,21 @@ FILE is the file where FUNCTION was probably defined."
565 (or (and advised 570 (or (and advised
566 (advice--cd*r (advice--symbol-function function))) 571 (advice--cd*r (advice--symbol-function function)))
567 function)) 572 function))
568 ;; Get the real definition. 573 ;; Get the real definition, if any.
569 (def (if (symbolp real-function) 574 (def (if (symbolp real-function)
570 (or (symbol-function real-function) 575 (cond ((symbol-function real-function))
571 (signal 'void-function (list real-function))) 576 ((get real-function 'function-documentation)
577 nil)
578 (t (signal 'void-function (list real-function))))
572 real-function)) 579 real-function))
573 (aliased (or (symbolp def) 580 (aliased (and def
574 ;; Advised & aliased function. 581 (or (symbolp def)
575 (and advised (symbolp real-function) 582 ;; Advised & aliased function.
576 (not (eq 'autoload (car-safe def)))) 583 (and advised (symbolp real-function)
577 (and (subrp def) 584 (not (eq 'autoload (car-safe def))))
578 (not (string= (subr-name def) 585 (and (subrp def)
579 (symbol-name function)))))) 586 (not (string= (subr-name def)
587 (symbol-name function)))))))
580 (real-def (cond 588 (real-def (cond
581 ((and aliased (not (subrp def))) 589 ((and aliased (not (subrp def)))
582 (let ((f real-function)) 590 (let ((f real-function))
@@ -605,6 +613,8 @@ FILE is the file where FUNCTION was probably defined."
605 ;; Print what kind of function-like object FUNCTION is. 613 ;; Print what kind of function-like object FUNCTION is.
606 (princ (cond ((or (stringp def) (vectorp def)) 614 (princ (cond ((or (stringp def) (vectorp def))
607 "a keyboard macro") 615 "a keyboard macro")
616 ((get function 'reader-construct)
617 "a reader construct")
608 ;; Aliases are Lisp functions, so we need to check 618 ;; Aliases are Lisp functions, so we need to check
609 ;; aliases before functions. 619 ;; aliases before functions.
610 (aliased 620 (aliased
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index a8d7294a5cc..3fb793e7aa5 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -328,7 +328,7 @@ Commands:
328 "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)" 328 "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)"
329 "[ \t\n]+\\)?" 329 "[ \t\n]+\\)?"
330 ;; Note starting with word-syntax character: 330 ;; Note starting with word-syntax character:
331 "['`‘]\\(\\sw\\(\\sw\\|\\s_\\)+\\)['’]")) 331 "['`‘]\\(\\sw\\(\\sw\\|\\s_\\)+\\|`\\)['’]"))
332 "Regexp matching doc string references to symbols. 332 "Regexp matching doc string references to symbols.
333 333
334The words preceding the quoted symbol can be used in doc strings to 334The words preceding the quoted symbol can be used in doc strings to