From 000f13a2bc60428bf02157956b22ba23570b0725 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 10 May 2022 15:01:00 +0200 Subject: [PATCH] Make `apropos-variable' include values in output * lisp/apropos.el (apropos-print): Include variable values in the output (bug#13842). --- etc/NEWS | 3 +++ lisp/apropos.el | 13 +++++++++++++ 2 files changed, 16 insertions(+) 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) -- 2.39.2