unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64281: [Feature Request] Recognize “#” syntax when reading local-variables
@ 2023-06-25 11:54 Shynur Xie
  2023-06-25 13:53 ` bug#64281: [Feature Request] Recognize “#” syntax Shynur Xie
  0 siblings, 1 reply; 7+ messages in thread
From: Shynur Xie @ 2023-06-25 11:54 UTC (permalink / raw)
  To: 64281

For example, if I want to use UTF-8-UNIX only for files directly under
directory DIR, and those under DIR/SUBDIR/ or its subdirectories, I
can write this way:

    ((nil . ((subdirs . nil)
               . #1=((coding . utf-8-unix))))
     ("SUBDIR" . ((nil . #1#))))

If “#” can be recognized when reading local-variables, we can write
“((coding . utf-8-unix))” only once.  Thanks.

--
shynur




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64281: [Feature Request] Recognize “#” syntax
  2023-06-25 11:54 bug#64281: [Feature Request] Recognize “#” syntax when reading local-variables Shynur Xie
@ 2023-06-25 13:53 ` Shynur Xie
  2023-06-25 15:08   ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Shynur Xie @ 2023-06-25 13:53 UTC (permalink / raw)
  To: 64281@debbugs.gnu.org

It seems that this is a intentional behavior:

<https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Local-Variables.html>:

> For additional safety, read-circle is temporarily bound to nil when
> Emacs reads file-local variables.

No further question; can be closed now.

(I wonder if we can treat ~/.emacs.d/.dir-locals.el specially, or tell
 Emacs which files can be treated specially -- enable read-circle.)




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64281: [Feature Request] Recognize “#” syntax
  2023-06-25 13:53 ` bug#64281: [Feature Request] Recognize “#” syntax Shynur Xie
@ 2023-06-25 15:08   ` Eli Zaretskii
  2023-06-25 15:46     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-06-25 15:08 UTC (permalink / raw)
  To: Shynur Xie, Stefan Monnier; +Cc: 64281

> From: Shynur Xie <one.last.kiss@outlook.com>
> Date: Sun, 25 Jun 2023 13:53:30 +0000
> msip_labels: 
> 
> It seems that this is a intentional behavior:
> 
> <https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Local-Variables.html>:
> 
> > For additional safety, read-circle is temporarily bound to nil when
> > Emacs reads file-local variables.
> 
> No further question; can be closed now.
> 
> (I wonder if we can treat ~/.emacs.d/.dir-locals.el specially, or tell
>  Emacs which files can be treated specially -- enable read-circle.)

Stefan, any comments before we close this?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64281: [Feature Request] Recognize “#” syntax
  2023-06-25 15:08   ` Eli Zaretskii
@ 2023-06-25 15:46     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-06-25 16:16       ` Drew Adams
  2023-06-26 12:21       ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-06-25 15:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Shynur Xie, 64281

>> It seems that this is a intentional behavior:
>>
>> <https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Local-Variables.html>:
>>
>> > For additional safety, read-circle is temporarily bound to nil when
>> > Emacs reads file-local variables.
>>
>> No further question; can be closed now.
>>
>> (I wonder if we can treat ~/.emacs.d/.dir-locals.el specially, or tell
>>  Emacs which files can be treated specially -- enable read-circle.)
>
> Stefan, any comments before we close this?

file/dir-local variables are dangerous enough as it is, I think.  If you
want to do better, you can use an actual ELisp file.


        Stefan






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64281: [Feature Request] Recognize “#” syntax
  2023-06-25 15:46     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-06-25 16:16       ` Drew Adams
  2023-06-26 10:21         ` Shynur Xie
  2023-06-26 12:21       ` Eli Zaretskii
  1 sibling, 1 reply; 7+ messages in thread
From: Drew Adams @ 2023-06-25 16:16 UTC (permalink / raw)
  To: Stefan Monnier, Eli Zaretskii; +Cc: Shynur Xie, 64281@debbugs.gnu.org

> >> It seems that this is a intentional behavior:
> >> .../File-Local-Variables.html:
> >>
> >> > For additional safety, read-circle is temporarily bound
> >> > to nil when Emacs reads file-local variables.
> >>
> >> No further question; can be closed now.
> >>
> >> (I wonder if we can treat ~/.emacs.d/.dir-locals.el specially, or tell
> >>  Emacs which files can be treated specially -- enable read-circle.)
> >
> > Stefan, any comments before we close this?
> 
> file/dir-local variables are dangerous enough as it is, I think.  If you
> want to do better, you can use an actual ELisp file.

1. That Elisp manual node (`File Local Variables')
doesn't say what danger is avoided by disabling
`read-circle', but it seems to suggest that that
danger is pointed out in node `Read Syntax for
Circular Objects':

  For additional safety, read-circle is temporarily
  bound to nil when Emacs reads file-local variables
  (see Input Functions). This prevents the Lisp reader
  from recognizing circular and shared Lisp structures
  (see Read Syntax for Circular Objects).

Yes, that's what it does, but why?  What's the
"additional safety" about?  What danger's involved?

Node `Read Syntax for Circular Objects' says nothing
about any possible danger (security/safety problem)
circular objects can introduce.  Can we please say
something about the danger in that node?

2. Wouldn't it make sense (be useful) to let users
and code decide whether to allow this for particular
file-local variables?

A question from ignorance - see #1, above.  Is it
helpful to talk about danger and avoiding it,
without giving readers some idea of what's involved?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64281: [Feature Request] Recognize “#” syntax
  2023-06-25 16:16       ` Drew Adams
@ 2023-06-26 10:21         ` Shynur Xie
  0 siblings, 0 replies; 7+ messages in thread
From: Shynur Xie @ 2023-06-26 10:21 UTC (permalink / raw)
  To: Drew Adams, Stefan Monnier, Eli Zaretskii; +Cc: 64281@debbugs.gnu.org

To: Drew

> drew> Node `Read Syntax for Circular Objects' says nothing about any
> drew> possible danger (security/safety problem) circular objects can
> drew> introduce.

I guess that “.dir-locals.el” _isn’t_ read by ELisp syntax, so if you
visit a “.dir-locals.el” file, Emacs will choose “Lisp-Data mode” for
it.  And (info "(elisp)Circular Objects") _is_ about Elisp read
syntax.

> stefan> To: Eli
> stefan> If you want to do better, you can use an actual ELisp file.
                                                ^^^^^^^^^^^^^^^^^^^^

Seems like it is indeed not now, though uses a “.el” postfix.

____________________

To: ALL

> drew> Wouldn't it make sense (be useful) to let users and code
> drew> decide whether to allow this for particular file-local
> drew> variables?

Agree.

There have already been numerous potential dangerous behaviors,
perhaps one more won’t make much of a difference.  I think as long as
users are provided with appropriate warnings, it should suffice.   For
instance, the following code snippet can cause Emacs to crash
instantly, but we still shouldn’t deprive users of their right to
execute it:

    (clear-string (symbol-name t))

Luckily, manual contains a corresponding warning.

--
shynur




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64281: [Feature Request] Recognize “#” syntax
  2023-06-25 15:46     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-06-25 16:16       ` Drew Adams
@ 2023-06-26 12:21       ` Eli Zaretskii
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-06-26 12:21 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: one.last.kiss, 64281-done

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Shynur Xie <one.last.kiss@outlook.com>,  64281@debbugs.gnu.org
> Date: Sun, 25 Jun 2023 11:46:13 -0400
> 
> >> It seems that this is a intentional behavior:
> >>
> >> <https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Local-Variables.html>:
> >>
> >> > For additional safety, read-circle is temporarily bound to nil when
> >> > Emacs reads file-local variables.
> >>
> >> No further question; can be closed now.
> >>
> >> (I wonder if we can treat ~/.emacs.d/.dir-locals.el specially, or tell
> >>  Emacs which files can be treated specially -- enable read-circle.)
> >
> > Stefan, any comments before we close this?
> 
> file/dir-local variables are dangerous enough as it is, I think.  If you
> want to do better, you can use an actual ELisp file.

Agreed.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-06-26 12:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-25 11:54 bug#64281: [Feature Request] Recognize “#” syntax when reading local-variables Shynur Xie
2023-06-25 13:53 ` bug#64281: [Feature Request] Recognize “#” syntax Shynur Xie
2023-06-25 15:08   ` Eli Zaretskii
2023-06-25 15:46     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-25 16:16       ` Drew Adams
2023-06-26 10:21         ` Shynur Xie
2023-06-26 12:21       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).