I've been trying to get midnight-mode to add to the following list. I have a feeling it has to do with an elisp error in my config I'm not seeing. It works fine with setq, but with add-to-list I get a type error:

clean-buffer-list: Format specifier doesn’t match argument type

(add-to-list 'clean-buffer-list-kill-regexps

I tried many variants of this with single quotes around the inside like in the docs \'^magit\'" I no longer get the error, but I also don't get a match. If I use just one item not in a list, it also works, but I want to add several things here.

My Final Solution

(setq clean-buffer-list-kill-regexps (nconc clean-buffer-list-kill-regexps

Corrected the wiki error, for further information see: https://www.emacswiki.org/emacs/CleanBufferList


You need to add them one by one, otherwise you wont't be adding N regexps to the list but you'll be adding 1 (sub)list element to the list:

(add-to-list 'clean-buffer-list-kill-regexps "\\`magit")
(add-to-list 'clean-buffer-list-kill-regexps "\\.log\\'")

I fixed some errors and misfeatures of your regexps along the way. If you don't like the duplication you can do:

(dolist (re '("\\`magit" "\\.log\\'"))
  (add-to-list 'clean-buffer-list-kill-regexps re))
  • I was basing my attempts on the example: (add-to-list 'clean-buffer-list-kill-regexps '("\`\*Customize .*\*\\'" "\`\*\(Wo\)?Man .*\*\\'")) at emacswiki.org/emacs/CleanBufferList I see on ergoemacs.org/emacs/emacs_regex_begin_end_line_string.html, the different ticks are beginning of string vs line (though they both work here it seems.) – Adam Watkins Mar 19 at 21:08
  • Yeah, I went through a similar thing a few weeks ago. I believe the examples on the emacswiki page are just wrong, with regard to their usage of add-to-list -- although it is possible that it used to act differently in older Emacsen, midnight-mode has been around for a while. – Willy Lee Mar 19 at 21:10
  • Seems there is a comment on the wiki from 2015 on how the examples don't work... – Adam Watkins Mar 19 at 21:23
  • Indeed, the examples are just wrong. It would be appreciated if you could correct them. – Stefan Mar 19 at 21:39

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.