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 01:48:46 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040430014041.F09B.LEKTU@mi.madritel.es> References: 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 1083282951 10605 80.91.224.253 (29 Apr 2004 23:55:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 29 Apr 2004 23:55:51 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Apr 30 01:55:42 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 1BJLNW-0002Iz-00 for ; Fri, 30 Apr 2004 01:55:42 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BJLNV-0007bH-01 for ; Fri, 30 Apr 2004 01:55:42 +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 1BJLKH-0008W6-26 for emacs-devel@quimby.gnus.org; Thu, 29 Apr 2004 19:52:21 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BJLJS-0008Jo-JH for emacs-devel@gnu.org; Thu, 29 Apr 2004 19:51:30 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BJLIp-0008Ab-VA for emacs-devel@gnu.org; Thu, 29 Apr 2004 19:51:23 -0400 Original-Received: from [62.81.186.18] (helo=smtp08.retemail.es) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BJLGq-0007U9-Hr for emacs-devel@gnu.org; Thu, 29 Apr 2004 19:48:48 -0400 Original-Received: from [127.0.0.1] ([213.37.34.102]) by smtp08.retemail.es (InterMail vM.5.01.05.32 201-253-122-126-132-20030307) with ESMTP id <20040429234845.THLV29422.smtp08.retemail.es@[127.0.0.1]> for ; Fri, 30 Apr 2004 01:48:45 +0200 Original-To: emacs-devel@gnu.org In-Reply-To: X-Mailer: Becky! ver. 2.09.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:22393 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22393 On 19 Apr 2004 13:50:58 +0200, storm@cua.dk (Kim F. Storm) wrote: > Here is another idea, enhancing on Richard's idea: > > Show the full doc string, but highlight occurrences of the upper case > PARAM name in the doc string -- then the user will be able to quickly > locate the relevant information and focus on that... Related to that, here's a (proof-of-concept) patch that sets the face `font-lock-variable-name-face' for all uses of the arguments of a function in a `describe-function' *Help* buffer. I say proof-of-concept because I've not provided a way to make it optional, I've hard-coded the face used, etc. Still, it works beautifully. The auxiliary function help-highlight-arguments is designed in such a way that it can be pased a nil WORDS argument (and then it highlights all arguments of the function), or a list of desired arguments to highlight, so it can be of help if highlighting info for an argument is desired (which was discused in this thread). Opinions? /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 29 Apr 2004 23:39:08 -0000 @@ -131,4 +131,25 @@ ;; Functions +(defun help-highlight-arguments (fun &rest words) + (save-excursion + (goto-char (point-min)) + (let* ((case-fold-search nil) + (next (and (not words) + (re-search-forward (concat "(" (symbol-name fun)) nil t)))) + ;; Make a list of all arguments + (while next + (when (re-search-forward " \\([^ &\)\.]+\\)" nil t) + (setq words (cons (match-string 1) words))) + (setq next (not (search-forward ")" (1+ (point)) t)))) + ;; Highlight all found arguments anywhere in the *Help* buffer + (while words + (let* ((word (car words)) + (solo (concat "\\<" word "\\>")) + (high (propertize word 'face 'font-lock-variable-name-face))) + (setq words (cdr words)) + (goto-char (point-min)) + (while (re-search-forward solo nil t) + (replace-match high nil t))))))) + ;;;###autoload (defun describe-function (function) @@ -156,4 +177,6 @@ (print-help-return-message) (with-current-buffer standard-output + ;; highlight argument names + (help-highlight-arguments function) ;; Return the text we displayed. (buffer-string))))))