emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 2594162: Make the button completion predicate be more useful


From: Lars Ingebrigtsen
Subject: master 2594162: Make the button completion predicate be more useful
Date: Sun, 14 Feb 2021 22:42:41 -0500 (EST)

branch: master
commit 2594162b23f64dc394e8fe4035ea651ed54661ac
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make the button completion predicate be more useful
    
    * lisp/simple.el (completion-button-p): Rework from
    `completion-at-point-p'.
    
    * lisp/net/shr.el (shr-show-alt-text): It should be possible to
    complete to commands that aren't bound to a key.
---
 lisp/net/shr.el | 2 +-
 lisp/simple.el  | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 2596a34..739b56b 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -434,7 +434,7 @@ Value is a pair of positions (START . END) if there is a 
non-nil
 
 (defun shr-show-alt-text ()
   "Show the ALT text of the image under point."
-  (declare (completion 'completion-at-point-p))
+  (declare (completion (lambda (_ b) (completion-button-p 'shr b))))
   (interactive)
   (let ((text (get-text-property (point) 'shr-alt)))
     (if (not text)
diff --git a/lisp/simple.el b/lisp/simple.el
index ed0e753..8d27cf8 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2005,11 +2005,11 @@ or (if one of MODES is a minor mode), if it is switched 
on in BUFFER."
                         (buffer-local-value 'minor-modes buffer)
                         #'eq)))
 
-(defun completion-at-point-p (symbol buffer)
-  "Return non-nil if SYMBOL is in a local map at point in BUFFER."
+(defun completion-button-p (category buffer)
+  "Return non-nil if there's a button of CATEGORY at point in BUFFER."
   (with-current-buffer buffer
-    (when-let ((map (get-text-property (point) 'keymap)))
-      (where-is-internal symbol map))))
+    (and (get-text-property (point) 'button)
+         (eq (get-text-property (point) 'category) category))))
 
 (defun read-extended-command--affixation (command-names)
   (with-selected-window (or (minibuffer-selected-window) (selected-window))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]