3

I try to use "Easy Customization" for most of my customization of Emacs. Some of my customizations are changes to the defaults, i. e. sentence-end-base gets customized from:

"[.?!][]\"'”)}]*"

to:

"[.?!][]\"'””)}]*\\( :-)\\)?"

When a new Emacs version is released, I have to go through all my customizations to see if the default has changed so that I need to reflect that in my customization as well.

Some/most customizable variables have information about when their default value was introduced or changed, for example:

(defcustom sentence-end-base "[.?!][]\"'”)}]*"
  "Regexp matching the basic end of a sentence, not including following     space."
  :group 'paragraphs
  :type 'string
  :version "22.1")

How would a sniplet look like that prompts for the Emacs version used previously and then lists all variables and faces that were customized and whose default has changed since that Emacs version?

3

Command customize-changed (unfortunately aliased to customize-changed-options, even though it applies also to faces) does what you want, if I understand the question correctly.

It opens a Customize buffer showing all of the options and faces that have changed in Emacs since the previous major release.

customize-changed is an alias for customize-changed-options in cus-edit.el.

(customize-changed &optional SINCE-VERSION)

Customize all settings whose meanings have changed in Emacs itself. This includes new user options and faces, and new customization groups, as well as older options and faces whose meanings or default values have changed since the previous major Emacs release.

With argument SINCE-VERSION (a string), customize all settings that were added or redefined since that version.

  • This is much better than I expected: Directly integrated in the UI I'm used to. The only "disadvantage" I see is that the list is not limited to "my" customizations, so I need to grep for "SAVED", but that is acceptable. (And, to my shame, this function is even described in the manual.) Thanks! – Tim Landscheidt Dec 1 '16 at 22:48
0

To iterate over all variables, one needs to use mapatoms. Variables and faces that have been customized have the properties saved-value or saved-face set. The version when a default was changed is kept in the custom-version property:

(defun tl-list-customizations-with-changed-defaults (old-emacs-version)
  "List customizations with changed defaults since OLD-EMACS-VERSION."
  (interactive "sOld Emacs version: ")
  (let (variables-with-changed-defaults)
    (mapatoms (lambda (symbol)
                (if (and
                     (or (get symbol 'saved-face)
                         (get symbol 'saved-value))
                     (get symbol 'custom-version)
                     (version< old-emacs-version (get symbol 'custom-version)))
                    (add-to-list 'variables-with-changed-defaults (cons (symbol-name symbol) (get symbol 'custom-version))))))
    (if variables-with-changed-defaults
        (message "Customizations with changed defaults since %s: %s."
                 old-emacs-version
                 (mapconcat (lambda (v)
                              (concat (car v) " (" (cdr v) ")"))
                            (sort variables-with-changed-defaults
                                  (lambda (a b)
                                    (string< (car a) (car b))))
                            ", "))
      (message "No customizations have changed defaults since %s." old-emacs-version))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.