From: Lars Ingebrigtsen Date: Tue, 10 May 2022 13:01:00 +0000 (+0200) Subject: Make `apropos-variable' include values in output X-Git-Tag: emacs-29.0.90~1910^2~844 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=000f13a2bc60428bf02157956b22ba23570b0725;p=emacs.git Make `apropos-variable' include values in output * lisp/apropos.el (apropos-print): Include variable values in the output (bug#13842). --- diff --git a/etc/NEWS b/etc/NEWS index 212253d3dbf..13c8aacb2b7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -476,6 +476,9 @@ This allows you to enter emoji using short strings, eg :face_palm: or ** Help +--- +*** 'M-x apropos-variable' output now includes values of variables. + +++ *** New doc string syntax to indicate that symbols shouldn't be links. When displaying doc strings in *Help* buffers, strings that are diff --git a/lisp/apropos.el b/lisp/apropos.el index 79c4df10d25..28184476e68 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el @@ -1247,6 +1247,19 @@ as a heading." 'apropos-user-option 'apropos-variable) (not nosubst)) + ;; Insert an excerpt of variable values. + (when (boundp symbol) + (insert " Value: ") + (let* ((print-escape-newlines t) + (value (prin1-to-string (symbol-value symbol))) + (truncated (truncate-string-to-width + value (- (window-width) 20) nil nil t))) + (insert truncated) + (unless (equal value truncated) + (buttonize-region (1- (point)) (point) + (lambda (_) + (message "Value: %s" value)))) + (insert "\n"))) (apropos-print-doc 7 'apropos-group t) (apropos-print-doc 6 'apropos-face t) (apropos-print-doc 5 'apropos-widget t)