unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19328: [PATCH] Add mechanism to prompt about unsaved customizations
@ 2014-12-09 15:46 Cameron Desautels
  2014-12-09 15:54 ` Drew Adams
  2014-12-10 15:32 ` Ted Zlatanov
  0 siblings, 2 replies; 23+ messages in thread
From: Cameron Desautels @ 2014-12-09 15:46 UTC (permalink / raw)
  To: 19328


[-- Attachment #1.1: Type: text/plain, Size: 452 bytes --]

Implements the following, as requested in `etc/TODO`:

** 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.

My copyright assignment info should be on file.

Cheers.

-- 
Cameron Desautels <camdez@gmail.com>

[-- Attachment #1.2: Type: text/html, Size: 686 bytes --]

[-- Attachment #2: 0001-Add-mechanism-to-prompt-about-unsaved-customizations.patch --]
[-- Type: application/octet-stream, Size: 3660 bytes --]

From dd192cd7c45f3e815b5a731420c5293d74c6075a Mon Sep 17 00:00:00 2001
From: Cameron Desautels <camdez@gmail.com>
Date: Tue, 9 Dec 2014 00:28:44 -0600
Subject: [PATCH] Add mechanism to prompt about unsaved customizations

- Requested in `etc/TODO'
- Suitable for use in `kill-emacs-query-functions'.
---
 etc/TODO         |  6 ------
 lisp/ChangeLog   |  5 +++++
 lisp/cus-edit.el | 29 +++++++++++++++++++++++------
 3 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/etc/TODO b/etc/TODO
index ccd00e5..cbb2394 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -419,12 +419,6 @@ rather than interactively.  This a trivial one-liner in easy-mode.el.
 
 ** Make byte-optimization warnings issue accurate line numbers.
 
-** 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.
-
 ** Record the sxhash of the default value for customized variables
   and notify the user (maybe by adding a menu item or toolbar button,
   as the detection can occur during autoload time) when the default
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bf139d6..9e4a7a7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-09  Cameron Desautels  <camdez@gmail.com>
+
+	* cus-edit.el (custom-prompt-customize-unsaved-options): Add a
+	mechanism for prompting user about unsaved customizations.
+
 2014-12-09  Eric S. Raymond  <esr@snark.thyrsus.com>
 
 	* vc/vc-src.el (vc-src-do-comand): Prepend -- to file argument
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index c8e9b90..a6da50e 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -1356,12 +1356,10 @@ suggest to customize that face, if it's customizable."
                                      (or (face-at-point t t) "all faces") t)))
   (customize-face face t))
 
-(defalias 'customize-customized 'customize-unsaved)
-
-;;;###autoload
-(defun customize-unsaved ()
-  "Customize all options and faces set in this session but not saved."
-  (interactive)
+(defun custom-unsaved-options ()
+  "List of options and faces set in this session but not saved.
+Each entry is of the form (SYMBOL TYPE), where TYPE is one of the
+symbols `custom-face' or `custom-variable'."
   (let ((found nil))
     (mapatoms (lambda (symbol)
 		(and (or (get symbol 'customized-face)
@@ -1372,6 +1370,15 @@ suggest to customize that face, if it's customizable."
 			 (get symbol 'customized-variable-comment))
 		     (boundp symbol)
 		     (push (list symbol 'custom-variable) found))))
+    found))
+
+(defalias 'customize-customized 'customize-unsaved)
+
+;;;###autoload
+(defun customize-unsaved ()
+  "Customize all options and faces set in this session but not saved."
+  (interactive)
+  (let ((found (custom-unsaved-options)))
     (if (not found)
 	(error "No user options are set but unsaved")
       (custom-buffer-create (custom-sort-items found t nil)
@@ -1477,6 +1484,16 @@ If TYPE is `groups', include only groups."
   (interactive (list (apropos-read-pattern "groups")))
   (customize-apropos regexp 'groups))
 
+;;;###autoload
+(defun custom-prompt-customize-unsaved-options ()
+  "Prompt user to customize any unsaved customization options.
+Return non-nil if user chooses to customize, for use in
+`kill-emacs-query-functions'."
+  (not (and (custom-unsaved-options)
+	    (yes-or-no-p "Some customized options have not been saved; Examine? ")
+	    (customize-unsaved)
+	    t)))
+
 ;;; Buffer.
 
 (defcustom custom-buffer-style 'links
-- 
2.2.0


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

end of thread, other threads:[~2016-02-23 11:36 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).