unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Cameron Desautels <camdez@gmail.com>
Cc: 19328@debbugs.gnu.org
Subject: bug#19328: [PATCH] Add mechanism to prompt about unsaved customizations
Date: Tue, 9 Dec 2014 09:46:30 -0800 (PST)	[thread overview]
Message-ID: <09009907-c8b9-4279-baa8-5c4be0cdf66b@default> (raw)
In-Reply-To: <2C7E5AC2-9C0A-43EB-8FC7-A2C9FB091EA3@gmail.com>

> Got it.  Thank you for the clarification, I think I see where our
> thinking has diverged: `customize-unsaved' is the existing mechanism
> to pop up a customize buffer displaying unsaved customization
> options. I've put a thin layer around this which provides a yes / no
> prompt to the user before (conditionally) invoking `customized-unsaved'.
> This is in the general spirit of hooks that run when killing Emacs
> ("Modified buffers exist", "Active processes exist", etc.).
> 
> > If you want a named function and no error handling, then, well,
> > try `customize-unsaved'.
> 
> `customize-unsaved' is not suitable for use in
> `kill-emacs-query-functions` because it signals an error if nothing
> has been customized, meaning that it will block the user from
> quitting Emacs if there are no unsaved customizations, and it will
> invoke the customization mechanism there are any.  Ergo, they can
> never quit. (Drew: I'm sure you're aware of this given the way you've
> wrapped the call to `customize-unsaved', but I'm spelling it out
> for the benefit of others.)
> 
> That said, the lambda you've added to `kill-emacs-query-functions'
> doesn't function properly either (at least not on my machine).  It
> returns `t' in the no-unsaved-customizations case (after catching
> the error thrown my `customize-unsaved'), and it returns a (truthy)
> string, courtesy of `customize-unsaved', in the
> have-unsaved-custoizations case.  Truthy values returned by the
> functions in `kill-emacs-query-functions' mean "continue with
> quitting Emacs", ergo the user is never prompted about unsaved
> customizations.
> 
> Of course you can fix this easily by making sure to return nil in
> the happy path, but you're working up to exactly what my patch does...
> 
> The one behavioral difference between the two is how we prompt: in
> the patched version the user is prompted in the minibuffer: "Some
> customized options have not been saved; Examine?", and shown a
> customization buffer only if they say yes.
> 
> In yours, the customization buffer is automatically shown, without
> explanation, and attempts to quit the editor will continue to fail
> until the user finds either the `Revert...` or the `Apply and Save`
> button.
> 
> I believe the patched version is a superior user experience.  Have I
> managed to convince you? :)

OK.  In fact, I use `cus-edit+.el', which redefines `customize-unsaved'
so that it DTRT.  I offered this to Emacs Dev long ago, but no interest.
Perhaps you will have better luck. ;-)

FWIW, These are the changes I made to `customize-unsaved':

;; 1. By default, ignores preferences in `customize-customized-ignore'.
;; 2. Added prefix arg to override `customize-customized-ignore'.
;; 3. When not interactive and there are changes, ask for confirmation.
;; 4. Always returns `t', so it can be used as a
;;    `kill-emacs-query-functions' hook.
;; 5. Wrap in `condition-case' and reissue error.

The code is here, in case you are interested:
http://www.emacswiki.org/emacs-en/download/cus-edit%2b.el

And here is some info about it:
http://www.emacswiki.org/CustomizingAndSaving#CustomizePlus

HTH.





  reply	other threads:[~2014-12-09 17:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09 15:46 bug#19328: [PATCH] Add mechanism to prompt about unsaved customizations Cameron Desautels
2014-12-09 15:54 ` Drew Adams
2014-12-09 16:16   ` Cameron Desautels
2014-12-09 16:24     ` Drew Adams
2014-12-09 17:05       ` Cameron Desautels
2014-12-09 17:46         ` Drew Adams [this message]
2014-12-09 19:47           ` Cameron Desautels
2014-12-09 20:10             ` Drew Adams
2014-12-10 15:32 ` Ted Zlatanov
2014-12-12  1:04   ` Cameron Desautels
2014-12-12  1:40     ` Stefan Monnier
2014-12-12  1:56       ` Cameron Desautels
2014-12-12  2:36         ` Stefan Monnier
2014-12-12  2:39           ` Cameron Desautels
2014-12-13  1:17             ` Ted Zlatanov
2014-12-13  5:55               ` Stefan Monnier
2014-12-13 13:06                 ` Ted Zlatanov
2014-12-13 23:23                   ` Cameron Desautels
2014-12-14 11:54                   ` Ted Zlatanov
2014-12-14 14:02                     ` Stefan Monnier
2014-12-14 16:31                       ` Ted Zlatanov
2016-02-23 11:36                 ` Lars Ingebrigtsen
2014-12-12  2:48       ` Drew Adams

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=09009907-c8b9-4279-baa8-5c4be0cdf66b@default \
    --to=drew.adams@oracle.com \
    --cc=19328@debbugs.gnu.org \
    --cc=camdez@gmail.com \
    /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).