From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#19328: [PATCH] Add mechanism to prompt about unsaved customizations Date: Tue, 9 Dec 2014 09:46:30 -0800 (PST) Message-ID: <09009907-c8b9-4279-baa8-5c4be0cdf66b@default> References: <745fafd0-6bc9-40f7-830f-32a916dd898e@default> <8DD29730-77B2-49C6-9FB4-8ABF0D73C2E4@gmail.com> <22ed7d40-17aa-4f93-85fc-565b659fd43f@default> <2C7E5AC2-9C0A-43EB-8FC7-A2C9FB091EA3@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1418147257 21187 80.91.229.3 (9 Dec 2014 17:47:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Dec 2014 17:47:37 +0000 (UTC) Cc: 19328@debbugs.gnu.org To: Cameron Desautels Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 09 18:47:26 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XyOsc-0005Ef-FW for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Dec 2014 18:47:22 +0100 Original-Received: from localhost ([::1]:41669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyOsc-0005YA-2p for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Dec 2014 12:47:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyOsQ-0005OK-OC for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 12:47:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyOsJ-0006VM-53 for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 12:47:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyOsI-0006VI-Qb for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 12:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XyOsI-0000Go-LM for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 12:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Dec 2014 17:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19328 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 19328-submit@debbugs.gnu.org id=B19328.14181471971001 (code B ref 19328); Tue, 09 Dec 2014 17:47:02 +0000 Original-Received: (at 19328) by debbugs.gnu.org; 9 Dec 2014 17:46:37 +0000 Original-Received: from localhost ([127.0.0.1]:59887 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XyOrs-0000G3-8A for submit@debbugs.gnu.org; Tue, 09 Dec 2014 12:46:36 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:32361) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XyOrq-0000Fv-2M for 19328@debbugs.gnu.org; Tue, 09 Dec 2014 12:46:34 -0500 Original-Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sB9HkW7v003535 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 9 Dec 2014 17:46:33 GMT Original-Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id sB9HkVwN022002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 9 Dec 2014 17:46:32 GMT Original-Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sB9HkV6j019555; Tue, 9 Dec 2014 17:46:31 GMT In-Reply-To: <2C7E5AC2-9C0A-43EB-8FC7-A2C9FB091EA3@gmail.com> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97092 Archived-At: > 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.). >=20 > > If you want a named function and no error handling, then, well, > > try `customize-unsaved'. >=20 > `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.) >=20 > 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. >=20 > 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... >=20 > 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. >=20 > 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. >=20 > 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.