From 2bc603819f2f37b052c0062dcd9fc7d00cc0cbc6 Mon Sep 17 00:00:00 2001 From: Al Haji-Ali Date: Wed, 11 Jan 2023 10:59:48 +0000 Subject: [PATCH] Always showing global value. NOTE: This is https://github.com/Wilfred/helpful/pull/311 --- helpful.el | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/helpful.el b/helpful.el index 60049a2..df0a339 100644 --- a/helpful.el +++ b/helpful.el @@ -2267,6 +2267,10 @@ state of the current symbol." (when (not helpful--callable-p) (helpful--insert-section-break) (let* ((sym helpful--sym) + (local-p (and + helpful--associated-buffer + (local-variable-p sym helpful--associated-buffer))) + (local-set-p (local-variable-if-set-p sym)) (multiple-views-p (or (stringp val) (keymapp val) @@ -2283,9 +2287,7 @@ state of the current symbol." (cond ;; Buffer-local variable and we're looking at the value in ;; a specific buffer. - ((and - helpful--associated-buffer - (local-variable-p sym helpful--associated-buffer)) + (local-p (format "Value in %s" (helpful--button (format "#" (buffer-name helpful--associated-buffer)) @@ -2293,8 +2295,7 @@ state of the current symbol." 'buffer helpful--associated-buffer 'position pos))) ;; Buffer-local variable but default/global value. - ((local-variable-if-set-p sym) - "Global Value") + (local-set-p "Global Value") ;; This variable is not buffer-local. (t "Value"))) (helpful--format-value sym val) @@ -2306,6 +2307,13 @@ state of the current symbol." sym (car (helpful--original-value sym))) "\n\n")) + (when (and local-p (not local-set-p)) + (insert + (helpful--heading "Global Value") + (helpful--format-value + sym + (helpful--sym-value sym nil)) + "\n\n")) (when multiple-views-p (insert (helpful--make-toggle-literal-button) " "))