On 02/02/2023 17:53, Ihor Radchenko wrote:
  (defun org-set-emph-re (var val)
-  "Set variable and compute the emphasis regular expression."
+  "Set VAR to VAL and compute the emphasis regular expression.
+The function is intended for :set argument of `defcustom' for
+`org-emphasis-alist'."
    (set-default-toplevel-value var val)
...
+(add-variable-watcher 'org-emphasis-alist #'org-emphasis-alist--check-value)

Thinking more I have realized that I am in doubts if `add-variable-watcher' is appropriate tool in this particular case. The only way to get some effect from change of `org-emphasis-alist' is to call `org-set-emph-re' (its :set function), so it should be enough to call `org-emphasis-alist--check-value' from `org-set-emph-re'.

I have no idea what should be considered as best practice: should `set-default-toplevel-value' be combined with changes of `org-emph-re' as it is done in current code or `org-set-emph-re' should be split into the function that modifies `org-emph-re' (so it can be called separately) and a tiny setter (that may be defined as lambda this case) that calls the new function and `set-default-toplevel-value'.


Reply via email to