all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Wait for a specific command call
@ 2004-11-17 10:24 Matthias
  2004-11-17 17:59 ` Kevin Rodgers
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Matthias @ 2004-11-17 10:24 UTC (permalink / raw)


Hi,

I have written a command displaying a list of buffer, the user can
edit it, etc. I want this command to end (or return) if and only if
the user call `quit-window'...

It seems that it is possible using `recursive-edit' but the manual
says `Most applications should not use recursive editing, except as
part of using the minibuffer.'

Any other idea?

Thanks for your help.
-- 
Matthias

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

* Re: Wait for a specific command call
  2004-11-17 10:24 Wait for a specific command call Matthias
@ 2004-11-17 17:59 ` Kevin Rodgers
  2004-11-20 17:31 ` Kai Grossjohann
       [not found] ` <mailman.238.1100972454.27204.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2004-11-17 17:59 UTC (permalink / raw)


Matthias wrote:
 > I have written a command displaying a list of buffer, the user can
 > edit it, etc. I want this command to end (or return) if and only if
 > the user call `quit-window'...
 >
 > It seems that it is possible using `recursive-edit' but the manual
 > says `Most applications should not use recursive editing, except as
 > part of using the minibuffer.'

Why don't you try doing it that way, and see if you like it?

 > Any other idea?

Check out how electric-buffer-list is implemented in ebuff-menu.el

-- 
Kevin Rodgers

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

* Re: Wait for a specific command call
  2004-11-17 10:24 Wait for a specific command call Matthias
  2004-11-17 17:59 ` Kevin Rodgers
@ 2004-11-20 17:31 ` Kai Grossjohann
       [not found] ` <mailman.238.1100972454.27204.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Kai Grossjohann @ 2004-11-20 17:31 UTC (permalink / raw)


Matthias <cimosque@free.fr> writes:

> I have written a command displaying a list of buffer, the user can
> edit it, etc. I want this command to end (or return) if and only if
> the user call `quit-window'...

Why do you want to do this?

The normal Emacs way goes like this:

You write a major mode for editing the buffer list.  You write the
command to display the buffer list in such a way that it invokes the
major mode.  The major mode binds a specific key (q, say) to a special
quit command which does whatever you wanted to do after the user
invoked quit-window.

My question was intended to find out why the normal Emacs approach
wouldn't work for you, to be able to make better suggestions.

Kai

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

* Re: Wait for a specific command call
       [not found] ` <mailman.238.1100972454.27204.help-gnu-emacs@gnu.org>
@ 2004-11-21  7:35   ` Matthias
  2004-11-21 20:13     ` Kai Grossjohann
  0 siblings, 1 reply; 5+ messages in thread
From: Matthias @ 2004-11-21  7:35 UTC (permalink / raw)


Kai Grossjohann <kai@emptydomain.de> wrote:

> (...) Why do you want to do this?

I have (thanks to people posting in this newsgroup) a command (called
`list-desktop-buffers') which displays names of buffers that will be
saved by `desktop-save'. The list is displayed using `list-buffers',
so that one can delete, save, etc any of those buffers.

Now I want this list to be displayed when exiting emacs; the editor
should also wait for a confirmation coming from the user.

So, I need to add a modified version of my command to the list
`kill-emacs-query-functions'. E.g. the following:

(defun desktop-save-query-function ()
  (list-desktop-buffers)
  (yes-or-no-p "Reopen displayed buffers in next session? "))

(add-to-list 'kill-emacs-query-functions 'desktop-save-query-function)

But there I lost the hability to edit the list of buffers.

In other words, my initial question was: how to make
desktop-save-query-function select the *Buffer List* buffer and exit
(returning true) when the user quit its window (by pressing the `q'
key or using the mouse)?
-- 
Matthias

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

* Re: Wait for a specific command call
  2004-11-21  7:35   ` Matthias
@ 2004-11-21 20:13     ` Kai Grossjohann
  0 siblings, 0 replies; 5+ messages in thread
From: Kai Grossjohann @ 2004-11-21 20:13 UTC (permalink / raw)


Matthias <cimosque@free.fr> writes:

> In other words, my initial question was: how to make
> desktop-save-query-function select the *Buffer List* buffer and exit
> (returning true) when the user quit its window (by pressing the `q'
> key or using the mouse)?

Define a variable desktops-saved that is normally nil.

Have desktop-save-query-function look at desktops-saved.  If it is
nil, then invoke list-desktop-buffers and return nil.

Bind a function to q that will set desktops-saved to t before invoking
save-buffers-kill-emacs.

Have desktop-save-query-function look at desktops-saved.  If it is t,
then do nothing and return t.

Would this work?

Kai

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

end of thread, other threads:[~2004-11-21 20:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-17 10:24 Wait for a specific command call Matthias
2004-11-17 17:59 ` Kevin Rodgers
2004-11-20 17:31 ` Kai Grossjohann
     [not found] ` <mailman.238.1100972454.27204.help-gnu-emacs@gnu.org>
2004-11-21  7:35   ` Matthias
2004-11-21 20:13     ` Kai Grossjohann

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.