[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Improved help from minibuffer prompts
From: |
Juanma Barranquero |
Subject: |
Re: Improved help from minibuffer prompts |
Date: |
Sat, 01 May 2004 00:20:21 +0200 |
On 30 Apr 2004 17:50:38 +0200, address@hidden (Kim F. Storm) wrote:
> the bracketed (optional) args are not recognized.
I forgot about them. It's just a matter of fixing the regexp.
New iteration attached.
Thanks a lot for testing.
/L/e/k/t/u
Index: help-fns.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/help-fns.el,v
retrieving revision 1.40
diff -u -2 -r1.40 help-fns.el
--- help-fns.el 29 Apr 2004 18:46:13 -0000 1.40
+++ help-fns.el 30 Apr 2004 22:15:08 -0000
@@ -131,4 +131,33 @@
;; Functions
+(defun help-highlight-arguments (fun &rest args)
+ (save-excursion
+ (goto-char (point-min))
+ (let* ((case-fold-search nil)
+ (next (and (not args)
+ (re-search-forward (concat "(" (symbol-name fun)) nil
t))))
+ (save-restriction
+ (narrow-to-region (point) (re-search-forward ")\n" nil t))
+ (goto-char (point-min))
+ ;; Make a list of all arguments
+ (while next
+ (if (not (re-search-forward " \\([\\[(]?\\)\\([^] &)\.]+\\)" nil t))
+ (setq next nil)
+ (setq args (cons (match-string 2) args))
+ (when (string= (match-string 1) "(")
+ ;; A pesky CL-style optional argument with default value,
+ ;; so let's skip over it
+ (search-backward "(")
+ (goto-char (scan-sexps (point) 1))))))
+ ;; Highlight all found arguments anywhere in the *Help* buffer
+ (while args
+ (let* ((arg (car args))
+ (solo (concat "\\<\\(" arg "\\)e?s?\\>"))
+ (high (propertize arg 'face 'font-lock-variable-name-face)))
+ (setq args (cdr args))
+ (goto-char (point-min))
+ (while (re-search-forward solo nil t)
+ (replace-match high nil t nil 1)))))))
+
;;;###autoload
(defun describe-function (function)
@@ -156,4 +185,6 @@
(print-help-return-message)
(with-current-buffer standard-output
+ ;; highlight argument names
+ (help-highlight-arguments function)
;; Return the text we displayed.
(buffer-string))))))
- Re: Improved help from minibuffer prompts, (continued)
- Re: Improved help from minibuffer prompts, Kim F. Storm, 2004/04/16
- Re: Improved help from minibuffer prompts, Richard Stallman, 2004/04/17
- Re: Improved help from minibuffer prompts, Stefan Reichör, 2004/04/19
- Re: Improved help from minibuffer prompts, Kim F. Storm, 2004/04/19
- Re: Improved help from minibuffer prompts, Juanma Barranquero, 2004/04/29
- Re: Improved help from minibuffer prompts, Stefan Reichör, 2004/04/30
- Re: Improved help from minibuffer prompts, Juanma Barranquero, 2004/04/30
- Re: Improved help from minibuffer prompts, Kim F. Storm, 2004/04/30
- Re: Improved help from minibuffer prompts, Juanma Barranquero, 2004/04/30
- Re: Improved help from minibuffer prompts, Kim F. Storm, 2004/04/30
- Re: Improved help from minibuffer prompts,
Juanma Barranquero <=
- Re: Improved help from minibuffer prompts, Stefan Monnier, 2004/04/30
- Re: Improved help from minibuffer prompts, Juanma Barranquero, 2004/04/30
- Re: Improved help from minibuffer prompts, Stefan Monnier, 2004/04/30
- Re: Improved help from minibuffer prompts, Juanma Barranquero, 2004/04/30
- RE: Improved help from minibuffer prompts, Drew Adams, 2004/04/19
- Re: Improved help from minibuffer prompts, Richard Stallman, 2004/04/20
- RE: Improved help from minibuffer prompts, Drew Adams, 2004/04/20
- Re: Improved help from minibuffer prompts, Eli Zaretskii, 2004/04/21
- Re: Improved help from minibuffer prompts, Richard Stallman, 2004/04/19
- Re: Improved help from minibuffer prompts, Richard Stallman, 2004/04/16