aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVisuwesh2025-03-23 11:28:16 +0530
committerEli Zaretskii2025-04-05 11:45:37 +0300
commitc73e4cdece0d97f3f5793590fefa258923dca08b (patch)
treeafcdf26d73a01bd7c5d07e4377967283ccfb33e6
parentcffe5a02454f0d2201172c07a239bd9a3682ad68 (diff)
downloademacs-c73e4cdece0d97f3f5793590fefa258923dca08b.tar.gz
emacs-c73e4cdece0d97f3f5793590fefa258923dca08b.zip
Improve formatting of 'setopt' suggestion in *Help* buffer
* lisp/help-fns.el (help--recommend-setopt): Remove function, and... (help-fns--customize-variable): ... move the relevant code here to keep related code in the same place. Change the formatting to also include the :set function if it is set to a named function. (Bug#77173)
-rw-r--r--lisp/help-fns.el34
1 files changed, 17 insertions, 17 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index ee615bfea29..6c4c3f4da97 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -875,20 +875,6 @@ the C sources, too."
875 (function-get function 'disabled)) 875 (function-get function 'disabled))
876 (insert " This function is disabled.\n"))) 876 (insert " This function is disabled.\n")))
877 877
878(add-hook 'help-fns-describe-variable-functions #'help--recommend-setopt)
879(defun help--recommend-setopt (symbol)
880 ;; TODO: This would be better if added to the docstring itself, but I
881 ;; ran into `byte-compile-dynamic-docstring' and gave up.
882 (when (and (get symbol 'custom-set)
883 ;; Don't override manually written documentation.
884 (not (string-match (rx word-start "setopt" word-end)
885 (documentation-property
886 symbol 'variable-documentation))))
887 ;; FIXME: `princ` removes text properties added by s-c-k.
888 (princ (substitute-command-keys "\
889Setting this variable with `setq' has no effect; use either `setopt'
890or \\[customize-option] to change its value.\n\n"))))
891
892(defun help-fns--first-release-regexp (symbol) 878(defun help-fns--first-release-regexp (symbol)
893 (let* ((name (symbol-name symbol)) 879 (let* ((name (symbol-name symbol))
894 (quoted (regexp-quote name))) 880 (quoted (regexp-quote name)))
@@ -1602,12 +1588,26 @@ it is displayed along with the global value."
1602(defun help-fns--customize-variable (variable &optional text) 1588(defun help-fns--customize-variable (variable &optional text)
1603 ;; Make a link to customize if this variable can be customized. 1589 ;; Make a link to customize if this variable can be customized.
1604 (when (custom-variable-p variable) 1590 (when (custom-variable-p variable)
1605 (let ((customize-label "customize")) 1591 (let ((customize-label "customize")
1592 (custom-set (get variable 'custom-set)))
1606 (princ (concat " You can " customize-label (or text " this variable."))) 1593 (princ (concat " You can " customize-label (or text " this variable.")))
1594 (when (and custom-set
1595 ;; Don't override manually written documentation.
1596 (not (string-match (rx word-start "setopt" word-end)
1597 (documentation-property
1598 variable 'variable-documentation))))
1599 (princ (substitute-quotes
1600 (concat "\n Setting this variable directly with `setq' may not take effect;"
1601 "\n use either customize or `setopt'"
1602 ;; Skip text if `custom-set' property is an
1603 ;; anonymous function.
1604 (when (symbolp custom-set)
1605 (concat ", or call `" (symbol-name custom-set) "'"))
1606 "."))))
1607 (with-current-buffer standard-output 1607 (with-current-buffer standard-output
1608 (save-excursion 1608 (save-excursion
1609 (re-search-backward (concat "\\(" customize-label "\\)")) 1609 (while (re-search-backward (concat "\\(" customize-label "\\)") nil t)
1610 (help-xref-button 1 'help-customize-variable variable))) 1610 (help-xref-button 1 'help-customize-variable variable))))
1611 (terpri)))) 1611 (terpri))))
1612 1612
1613(add-hook 'help-fns-describe-variable-functions 1613(add-hook 'help-fns-describe-variable-functions