unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Trapping Quit from x-popup-menu
@ 2014-06-27 22:44 Tim Johnson
  2014-06-29 20:56 ` Michael Heerdegen
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Johnson @ 2014-06-27 22:44 UTC (permalink / raw)
  To: Emacs

Using 
GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2)
on Ubuntu 12.04

Here is a code snippet :

;; ---------------------------------------------------------
(let ((menu (tj-dir-menu curdir get-hidden))
	choice nextdir
	(default curdir))
    (setq choice
	  (x-popup-menu (list '(0 0) (selected-window)) menu))
    (message (concat "choice: " choice))
;; ---------------------------------------------------------

If I quit x-popup-menu without making a selection, than the rest of
the code in the defun - beginning with 

  (message (concat "choice: " choice)

is not executed. 

What is the proper way to trap the call to x-popup-menu so that I
can have some sort of a default value for 'choice?

Thanks
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trapping Quit from x-popup-menu
  2014-06-27 22:44 Trapping Quit from x-popup-menu Tim Johnson
@ 2014-06-29 20:56 ` Michael Heerdegen
  2014-06-30  0:07   ` Tim Johnson
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2014-06-29 20:56 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

> ;; ---------------------------------------------------------
> (let ((menu (tj-dir-menu curdir get-hidden))
> 	choice nextdir
> 	(default curdir))
>     (setq choice
> 	  (x-popup-menu (list '(0 0) (selected-window)) menu))
>     (message (concat "choice: " choice))
> ;; ---------------------------------------------------------
>
> If I quit x-popup-menu without making a selection, than the rest of
> the code in the defun - beginning with 
>
>   (message (concat "choice: " choice)
>
> is not executed. 
>
> What is the proper way to trap the call to x-popup-menu so that I
> can have some sort of a default value for 'choice?

If you cannot/don't want to use a mouse button event as position
argument of `x-popup-menu` (as it is described in the docstring and
prevents the function from signaling quit), catch the quit signal
with condition-case:

    (condition-case nil
        (x-popup-menu ...)
      ((quit) a-default-value))


Michael




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trapping Quit from x-popup-menu
  2014-06-29 20:56 ` Michael Heerdegen
@ 2014-06-30  0:07   ` Tim Johnson
  2014-06-30  2:15     ` Drew Adams
  2014-06-30 19:18     ` Tim Johnson
  0 siblings, 2 replies; 7+ messages in thread
From: Tim Johnson @ 2014-06-30  0:07 UTC (permalink / raw)
  To: help-gnu-emacs

* Michael Heerdegen <michael_heerdegen@web.de> [140629 12:58]:
> Tim Johnson <tim@akwebsoft.com> writes:
> 
> > ;; ---------------------------------------------------------
> > (let ((menu (tj-dir-menu curdir get-hidden))
> > 	choice nextdir
> > 	(default curdir))
> >     (setq choice
> > 	  (x-popup-menu (list '(0 0) (selected-window)) menu))
> >     (message (concat "choice: " choice))
> > ;; ---------------------------------------------------------
> >
> > If I quit x-popup-menu without making a selection, than the rest of
> > the code in the defun - beginning with 
> >
> >   (message (concat "choice: " choice)
> >
> > is not executed. 
> >
> > What is the proper way to trap the call to x-popup-menu so that I
> > can have some sort of a default value for 'choice?
> 
> If you cannot/don't want to use a mouse button event as position
> argument of `x-popup-menu` (as it is described in the docstring and
> prevents the function from signaling quit), catch the quit signal
> with condition-case:
> 
>     (condition-case nil
>         (x-popup-menu ...)
>       ((quit) a-default-value))
  Thanks Michael. That is exactly what I was looking for.
  On a related note, can you tell me how to use help to get a list
  of standard errors?

  I can see documentation at
  http://www.chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_40.html#SEC592
  But don't know how to invoke it from emacs itself.

  Thanks again
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Trapping Quit from x-popup-menu
  2014-06-30  0:07   ` Tim Johnson
@ 2014-06-30  2:15     ` Drew Adams
  2014-06-30 15:33       ` Michael Heerdegen
  2014-06-30 19:18     ` Tim Johnson
  1 sibling, 1 reply; 7+ messages in thread
From: Drew Adams @ 2014-06-30  2:15 UTC (permalink / raw)
  To: Tim Johnson, help-gnu-emacs

> can you tell me how to use help to get a list of standard errors?
> I can see documentation at
> http://www.chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_40.html#SEC592
> But don't know how to invoke it from emacs itself.

C-h i m elisp RET

i standard errors RET

In Info, `i' is your friend.  It looks things up in the index.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trapping Quit from x-popup-menu
  2014-06-30  2:15     ` Drew Adams
@ 2014-06-30 15:33       ` Michael Heerdegen
  2014-06-30 15:43         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2014-06-30 15:33 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams <drew.adams@oracle.com> writes:

> > can you tell me how to use help to get a list of standard errors?
> > I can see documentation at
> > http://www.chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_40.html#SEC592
> > But don't know how to invoke it from emacs itself.
>
> C-h i m elisp RET
>
> i standard errors RET
>
> In Info, `i' is your friend.  It looks things up in the index.

Exactly.  Or use g to search the nodes.  You can also isearch (C-s) through
the whole manual.


Michael.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trapping Quit from x-popup-menu
  2014-06-30 15:33       ` Michael Heerdegen
@ 2014-06-30 15:43         ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2014-06-30 15:43 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Date: Mon, 30 Jun 2014 17:33:56 +0200
> 
> > In Info, `i' is your friend.  It looks things up in the index.
> 
> Exactly.  Or use g to search the nodes.  You can also isearch (C-s) through
> the whole manual.

In addition, in a good manual every node name that is "important"
(i.e. it is a phrase one might want to look up) should also appear in
the index.  So theoretically, you need only 'i' (and report as
potential bugs any nodes that deviate from this rule).



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Trapping Quit from x-popup-menu
  2014-06-30  0:07   ` Tim Johnson
  2014-06-30  2:15     ` Drew Adams
@ 2014-06-30 19:18     ` Tim Johnson
  1 sibling, 0 replies; 7+ messages in thread
From: Tim Johnson @ 2014-06-30 19:18 UTC (permalink / raw)
  To: help-gnu-emacs

* Tim Johnson <tim@akwebsoft.com> [140629 16:11]:
<...>   Thanks Michael. That is exactly what I was looking for.
>   On a related note, can you tell me how to use help to get a list
>   of standard errors?
> 
>   I can see documentation at
>   http://www.chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_40.html#SEC592
>   But don't know how to invoke it from emacs itself.
    Thanks to all for answers on this related question.
	cheers
	"""Teach a man to fish ... """
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-30 19:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-27 22:44 Trapping Quit from x-popup-menu Tim Johnson
2014-06-29 20:56 ` Michael Heerdegen
2014-06-30  0:07   ` Tim Johnson
2014-06-30  2:15     ` Drew Adams
2014-06-30 15:33       ` Michael Heerdegen
2014-06-30 15:43         ` Eli Zaretskii
2014-06-30 19:18     ` Tim Johnson

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).