Kyle Meyer <[email protected]> writes:

> There are handful of defcustom's that declare ':safe t':
> ...
> As far as I understand, that's invalid.  See Emacs's 4341e79a5fa (Remove
> bogus ":safe t" custom properties, 2021-10-02), which previously pruned
> a bunch of these from Org's tree.
>
> Likewise, I think ':safe nil' properties should be removed, for the
> reason given in Emacs's 62d6cecfcd1 (Remove bogus ":safe nil" custom
> properties, 2021-10-02).

See the attached patch.
If you do not see any further issues, I will apply it onto bugfix.

>From 130c0468adb88495e2d5efe3ed60d1fc6b79d559 Mon Sep 17 00:00:00 2001
Message-ID: <130c0468adb88495e2d5efe3ed60d1fc6b79d559.1774980005.git.yanta...@posteo.net>
From: Ihor Radchenko <[email protected]>
Date: Tue, 31 Mar 2026 19:55:13 +0200
Subject: [PATCH] Fix incorrect values of :safe t and :safe nil

* lisp/ob-csharp.el (org-babel-csharp-compiler):
(org-babel-csharp-default-target-framework):
(org-babel-csharp-generate-compile-command):
(org-babel-csharp-generate-restore-command):
(org-babel-csharp-additional-project-flags):
* lisp/ob-ditaa.el (org-ditaa-default-exec-mode):
(org-ditaa-exec):
(org-ditaa-java-exec):
* lisp/ob-latex.el (org-babel-latex-preamble):
(org-babel-latex-process-alist):
* lisp/ob-lisp.el (org-babel-lisp-dir-fmt):
* lisp/ob-tangle.el (org-babel-tangle-lang-exts):
* lisp/oc-bibtex.el (org-cite-bibtex-bibliography-style):
* lisp/ol.el (org-link-parameters):
(org-link-frame-setup):
(org-link-preview-delay):
(org-link-preview-batch-size):
(org-image-max-width):
* lisp/org-archive.el (org-archive-save-context-info):
(org-archive-hook):
(org-archive-finalize-hook):
* lisp/org-capture.el (org-capture-templates):
* lisp/org-cycle.el (org-cycle-link-previews-display):
* lisp/org-id.el (org-id-completion-targets):
* lisp/org-keys.el (org-speed-commands):
* lisp/org-plot.el (org-plot/preset-plot-types):
* lisp/org-src.el (org-src-lang-modes):
* lisp/org.el (org-edit-keep-region):
(org-priority-highest):
(org-priority-lowest):
(org-priority-default):
(org-timestamp-custom-formats):
(org-tags-sort-function):
(org-preview-latex-process-alist):
(org-latex-mathml-directory):
* lisp/ox-html.el (org-html-style-default):
(org-html-datetime-formats):
(org-html-head):
(org-html-head-extra):
* lisp/ox-md.el (org-md-link-org-files-as-md):
* lisp/ox-odt.el (org-odt-with-forbidden-chars):
(org-odt-with-latex):
Use function as a value of :safe.  Use :risky t instead of :safe nil.

Reported-by: Kyle Meyer <[email protected]>
Link: https://orgmode.org/list/[email protected]
---
 lisp/ob-csharp.el   | 10 +++++-----
 lisp/ob-ditaa.el    |  6 +++---
 lisp/ob-latex.el    |  4 ++--
 lisp/ob-lisp.el     |  2 +-
 lisp/ob-tangle.el   |  2 +-
 lisp/oc-bibtex.el   |  2 +-
 lisp/ol.el          | 10 +++++-----
 lisp/org-archive.el |  6 +++---
 lisp/org-capture.el |  2 +-
 lisp/org-cycle.el   |  2 +-
 lisp/org-id.el      |  2 +-
 lisp/org-keys.el    |  2 +-
 lisp/org-plot.el    |  2 +-
 lisp/org-src.el     |  2 +-
 lisp/org.el         | 16 ++++++++--------
 lisp/ox-html.el     |  8 ++++----
 lisp/ox-md.el       |  2 +-
 lisp/ox-odt.el      |  4 ++--
 18 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/lisp/ob-csharp.el b/lisp/ob-csharp.el
index 1d22e48bc..7bd30e151 100644
--- a/lisp/ob-csharp.el
+++ b/lisp/ob-csharp.el
@@ -52,7 +52,7 @@ (defcustom org-babel-csharp-compiler "dotnet"
   :group 'org-babel
   :package-version '(Org. "9.8")
   :type 'string
-  :safe nil)
+  :risky t)
 
 (defun org-babel-csharp--default-compile-command (dir-proj-sln bin-dir)
   "Construct the default compilation command for C#.
@@ -92,7 +92,7 @@ (defcustom org-babel-csharp-default-target-framework
   :group 'org-babel
   :package-version '(Org. "9.8")
   :type 'string
-  :safe t)
+  :safe #'stringp)
 
 (defcustom org-babel-csharp-generate-compile-command
   #'org-babel-csharp--default-compile-command
@@ -103,7 +103,7 @@ (defcustom org-babel-csharp-generate-compile-command
   :group 'org-babel
   :package-version '(Org. "9.8")
   :type 'function
-  :safe nil)
+  :risky t)
 
 (defcustom org-babel-csharp-generate-restore-command
   #'org-babel-csharp--default-restore-command
@@ -113,7 +113,7 @@ (defcustom org-babel-csharp-generate-restore-command
   :group 'org-babel
   :package-version '(Org. "9.8")
   :type 'function
-  :safe nil)
+  :risky t)
 
 (defcustom org-babel-csharp-additional-project-flags nil
   "Will be passed in the \"PropertyGroup\" defining the project.
@@ -122,7 +122,7 @@ (defcustom org-babel-csharp-additional-project-flags nil
   :group 'org-babel
   :package-version '(Org. "9.8")
   :type '(choice string (const nil))
-  :safe t)
+  :safe (lambda (x) (or (eq x nil) (stringp x))))
 
 (defun org-babel-csharp--generate-project-file (refs framework)
   "Generate the file content to be used in a csproj-file.
diff --git a/lisp/ob-ditaa.el b/lisp/ob-ditaa.el
index 839e4c252..55d375a85 100644
--- a/lisp/ob-ditaa.el
+++ b/lisp/ob-ditaa.el
@@ -98,21 +98,21 @@ (defcustom org-ditaa-default-exec-mode 'jar
   :package-version '(Org . "9.8")
   :type '(choice (const :tag "Use java together with a JAR file." jar)
                  (const :tag "Use ditaa executable." ditaa))
-  :safe t)
+  :safe (lambda (x) (memq x '(jar ditaa))))
 
 (defcustom org-ditaa-exec "ditaa"
   "File name of the ditaa executable."
   :group 'org-babel
   :package-version '(Org . "9.8")
   :type 'string
-  :safe nil)
+  :risky t)
 
 (define-obsolete-variable-alias 'org-babel-ditaa-java-cmd 'org-ditaa-java-exec "9.8")
 (defcustom org-ditaa-java-exec "java"
   "Java executable to use when evaluating ditaa blocks using a JAR."
   :group 'org-babel
   :type 'string
-  :safe nil)
+  :risky t)
 
 (defcustom org-ditaa-jar-path (expand-file-name
 			       "ditaa.jar"
diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index fc325f259..930e218e6 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -84,7 +84,7 @@ (defcustom org-babel-latex-preamble
   :group 'org-babel
   :package-version '(Org . "9.8")
   :type 'function
-  :safe nil)
+  :risky t)
 
 (defcustom org-babel-latex-begin-env
   (lambda (_)
@@ -150,7 +150,7 @@ (defcustom org-babel-latex-process-alist
   :package-version '(Org . "9.8")
   :type '(alist :tag "LaTeX to image backends"
 		:value-type (plist))
-  :safe nil)
+  :risky t)
 
 (defun org-babel-expand-body:latex (body params)
   "Expand BODY according to PARAMS, return the expanded body."
diff --git a/lisp/ob-lisp.el b/lisp/ob-lisp.el
index 90aedd4e7..2d005ee5e 100644
--- a/lisp/ob-lisp.el
+++ b/lisp/ob-lisp.el
@@ -68,7 +68,7 @@ (defcustom org-babel-lisp-dir-fmt
   :group 'org-babel
   :package-version '(Org . "9.8")
   :type 'string
-  :safe nil)
+  :risky t)
 
 (defun org-babel-expand-body:lisp (body params)
   "Expand BODY according to PARAMS, return the expanded body."
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 6fe553469..9d4c914c2 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -69,7 +69,7 @@ (defcustom org-babel-tangle-lang-exts
 	  (cons
 	   (string "Language name")
 	   (string "File Extension")))
-  :safe t)
+  :safe #'listp)
 
 (defcustom org-babel-tangle-use-relative-file-links t
   "Use relative path names in links from tangled source back the Org file."
diff --git a/lisp/oc-bibtex.el b/lisp/oc-bibtex.el
index 0e5496731..3adab6917 100644
--- a/lisp/oc-bibtex.el
+++ b/lisp/oc-bibtex.el
@@ -71,7 +71,7 @@ (defcustom org-cite-bibtex-bibliography-style "plain"
     (const :tag "IEEE" "ieeetr")
     (const :tag "SIAM" "siam")
     (string :tag "Other"))
-  :safe t)
+  :safe #'stringp)
 
 
 ;;; Export capability
diff --git a/lisp/ol.el b/lisp/ol.el
index 5fdff1de8..24ac9deb1 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -214,7 +214,7 @@ (defcustom org-link-parameters nil
   :package-version '(Org . "9.8")
   :type '(alist :tag "Link display parameters"
 		:value-type plist)
-  :safe nil)
+  :risky t)
 
 (defun org-link--set-link-display (symbol value)
   "Set `org-link-descriptive' (SYMBOL) to VALUE.
@@ -388,7 +388,7 @@ (defcustom org-link-frame-setup
 		(choice
 		 (const wl)
 		 (const wl-other-frame))))
-  :safe nil)
+  :risky t)
 
 (defcustom org-link-search-must-match-exact-headline 'query-to-create
   "Control fuzzy link behavior when specific matches not found.
@@ -552,7 +552,7 @@ (defcustom org-link-preview-delay 0.05
   :group 'org-link
   :package-version '(Org . "9.8")
   :type 'number
-  :safe t)
+  :safe #'numberp)
 
 (defcustom org-link-preview-batch-size 6
   "Number of links that are previewed at once with `org-link-preview'.
@@ -563,7 +563,7 @@ (defcustom org-link-preview-batch-size 6
   :group 'org-link
   :package-version '(Org . "9.8")
   :type 'natnum
-  :safe t)
+  :safe #'natnump)
 
 (defcustom org-display-remote-inline-images 'skip
   "How to display remote inline images.
@@ -602,7 +602,7 @@ (defcustom org-image-max-width 'fill-column
           (const :tag "Limit to window width" window)
           (integer :tag "Limit to a number of pixels")
           (float :tag "Limit to a fraction of window width"))
-  :safe t)
+  :safe (lambda (x) (or (numberp x) (member x '(nil 'fill-column 'window)))))
 
 (defcustom org-image-align 'left
   "How to align images previewed using `org-link-preview-region'.
diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index 783a9d878..e128a276e 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -146,7 +146,7 @@ (defcustom org-archive-save-context-info '(time file olpath category todo itags)
 	      (const :tag "Outline path" olpath)
 	      (const :tag "Outline parent id" olid)
 	      (const :tag "Local tags" ltags))
-  :safe t)
+  :safe #'listp)
 
 (defcustom org-archive-hook nil
   "Hook run after successfully archiving a subtree.
@@ -155,7 +155,7 @@ (defcustom org-archive-hook nil
 archive location, but not yet deleted from the original file."
   :group 'org-archive
   :type 'hook
-  :safe nil)
+  :risky t)
 
 (defcustom org-archive-finalize-hook nil
   "Hook run after successfully archiving a subtree in final location.
@@ -167,7 +167,7 @@ (defcustom org-archive-finalize-hook nil
   :group 'org-archive
   :package-version '(Org . "9.8")
   :type 'hook
-  :safe nil)
+  :risky t)
 
 ;;;###autoload
 (defun org-add-archive-files (files)
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 705fdc902..6f1d3bc39 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -535,7 +535,7 @@ (defcustom org-capture-templates nil
 				     ((const :format "%v " :unnarrowed) (const t))
 				     ((const :format "%v " :table-line-pos) (string))
 				     ((const :format "%v " :kill-buffer) (const t))))))))
-  :safe nil)
+  :risky t)
 
 (defcustom org-capture-before-finalize-hook nil
   "Hook that is run right before a capture process is finalized.
diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el
index 9f9f44ee9..dbda88738 100644
--- a/lisp/org-cycle.el
+++ b/lisp/org-cycle.el
@@ -246,7 +246,7 @@ (defcustom org-cycle-link-previews-display nil
   :group 'org-cycle
   :package-version '(Org . "9.8")
   :type 'boolean
-  :safe t)
+  :safe #'booleanp)
 
 (defvaralias 'org-tab-first-hook 'org-cycle-tab-first-hook)
 (defvar org-cycle-tab-first-hook nil
diff --git a/lisp/org-id.el b/lisp/org-id.el
index 6935a5115..c33ea7fbb 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -301,7 +301,7 @@ (defcustom org-id-completion-targets
   :group 'org-id
   :type (get 'org-refile-targets 'custom-type)
   :package-version '(Org . "9.8")
-  :safe t)
+  :risky t)
 
 ;;; The API functions
 
diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index 56f276e13..739a719b9 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -798,7 +798,7 @@ (defcustom org-speed-commands
 			       (choice
 				(function)
 				(sexp)))))
-  :safe nil)
+  :risky t)
 
 (defun org--print-speed-command (speed-command)
   "Print information about SPEED-COMMAND in help buffer.
diff --git a/lisp/org-plot.el b/lisp/org-plot.el
index 2a436a100..5b53699a5 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -407,7 +407,7 @@ (defcustom org-plot/preset-plot-types
   :group 'org-plot
   :package-version '(Org . "9.8")
   :type 'alist
-  :safe nil)
+  :risky t)
 
 (defvar org--plot/radar-template
   "### spider plot/chart with gnuplot
diff --git a/lisp/org-src.el b/lisp/org-src.el
index d19687d97..ed265d2d6 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -246,7 +246,7 @@ (defcustom org-src-lang-modes
 	  (cons
 	   (string :tag "Language name")
 	   (symbol :tag "Major mode")))
-  :safe t)
+  :safe #'listp)
 
 (defcustom org-src-block-faces nil
   "Alist of faces to be used for source-block.
diff --git a/lisp/org.el b/lisp/org.el
index db122f920..b8d22309e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1075,7 +1075,7 @@ (defcustom org-edit-keep-region
                    (const :tag "Deactivate region" nil))))
   :package-version '(Org . "9.8")
   :group 'org-edit-structure
-  :safe t)
+  :safe #'always)
 
 (defun org--deactivate-mark ()
   "Return non-nil when `this-command' should deactivate mark upon completion.
@@ -2498,7 +2498,7 @@ (defcustom org-priority-highest ?A
   :package-version '(Org . "9.8")
   :type '( restricted-sexp :tag "Number 0-64 or uppercase character A-Z"
            :match-alternatives ((lambda (val) (org-priority-valid-value-p val t))))
-  :safe t)
+  :safe #'integerp)
 
 (defvaralias 'org-lowest-priority 'org-priority-lowest)
 (defcustom org-priority-lowest ?C
@@ -2521,7 +2521,7 @@ (defcustom org-priority-lowest ?C
   :package-version '(Org . "9.8")
   :type '( restricted-sexp :tag "Number 0-64 or uppercase character A-Z"
            :match-alternatives ((lambda (val) (org-priority-valid-value-p val t))))
-  :safe t)
+  :safe #'integerp)
 
 (defvaralias 'org-default-priority 'org-priority-default)
 (defcustom org-priority-default ?B
@@ -2538,7 +2538,7 @@ (defcustom org-priority-default ?B
   :package-version '(Org . "9.8")
   :type '( restricted-sexp :tag "Number 0-64 or uppercase character A-Z"
            :match-alternatives ((lambda (val) (org-priority-valid-value-p val t))))
-  :safe t)
+  :safe #'integerp)
 
 (defcustom org-priority-start-cycle-with-default t
   "Non-nil means start with default priority when starting to cycle.
@@ -2631,7 +2631,7 @@ (defcustom org-timestamp-custom-formats
   :group 'org-time
   :package-version '(Org . "9.8")
   :type '(cons string string)
-  :safe t)
+  :safe #'consp)
 
 (defun org-time-stamp-format (&optional with-time inactive custom)
   "Get timestamp format for a time string.
@@ -3082,7 +3082,7 @@ (defcustom org-tags-sort-function nil
           (const :tag "Sort by hierarchy" org-tags-sort-hierarchy)
           (function :tag "Custom function" nil)
           (repeat function))
-  :safe nil)
+  :risky t)
 
 (defvar org-tags-history nil
   "History of minibuffer reads for tags.")
@@ -3554,7 +3554,7 @@ (defcustom org-preview-latex-process-alist
   :package-version '(Org . "9.8")
   :type '(alist :tag "LaTeX to image backends"
 		:value-type (plist))
-  :safe nil)
+  :risky t)
 
 (defcustom org-preview-latex-image-directory "ltximg/"
   "Path to store latex preview images.
@@ -3574,7 +3574,7 @@ (defcustom org-latex-mathml-directory "ltxmathml/"
   :group 'org-latex
   :package-version '(Org . "9.8")
   :type 'string
-  :safe nil)
+  :risky t)
 
 (defun org-format-latex-mathml-available-p ()
   "Return t if `org-latex-to-mathml-convert-command' is usable."
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 73d981fa0..6916cc216 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -457,7 +457,7 @@ (defcustom org-html-style-default
   :group 'org-export-html
   :package-version '(Org . "9.8")
   :type 'string
-  :safe t)
+  :safe #'stringp)
 
 
 ;;; User Configuration Variables
@@ -1177,7 +1177,7 @@ (defcustom org-html-datetime-formats '("%F" . "%FT%T")
   :type '(cons string string)
   :group 'org-export-html
   :package-version '(Org . "9.8")
-  :safe t)
+  :safe #'consp)
 
 ;;;; Template :: Mathjax
 
@@ -1569,7 +1569,7 @@ (defcustom org-html-head ""
   :package-version '(Org . "9.8")
   :type '(choice (string :tag "Literal text to insert")
                  (function :tag "Function evaluating to a string"))
-  :safe t)
+  :safe #'stringp)
 ;;;###autoload
 (put 'org-html-head 'safe-local-variable 'stringp)
 
@@ -1584,7 +1584,7 @@ (defcustom org-html-head-extra ""
   :package-version '(Org . "9.8")
   :type '(choice (string :tag "Literal text to insert")
                  (function :tag "Function evaluating to a string"))
-  :safe t)
+  :safe #'stringp)
 ;;;###autoload
 (put 'org-html-head-extra 'safe-local-variable 'stringp)
 
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index ae4224b3f..f15f3f568 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -107,7 +107,7 @@ (defcustom org-md-link-org-files-as-md t
   :group 'org-export-md
   :package-version '(Org . "9.8")
   :type 'boolean
-  :safe t)
+  :safe #'booleanp)
 
 
 
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 36c8342ef..232a64373 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -384,7 +384,7 @@ (defcustom org-odt-with-forbidden-chars ""
   :type '(choice (const :tag "Leave forbidden characters as-is" t)
                  (const :tag "Err when forbidden characters encountered" nil)
                  (string :tag "Replacement string"))
-  :safe t)
+  :safe #'always)
 
 ;;;; Debugging
 
@@ -744,7 +744,7 @@ (defcustom org-odt-with-latex org-export-with-latex
                            (,(lambda (v)
                                (assq v org-preview-latex-process-alist))))
           (const :tag "Leave math verbatim" verbatim))
-  :safe t)
+  :safe #'always)
 
 
 ;;;; Links
-- 
2.52.0

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to