Przeglądaj źródła

Use `set-default-toplevel-value' in `defcustom' setters

* lisp/ob-lilypond.el (org-babel-lilypond-commands):
* lisp/ob-shell.el (org-babel-shell-names):
* lisp/org-capture.el (org-capture-templates):
* lisp/org-clock.el (org-clock-ask-before-exiting):
* lisp/org-duration.el (org-duration-units):
* lisp/org-faces.el (org-set-tag-faces):
* lisp/org-footnote.el (org-footnote-section):
* lisp/org-list.el (org-plain-list-ordered-item-terminator):
(org-list-allow-alphabetical):
* lisp/org.el (org-babel-do-load-languages):
(org-set-modules):
(org-export-backends):
(org-use-fast-todo-selection):
(org-enforce-todo-dependencies):
(org-enforce-todo-checkbox-dependencies):
(org-display-custom-times):
(org-set-packages-alist):
(org-set-emph-re):
* lisp/ox-odt.el (org-odt-schema-dir): Use
`set-default-toplevel-value' instead of `set' or `set-default' in
`defcustom' :set argument.

This commit fixes a bug that occurred when using an autoload function
inside a let-binding for a custom variable when the feature defining
both the function and the custom variable had not been loaded yet.

See bug#54399 and
https://lists.gnu.org/archive/html/emacs-orgmode/2022-03/msg00085.html,
https://lists.gnu.org/archive/html/emacs-orgmode/2022-06/msg00226.html
Ignacio Casso 3 lat temu
rodzic
commit
f9ea6c61ed

+ 1 - 1
lisp/ob-lilypond.el

@@ -107,7 +107,7 @@ you can leave the string empty on this case."
   :package-version '(Org . "8.2.7")
   :package-version '(Org . "8.2.7")
   :set
   :set
   (lambda (symbol value)
   (lambda (symbol value)
-    (set symbol value)
+    (set-default-toplevel-value symbol value)
     (setq
     (setq
      org-babel-lilypond-ly-command   (nth 0 value)
      org-babel-lilypond-ly-command   (nth 0 value)
      org-babel-lilypond-pdf-command  (nth 1 value)
      org-babel-lilypond-pdf-command  (nth 1 value)

+ 1 - 1
lisp/ob-shell.el

@@ -68,7 +68,7 @@ outside the Customize interface."
   :group 'org-babel
   :group 'org-babel
   :type '(repeat (string :tag "Shell name: "))
   :type '(repeat (string :tag "Shell name: "))
   :set (lambda (symbol value)
   :set (lambda (symbol value)
-	 (set-default symbol value)
+	 (set-default-toplevel-value symbol value)
 	 (org-babel-shell-initialize)))
 	 (org-babel-shell-initialize)))
 
 
 (defcustom org-babel-shell-results-defaults-to-output t
 (defcustom org-babel-shell-results-defaults-to-output t

+ 1 - 1
lisp/org-capture.el

@@ -376,7 +376,7 @@ When you need to insert a literal percent sign in the template,
 you can escape ambiguous cases with a backward slash, e.g., \\%i."
 you can escape ambiguous cases with a backward slash, e.g., \\%i."
   :group 'org-capture
   :group 'org-capture
   :package-version '(Org . "9.5")
   :package-version '(Org . "9.5")
-  :set (lambda (s v) (set s (org-capture-upgrade-templates v)))
+  :set (lambda (s v) (set-default-toplevel-value s (org-capture-upgrade-templates v)))
   :type
   :type
   (let ((file-variants '(choice :tag "Filename       "
   (let ((file-variants '(choice :tag "Filename       "
 				(file :tag "Literal")
 				(file :tag "Literal")

+ 1 - 1
lisp/org-clock.el

@@ -493,7 +493,7 @@ This variable only has effect if set with \\[customize]."
          (if value
          (if value
              (add-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query)
              (add-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query)
            (remove-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query))
            (remove-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query))
-         (set symbol value))
+         (set-default-toplevel-value symbol value))
   :type 'boolean
   :type 'boolean
   :package-version '(Org . "9.5"))
   :package-version '(Org . "9.5"))
 
 

+ 1 - 1
lisp/org-duration.el

@@ -98,7 +98,7 @@ sure to call the following command:
   :version "26.1"
   :version "26.1"
   :package-version '(Org . "9.1")
   :package-version '(Org . "9.1")
   :set (lambda (var val)
   :set (lambda (var val)
-         (set-default var val)
+         (set-default-toplevel-value var val)
          ;; Avoid recursive load at startup.
          ;; Avoid recursive load at startup.
 	 (when (featurep 'org-duration)
 	 (when (featurep 'org-duration)
            (org-duration-set-regexps)))
            (org-duration-set-regexps)))

+ 1 - 1
lisp/org-faces.el

@@ -338,7 +338,7 @@ determines if it is a foreground or a background color."
 
 
 (defvar org-tags-special-faces-re nil)
 (defvar org-tags-special-faces-re nil)
 (defun org-set-tag-faces (var value)
 (defun org-set-tag-faces (var value)
-  (set var value)
+  (set-default-toplevel-value var value)
   (if (not value)
   (if (not value)
       (setq org-tags-special-faces-re nil)
       (setq org-tags-special-faces-re nil)
     (setq org-tags-special-faces-re
     (setq org-tags-special-faces-re

+ 1 - 1
lisp/org-footnote.el

@@ -110,7 +110,7 @@ you will need to run the following command after the change:
   :group 'org-footnote
   :group 'org-footnote
   :initialize 'custom-initialize-default
   :initialize 'custom-initialize-default
   :set (lambda (var val)
   :set (lambda (var val)
-	 (set var val)
+	 (set-default-toplevel-value var val)
 	 (when (fboundp 'org-element-cache-reset)
 	 (when (fboundp 'org-element-cache-reset)
 	   (org-element-cache-reset 'all)))
 	   (org-element-cache-reset 'all)))
   :type '(choice
   :type '(choice

+ 2 - 2
lisp/org-list.el

@@ -235,7 +235,7 @@ interface or run the following code after updating it:
   :type '(choice (const :tag "dot like in \"2.\"" ?.)
   :type '(choice (const :tag "dot like in \"2.\"" ?.)
 		 (const :tag "paren like in \"2)\"" ?\))
 		 (const :tag "paren like in \"2)\"" ?\))
 		 (const :tag "both" t))
 		 (const :tag "both" t))
-  :set (lambda (var val) (set var val)
+  :set (lambda (var val) (set-default-toplevel-value var val)
 	 (when (featurep 'org-element) (org-element-update-syntax))))
 	 (when (featurep 'org-element) (org-element-update-syntax))))
 
 
 (defcustom org-list-allow-alphabetical nil
 (defcustom org-list-allow-alphabetical nil
@@ -253,7 +253,7 @@ interface or run the following code after updating it:
   :group 'org-plain-lists
   :group 'org-plain-lists
   :version "24.1"
   :version "24.1"
   :type 'boolean
   :type 'boolean
-  :set (lambda (var val) (set var val)
+  :set (lambda (var val) (set-default-toplevel-value var val)
 	 (when (featurep 'org-element) (org-element-update-syntax))))
 	 (when (featurep 'org-element) (org-element-update-syntax))))
 
 
 (defcustom org-list-two-spaces-after-bullet-regexp nil
 (defcustom org-list-two-spaces-after-bullet-regexp nil

+ 11 - 12
lisp/org.el

@@ -231,7 +231,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
 ;;;###autoload
 ;;;###autoload
 (defun org-babel-do-load-languages (sym value)
 (defun org-babel-do-load-languages (sym value)
   "Load the languages defined in `org-babel-load-languages'."
   "Load the languages defined in `org-babel-load-languages'."
-  (set-default sym value)
+  (set-default-toplevel-value sym value)
   (dolist (pair org-babel-load-languages)
   (dolist (pair org-babel-load-languages)
     (let ((active (cdr pair)) (lang (symbol-name (car pair))))
     (let ((active (cdr pair)) (lang (symbol-name (car pair))))
       (if active
       (if active
@@ -706,7 +706,7 @@ defined in org-duration.el.")
 
 
 (defun org-set-modules (var value)
 (defun org-set-modules (var value)
   "Set VAR to VALUE and call `org-load-modules-maybe' with the force flag."
   "Set VAR to VALUE and call `org-load-modules-maybe' with the force flag."
-  (set var value)
+  (set-default-toplevel-value var value)
   (when (featurep 'org)
   (when (featurep 'org)
     (org-load-modules-maybe 'force)
     (org-load-modules-maybe 'force)
     (org-element-cache-reset 'all)))
     (org-element-cache-reset 'all)))
@@ -837,7 +837,7 @@ depends on, if any."
   :package-version '(Org . "9.0")
   :package-version '(Org . "9.0")
   :initialize 'custom-initialize-set
   :initialize 'custom-initialize-set
   :set (lambda (var val)
   :set (lambda (var val)
-	 (if (not (featurep 'ox)) (set-default var val)
+	 (if (not (featurep 'ox)) (set-default-toplevel-value var val)
 	   ;; Any back-end not required anymore (not present in VAL and not
 	   ;; Any back-end not required anymore (not present in VAL and not
 	   ;; a parent of any back-end in the new value) is removed from the
 	   ;; a parent of any back-end in the new value) is removed from the
 	   ;; list of registered back-ends.
 	   ;; list of registered back-ends.
@@ -862,7 +862,7 @@ depends on, if any."
 			  backend))
 			  backend))
 		((not (memq backend new-list)) (push backend new-list))))
 		((not (memq backend new-list)) (push backend new-list))))
 	     ;; Set VAR to that list with fixed dependencies.
 	     ;; Set VAR to that list with fixed dependencies.
-	     (set-default var new-list))))
+	     (set-default-toplevel-value var new-list))))
   :type '(set :greedy t
   :type '(set :greedy t
 	      (const :tag "   ascii       Export buffer to ASCII format" ascii)
 	      (const :tag "   ascii       Export buffer to ASCII format" ascii)
 	      (const :tag "   beamer      Export buffer to Beamer presentation" beamer)
 	      (const :tag "   beamer      Export buffer to Beamer presentation" beamer)
@@ -1815,9 +1815,9 @@ are followed by a letter in parenthesis, like TODO(t)."
   :group 'org-todo
   :group 'org-todo
   :set (lambda (var val)
   :set (lambda (var val)
 	 (cond
 	 (cond
-	  ((eq var t) (set var 'auto))
-	  ((eq var 'prefix) (set var nil))
-	  (t (set var val))))
+	  ((eq var t) (set-default-toplevel-value var 'auto))
+	  ((eq var 'prefix) (set-default-toplevel-value var nil))
+	  (t (set-default-toplevel-value var val))))
   :type '(choice
   :type '(choice
 	  (const :tag "Never" nil)
 	  (const :tag "Never" nil)
 	  (const :tag "Automatically, when key letter have been defined" auto)
 	  (const :tag "Automatically, when key letter have been defined" auto)
@@ -1899,7 +1899,7 @@ be blocked if any prior sibling is not yet done.
 Finally, if the parent is blocked because of ordered siblings of its own,
 Finally, if the parent is blocked because of ordered siblings of its own,
 the child will also be blocked."
 the child will also be blocked."
   :set (lambda (var val)
   :set (lambda (var val)
-	 (set var val)
+	 (set-default-toplevel-value var val)
 	 (if val
 	 (if val
 	     (add-hook 'org-blocker-hook
 	     (add-hook 'org-blocker-hook
 		       'org-block-todo-from-children-or-siblings-or-parent)
 		       'org-block-todo-from-children-or-siblings-or-parent)
@@ -1917,7 +1917,7 @@ This variable needs to be set before org.el is loaded, and you need to
 restart Emacs after a change to make the change effective.  The only way
 restart Emacs after a change to make the change effective.  The only way
 to change it while Emacs is running is through the customize interface."
 to change it while Emacs is running is through the customize interface."
   :set (lambda (var val)
   :set (lambda (var val)
-	 (set var val)
+	 (set-default-toplevel-value var val)
 	 (if val
 	 (if val
 	     (add-hook 'org-blocker-hook
 	     (add-hook 'org-blocker-hook
 		       'org-block-todo-from-checkboxes)
 		       'org-block-todo-from-checkboxes)
@@ -2368,7 +2368,6 @@ The formats are defined through the variable `org-time-stamp-custom-formats'.
 To turn this on on a per-file basis, insert anywhere in the file:
 To turn this on on a per-file basis, insert anywhere in the file:
    #+STARTUP: customtime"
    #+STARTUP: customtime"
   :group 'org-time
   :group 'org-time
-  :set 'set-default
   :type 'sexp)
   :type 'sexp)
 (make-variable-buffer-local 'org-display-custom-times)
 (make-variable-buffer-local 'org-display-custom-times)
 
 
@@ -3275,7 +3274,7 @@ header, or they will be appended."
 
 
 (defun org-set-packages-alist (var val)
 (defun org-set-packages-alist (var val)
   "Set the packages alist and make sure it has 3 elements per entry."
   "Set the packages alist and make sure it has 3 elements per entry."
-  (set var (mapcar (lambda (x)
+  (set-default-toplevel-value var (mapcar (lambda (x)
 		     (if (and (consp x) (= (length x) 2))
 		     (if (and (consp x) (= (length x) 2))
 			 (list (car x) (nth 1 x) t)
 			 (list (car x) (nth 1 x) t)
 		       x))
 		       x))
@@ -3548,7 +3547,7 @@ After a match, the match groups contain these elements:
 (defvar org-emphasis-alist) ; defined just below
 (defvar org-emphasis-alist) ; defined just below
 (defun org-set-emph-re (var val)
 (defun org-set-emph-re (var val)
   "Set variable and compute the emphasis regular expression."
   "Set variable and compute the emphasis regular expression."
-  (set var val)
+  (set-default-toplevel-value var val)
   (when (and (boundp 'org-emphasis-alist)
   (when (and (boundp 'org-emphasis-alist)
 	     (boundp 'org-emphasis-regexp-components)
 	     (boundp 'org-emphasis-regexp-components)
 	     org-emphasis-alist org-emphasis-regexp-components)
 	     org-emphasis-alist org-emphasis-regexp-components)

+ 1 - 1
lisp/ox-odt.el

@@ -404,7 +404,7 @@ with GNU ELPA tar or standard Emacs distribution."
     "Set `org-odt-schema-dir'.
     "Set `org-odt-schema-dir'.
 Also add it to `rng-schema-locating-files'."
 Also add it to `rng-schema-locating-files'."
     (let ((schema-dir value))
     (let ((schema-dir value))
-      (set var
+      (set-default-toplevel-value var
 	   (if (and
 	   (if (and
 		(file-expand-wildcards
 		(file-expand-wildcards
 		 (expand-file-name "od-manifest-schema*.rnc" schema-dir))
 		 (expand-file-name "od-manifest-schema*.rnc" schema-dir))