summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2023-05-27 20:09:40 +0300
committerEli Zaretskii <eliz@gnu.org>2023-05-27 20:09:40 +0300
commit5d844e129ad5b42b74c363cde50aedc08a96cf39 (patch)
tree7adb839cedd1c5e6a2a48a537b614606bf34da50 /lisp
parent5e7c826bfa5cb7459f5b162b498af1c57c4578e6 (diff)
downloademacs-5d844e129ad5b42b74c363cde50aedc08a96cf39.tar.gz
emacs-5d844e129ad5b42b74c363cde50aedc08a96cf39.tar.bz2
emacs-5d844e129ad5b42b74c363cde50aedc08a96cf39.zip
Fix tmm-menubar when 'tmm-completion-prompt' is nil
* lisp/tmm.el (tmm-prompt): Handle nil value of 'tmm-mid-prompt'. (tmm-completion-delete-prompt): Don't rely on the exact text of the completion heading line, as it is now a customizable format string, and can be nil, meaning no heading line is inserted at all. Instead, search for the first character of the menu based on text properties used for it. (Bug#63754)
Diffstat (limited to 'lisp')
-rw-r--r--lisp/tmm.el24
1 files changed, 21 insertions, 3 deletions
diff --git a/lisp/tmm.el b/lisp/tmm.el
index 1f9a877c20b..6088961fa4c 100644
--- a/lisp/tmm.el
+++ b/lisp/tmm.el
@@ -28,6 +28,7 @@
;;; Code:
(require 'electric)
+(require 'text-property-search)
(defgroup tmm nil
"Text mode access to menu-bar."
@@ -192,7 +193,11 @@ instead of executing it."
(or (not visible) (eval visible))))))
(setq index-of-default (1+ index-of-default)))
(setq tail (cdr tail)))))
- (let ((prompt (concat "^." (regexp-quote tmm-mid-prompt))))
+ (let ((prompt
+ (concat "^"
+ (if (stringp tmm-mid-prompt)
+ (concat "."
+ (regexp-quote tmm-mid-prompt))))))
(setq tmm--history
(reverse (delq nil
(mapcar
@@ -320,8 +325,21 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
(defun tmm-completion-delete-prompt ()
(with-current-buffer standard-output
- (goto-char (point-min))
- (delete-region (point) (search-forward "Possible completions are:\n"))))
+ (goto-char (point-min))
+ (let* (;; First candidate: first string with mouse-face
+ (menu-start-1 (next-single-char-property-change (point) 'mouse-face))
+ ;; Second candidate: an inactive menu item with tmm-inactive face
+ (tps-result (save-excursion
+ (text-property-search-forward 'face 'tmm-inactive t)))
+ (menu-start-2 (and tps-result (prop-match-beginning tps-result))))
+ (or (and (null menu-start-1) (null menu-start-2))
+ (delete-region (point)
+ ;; Use the smallest position of the two candidates.
+ (or (and menu-start-1 menu-start-2
+ (min menu-start-1 menu-start-2))
+ ;; Otherwise use the one that is non-nil.
+ menu-start-1
+ menu-start-2))))))
(defun tmm-remove-inactive-mouse-face ()
"Remove the mouse-face property from inactive menu items."