1

I usually use Emacs 27.1, but on a particular remote machine, it has Emacs 26.3 installed instead. After cloning my dotfiles repository onto this remote machine, all of the "custom set variables" that Emacs automatically sets for me in init.el have the literal word "quote" instead of the quote symbol ( ' ) that I have on my usual machine.

This is leading to git thinking that my init.el files have been modified when they really haven't changed. What is a good fix for this? Would shifting these custom set variables to another location help, or can I suppress this changing of quote symbol to the literal word "quote"?

Before

(custom-set-variables
   ;; custom-set-variables was added by Custom.
   ;; If you edit it by hand, you could mess it up, so be careful.
   ;; Your init file should contain only one such instance.
   ;; If there is more than one, they won't work right.
 '(custom-safe-themes
     '("7451f243a18b4b37cabfec57facc01bd1fe28b00e101e488c61e1eed913d9db9" default))
   '(org-agenda-custom-commands
     '(("n" "Agenda and all TODOs"
......

After:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(custom-safe-themes
   (quote
    ("7451f243a18b4b37cabfec57facc01bd1fe28b00e101e488c61e1eed913d9db9" default)))
 '(org-agenda-custom-commands
   (quote
    (("n" "Agenda and all TODOs"
......
  • Are you suggesting that Emacs alters your init.el automatically just by launching and/or exiting the program? – lawlist Nov 21 at 20:22
  • 1
    ' is just a shorter way to write quote, so for Emacs, the file remains the same. – choroba Nov 21 at 20:29
  • @lawlist My init.el was written in Emacs 27. When I first start the same init.el on a machine with Emacs 26, yes, it does change the init.el without telling me anything – herophant Nov 21 at 23:57
  • @choroba yes, I am aware. However, quote is not a "function" per se in Emacs, so I wasn't really sure what to call it, thus I called it the "literal word quote". I'm sure there's better terminology, but semantically for elisp they do the mean the same thing, yes – herophant Nov 21 at 23:58
1

You can't stop Emacs 26 from writing the custom file in this format, unless you patch Emacs 26 with the same changes which were made to Emacs 27 to make it start using the more concise syntax.

You could certainly tell your config to use a different custom-file when emacs-major-version is < 27.

Or if you didn't particularly care about changes made to that file in the Emacs 26 instance, you could make git ignore it entirely with

git update-index --assume-unchanged custom.el

(or whatever the filename is)

Git would ignore it in that working copy until such time as you manually repeat that command with --no-assume-unchanged

| improve this answer | |
0

@phils answered this.

If you really want to fiddle with this for Emacs prior to Emacs 27, you can advise the Customize functions that save settings (custom-save-all, custom-save-variables, custom-save-faces), by let-binding print-quoted to t around their bodies.

| improve this answer | |
  • Surely you mean custom-set-variables, etc? – herophant Nov 22 at 0:12
  • No. Why do you think so? Those are the functions that do the "printing" that's susceptible to things like print-quoted. Other functions use those, of course, but those are, I think, the (only) ones that need modifying to get what you want. – Drew Nov 22 at 1:52
  • I'm very confused by custom-save-variables and custom-save-faces. It seems as though I don't even have custom-save-variables or custom-save-faces in my init.el. I only have custom-set-variables (the truncated example in my question) and custom-set-faces in my init.el. In fact, doing an apropos search for custom-save only yields custom-save-all – herophant Nov 22 at 2:13
  • They are not used in your init file. They are used to write (save) customizations to your init file (or custom-file). See file cus-edit.el: custom-save-all calls custom-save-variables and custom-save-faces to do the work. The point is that these are the functions that actually call the print functions (which are affected by print-quoted). – Drew Nov 22 at 6:00

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.