From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: Getting help for a widget Date: Sun, 02 Apr 2006 11:30:34 +0200 Message-ID: <442F99BA.2080008@student.lu.se> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1143970266 22026 80.91.229.2 (2 Apr 2006 09:31:06 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 2 Apr 2006 09:31:06 +0000 (UTC) Cc: Drew Adams , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 02 11:31:03 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FPyv8-0008Sl-3V for ged-emacs-devel@m.gmane.org; Sun, 02 Apr 2006 11:30:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FPyv7-0001jX-8G for ged-emacs-devel@m.gmane.org; Sun, 02 Apr 2006 05:30:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FPyut-0001j4-K2 for emacs-devel@gnu.org; Sun, 02 Apr 2006 05:30:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FPyur-0001hv-Tc for emacs-devel@gnu.org; Sun, 02 Apr 2006 05:30:38 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FPyur-0001ho-LC for emacs-devel@gnu.org; Sun, 02 Apr 2006 05:30:37 -0400 Original-Received: from [81.228.8.83] (helo=pne-smtpout1-sn2.hy.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FPyxe-0005Wp-Hh; Sun, 02 Apr 2006 05:33:30 -0400 Original-Received: from [192.168.123.121] (83.249.218.244) by pne-smtpout1-sn2.hy.skanova.net (7.2.070) id 442A9994000D38FC; Sun, 2 Apr 2006 11:30:35 +0200 User-Agent: Thunderbird 1.5 (Windows/20051201) Original-To: rms@gnu.org In-Reply-To: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:52316 Archived-At: Richard Stallman wrote: > This is perhaps the main difficulty of working with or even talking about > widgets (and, so, with Customize too) as either a user or a casual > developer: understanding what the &^!@% is going on. > > I agree. I find it very hard to understand that code. > > But what does it mean to "get help for a widget"? > It is not clear to me, and maybe there is more than one > kind we need. > > If you press > > C-h k > > on a file you get help for `widget-button-press'. But what does the > button do? > > I don't really follow that, but it seems to be a request > for a better answer to the question, "What happens if i click here"? > > That could be useful, and perhaps C-h k ought to make a special > case for the function widget-button-press. That would not be hard. > But where can it get the useful doc string to display? > > Meanwhile, this would not help people who are doing programming with > widgets. They need a different kind of help. > > In other words, it will take some real thought and study to figure out > what "good help for widgets" would mean. It would be useful for > people to start exploring this now. > As a little starter the two functions below can be used. The first one is new. Pub point over a widget or button and do M-x describe-field This will open the widget browser. Badly needed in this are back and forward buttons (widgets of course ;-). Also badly needed IMHO are links to where widget-create are called. Can anyone explain how to add this? The information is available to the debugger, but is there a fast and simple way to get this information in `widget-create'? The second function just makes links out of descriptions that are function names. (defun describe-field(pos &optional use-mouse-action) (interactive (list (point))) ;; widget-browse-at (let* ((field (get-char-property pos 'field)) (wbutton (get-char-property pos 'button)) (doc (get-char-property pos 'widget-doc)) (widget (or field wbutton doc))) ;;(message "widget=%s" widget)(sit-for 1) (if (and widget (if (symbolp widget) (get widget 'widget-type) (and (consp widget) (get (widget-type widget) 'widget-type)))) (widget-browse-at pos) ;; push-button (let ((button (button-at pos))) ;;(message "button=%s" button)(sit-for 1) (if button (let ((action (or (and use-mouse-action (button-get button 'mouse-action)) (button-get button 'action)))) (message "action=%s" action)(sit-for 1) (describe-function (intern-soft action))) (message "No widget or button at point")))))) (defun widget-browse-sexp (widget key value) "Insert description of WIDGET's KEY VALUE. Nothing is assumed about value." (let ((pp (condition-case signal (pp-to-string value) (error (prin1-to-string signal))))) (when (string-match "\n\\'" pp) (setq pp (substring pp 0 (1- (length pp))))) (if (cond ((string-match "\n" pp) nil) ((> (length pp) (- (window-width) (current-column))) nil) (t t)) (progn ;;(message "pp=<%s>" pp) (sit-for 1) (let ((pp-sym (intern-soft pp))) (if (and pp-sym (fboundp pp-sym)) (widget-create 'push-button :tag pp :value pp :action '(lambda (widget &optional event) (let ((pp-symf (intern-soft (widget-get widget :value)))) (describe-function pp-symf))) pp) (widget-insert pp)))) (widget-create 'push-button :tag "show" :action (lambda (widget &optional event) (with-output-to-temp-buffer "*Pp Eval Output*" (princ (widget-get widget :value)))) pp))))