Skip to content

Commit f9ea6c6

Browse files
igmacsyantar92
authored andcommitted
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
1 parent 2261191 commit f9ea6c6

File tree

10 files changed

+21
-22
lines changed

10 files changed

+21
-22
lines changed

lisp/ob-lilypond.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ you can leave the string empty on this case."
107107
:package-version '(Org . "8.2.7")
108108
:set
109109
(lambda (symbol value)
110-
(set symbol value)
110+
(set-default-toplevel-value symbol value)
111111
(setq
112112
org-babel-lilypond-ly-command (nth 0 value)
113113
org-babel-lilypond-pdf-command (nth 1 value)

lisp/ob-shell.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ outside the Customize interface."
6868
:group 'org-babel
6969
:type '(repeat (string :tag "Shell name: "))
7070
:set (lambda (symbol value)
71-
(set-default symbol value)
71+
(set-default-toplevel-value symbol value)
7272
(org-babel-shell-initialize)))
7373

7474
(defcustom org-babel-shell-results-defaults-to-output t

lisp/org-capture.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ When you need to insert a literal percent sign in the template,
376376
you can escape ambiguous cases with a backward slash, e.g., \\%i."
377377
:group 'org-capture
378378
:package-version '(Org . "9.5")
379-
:set (lambda (s v) (set s (org-capture-upgrade-templates v)))
379+
:set (lambda (s v) (set-default-toplevel-value s (org-capture-upgrade-templates v)))
380380
:type
381381
(let ((file-variants '(choice :tag "Filename "
382382
(file :tag "Literal")

lisp/org-clock.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ This variable only has effect if set with \\[customize]."
493493
(if value
494494
(add-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query)
495495
(remove-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query))
496-
(set symbol value))
496+
(set-default-toplevel-value symbol value))
497497
:type 'boolean
498498
:package-version '(Org . "9.5"))
499499

lisp/org-duration.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ sure to call the following command:
9898
:version "26.1"
9999
:package-version '(Org . "9.1")
100100
:set (lambda (var val)
101-
(set-default var val)
101+
(set-default-toplevel-value var val)
102102
;; Avoid recursive load at startup.
103103
(when (featurep 'org-duration)
104104
(org-duration-set-regexps)))

lisp/org-faces.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ determines if it is a foreground or a background color."
338338

339339
(defvar org-tags-special-faces-re nil)
340340
(defun org-set-tag-faces (var value)
341-
(set var value)
341+
(set-default-toplevel-value var value)
342342
(if (not value)
343343
(setq org-tags-special-faces-re nil)
344344
(setq org-tags-special-faces-re

lisp/org-footnote.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ you will need to run the following command after the change:
110110
:group 'org-footnote
111111
:initialize 'custom-initialize-default
112112
:set (lambda (var val)
113-
(set var val)
113+
(set-default-toplevel-value var val)
114114
(when (fboundp 'org-element-cache-reset)
115115
(org-element-cache-reset 'all)))
116116
:type '(choice

lisp/org-list.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ interface or run the following code after updating it:
235235
:type '(choice (const :tag "dot like in \"2.\"" ?.)
236236
(const :tag "paren like in \"2)\"" ?\))
237237
(const :tag "both" t))
238-
:set (lambda (var val) (set var val)
238+
:set (lambda (var val) (set-default-toplevel-value var val)
239239
(when (featurep 'org-element) (org-element-update-syntax))))
240240

241241
(defcustom org-list-allow-alphabetical nil
@@ -253,7 +253,7 @@ interface or run the following code after updating it:
253253
:group 'org-plain-lists
254254
:version "24.1"
255255
:type 'boolean
256-
:set (lambda (var val) (set var val)
256+
:set (lambda (var val) (set-default-toplevel-value var val)
257257
(when (featurep 'org-element) (org-element-update-syntax))))
258258

259259
(defcustom org-list-two-spaces-after-bullet-regexp nil

lisp/org.el

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
231231
;;;###autoload
232232
(defun org-babel-do-load-languages (sym value)
233233
"Load the languages defined in `org-babel-load-languages'."
234-
(set-default sym value)
234+
(set-default-toplevel-value sym value)
235235
(dolist (pair org-babel-load-languages)
236236
(let ((active (cdr pair)) (lang (symbol-name (car pair))))
237237
(if active
@@ -706,7 +706,7 @@ defined in org-duration.el.")
706706

707707
(defun org-set-modules (var value)
708708
"Set VAR to VALUE and call `org-load-modules-maybe' with the force flag."
709-
(set var value)
709+
(set-default-toplevel-value var value)
710710
(when (featurep 'org)
711711
(org-load-modules-maybe 'force)
712712
(org-element-cache-reset 'all)))
@@ -837,7 +837,7 @@ depends on, if any."
837837
:package-version '(Org . "9.0")
838838
:initialize 'custom-initialize-set
839839
:set (lambda (var val)
840-
(if (not (featurep 'ox)) (set-default var val)
840+
(if (not (featurep 'ox)) (set-default-toplevel-value var val)
841841
;; Any back-end not required anymore (not present in VAL and not
842842
;; a parent of any back-end in the new value) is removed from the
843843
;; list of registered back-ends.
@@ -862,7 +862,7 @@ depends on, if any."
862862
backend))
863863
((not (memq backend new-list)) (push backend new-list))))
864864
;; Set VAR to that list with fixed dependencies.
865-
(set-default var new-list))))
865+
(set-default-toplevel-value var new-list))))
866866
:type '(set :greedy t
867867
(const :tag " ascii Export buffer to ASCII format" ascii)
868868
(const :tag " beamer Export buffer to Beamer presentation" beamer)
@@ -1815,9 +1815,9 @@ are followed by a letter in parenthesis, like TODO(t)."
18151815
:group 'org-todo
18161816
:set (lambda (var val)
18171817
(cond
1818-
((eq var t) (set var 'auto))
1819-
((eq var 'prefix) (set var nil))
1820-
(t (set var val))))
1818+
((eq var t) (set-default-toplevel-value var 'auto))
1819+
((eq var 'prefix) (set-default-toplevel-value var nil))
1820+
(t (set-default-toplevel-value var val))))
18211821
:type '(choice
18221822
(const :tag "Never" nil)
18231823
(const :tag "Automatically, when key letter have been defined" auto)
@@ -1899,7 +1899,7 @@ be blocked if any prior sibling is not yet done.
18991899
Finally, if the parent is blocked because of ordered siblings of its own,
19001900
the child will also be blocked."
19011901
:set (lambda (var val)
1902-
(set var val)
1902+
(set-default-toplevel-value var val)
19031903
(if val
19041904
(add-hook 'org-blocker-hook
19051905
'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
19171917
restart Emacs after a change to make the change effective. The only way
19181918
to change it while Emacs is running is through the customize interface."
19191919
:set (lambda (var val)
1920-
(set var val)
1920+
(set-default-toplevel-value var val)
19211921
(if val
19221922
(add-hook 'org-blocker-hook
19231923
'org-block-todo-from-checkboxes)
@@ -2368,7 +2368,6 @@ The formats are defined through the variable `org-time-stamp-custom-formats'.
23682368
To turn this on on a per-file basis, insert anywhere in the file:
23692369
#+STARTUP: customtime"
23702370
:group 'org-time
2371-
:set 'set-default
23722371
:type 'sexp)
23732372
(make-variable-buffer-local 'org-display-custom-times)
23742373

@@ -3275,7 +3274,7 @@ header, or they will be appended."
32753274

32763275
(defun org-set-packages-alist (var val)
32773276
"Set the packages alist and make sure it has 3 elements per entry."
3278-
(set var (mapcar (lambda (x)
3277+
(set-default-toplevel-value var (mapcar (lambda (x)
32793278
(if (and (consp x) (= (length x) 2))
32803279
(list (car x) (nth 1 x) t)
32813280
x))
@@ -3548,7 +3547,7 @@ After a match, the match groups contain these elements:
35483547
(defvar org-emphasis-alist) ; defined just below
35493548
(defun org-set-emph-re (var val)
35503549
"Set variable and compute the emphasis regular expression."
3551-
(set var val)
3550+
(set-default-toplevel-value var val)
35523551
(when (and (boundp 'org-emphasis-alist)
35533552
(boundp 'org-emphasis-regexp-components)
35543553
org-emphasis-alist org-emphasis-regexp-components)

lisp/ox-odt.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ with GNU ELPA tar or standard Emacs distribution."
404404
"Set `org-odt-schema-dir'.
405405
Also add it to `rng-schema-locating-files'."
406406
(let ((schema-dir value))
407-
(set var
407+
(set-default-toplevel-value var
408408
(if (and
409409
(file-expand-wildcards
410410
(expand-file-name "od-manifest-schema*.rnc" schema-dir))

0 commit comments

Comments
 (0)