From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: Improved help from minibuffer prompts Date: Fri, 30 Apr 2004 15:39:24 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040430153555.28AE.JMBARRANQUERO@wke.es> References: <20040430014041.F09B.LEKTU@mi.madritel.es> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1083338509 25622 80.91.224.253 (30 Apr 2004 15:21:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 30 Apr 2004 15:21:49 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Apr 30 17:21:38 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BJZpZ-0004Wz-00 for ; Fri, 30 Apr 2004 17:21:37 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BJZpY-00063j-00 for ; Fri, 30 Apr 2004 17:21:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BJZKQ-00057I-Cp for emacs-devel@quimby.gnus.org; Fri, 30 Apr 2004 10:49:26 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BJZKJ-00056L-MD for emacs-devel@gnu.org; Fri, 30 Apr 2004 10:49:19 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BJYEq-0000JO-6t for emacs-devel@gnu.org; Fri, 30 Apr 2004 09:40:07 -0400 Original-Received: from [62.22.181.117] (helo=idefix.laley.net) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BJYEe-0000Hr-TR for emacs-devel@gnu.org; Fri, 30 Apr 2004 09:39:25 -0400 Original-Received: from [172.17.221.23] (jsredondo.wk.org [172.17.221.23]) by idefix.laley.net with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2655.55) id JN3LKWQR; Fri, 30 Apr 2004 15:38:56 +0200 Original-To: storm@cua.dk (Kim F. Storm), emacs-devel@gnu.org In-Reply-To: X-Mailer: Becky! ver. 2.08.01 [en] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:22444 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22444 On 30 Apr 2004 12:08:47 +0200 storm@cua.dk (Kim F. Storm) wrote: > I have applied your patch locally; I'll use it for a while before > I'll make a judgement. Please, try this one instead. It's a bit less elegant because of the support for CL-style optional arguments, but it works in all tests cases I've tried. > But initially, I like it. Glad to hear. Juanma --- help-fns.el.orig 2004-04-30 15:31:10.000000000 +0200 +++ help-fns.el 2004-04-30 15:28:47.000000000 +0200 @@ -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)) + (unless (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))))))