unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Mauro Aranda <maurooaranda@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 139@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>,
	jidanni@jidanni.org
Subject: bug#139: describe-key vs. widget red tape
Date: Mon, 30 Sep 2019 07:55:06 -0300	[thread overview]
Message-ID: <CABczVwc30M8ok2oqxdnz=CtiVfRH6ui7938dkhi=VeCeju2M+Q@mail.gmail.com> (raw)
In-Reply-To: <CABczVwfrEa0UispM9qGCfnDwLP9tNR=x9O3iZ-nY=qVYYXHk0w@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 16 bytes --]

Here's the file

[-- Attachment #1.2: Type: text/html, Size: 45 bytes --]

[-- Attachment #2: widget-describe-actions.el --]
[-- Type: text/x-emacs-lisp, Size: 2537 bytes --]

;;; widget-describe-actions.el --- Example of describing widget actions -*- lexical-binding:t -*-

(require 'wid-edit)
(require 'wid-browse)

(defun widget-describe-actions (&optional widget-or-pos)
  "Describe the actions associated to the widget at point.
Displays a buffer with a description about the actions, as well as a link to
browse all the properties of the widget.
This command resolves the indirection of widgets running the action of its
parents, so the real action executed can be known.

When called from Lisp, pass WIDGET-OR-POS as the widget to describe,
or a buffer position where a widget is present.  If WIDGET-OR-POS is nil,
the widget at point is the widget to describe."
  (interactive "d")
  (let ((widget (if (widgetp widget-or-pos)
		    widget-or-pos
		  (widget-at (or widget-or-pos (point)))))
	(inhibit-read-only t) ; For erasing the contents of the buffer.
	(map (make-sparse-keymap)) ; We will change the binding of `q'.
	action mouse-down-action)
    (when widget
      (setq action (widget-resolve-parent-action widget)
	    mouse-down-action (widget-get widget :mouse-down-action))
      (pop-to-buffer "*Widget Actions*" nil t)
      (erase-buffer)
      (widget-browse-mode)
      ;; In order to be more like a *Help* buffer, use quit-window instead
      ;; of bury-buffer.
      (set-keymap-parent map widget-browse-mode-map)
      (define-key map "q" 'quit-window)
      (use-local-map map)
      (widget-insert "This widget type is ")
      (widget-create 'widget-browse :format "%[%v%]\n%d"
		     :doc (get (car widget) 'widget-documentation)
		     widget)
      (widget-insert "\n")
      (when (symbolp action)
	(widget-insert (propertize "Action" 'face 'bold))
	(widget-insert "\nThe action of this widget is ")
	(widget-create 'function-link :value action)
	(widget-insert "\n\n"))
      (when (symbolp mouse-down-action)
	(widget-insert (propertize "Mouse-down-action" 'face 'bold))
	(widget-insert "\nThe mouse-down-action of this widget is ")
	(widget-create 'function-link :value mouse-down-action)
	(widget-insert "\n"))
      (widget-setup)
      (goto-char (point-min)))))

(defun widget-resolve-parent-action (widget)
  "If action of WIDGET is `widget-parent-action', find out what would that be."
  (let ((action (widget-get widget :action))
	(parent (widget-get widget :parent)))
    (while (and (eq action 'widget-parent-action)
		(setq parent (widget-get parent :parent)))
      (setq action (widget-get parent :action)))
    action))
      
(provide 'widget-describe-actions)

  reply	other threads:[~2019-09-30 10:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-14 19:25 describe-key vs. widget red tape jidanni
2019-09-30  5:56 ` bug#139: " Lars Ingebrigtsen
2019-09-30  7:31   ` Eli Zaretskii
2019-09-30  7:40     ` Lars Ingebrigtsen
2019-09-30  8:25       ` Eli Zaretskii
2019-09-30 10:54         ` Mauro Aranda
2019-09-30 10:55           ` Mauro Aranda [this message]
2019-09-30 14:57           ` Lars Ingebrigtsen
2019-09-30 20:06             ` Mauro Aranda
2019-10-01 12:29               ` Lars Ingebrigtsen
2019-10-05 14:06                 ` Mauro Aranda
2019-10-06  0:39                   ` Basil L. Contovounesios
2019-10-07  1:55                     ` Lars Ingebrigtsen
2019-10-08 13:04                     ` Mauro Aranda
2019-10-11 14:38                       ` Mauro Aranda
2019-10-11 15:23                         ` Drew Adams
2019-10-11 18:57                         ` Lars Ingebrigtsen
2020-08-07 11:16                           ` Lars Ingebrigtsen
2020-08-07 11:38                             ` Lars Ingebrigtsen
2020-10-31  1:32 ` bug#139: Still can't figure out what the command I used is called 積丹尼 Dan Jacobson
2020-10-31  2:55   ` Thien-Thi Nguyen
2020-10-31 10:33     ` 積丹尼 Dan Jacobson
2021-01-19 18:30   ` bug#139: describe-key vs. widget red tape Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABczVwc30M8ok2oqxdnz=CtiVfRH6ui7938dkhi=VeCeju2M+Q@mail.gmail.com' \
    --to=maurooaranda@gmail.com \
    --cc=139@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jidanni@jidanni.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).