Prefer defcustom :safe to putting 'safe-local-variable'

* lisp/emacs-lisp/lisp-mode.el (lisp-indent-offset)
(lisp-body-indent, emacs-lisp-docstring-fill-column):
* lisp/files.el (version-control):
* lisp/progmodes/modula2.el (m2-indent):
* lisp/progmodes/octave.el (octave-block-offset):
* lisp/progmodes/sh-script.el (sh-basic-offset):
* lisp/progmodes/tcl.el (tcl-indent-level)
(tcl-continued-indent-level):
* lisp/simple.el (fill-prefix):
* lisp/textmodes/fill.el (colon-double-space):
* lisp/textmodes/paragraphs.el (paragraph-start)
(paragraph-separate, sentence-end-double-space)
(sentence-end-without-period, sentence-end-without-space)
(sentence-end, sentence-end-base, page-delimiter)
(paragraph-ignore-fill-prefix):
* lisp/textmodes/tex-mode.el (tex-fontify-script):
* lisp/vc/add-log.el (add-log-dont-create-changelog-file):
* lisp/vc/vc-hooks.el (vc-follow-symlinks): Prefer defcustom :safe to
putting 'safe-local-variable'.
This commit is contained in:
Stefan Kangas 2022-07-06 19:56:32 +02:00
parent 5866fd5fec
commit 3e7f6ff4b0
12 changed files with 39 additions and 45 deletions

View file

@ -838,9 +838,8 @@ or to switch back to an existing one."
(defcustom lisp-indent-offset nil
"If non-nil, indent second line of expressions that many more columns."
:group 'lisp
:type '(choice (const nil) integer))
(put 'lisp-indent-offset 'safe-local-variable
(lambda (x) (or (null x) (integerp x))))
:type '(choice (const nil) integer)
:safe (lambda (x) (or (null x) (integerp x))))
(defcustom lisp-indent-function 'lisp-indent-function
"A function to be called by `calculate-lisp-indent'.
@ -1252,8 +1251,8 @@ Lisp function does not specify a special indentation."
(defcustom lisp-body-indent 2
"Number of columns to indent the second line of a `(def...)' form."
:group 'lisp
:type 'integer)
(put 'lisp-body-indent 'safe-local-variable 'integerp)
:type 'integer
:safe #'integerp)
(defun lisp-indent-specform (count state indent-point normal-indent)
(let ((containing-form-start (elt state 1))
@ -1414,9 +1413,8 @@ Any non-integer value means do not use a different value of
`fill-column' when filling docstrings."
:type '(choice (integer)
(const :tag "Use the current `fill-column'" t))
:safe (lambda (x) (or (eq x t) (integerp x)))
:group 'lisp)
(put 'emacs-lisp-docstring-fill-column 'safe-local-variable
(lambda (x) (or (eq x t) (integerp x))))
(defun lisp-fill-paragraph (&optional justify)
"Like \\[fill-paragraph], but handle Emacs Lisp comments and docstrings.

View file

@ -304,16 +304,14 @@ When nil, make them for files that have some already.
The value `never' means do not make them."
:type '(choice (const :tag "Never" never)
(const :tag "If existing" nil)
(other :tag "Always" t))
(other :tag "Always" t))
:safe #'version-control-safe-local-p
:group 'backup)
(defun version-control-safe-local-p (x)
"Return whether X is safe as local value for `version-control'."
(or (booleanp x) (equal x 'never)))
(put 'version-control 'safe-local-variable
#'version-control-safe-local-p)
(defcustom dired-kept-versions 2
"When cleaning directory, number of versions to keep."
:type 'natnum

View file

@ -101,9 +101,8 @@
(defcustom m2-indent 5
"This variable gives the indentation in Modula-2 mode."
:type 'integer)
(put 'm2-indent 'safe-local-variable
(lambda (v) (or (null v) (integerp v))))
:type 'integer
:safe (lambda (v) (or (null v) (integerp v))))
(defconst m2-smie-grammar
;; An official definition can be found as "M2R10.pdf". This grammar does

View file

@ -197,8 +197,8 @@ newline or semicolon after an else or end keyword."
(defcustom octave-block-offset 2
"Extra indentation applied to statements in Octave block structures."
:type 'integer)
(put 'octave-block-offset 'safe-local-variable 'integerp)
:type 'integer
:safe #'integerp)
(defvar octave-block-comment-start
(concat (make-string 2 octave-comment-char) " ")

View file

@ -1156,8 +1156,8 @@ Can be set to a number, or to nil which means leave it as is."
"The default indentation increment.
This value is used for the `+' and `-' symbols in an indentation variable."
:type 'integer
:safe #'integerp
:group 'sh-indentation)
(put 'sh-basic-offset 'safe-local-variable 'integerp)
(defcustom sh-indent-comment t
"How a comment line is to be indented.

View file

@ -120,13 +120,13 @@
(defcustom tcl-indent-level 4
"Indentation of Tcl statements with respect to containing block."
:type 'integer)
(put 'tcl-indent-level 'safe-local-variable #'integerp)
:type 'integer
:safe #'integerp)
(defcustom tcl-continued-indent-level 4
"Indentation of continuation line relative to first line of command."
:type 'integer)
(put 'tcl-continued-indent-level 'safe-local-variable #'integerp)
:type 'integer
:safe #'integerp)
(defcustom tcl-auto-newline nil
"Non-nil means automatically newline before and after braces you insert."

View file

@ -8609,10 +8609,10 @@ constitute a word."
(defcustom fill-prefix nil
"String for filling to insert at front of new line, or nil for none."
:type '(choice (const :tag "None" nil)
string)
string)
:safe #'string-or-null-p
:group 'fill)
(make-variable-buffer-local 'fill-prefix)
(put 'fill-prefix 'safe-local-variable 'string-or-null-p)
(defcustom auto-fill-inhibit-regexp nil
"Regexp to match lines that should not be auto-filled."

View file

@ -46,8 +46,8 @@ A value of nil means that any change in indentation starts a new paragraph."
(defcustom colon-double-space nil
"Non-nil means put two spaces after a colon when filling."
:type 'boolean)
(put 'colon-double-space 'safe-local-variable #'booleanp)
:type 'boolean
:safe #'booleanp)
(defcustom fill-separate-heterogeneous-words-with-space nil
"Non-nil means to use a space to separate words of a different kind.

View file

@ -96,8 +96,8 @@ lines that start paragraphs from lines that separate them.
If the variable `use-hard-newlines' is non-nil, then only lines following a
hard newline are considered to match."
:type 'regexp)
(put 'paragraph-start 'safe-local-variable #'stringp)
:type 'regexp
:safe #'stringp)
;; paragraph-start requires a hard newline, but paragraph-separate does not:
;; It is assumed that paragraph-separate is distinctive enough to be believed
@ -113,8 +113,8 @@ This is matched against the text at the left margin, which is not necessarily
the beginning of the line, so it should not use \"^\" as an anchor. This
ensures that the paragraph functions will work equally within a region of
text indented by a margin setting."
:type 'regexp)
(put 'paragraph-separate 'safe-local-variable #'stringp)
:type 'regexp
:safe #'stringp)
(defcustom sentence-end-double-space t
"Non-nil means a single space does not end a sentence.
@ -125,8 +125,8 @@ This value is used by the function `sentence-end' to construct the
regexp describing the end of a sentence, when the value of the variable
`sentence-end' is nil. See Info node `(elisp)Standard Regexps'."
:type 'boolean
:safe #'booleanp
:group 'fill)
(put 'sentence-end-double-space 'safe-local-variable #'booleanp)
(defcustom sentence-end-without-period nil
"Non-nil means a sentence will end without a period.
@ -137,8 +137,8 @@ This value is used by the function `sentence-end' to construct the
regexp describing the end of a sentence, when the value of the variable
`sentence-end' is nil. See Info node `(elisp)Standard Regexps'."
:type 'boolean
:safe #'booleanp
:group 'fill)
(put 'sentence-end-without-period 'safe-local-variable #'booleanp)
(defcustom sentence-end-without-space
"。.?!"
@ -147,8 +147,8 @@ regexp describing the end of a sentence, when the value of the variable
This value is used by the function `sentence-end' to construct the
regexp describing the end of a sentence, when the value of the variable
`sentence-end' is nil. See Info node `(elisp)Standard Regexps'."
:type 'string)
(put 'sentence-end-without-space 'safe-local-variable #'stringp)
:type 'string
:safe #'stringp)
(defcustom sentence-end nil
"Regexp describing the end of a sentence.
@ -158,14 +158,14 @@ All paragraph boundaries also end sentences, regardless.
The value nil means to use the default value defined by the
function `sentence-end'. You should always use this function
to obtain the value of this variable."
:type '(choice regexp (const :tag "Use default value" nil)))
(put 'sentence-end 'safe-local-variable #'string-or-null-p)
:type '(choice regexp (const :tag "Use default value" nil))
:safe #'string-or-null-p)
(defcustom sentence-end-base "[.?!…‽][]\"'”’)}»›]*"
"Regexp matching the basic end of a sentence, not including following space."
:type 'regexp
:safe #'stringp
:version "25.1")
(put 'sentence-end-base 'safe-local-variable #'stringp)
(defun sentence-end ()
"Return the regexp describing the end of a sentence.
@ -192,14 +192,14 @@ in between. See Info node `(elisp)Standard Regexps'."
(defcustom page-delimiter "^\014"
"Regexp describing line-beginnings that separate pages."
:type 'regexp)
(put 'page-delimiter 'safe-local-variable #'stringp)
:type 'regexp
:safe #'stringp)
(defcustom paragraph-ignore-fill-prefix nil
"Non-nil means the paragraph commands are not affected by `fill-prefix'.
This is desirable in modes where blank lines are the paragraph delimiters."
:type 'boolean)
(put 'paragraph-ignore-fill-prefix 'safe-local-variable #'booleanp)
:type 'boolean
:safe #'booleanp)
;; Silence the compiler.
(defun forward-paragraph (&optional arg)

View file

@ -248,9 +248,9 @@ Normally set to either `plain-tex-mode' or `latex-mode'."
(defcustom tex-fontify-script t
"If non-nil, fontify subscript and superscript strings."
:type 'boolean
:safe #'booleanp
:group 'tex
:version "23.1")
(put 'tex-fontify-script 'safe-local-variable #'booleanp)
(defcustom tex-font-script-display '(-0.2 0.2)
"How much to lower and raise subscript and superscript content.

View file

@ -789,10 +789,9 @@ Optional arg BUFFER-FILE overrides `buffer-file-name'."
If a ChangeLog file does not already exist, a non-nil value
means to put log entries in a suitably named buffer."
:type 'boolean
:safe #'booleanp
:version "27.1")
(put 'add-log-dont-create-changelog-file 'safe-local-variable #'booleanp)
(defun add-log--pseudo-changelog-buffer-name (changelog-file-name)
"Compute a suitable name for a non-file visiting ChangeLog buffer.
CHANGELOG-FILE-NAME is the file name of the actual ChangeLog file

View file

@ -141,9 +141,9 @@ confirmation whether it should follow the link. If nil, the link is
visited and a warning displayed."
:type '(choice (const :tag "Ask for confirmation" ask)
(const :tag "Visit link and warn" nil)
(const :tag "Follow link" t))
(const :tag "Follow link" t))
:safe #'null
:group 'vc)
(put 'vc-follow-symlinks 'safe-local-variable #'null)
(defcustom vc-display-status t
"If non-nil, display revision number and lock status in mode line.