summaryrefslogtreecommitdiff
path: root/cape.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-08-18 20:56:06 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2023-08-18 20:56:06 +0200
commit9bba4a80e2dc9177f461ceca9c0735e11ef45d9a (patch)
tree526eb43db8a77c4eab34cbd8e26781baea266f8d /cape.el
parentbe4379ba2cf9177e116876e0d6d6391173a58e4c (diff)
cape-wrap-debug: Add optional NAME argument
Diffstat (limited to 'cape.el')
-rw-r--r--cape.el51
1 files changed, 27 insertions, 24 deletions
diff --git a/cape.el b/cape.el
index 3d0ae01..535891d 100644
--- a/cape.el
+++ b/cape.el
@@ -899,30 +899,33 @@ changed. The function `cape-company-to-capf' is experimental."
(if interactive (cape-interactive capf) (funcall capf))))
;;;###autoload
-(defun cape-wrap-debug (capf)
- "Call CAPF and return a completion table which prints trace messages."
- (let ((name (if (symbolp capf) (symbol-name capf) "capf")))
- (pcase (funcall capf)
- (`(,beg ,end ,table . ,plist)
- (let* (completion-ignore-case completion-regexp-list
- (limit cape--debug-length)
- (cands (all-completions
- "" table
- (lambda (&rest _)
- (>= (cl-decf limit) 0)))))
- (message
- "%s() => input=%s:%s:%S table=(%s%s)%s"
- name (+ beg 0) (+ end 0) (buffer-substring-no-properties beg end)
- (string-join (mapcar #'prin1-to-string cands) " ")
- (and (< limit 0) " ...")
- (if plist (format " plist=%s" (cape--debug-print plist t)) "")))
- `(,beg ,end
- ,(cape--debug-table table name
- (copy-marker beg) (copy-marker end t))
- . ,plist))
- (result
- (message "%s() => %s (No completion)"
- name (cape--debug-print result))))))
+(defun cape-wrap-debug (capf &optional name)
+ "Call CAPF and return a completion table which prints trace messages.
+If CAPF is an anonymous lambda, pass the Capf NAME explicitly for
+meaningful debugging output."
+ (unless name
+ (setq name (if (symbolp capf) capf "capf")))
+ (pcase (funcall capf)
+ (`(,beg ,end ,table . ,plist)
+ (let* (completion-ignore-case completion-regexp-list
+ (limit cape--debug-length)
+ (cands (all-completions
+ "" table
+ (lambda (&rest _)
+ (>= (cl-decf limit) 0)))))
+ (message
+ "%s() => input=%s:%s:%S table=(%s%s)%s"
+ name (+ beg 0) (+ end 0) (buffer-substring-no-properties beg end)
+ (string-join (mapcar #'prin1-to-string cands) " ")
+ (and (< limit 0) " ...")
+ (if plist (format " plist=%s" (cape--debug-print plist t)) "")))
+ `(,beg ,end
+ ,(cape--debug-table table name
+ (copy-marker beg) (copy-marker end t))
+ . ,plist))
+ (result
+ (message "%s() => %s (No completion)"
+ name (cape--debug-print result)))))
;;;###autoload
(defun cape-wrap-buster (capf &optional valid)