unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#28104: 25.2; autoload defcustom should put safe-local-variable
@ 2017-08-15 21:30 Allen Li
  2017-08-15 23:57 ` Glenn Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Allen Li @ 2017-08-15 21:30 UTC (permalink / raw)
  To: 28104

Generating autoloads for a defcustom form will not put
safe-local-variable.  Given:

;;;###autoload
(defcustom mir-python-hanging-indent-levels 1
  "Number of ‘python-indent-offset’ to use for hanging indentation."
  :type 'integer
  :safe 'integerp)

This generates the following autoloads:

(defvar mir-python-hanging-indent-levels 1 "\
Number of ‘python-indent-offset’ to use for hanging indentation.")

(custom-autoload 'mir-python-hanging-indent-levels "mir-python" t)

It would be useful to also include:

(put 'mir-python-hanging-indent-levels 'safe-local-variable 'integerp)

Otherwise, Emacs will complain about file local variables that are
safe if you do not (require 'foo) in advance, which is very annoying.

In GNU Emacs 25.2.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8),
modified by Debian
Windowing system distributor 'The X.Org Foundation', version 11.0.11803000
System Description: Ubuntu 14.04 LTS





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

* bug#28104: 25.2; autoload defcustom should put safe-local-variable
  2017-08-15 21:30 bug#28104: 25.2; autoload defcustom should put safe-local-variable Allen Li
@ 2017-08-15 23:57 ` Glenn Morris
  2017-08-16  3:29   ` Allen Li
  0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2017-08-15 23:57 UTC (permalink / raw)
  To: Allen Li; +Cc: 28104


It's rare to need to autoload a defcustom.
If you need to autoload the safety property, specify it separately,
and autoload just that statement. Otherwise I suppose you could wrap
the defcustom in a progn and autoload the whole thing.





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

* bug#28104: 25.2; autoload defcustom should put safe-local-variable
  2017-08-15 23:57 ` Glenn Morris
@ 2017-08-16  3:29   ` Allen Li
  2021-07-05 13:56     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Allen Li @ 2017-08-16  3:29 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 28104

On Tue, Aug 15, 2017 at 4:57 PM, Glenn Morris <rgm@gnu.org> wrote:
>
> It's rare to need to autoload a defcustom.

What are some intended use cases for an autoloaded defcustom?  For me,
applying safe-local-variable seems like a leading use case.

I'm fine with writing

(defcustom foo nil
  "Doc"
  :safe 'symbolp)
;;;###autoload
(put 'foo 'safe-local-variable 'symbolp)

But that seems redundant, and especially so in such use cases where
you would want to autoload the defcustom.

;;;###autoload
(defcustom foo nil
  "Doc"
  :safe 'symbolp)
;;;###autoload
(put 'foo 'safe-local-variable 'symbolp)

You could omit the :safe in defcustom, I suppose, but the
inconsistency bugs me; defcustom can be autoloaded and defcustom can
set safe-local-variable, but not both at the same time.  It makes
either feature feel like it was tacked on as an afterthought and not
part of a homogeneous whole.

> If you need to autoload the safety property, specify it separately,
> and autoload just that statement. Otherwise I suppose you could wrap
> the defcustom in a progn and autoload the whole thing.





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

* bug#28104: 25.2; autoload defcustom should put safe-local-variable
  2017-08-16  3:29   ` Allen Li
@ 2021-07-05 13:56     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-05 13:56 UTC (permalink / raw)
  To: Allen Li; +Cc: 28104, Glenn Morris

Allen Li <vianchielfaura@gmail.com> writes:

> You could omit the :safe in defcustom, I suppose, but the
> inconsistency bugs me; defcustom can be autoloaded and defcustom can
> set safe-local-variable, but not both at the same time. 

Yeah, I think it makes sense to propagate the :safe setting to the
loaddefs file when doing this (even if it's slightly unusual).  So I've
now made this change in Emacs 28.

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





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

end of thread, other threads:[~2021-07-05 13:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-15 21:30 bug#28104: 25.2; autoload defcustom should put safe-local-variable Allen Li
2017-08-15 23:57 ` Glenn Morris
2017-08-16  3:29   ` Allen Li
2021-07-05 13:56     ` Lars Ingebrigtsen

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).