[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 5d844e129ad: Fix tmm-menubar when 'tmm-completion-prompt' is ni
From: |
Eli Zaretskii |
Subject: |
emacs-29 5d844e129ad: Fix tmm-menubar when 'tmm-completion-prompt' is nil |
Date: |
Sat, 27 May 2023 13:14:44 -0400 (EDT) |
branch: emacs-29
commit 5d844e129ad5b42b74c363cde50aedc08a96cf39
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
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)
---
lisp/tmm.el | 24 +++++++++++++++++++++---
1 file 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."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 5d844e129ad: Fix tmm-menubar when 'tmm-completion-prompt' is nil,
Eli Zaretskii <=