GNU bug report logs - #20709
25.0.50; anonymous functions in `auto-mode-alist'

Previous Next

Package: emacs;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20709 in the body.
You can then email your comments to 20709 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#20709; Package emacs. (Mon, 01 Jun 2015 16:00:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to michael_heerdegen <at> web.de:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 01 Jun 2015 16:00:09 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; anonymous functions in `auto-mode-alist'
Date: Mon, 01 Jun 2015 17:58:25 +0200
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)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20709; Package emacs. (Tue, 02 Jun 2015 16:12:02 GMT) Full text and rfc822 format available.

Message #8 received at 20709 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 20709 <at> debbugs.gnu.org
Subject: Re: bug#20709: 25.0.50; anonymous functions in `auto-mode-alist'
Date: Tue, 02 Jun 2015 11:42:42 -0400
> File mode specification error: (void-function closure)

Plain bug, yes.  Please add a (not (functionp mode)) test in there.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20709; Package emacs. (Tue, 02 Jun 2015 16:20:03 GMT) Full text and rfc822 format available.

Message #11 received at 20709 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 20709 <at> debbugs.gnu.org
Subject: Re: bug#20709: 25.0.50; anonymous functions in `auto-mode-alist'
Date: Tue, 02 Jun 2015 18:18:53 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> > File mode specification error: (void-function closure)
>
> Plain bug, yes.  Please add a (not (functionp mode)) test in there.

Should I do it?  I have the rights now, but it'll be my first commit to
the emacs repo, so I'll have to read some stuff before to make sure I
make a commit confirming to the standards.

You don't need to answer, just expect a short delay.

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20709; Package emacs. (Tue, 02 Jun 2015 18:52:02 GMT) Full text and rfc822 format available.

Message #14 received at 20709 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 20709 <at> debbugs.gnu.org
Subject: Re: bug#20709: 25.0.50; anonymous functions in `auto-mode-alist'
Date: Tue, 02 Jun 2015 14:13:22 -0400
>> > File mode specification error: (void-function closure)
>> Plain bug, yes.  Please add a (not (functionp mode)) test in there.
> Should I do it?

Sure.

> I have the rights now, but it'll be my first commit to
> the emacs repo, so I'll have to read some stuff before to make sure I
> make a commit confirming to the standards.
> You don't need to answer, just expect a short delay.

No hurry,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20709; Package emacs. (Sun, 29 Sep 2019 23:33:02 GMT) Full text and rfc822 format available.

Message #17 received at 20709 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 20709 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#20709: 25.0.50; anonymous functions in `auto-mode-alist'
Date: Mon, 30 Sep 2019 01:32:11 +0200
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
>> > File mode specification error: (void-function closure)
>>
>> Plain bug, yes.  Please add a (not (functionp mode)) test in there.
>
> Should I do it?  I have the rights now, but it'll be my first commit to
> the emacs repo, so I'll have to read some stuff before to make sure I
> make a commit confirming to the standards.
>
> You don't need to answer, just expect a short delay.

Hi Michael,

Did you ever get around to fixing this?

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20709; Package emacs. (Mon, 30 Sep 2019 04:41:03 GMT) Full text and rfc822 format available.

Message #20 received at 20709 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 20709 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#20709: 25.0.50; anonymous functions in `auto-mode-alist'
Date: Mon, 30 Sep 2019 06:39:37 +0200
Stefan Kangas <stefan <at> marxist.se> writes:

> Did you ever get around to fixing this?

I don't recall - probably not.  I will be absent for three days, I'll
have a look when I'm back.

Regards,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20709; Package emacs. (Thu, 07 Nov 2019 00:26:02 GMT) Full text and rfc822 format available.

Message #23 received at 20709 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 20709 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#20709: 25.0.50; anonymous functions in `auto-mode-alist'
Date: Thu, 07 Nov 2019 01:24:58 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Stefan Kangas <stefan <at> marxist.se> writes:
>
>> Did you ever get around to fixing this?
>
> I don't recall - probably not.  I will be absent for three days, I'll
> have a look when I'm back.

Just a reminder to please take a look at this when you find some time.

Thanks in advance.

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20709; Package emacs. (Mon, 24 Jan 2022 14:07:01 GMT) Full text and rfc822 format available.

Message #26 received at 20709 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 20709 <at> debbugs.gnu.org
Subject: Re: bug#20709: 25.0.50; anonymous functions in `auto-mode-alist'
Date: Mon, 24 Jan 2022 15:05:47 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> The problem is these lines in the defun of `set-auto-mode' starting from
> line 2871 in files.el:
>
> (if (and mode
>          (consp mode)
>          (cadr mode))
>     (setq mode (car mode)
>          ...
>
> 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.

I've now fixed this in Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 20709 <at> debbugs.gnu.org and michael_heerdegen <at> web.de Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 24 Jan 2022 14:07:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 22 Feb 2022 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 177 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.