aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryuhan0 <qythium@gmail.com>2023-06-10 18:51:20 +0800
committerWilfred Hughes <me@wilfred.me.uk>2023-08-08 08:16:26 -0700
commit69f2bc0609f8017341b7c868f7ca27a00485bf3d (patch)
treed61bb963e217bf5ca48b718b857079374a6d3996
parentacb3e335c7e1d52ac4887ff96f05b08dabf3a646 (diff)
Support describing faces using `helpful-symbol`.
Uses the native `describe-face`, possible to switch to a `helpful-face` command if implemented in the future.
-rw-r--r--helpful.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/helpful.el b/helpful.el
index acec238..d0fc4c7 100644
--- a/helpful.el
+++ b/helpful.el
@@ -2735,12 +2735,13 @@ See also `helpful-macro', `helpful-function' and `helpful-command'."
(not (eq symbol t)))))
(defun helpful--bound-p (symbol)
- "Return non-nil if SYMBOL is a variable or callable.
+ "Return non-nil if SYMBOL is a variable, callable, or face.
This differs from `boundp' because we do not consider nil, t
or :foo."
(or (fboundp symbol)
- (helpful--variable-p symbol)))
+ (helpful--variable-p symbol)
+ (facep symbol)))
(defun helpful--bookmark-jump (bookmark)
"Create and switch to helpful bookmark BOOKMARK."
@@ -2799,7 +2800,7 @@ calls (helpful-variable SYM) when the key `v' is pressed in the prompt."
;;;###autoload
(defun helpful-symbol (symbol)
- "Show help for SYMBOL, a variable, function or macro.
+ "Show help for SYMBOL, a variable, function, macro, or face.
See also `helpful-callable' and `helpful-variable'."
(interactive
@@ -2820,6 +2821,12 @@ See also `helpful-callable' and `helpful-variable'."
(push (list #'helpful-callable "[c]allable" ?c) choices))
(when (boundp symbol)
(push (list #'helpful-variable "[v]ariable" ?v) choices))
+ (when (facep symbol)
+ (push (list (lambda (face)
+ (describe-face face)
+ (funcall helpful-switch-buffer-function (help-buffer)))
+ "[f]ace" ?f)
+ choices))
(cond
((null choices)
(user-error "Not bound: %S" symbol))