summaryrefslogtreecommitdiff
path: root/lisp/help-fns.el
diff options
context:
space:
mode:
authorKaroly Lorentey <lorentey@elte.hu>2004-05-18 19:12:15 +0000
committerKaroly Lorentey <lorentey@elte.hu>2004-05-18 19:12:15 +0000
commitc23670f81e059ebe645c88575f4ddfa67f26bf6b (patch)
tree71667a6ceaa877ccf3953abedfa7b0fd5f0f5369 /lisp/help-fns.el
parentd9858e4f1889a61b216ae1f99053846362067ccc (diff)
parenta7f7f2540f02834ad128d0c9357a4dbd8222dff4 (diff)
downloademacs-c23670f81e059ebe645c88575f4ddfa67f26bf6b.tar.gz
emacs-c23670f81e059ebe645c88575f4ddfa67f26bf6b.tar.bz2
emacs-c23670f81e059ebe645c88575f4ddfa67f26bf6b.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-301 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-302 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-303 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-304 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-305 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-306 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-307 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-308 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-309 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-310 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-311 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-312 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-313 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-314 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-315 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-316 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-317 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-318 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-319 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-320 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-321 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-322 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-323 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-324 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-163
Diffstat (limited to 'lisp/help-fns.el')
-rw-r--r--lisp/help-fns.el57
1 files changed, 36 insertions, 21 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index df8f9359853..e0692119a21 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -158,31 +158,31 @@ and the file name is displayed in the echo area."
;; Return the text we displayed.
(buffer-string))))))
-(defun help-split-fundoc (doc def)
- "Split a function docstring DOC into the actual doc and the usage info.
+(defun help-split-fundoc (docstring def)
+ "Split a function DOCSTRING into the actual doc and the usage info.
Return (USAGE . DOC) or nil if there's no usage info.
-DEF is the function whose usage we're looking for in DOC."
+DEF is the function whose usage we're looking for in DOCSTRING."
;; Functions can get the calling sequence at the end of the doc string.
;; In cases where `function' has been fset to a subr we can't search for
;; function's name in the doc string so we use `fn' as the anonymous
;; function name instead.
- (when (and doc (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc))
+ (when (and docstring (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" docstring))
(cons (format "(%s%s"
;; Replace `fn' with the actual function name.
(if (consp def) "anonymous" def)
- (match-string 1 doc))
- (substring doc 0 (match-beginning 0)))))
-
-(defun help-add-fundoc-usage (doc arglist)
- "Add the usage info to the docstring DOC.
-If DOC already has a usage info, then just return DOC unchanged.
-The usage info is built from ARGLIST. DOC can be nil.
-ARGLIST can also be t or a string of the form \"(fun ARG1 ARG2 ...)\"."
- (unless (stringp doc) (setq doc "Not documented"))
- (if (or (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc) (eq arglist t))
- doc
- (format "%s%s%S" doc
- (if (string-match "\n?\n\\'" doc)
+ (match-string 1 docstring))
+ (substring docstring 0 (match-beginning 0)))))
+
+(defun help-add-fundoc-usage (docstring arglist)
+ "Add the usage info to DOCSTRING.
+If DOCSTRING already has a usage info, then just return it unchanged.
+The usage info is built from ARGLIST. DOCSTRING can be nil.
+ARGLIST can also be t or a string of the form \"(FUN ARG1 ARG2 ...)\"."
+ (unless (stringp docstring) (setq docstring "Not documented"))
+ (if (or (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" docstring) (eq arglist t))
+ docstring
+ (format "%s%s%S" docstring
+ (if (string-match "\n?\n\\'" docstring)
(if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "")
"\n\n")
(if (and (stringp arglist)
@@ -237,8 +237,14 @@ KIND should be `var' for a variable or `subr' for a subroutine."
(concat "src/" file)
file)))))
-(defface help-argument-name '((t (:slant italic)))
- "Face to highlight function arguments in docstrings.")
+(defun help-default-arg-highlight (arg)
+ "Default function to highlight arguments in *Help* buffers.
+It returns ARG in lowercase italics, if the display supports it;
+else ARG is returned in uppercase normal."
+ (let ((attrs '(:slant italic)))
+ (if (display-supports-face-attributes-p attrs)
+ (propertize (downcase arg) 'face attrs)
+ arg)))
(defun help-do-arg-highlight (doc args)
(with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table)
@@ -246,8 +252,17 @@ KIND should be `var' for a variable or `subr' for a subroutine."
(while args
(let ((arg (prog1 (car args) (setq args (cdr args)))))
(setq doc (replace-regexp-in-string
- (concat "\\<\\(" arg "\\)\\(?:es\\|s\\|th\\)?\\>")
- (propertize arg 'face 'help-argument-name)
+ ;; This is heuristic, but covers all common cases
+ ;; except ARG1-ARG2
+ (concat "\\<" ; beginning of word
+ "\\(?:[a-z-]+-\\)?" ; for xxx-ARG
+ "\\("
+ arg
+ "\\)"
+ "\\(?:es\\|s\\|th\\)?" ; for ARGth, ARGs
+ "\\(?:-[a-z-]+\\)?" ; for ARG-xxx
+ "\\>") ; end of word
+ (help-default-arg-highlight arg)
doc t t 1))))
doc))