* why isn't quitting Customize like quitting Info?
@ 2005-01-21 20:07 Drew Adams
2005-01-23 17:37 ` Richard Stallman
0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2005-01-21 20:07 UTC (permalink / raw)
Summary - not really much of a bug, not really much of a feature request:
1) `quit-window' should be used by, default, in Customize.
2) Things could probably be simplified; I smell cruft.
Details -
1) I use `pop-up-frames' non-nil, and I have removed *Customiz.* from
`same-window-regexps', so customize buffers open in special-display-buffer
dedicated frames. Likewise, for Info.
In Info, I hit `q' and it exits - the Info frame disappears. In Customize, I
get an error "Cannot switch buffers in a dedicated buffer". (Okay, I can
deal with that...)
In Info, there is a simple key binding of `q' to `Info-exit', which is
essentially `quit-window. That function DTRT: `quit-window' seems _designed_
for this kind of thing, taking into account the window/frame context etc. I
suspect that it is appropriate for Customize too.
In Customize, `q' is bound to `Custom-buffer-done', which runs
`custom-buffer-done-function' on the current buffer. That is bound, by
default, to `custom-bury-buffer', which just does `bury-buffer' (in a
roundabout way).
You can of course choose a different function for
`custom-buffer-done-function'. The predefined choices for this variable
include `custom-bury-buffer' and `kill-buffer'. They do not include
`quit-window'.
I would think that `quit-window' would: a) be a predefined choice for
`custom-buffer-done-function', and in fact b) be the _default_ choice. It
already deals with both `bury-buffer' and `kill-buffer' in a DTRT way. It
works in my setup; `bury-buffer' does not.
2) I also wonder (I haven't followed all the code strands to the end, to
analyze this completely) if some of the layers of defining and binding the
customize quit function might just be overkill. I suppose that some of it is
because there is not just a single key binding (`q') - there are also button
and menu ways to quit (but Info has menu quit too). Nevertheless, I suspect
there may be something to be gained by using the Info code as inspiration
and trying to simplify the customize code a bit.
Here, for instance is a section of `custom-buffer-create-internal', which
creates the Customize buffers:
(widget-create 'push-button
:tag "Finish"
:help-echo
(lambda (&rest ignore)
(cond
((eq custom-buffer-done-function
'custom-bury-buffer)
"Bury this buffer")
((eq custom-buffer-done-function 'kill-buffer)
"Kill this buffer")
(t "Finish with this buffer")))
:action #'Custom-buffer-done)
In spite of the trouble gone to in providing multiple layers of indirection
(`Custom-buffer-done', `custom-buffer-done-function', key bindings), this
_hard-codes_ tests to provide proper tooltip strings for each of the
predefined quit-function choices. That seems unnecessary and maintenance
unfriendly, to me. If we have indirection in order to decouple the function
from its bindings, then the tooltip should either just be generic or
(somehow) automatically use the doc string of the particular quit function
used. And the generic tooltip just repeats the :tag, so it is really
useless, IMO.
All of this unsimple code seems like a great todo about nothing, to me. What
in Info is just a command bound to a key is here a plate of spaghetti.
Instead of just binding a different quit command to the quit key (and
associated menu items etc.), a user gets the privilege of using all of the
Customize heavy machineray to bind the quit command. What's the advantage?
I admit - I don't get it. There are no doubt good reasons for all this
stuff - it was added after Emacs 20, for some reason. But I don't get it.
And even in Emacs 20, the quit command for Customize was `bury-buffer', so
the "bug" that it should probably be `quit-window' is not new.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: why isn't quitting Customize like quitting Info?
2005-01-21 20:07 why isn't quitting Customize like quitting Info? Drew Adams
@ 2005-01-23 17:37 ` Richard Stallman
2005-01-23 18:55 ` Drew Adams
0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2005-01-23 17:37 UTC (permalink / raw)
Cc: emacs-devel
How about this patch?
*** cus-edit.el 08 Jan 2005 21:43:12 -0500 1.206
--- cus-edit.el 23 Jan 2005 08:04:52 -0500
***************
*** 1181,1199 ****
(const links))
:group 'custom-buffer)
! ;; If we pass BUFFER to `bury-buffer', the buffer isn't removed from
! ;; the window.
! (defun custom-bury-buffer (buffer)
! (with-current-buffer buffer
! (bury-buffer)))
!
! (defcustom custom-buffer-done-function 'custom-bury-buffer
! "*Function called to remove a Custom buffer when the user is done with it.
! Called with one argument, the buffer to remove."
! :type '(choice (function-item :tag "Bury buffer" custom-bury-buffer)
! (function-item :tag "Kill buffer" kill-buffer)
! (function :tag "Other"))
! :version "21.1"
:group 'custom-buffer)
(defcustom custom-buffer-indent 3
--- 1181,1190 ----
(const links))
:group 'custom-buffer)
! (defcustom custom-buffer-done-kill nil
! "*Non-nil means exiting a Custom buffer should kill it."
! :type 'boolean
! :version "21.4"
:group 'custom-buffer)
(defcustom custom-buffer-indent 3
***************
*** 1265,1273 ****
:group 'custom-buffer)
(defun Custom-buffer-done (&rest ignore)
! "Remove current buffer by calling `custom-buffer-done-function'."
(interactive)
! (funcall custom-buffer-done-function (current-buffer)))
(defcustom custom-raised-buttons (not (equal (face-valid-attribute-values :box)
'(("unspecified" . unspecified))))
--- 1256,1264 ----
:group 'custom-buffer)
(defun Custom-buffer-done (&rest ignore)
! "Exit current Custom buffer according to `custom-buffer-done-kill'."
(interactive)
! (quit-window custom-buffer-done-kill))
(defcustom custom-raised-buttons (not (equal (face-valid-attribute-values :box)
'(("unspecified" . unspecified))))
***************
*** 1353,1365 ****
:tag "Finish"
:help-echo
(lambda (&rest ignore)
! (cond
! ((eq custom-buffer-done-function
! 'custom-bury-buffer)
! "Bury this buffer")
! ((eq custom-buffer-done-function 'kill-buffer)
! "Kill this buffer")
! (t "Finish with this buffer")))
:action #'Custom-buffer-done)
(widget-insert "\n\n")
(message "Creating customization items...")
--- 1344,1352 ----
:tag "Finish"
:help-echo
(lambda (&rest ignore)
! (if custom-buffer-done-kill
! "Kill this buffer"
! "Bury this buffer"))
:action #'Custom-buffer-done)
(widget-insert "\n\n")
(message "Creating customization items...")
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-01-23 18:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-21 20:07 why isn't quitting Customize like quitting Info? Drew Adams
2005-01-23 17:37 ` Richard Stallman
2005-01-23 18:55 ` Drew Adams
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.