GNU bug report logs -
#20709
25.0.50; anonymous functions in `auto-mode-alist'
Previous Next
Reported by: michael_heerdegen <at> web.de
Date: Mon, 1 Jun 2015 16:00:06 UTC
Severity: minor
Found in version 25.0.50
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hello,
the doc of `auto-mode-alist' doesn't say that the mode functions
specified must be named functions. That's good IMO, since using
anonymous functions in the alist e.g. while let-binding it can sometimes
be useful.
But this is buggy. Try this:
--8<---------------cut here---------------start------------->8---
;; -*- lexical-binding: t -*-
(setq auto-mode-alist
`((".*" . ,(lambda ()
(emacs-lisp-mode)
'and-do-something-in-addition))))
--8<---------------cut here---------------end--------------->8---
Save it in a file, and load it (uncompiled) so that
auto-mode-alist
=> ((".*" closure (t) nil (emacs-lisp-mode) (quote and-do-something-in-addition)))
Now open any file. You get:
File mode specification error: (void-function closure)
The problem is these lines in the defun of `set-auto-mode' starting from
line 2871 in files.el:
--8<---------------cut here---------------start------------->8---
(if (and mode
(consp mode)
(cadr mode))
(setq mode (car mode)
...
--8<---------------cut here---------------end--------------->8---
i.e., the value in the alist pair is not tested whether it is a
function, and the (REGEXP FUNCTION NON-NIL) case is assumed, which is
wrong.
Thanks,
Michael.
In GNU Emacs 25.0.50.4 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.5)
of 2015-05-30 on drachen
Windowing system distributor `The X.Org Foundation', version 11.0.11701000
System Description: Debian GNU/Linux testing (stretch)
This bug report was last modified 3 years and 196 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.