From b0cd36e8f0caaddeacb3933e6111842b6560d9c9 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 12 Mar 2019 22:36:08 +0100 Subject: Show if a function is compiled Include this info like in `describe-function` --- helpful.el | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/helpful.el b/helpful.el index b70cadc..9dfd4be 100644 --- a/helpful.el +++ b/helpful.el @@ -1766,6 +1766,11 @@ OBJ may be a symbol or a compiled function object." (setq file-name (s-chop-suffix ".gz" file-name)) (help-fns--autoloaded-p sym file-name))) +(defun helpful--compiled-p (sym) + "Return non-nil if function SYM is byte-compiled" + (and (symbolp sym) + (byte-code-function-p (symbol-function sym)))) + (defun helpful--summary (sym callable-p buf pos) "Return a one sentence summary for SYM." (-let* ((primitive-p (helpful--primitive-p sym callable-p)) @@ -1804,6 +1809,11 @@ OBJ may be a symbol or a compiled function object." "autoloaded" 'helpful-info-button 'info-node "(elisp)Autoload")) + (compiled-button + (helpful--button + "compiled" + 'helpful-info-button + 'info-node "(elisp)Byte Compilation")) (buffer-local-button (helpful--button "buffer-local" @@ -1811,24 +1821,32 @@ OBJ may be a symbol or a compiled function object." 'info-node "(elisp)Buffer-Local Variables")) (autoloaded-p (and callable-p buf (helpful--autoloaded-p sym buf))) + (compiled-p + (and callable-p (helpful--compiled-p sym))) (description - (cond - (alias-p - (format "%s %s" - (if callable-p "a" "an") - alias-button)) - ((and callable-p (commandp sym) autoloaded-p) - (format "an %s, %s" interactive-button autoload-button)) - ((helpful--kbd-macro-p sym) "a") - ((and callable-p (commandp sym)) - (format "an %s" interactive-button)) - ((and callable-p autoloaded-p) - (format "an %s" autoload-button)) - ((and (not callable-p) - (local-variable-if-set-p sym)) - (format "a %s" buffer-local-button)) - (t - "a"))) + (concat + (cond + (alias-p + (format "%s %s" + (if callable-p "a" "an") + alias-button)) + ((and callable-p (commandp sym) autoloaded-p) + (format "an %s, %s" interactive-button autoload-button)) + ((helpful--kbd-macro-p sym) "a") + ((and callable-p (commandp sym)) + (format "an %s" interactive-button)) + ((and callable-p autoloaded-p) + (format "an %s" autoload-button)) + ((and (not callable-p) + (local-variable-if-set-p sym)) + (format "a %s" buffer-local-button)) + (t + "a")) + (if compiled-p + (format "%s %s" + (if (or (commandp sym) autoloaded-p) "," "") + compiled-button)) + "")) (kind (cond ((special-form-p sym) -- cgit v1.0