GNU bug report logs - #32129
26.1; Bug in add-dir-local-variable when used with eval, progn and setenv

Previous Next

Package: emacs;

Reported by: Luis Gerhorst <privat <at> luisgerhorst.de>

Date: Wed, 11 Jul 2018 23:08:01 UTC

Severity: normal

Tags: notabug

Found in version 26.1

Done: Noam Postavsky <npostavs <at> gmail.com>

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 32129 in the body.
You can then email your comments to 32129 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#32129; Package emacs. (Wed, 11 Jul 2018 23:08:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Luis Gerhorst <privat <at> luisgerhorst.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 11 Jul 2018 23:08:01 GMT) Full text and rfc822 format available.

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

From: Luis Gerhorst <privat <at> luisgerhorst.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1;
 Bug in add-dir-local-variable when used with eval, progn and setenv
Date: Thu, 12 Jul 2018 01:07:17 +0200
(1) Open Emacs with emacs -Q
(2) Type the following code into *scratch*

    (add-dir-local-variable
     'c-mode
     'eval
     '(progn (make-local-variable 'process-environment)
             (setq process-environment (copy-sequence process-environment))
             (setenv "TEST" "hello")))

(3) M-x eval-buffer

Expected .dir-locals.el contents:
((c-mode (eval . (progn (make-local-variable 'process-environment)
                        (setq process-environment (copy-sequence process-environment))
                        (setenv "TEST" "hello")))))

Actual contents:
((c-mode (eval progn (make-local-variable 'process-environment)
                     (setq process-environment (copy-sequence process-environment))
                     (setenv "TEST" "hello"))))

When I open a C file and inspect process-environment, TEST is not set.

When I manually create a .dir-locals.el with the expected contents, it
works.

Please correct me if I'm using add-dir-local-variable wrong, I was not
able to find a version that works as expected with the above
progn. Strangely, if I use (progn (message "hello")), instead of the
progn with setenv, "hello" gets printed every time I open a C file.

Configured using:
 'configure --prefix=/home/cip/2016/un65esoq/local'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LCMS2

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: C.UTF-8
  value of $LC_MESSAGES: C.UTF-8
  value of $LC_MONETARY: de_DE.UTF-8
  value of $LC_NUMERIC: de_DE.UTF-8
  value of $LC_TIME: de_DE.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32129; Package emacs. (Wed, 11 Jul 2018 23:19:01 GMT) Full text and rfc822 format available.

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

From: Luis Gerhorst <privat <at> luisgerhorst.de>
To: 32129 <at> debbugs.gnu.org
Subject: Re: bug#32129: 26.1; Bug in add-dir-local-variable when used with
 eval, progn and setenv
Date: Thu, 12 Jul 2018 01:18:19 +0200
I'm sorry for the noise, I just retried it and it worked, TEST was set. So the generated .dir-locals.el does the right thing.

Anyway: Shouldn't the .dir-locals.el look different? This is of course just a question of preference, if it makes the code more elegant or something I would accept that it's better to leave it as it is.

Best regards,
Luis

> On 12. Jul 2018, at 01:07, Luis Gerhorst <privat <at> luisgerhorst.de> wrote:
> 
> 
> (1) Open Emacs with emacs -Q
> (2) Type the following code into *scratch*
> 
>    (add-dir-local-variable
>     'c-mode
>     'eval
>     '(progn (make-local-variable 'process-environment)
>             (setq process-environment (copy-sequence process-environment))
>             (setenv "TEST" "hello")))
> 
> (3) M-x eval-buffer
> 
> Expected .dir-locals.el contents:
> ((c-mode (eval . (progn (make-local-variable 'process-environment)
>                        (setq process-environment (copy-sequence process-environment))
>                        (setenv "TEST" "hello")))))
> 
> Actual contents:
> ((c-mode (eval progn (make-local-variable 'process-environment)
>                     (setq process-environment (copy-sequence process-environment))
>                     (setenv "TEST" "hello"))))
> 
> When I open a C file and inspect process-environment, TEST is not set.
> 
> When I manually create a .dir-locals.el with the expected contents, it
> works.
> 
> Please correct me if I'm using add-dir-local-variable wrong, I was not
> able to find a version that works as expected with the above
> progn. Strangely, if I use (progn (message "hello")), instead of the
> progn with setenv, "hello" gets printed every time I open a C file.
> 
> Configured using:
> 'configure --prefix=/home/cip/2016/un65esoq/local'
> 
> Configured features:
> XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
> ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
> TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LCMS2
> 
> Important settings:
>  value of $LC_ALL: en_US.UTF-8
>  value of $LC_CTYPE: C.UTF-8
>  value of $LC_MESSAGES: C.UTF-8
>  value of $LC_MONETARY: de_DE.UTF-8
>  value of $LC_NUMERIC: de_DE.UTF-8
>  value of $LC_TIME: de_DE.UTF-8
>  value of $LANG: en_US.UTF-8
>  locale-coding-system: utf-8-unix
> 
> 
> 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32129; Package emacs. (Wed, 11 Jul 2018 23:21:01 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Luis Gerhorst <privat <at> luisgerhorst.de>
Cc: 32129 <at> debbugs.gnu.org
Subject: Re: bug#32129: 26.1;
 Bug in add-dir-local-variable when used with eval, progn and setenv
Date: Wed, 11 Jul 2018 19:20:27 -0400
Luis Gerhorst <privat <at> luisgerhorst.de> writes:

> (1) Open Emacs with emacs -Q
> (2) Type the following code into *scratch*
>
>     (add-dir-local-variable
>      'c-mode
>      'eval
>      '(progn (make-local-variable 'process-environment)
>              (setq process-environment (copy-sequence process-environment))
>              (setenv "TEST" "hello")))
>
> (3) M-x eval-buffer
>
> Expected .dir-locals.el contents:
> ((c-mode (eval . (progn (make-local-variable 'process-environment)
>                         (setq process-environment (copy-sequence process-environment))
>                         (setenv "TEST" "hello")))))
>
> Actual contents:
> ((c-mode (eval progn (make-local-variable 'process-environment)
>                      (setq process-environment (copy-sequence process-environment))
>                      (setenv "TEST" "hello"))))
>
> When I open a C file and inspect process-environment, TEST is not set.
>
> When I manually create a .dir-locals.el with the expected contents, it
> works.

When I manually create a .dir-locals.el with the actual contents it
works too.

> Please correct me if I'm using add-dir-local-variable wrong, I was not
> able to find a version that works as expected with the above
> progn. Strangely, if I use (progn (message "hello")), instead of the
> progn with setenv, "hello" gets printed every time I open a C file.

I think add-dir-local-variable is fine, both the expected and actual
values you posted are the same (the expected one just happens to use
dotted pair notation).

Maybe the problem is that you need to use

    (setq-local process-environment ...)

Otherwise your eval clause sets the global value (which is possibly
being clobbered by other things in your config?).





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32129; Package emacs. (Fri, 13 Jul 2018 09:27:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Luis Gerhorst <privat <at> luisgerhorst.de>
Cc: 32129 <at> debbugs.gnu.org
Subject: Re: bug#32129: 26.1;
 Bug in add-dir-local-variable when used with eval, progn and setenv
Date: Fri, 13 Jul 2018 05:26:23 -0400
tags 32129 notabug
close 32129
quit

Luis Gerhorst <privat <at> luisgerhorst.de> writes:

> I'm sorry for the noise, I just retried it and it worked, TEST was
> set. So the generated .dir-locals.el does the right thing.

Right, I'm pretty sure you really do want setq-local though.

> Anyway: Shouldn't the .dir-locals.el look different? This is of course
> just a question of preference, if it makes the code more elegant or
> something I would accept that it's better to leave it as it is.

Yeah, it currently just does `pp' for the whole structure.  We would
need to special case the top level printing of values I think.  It might
be interesting to have a pretty printer that's able to take a sort of
"descriptor" of printing structure, to handle this sort of thing more
generally.  But I'm going to go ahead and close this report as notabug,
since special casing the dir-local printing is not worth the trouble.





Added tag(s) notabug. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 13 Jul 2018 09:27:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 32129 <at> debbugs.gnu.org and Luis Gerhorst <privat <at> luisgerhorst.de> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 13 Jul 2018 09:27:03 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. (Fri, 10 Aug 2018 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 313 days ago.

Previous Next


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