unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ignacio Casso <ignaciocasso@hotmail.com>
To: 53876@debbugs.gnu.org
Subject: bug#53876: 27.2; "eval: (X-mode)" is always safe as file local variable
Date: Tue, 08 Feb 2022 10:29:16 +0100	[thread overview]
Message-ID: <PAXPR06MB77604A00190ED919333B43AFC62D9@PAXPR06MB7760.eurprd06.prod.outlook.com> (raw)

Hello,

I've noticed something that I believe it might be a bug. With Emacs 27.2
and the default configuration (starting with emacs -Q), I get the
following behavior:

If I visit a file ending with the three lines below, I get the usual
prompt asking whether I want to apply the local variables since they
might not be safe. So far so good.

# Local Variables:
# eval: (message "file was visited")
# End:

If I visit a file with the following local variables instead, I don't
get that prompt and the form is evaluated immediately, so I get line
numbers in the buffer. This happens for any other mode.

# Local Variables:
# eval: (display-line-numbers-mode)
# End:

I'm not sure if that is still good, but the real problem comes now, when I
define a function with a name ending in "-mode", like the following:

(defun not-really-a-mode ()
  (message "This could be doing something nasty"))

If I visit a file with the following local variables, I don't get the
prompt either and the form is evaluated immediately.

# Local Variables:
# eval: (not-really-a-mode)
# End:

(Of course, activating an actual mode could be doing something equally
nasty, but somehow I find this worse)

I've investigated a little and found the function
hack-one-local-variable-eval-safep in files.el, which is responsible for
this. It has a comment that says "Allow (minor)-modes calls with no
arguments.", and just checks whether the function ends in "-mode".

I'm not sure if it's a bug or a feature, and it's not important at all
to me, since it's actually convenient. I'm just reporting it since I
noticed it and I'm trying to get in the habit of reporting (possible)
bugs when I find them.

Best regards,

Ignacio

In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20)
 of 2022-01-16 built on ignacio-IdeaPad-3-15ADA05
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.3 LTS





             reply	other threads:[~2022-02-08  9:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08  9:29 Ignacio Casso [this message]
2022-02-08 16:42 ` bug#53876: 27.2; "eval: (X-mode)" is always safe as file local variable Glenn Morris
2022-02-09  1:08   ` Glenn Morris
2022-02-09  8:23   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PAXPR06MB77604A00190ED919333B43AFC62D9@PAXPR06MB7760.eurprd06.prod.outlook.com \
    --to=ignaciocasso@hotmail.com \
    --cc=53876@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).