aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2015-06-13 09:35:10 -0700
committerPaul Eggert2015-06-13 09:35:46 -0700
commit8afef016e2bc413c7a4913554ea6ed2c55474de6 (patch)
treedddc5194079a7a04941838ef9ab0626cf30daf90
parenteb92f89c2125aaf8fdf93cdd85ab46ae278dd950 (diff)
downloademacs-8afef016e2bc413c7a4913554ea6ed2c55474de6.tar.gz
emacs-8afef016e2bc413c7a4913554ea6ed2c55474de6.zip
Better fix for documenting `X as "`X"
Fix suggested by Stefan Monnier. * lisp/help-fns.el (help-fns--signature): Insert "`X", not "(\` X)", when documenting `X (Bug#20759). * lisp/help.el (help-split-fundoc, help--make-usage-docstring): Don't treat `X specially, as help-fns--signature now handles this.
-rw-r--r--lisp/help-fns.el8
-rw-r--r--lisp/help.el28
2 files changed, 17 insertions, 19 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 931e8af4df0..80f30e88fa4 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -383,9 +383,13 @@ suitable file is found, return nil."
383 (help--docstring-quote 383 (help--docstring-quote
384 (format-kbd-macro real-def)))) 384 (format-kbd-macro real-def))))
385 (t "[Missing arglist. Please make a bug report.]"))) 385 (t "[Missing arglist. Please make a bug report.]")))
386 ;; Insert "`X", not "(\` X)", when documenting `X.
387 (use1 (replace-regexp-in-string
388 "\\`(\\\\=\\\\\\\\=` \\([^\n ]*\\))\\'"
389 "\\\\=`\\1" use t))
386 (high (if raw 390 (high (if raw
387 (cons use doc) 391 (cons use1 doc)
388 (help-highlight-arguments (substitute-command-keys use) 392 (help-highlight-arguments (substitute-command-keys use1)
389 (substitute-command-keys doc))))) 393 (substitute-command-keys doc)))))
390 (let ((fill-begin (point)) 394 (let ((fill-begin (point))
391 (high-usage (car high)) 395 (high-usage (car high))
diff --git a/lisp/help.el b/lisp/help.el
index d24fbfd64ec..2bf53c09b05 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1368,21 +1368,17 @@ DEF is the function whose usage we're looking for in DOCSTRING."
1368 ;; In cases where `function' has been fset to a subr we can't search for 1368 ;; In cases where `function' has been fset to a subr we can't search for
1369 ;; function's name in the doc string so we use `fn' as the anonymous 1369 ;; function's name in the doc string so we use `fn' as the anonymous
1370 ;; function name instead. 1370 ;; function name instead.
1371 (when (and docstring 1371 (when (and docstring (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" docstring))
1372 (string-match "\n\n(fn\\(\\( +\\([^\n ]+\\( .*\\)?\\)?\\)?)\\)\\'"
1373 docstring))
1374 (let ((doc (unless (zerop (match-beginning 0)) 1372 (let ((doc (unless (zerop (match-beginning 0))
1375 (substring docstring 0 (match-beginning 0))))) 1373 (substring docstring 0 (match-beginning 0))))
1376 (cons (if (and (eq def '\`) (match-beginning 3) (not (match-beginning 4))) 1374 (usage-tail (match-string 1 docstring)))
1377 (concat "\\=`" (match-string 3 docstring)) 1375 (cons (format "(%s%s"
1378 (let ((usage-tail (match-string 1 docstring))) 1376 ;; Replace `fn' with the actual function name.
1379 (format "(%s%s" 1377 (if (symbolp def)
1380 ;; Replace `fn' with the actual function name. 1378 (help--docstring-quote (format "%S" def))
1381 (if (symbolp def) 1379 'anonymous)
1382 (help--docstring-quote (format "%S" def)) 1380 usage-tail)
1383 'anonymous) 1381 doc))))
1384 usage-tail)))
1385 doc))))
1386 1382
1387(defun help-add-fundoc-usage (docstring arglist) 1383(defun help-add-fundoc-usage (docstring arglist)
1388 "Add the usage info to DOCSTRING. 1384 "Add the usage info to DOCSTRING.
@@ -1470,9 +1466,7 @@ the same names as used in the original source code, when possible."
1470(define-obsolete-function-alias 'help-make-usage 'help--make-usage "25.1") 1466(define-obsolete-function-alias 'help-make-usage 'help--make-usage "25.1")
1471 1467
1472(defun help--make-usage-docstring (fn arglist) 1468(defun help--make-usage-docstring (fn arglist)
1473 (help--docstring-quote 1469 (help--docstring-quote (format "%S" (help--make-usage fn arglist))))
1474 (let ((print-quoted (eq fn '\`)))
1475 (format "%S" (help--make-usage fn arglist)))))
1476 1470
1477 1471
1478(provide 'help) 1472(provide 'help)