From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Cameron Desautels Newsgroups: gmane.emacs.bugs Subject: bug#19328: [PATCH] Add mechanism to prompt about unsaved customizations Date: Tue, 9 Dec 2014 11:05:06 -0600 Message-ID: <2C7E5AC2-9C0A-43EB-8FC7-A2C9FB091EA3@gmail.com> References: <745fafd0-6bc9-40f7-830f-32a916dd898e@default> <8DD29730-77B2-49C6-9FB4-8ABF0D73C2E4@gmail.com> <22ed7d40-17aa-4f93-85fc-565b659fd43f@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1418144787 10617 80.91.229.3 (9 Dec 2014 17:06:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Dec 2014 17:06:27 +0000 (UTC) Cc: 19328@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 09 18:06:19 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 1XyOEs-0007oa-OO for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Dec 2014 18:06:19 +0100 Original-Received: from localhost ([::1]:41523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyOEs-0003I2-9J for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Dec 2014 12:06:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyOEi-0003GE-H6 for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 12:06:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyOEc-0002Dw-Sd for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 12:06:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyOEc-0002Ds-Pq for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 12:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XyOEc-0007ee-Hg for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 12:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Cameron Desautels Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Dec 2014 17:06: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.141814471329354 (code B ref 19328); Tue, 09 Dec 2014 17:06:02 +0000 Original-Received: (at 19328) by debbugs.gnu.org; 9 Dec 2014 17:05:13 +0000 Original-Received: from localhost ([127.0.0.1]:59868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XyODo-0007dN-7h for submit@debbugs.gnu.org; Tue, 09 Dec 2014 12:05:13 -0500 Original-Received: from mail-ob0-f175.google.com ([209.85.214.175]:34930) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XyODl-0007dE-Af for 19328@debbugs.gnu.org; Tue, 09 Dec 2014 12:05:10 -0500 Original-Received: by mail-ob0-f175.google.com with SMTP id wp4so770221obc.20 for <19328@debbugs.gnu.org>; Tue, 09 Dec 2014 09:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=mFIXi4A/pv1w3BPQZYux5TsMTG4jRex/rCEiwvxBi8w=; b=09arxu69qKSsqDMa4M5f9v9a+JW1oMzMO+RDuZesqjX6XwsT+7/C3W6cEJHNzKL769 xrKb3w19pkuB23nN5sIdsBvLxP14e/0YAqYF5VqZ+fWX5oRZjcmvgWgJsXm823esPncy Cb6VmDRYzs+WMKZrbT+VBk9WYnB/uTsG6Gd1P4vjW2VFMNDClxOcdGJuq2gyYjAOz5ro G+/qFosJ+9GEEn6pSgHO/99Rd2LH4AAtjOikTxjK+UEFW50uZm8SNKHlZIvEGKiOMs6C IgHPqr3gUO+yqShhha4dHeICXz9RnaArfDirB3vmCaxDsyuDeGiIzrAX+dG4Fpt5eFgF AC7Q== X-Received: by 10.60.37.97 with SMTP id x1mr11724374oej.57.1418144708516; Tue, 09 Dec 2014 09:05:08 -0800 (PST) Original-Received: from [192.168.168.59] (rrcs-24-227-130-234.sw.biz.rr.com. [24.227.130.234]) by mx.google.com with ESMTPSA id u6sm693050oej.11.2014.12.09.09.05.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 09:05:08 -0800 (PST) X-Priority: 3 In-Reply-To: <22ed7d40-17aa-4f93-85fc-565b659fd43f@default> X-Mailer: Apple Mail (2.1993) 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:97089 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.). > 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? :) -- Cameron Desautels > On 2014-12-09, at 10:24 AM, Drew Adams wrote: > >>> Why is this in etc/TODO? >> >> If you're asking me in particular, I don't know. I just found it >> there and thought I'd help out. > > Thanks for helping out! The question is for Emacs Dev in general, > i.e., for this bug thread. > >>> This already exists, no? I've been using this for years: >>> >>> (add-hook 'kill-emacs-query-functions >>> (lambda () >>> (condition-case nil >>> (customize-unsaved) >>> (error t)))) >> >> A named function is probably more suitable for an end user than an >> arbitrary lambda, no? Plus using error handling for control flow is >> generally not considered a best practice, especially when it's as >> broad in scope as `(condition-case nil ...)`. > > That's what *I* use. I'm not saying that everyone should use it. > My .emacs is used for multiple Emacs versions. You might prefer > `ignore-errors', which does not exist in older versions. Or you > might prefer not to ignore errors... > > If you want a named function and no error handling, then, well, > try `customize-unsaved'. > > My point was that `customized-unsaved' already exists. It is > precisely a "mechanism to prompt about unsaved customizations". > Unless I'm missing something. AFAICT, it is exactly what is > described in that TODO item: > > A function to check for customizable options that have been > set but not saved, and ask the user whether to save them. > This could go in kill-emacs-query-functions, to remind people > to save their changes. If the user says yes, show them > in a Custom buffer using customize-customized.