From f02c93ae7a4f627f5bc37a8cf0cd70cffc4b7bb7 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 14 Feb 2021 20:34:03 +0100 Subject: [PATCH] Add a possible completion predicate for buttons * lisp/simple.el (completion-at-point-p): New predicate. * lisp/net/shr.el (shr-show-alt-text): Mark up as a button. --- lisp/net/shr.el | 1 + lisp/simple.el | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 9c3740fccc9..2596a348384 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -434,6 +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)) (interactive) (let ((text (get-text-property (point) 'shr-alt))) (if (not text) diff --git a/lisp/simple.el b/lisp/simple.el index 02d3b7df5f6..a547417d7ef 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1997,6 +1997,12 @@ 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." + (with-current-buffer buffer + (when-let ((map (get-text-property (point) 'keymap))) + (where-is-internal symbol map)))) + (defun read-extended-command--affixation (command-names) (with-selected-window (or (minibuffer-selected-window) (selected-window)) (mapcar -- 2.39.2