X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/1e4a57ac6d0ad48188fe085d2f387e8bbe3c5fb4..e82fd952f1548e3873ee78a748078ebc2eeb5119:/lisp/cus-edit.el diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 86936df290..9f57d0da24 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -1,9 +1,9 @@ ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages -*- lexical-binding:t -*- ;; -;; Copyright (C) 1996-1997, 1999-2014 Free Software Foundation, Inc. +;; Copyright (C) 1996-1997, 1999-2015 Free Software Foundation, Inc. ;; ;; Author: Per Abrahamsen -;; Maintainer: FSF +;; Maintainer: emacs-devel@gnu.org ;; Keywords: help, faces ;; Package: emacs @@ -324,7 +324,7 @@ :group 'emacs) (defgroup help nil - "Support for on-line help systems." + "Support for Emacs help systems." :group 'emacs) (defgroup multimedia nil @@ -779,7 +779,8 @@ when the action is chosen.") "Call function FUN on all widgets in `custom-options'. If there is more than one widget, ask user for confirmation using the query string QUERY, using `y-or-n-p' if STRONG-QUERY is nil, -and `yes-or-no-p' otherwise." +and `yes-or-no-p' otherwise. Return non-nil if the functionality +has been executed, nil otherwise." (if (or (and (= 1 (length custom-options)) (memq (widget-type (car custom-options)) '(custom-variable custom-face))) @@ -892,16 +893,16 @@ making them as if they had never been customized at all." ;; Bind these temporarily. (let ((custom-reset-standard-variables-list '(t)) (custom-reset-standard-faces-list '(t))) - (custom-command-apply - (lambda (widget) - (and (or (null (widget-get widget :custom-standard-value)) - (widget-apply widget :custom-standard-value)) - (memq (widget-get widget :custom-state) - '(modified set changed saved rogue)) - (widget-apply widget :custom-mark-to-reset-standard))) - "The settings will revert to their default values, in this + (if (custom-command-apply + (lambda (widget) + (and (or (null (widget-get widget :custom-standard-value)) + (widget-apply widget :custom-standard-value)) + (memq (widget-get widget :custom-state) + '(modified set changed saved rogue)) + (widget-apply widget :custom-mark-to-reset-standard))) + "The settings will revert to their default values, in this and future sessions. Really erase customizations? " t) - (custom-reset-standard-save-and-update))) + (custom-reset-standard-save-and-update)))) ;;; The Customize Commands @@ -1355,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) @@ -1371,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) @@ -1476,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 @@ -3097,7 +3115,7 @@ face attributes (as specified by a `default' defface entry)." widget (widget-get widget :default-face-attributes))) entry) - (unless (looking-back "^ *") + (unless (looking-back "^ *" (line-beginning-position)) (insert ?\n)) (insert-char ?\s (widget-get widget :extra-offset)) (if (or alist defaults show-all) @@ -4359,7 +4377,8 @@ if only the first line of the docstring is shown.")) (defun custom-file (&optional no-error) "Return the file name for saving customizations." - (if (null user-init-file) + (if (or (null user-init-file) + (and (null custom-file) init-file-had-error)) ;; Started with -q, i.e. the file containing Custom settings ;; hasn't been read. Saving settings there won't make much ;; sense. @@ -4388,7 +4407,9 @@ if only the first line of the docstring is shown.")) old-buffer-name) (with-current-buffer (let ((find-file-visit-truename t)) - (or old-buffer (find-file-noselect filename))) + (or old-buffer + (let ((delay-mode-hooks t)) + (find-file-noselect filename)))) ;; We'll save using file-precious-flag, so avoid destroying ;; symlinks. (If we're not already visiting the buffer, this is ;; handled by find-file-visit-truename, above.) @@ -4397,7 +4418,7 @@ if only the first line of the docstring is shown.")) (set-visited-file-name (file-chase-links filename))) (unless (eq major-mode 'emacs-lisp-mode) - (emacs-lisp-mode)) + (delay-mode-hooks (emacs-lisp-mode))) (let ((inhibit-read-only t) (print-length nil) (print-level nil))