From: charles@aurox.ch (Charles A. Roelli)
To: Eli Zaretskii <eliz@gnu.org>
Cc: 32990@debbugs.gnu.org
Subject: bug#32990: 26.1.50; isearch-forward + t-m-m/mark-active doc
Date: Thu, 15 Nov 2018 20:57:12 +0100 [thread overview]
Message-ID: <m2d0r6yuzr.fsf@aurox.ch> (raw)
In-Reply-To: <831s7tauzy.fsf@gnu.org> (message from Eli Zaretskii on Sat, 10 Nov 2018 16:05:05 +0200)
> Date: Sat, 10 Nov 2018 16:05:05 +0200
> From: Eli Zaretskii <eliz@gnu.org>
>
> I think we should at least describe in the doc string what is
> described in "Basic Isearch", which would mean adding
> isearch-delete-char. Other than that, I'm okay with this text.
Ok, I will add that in too.
> > I remember reading somewhere a suggestion for adding a toolbar (and
> > (or) a dedicated menu) for use during isearch-mode, to help the
> > discoverability of these myriad keybindings. That could be a good
> > alternative to listing verbosely every binding in the docstring.
>
> I agree, but we should make sure clicking the menu won't exit Isearch.
>
> Thanks.
There's a first draft of a menu- and tool-bar for Isearch at the end
of this message (on branch master). Clicking the menu items and icons
should work okay with the mouse, but I haven't yet found a way to show
the menu with either "tmm-menubar" or TTY menus, since activating
these functions will normally exit Isearch.
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 035ff69..1f8a611 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -489,6 +489,142 @@ 'isearch-mode-help
\f
;; Define isearch-mode keymap.
+(defvar isearch-menu-bar-map
+ (let ((map (make-sparse-keymap "Isearch")))
+ (define-key map [isearch-complete]
+ '(menu-item "Complete current search string" isearch-complete
+ :help "Complete current search string over search history"))
+ (define-key map [isearch-complete-separator]
+ '(menu-item "--"))
+ (define-key map [isearch-query-replace-regexp]
+ '(menu-item "Replace search string as regexp" isearch-query-replace-regexp
+ :help "Replace matches for current search string as regexp"))
+ (define-key map [isearch-query-replace]
+ '(menu-item "Replace search string" isearch-query-replace
+ :help "Replace matches for current search string"))
+ (define-key map [isearch-occur]
+ '(menu-item "Show all matches for search string" isearch-occur
+ :help "Show all matches for current search string"))
+ (define-key map [isearch-highlight-regexp]
+ '(menu-item "Highlight all matches for search string"
+ isearch-highlight-regexp
+ :help "Highlight all matches for current search string"))
+ (define-key map [isearch-search-replace-separator]
+ '(menu-item "--"))
+ (define-key map [isearch-toggle-specified-input-method]
+ '(menu-item "Turn on specific input method"
+ isearch-toggle-specified-input-method
+ :help "Turn on specific input method for search"))
+ (define-key map [isearch-toggle-input-method]
+ '(menu-item "Toggle input method" isearch-toggle-input-method
+ :help "Toggle input method for search"))
+ (define-key map [isearch-input-method-separator]
+ '(menu-item "--"))
+ (define-key map [isearch-char-by-name]
+ '(menu-item "Search for char by name" isearch-char-by-name
+ :help "Search for character by name"))
+ (define-key map [isearch-quote-char]
+ '(menu-item "Search for literal char" isearch-quote-char
+ :help "Search for literal char"))
+ (define-key map [isearch-special-char-separator]
+ '(menu-item "--"))
+ (define-key map [isearch-toggle-word]
+ '(menu-item "Word matching" isearch-toggle-word
+ :help "Word matching"
+ :button (:toggle
+ . (eq isearch-regexp-function 'word-search-regexp))))
+ (define-key map [isearch-toggle-symbol]
+ '(menu-item "Symbol matching" isearch-toggle-symbol
+ :help "Symbol matching"
+ :button (:toggle
+ . (eq isearch-regexp-function
+ 'isearch-symbol-regexp))))
+ (define-key map [isearch-toggle-regexp]
+ '(menu-item "Regexp matching" isearch-toggle-regexp
+ :help "Regexp matching"
+ :button (:toggle . isearch-regexp)))
+ (define-key map [isearch-toggle-invisible]
+ '(menu-item "Invisible text matching" isearch-toggle-invisible
+ :help "Invisible text matching"
+ :button (:toggle . isearch-invisible)))
+ (define-key map [isearch-toggle-char-fold]
+ '(menu-item "Character folding matching" isearch-toggle-char-fold
+ :help "Character folding matching"
+ :button (:toggle
+ . (eq isearch-regexp-function
+ 'char-fold-to-regexp))))
+ (define-key map [isearch-toggle-case-fold]
+ '(menu-item "Case folding matching" isearch-toggle-case-fold
+ :help "Case folding matching"
+ :button (:toggle . isearch-case-fold-search)))
+ (define-key map [isearch-toggle-lax-whitespace]
+ '(menu-item "Lax whitespace matching" isearch-toggle-lax-whitespace
+ :help "Lax whitespace matching"
+ :button (:toggle . isearch-lax-whitespace)))
+ (define-key map [isearch-toggle-separator]
+ '(menu-item "--"))
+ (define-key map [isearch-del-char]
+ '(menu-item "Delete last character from search string" isearch-del-char
+ :help "Delete last character from search string"))
+ (define-key map [isearch-yank-pop]
+ '(menu-item "Yank previous kill on search string" isearch-yank-pop
+ :help "Replace yanked previous kill on search string"))
+ (define-key map [isearch-yank-kill]
+ '(menu-item "Yank current kill on search string" isearch-yank-kill
+ :help "Append current kill to search string"))
+ (define-key map [isearch-yank-line]
+ '(menu-item "Yank rest of line on search string" isearch-yank-line
+ :help "Yank the rest of the current line on search string"))
+ (define-key map [isearch-yank-symbol-or-char]
+ '(menu-item "Yank symbol/char on search string"
+ isearch-yank-symbol-or-char
+ :help "Yank next symbol or char on search string"))
+ (define-key map [isearch-yank-word-or-char]
+ '(menu-item "Yank word/char on search string"
+ isearch-yank-word-or-char
+ :help "Yank next word or char on search string"))
+ (define-key map [isearch-yank-char]
+ '(menu-item "Yank char on search string" isearch-yank-char
+ :help "Yank char at point on search string"))
+ (define-key map [isearch-yank-separator]
+ '(menu-item "--"))
+ (define-key map [isearch-edit-string]
+ '(menu-item "Edit current search string" isearch-edit-string
+ :help "Edit current search string"))
+ (define-key map [isearch-ring-retreat]
+ '(menu-item "Edit previous search string" isearch-ring-retreat
+ :help "Edit previous search string in Isearch history"))
+ (define-key map [isearch-ring-advance]
+ '(menu-item "Edit next search string" isearch-ring-advance
+ :help "Edit next search string in Isearch history"))
+ (define-key map [isearch-delete-char]
+ '(menu-item "Cancel last input item" isearch-delete-char
+ :help "Cancel the last Isearch command"))
+ (define-key map [isearch-repeat-backward]
+ '(menu-item "Repeat search backward" isearch-repeat-backward
+ :help "Repeat current search backward"))
+ (define-key map [isearch-repeat-forward]
+ '(menu-item "Repeat search forward" isearch-repeat-forward
+ :help "Repeat current search forward"))
+ (define-key map [isearch-nonincremental]
+ '(menu-item "Nonincremental search" isearch-exit
+ :help "Start nonincremental search"
+ :visible (string-equal isearch-string "")))
+ (define-key map [isearch-exit]
+ '(menu-item "Finish search" isearch-exit
+ :help "Finish search leaving point where it is"
+ :visible (not (string-equal isearch-string ""))))
+ (define-key map [isearch-abort]
+ '(menu-item "Remove characters not found" isearch-abort
+ :help "Quit current search"
+ :visible (not isearch-success)))
+ (define-key map [isearch-cancel]
+ `(menu-item "Cancel search" isearch-cancel
+ :help "Cancel current search and return to starting point"
+ :filter ,(lambda (binding)
+ (if isearch-success 'isearch-abort binding))))
+ map))
+
(defvar isearch-mode-map
(let ((i 0)
(map (make-keymap)))
@@ -595,9 +731,58 @@ isearch-mode-map
;; characters to the search string. See iso-transl.el.
(define-key map "\C-x8\r" 'isearch-char-by-name)
+ (define-key map [menu-bar search-menu]
+ (list 'menu-item "Isearch" isearch-menu-bar-map))
+
map)
"Keymap for `isearch-mode'.")
+(defvar isearch-tool-bar-old-map nil
+ "Variable holding the old local value of `tool-bar-map', if any.")
+
+(defun isearch-tool-bar-image (image-name)
+ "Return an image specification for IMAGE-NAME."
+ (eval (tool-bar--image-expression image-name)))
+
+(defvar isearch-tool-bar-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [isearch-describe-mode]
+ (list 'menu-item "Help" 'isearch-describe-mode
+ :help "Get help for Isearch"
+ :image '(isearch-tool-bar-image "help")))
+ (define-key map [isearch-occur]
+ (list 'menu-item "Show hits" 'isearch-occur
+ :help "Show each search hit"
+ :image '(isearch-tool-bar-image "index")))
+ (define-key map [isearch-query-replace]
+ (list 'menu-item "Replace" 'isearch-query-replace
+ :help "Replace search string"
+ :image '(isearch-tool-bar-image "search-replace")))
+ (define-key map [isearch-delete-char]
+ (list 'menu-item "Undo" 'isearch-delete-char
+ :help "Undo last input item"
+ :image '(isearch-tool-bar-image "undo")))
+ (define-key map [isearch-exit]
+ (list 'menu-item "Finish" 'isearch-exit
+ :help "Finish search leaving point where it is"
+ :image '(isearch-tool-bar-image "exit")
+ :visible '(not (string-equal isearch-string ""))))
+ (define-key map [isearch-cancel]
+ (list 'menu-item "Abort" 'isearch-cancel
+ :help "Abort search"
+ :image '(isearch-tool-bar-image "close")
+ :filter (lambda (binding)
+ (if isearch-success 'isearch-abort binding))))
+ (define-key map [isearch-repeat-forward]
+ (list 'menu-item "Repeat forward" 'isearch-repeat-forward
+ :help "Repeat search forward"
+ :image '(isearch-tool-bar-image "right-arrow")))
+ (define-key map [isearch-repeat-backward]
+ (list 'menu-item "Repeat backward" 'isearch-repeat-backward
+ :help "Repeat search backward"
+ :image '(isearch-tool-bar-image "left-arrow")))
+ map))
+
(defvar minibuffer-local-isearch-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map minibuffer-local-map)
@@ -733,6 +918,12 @@ isearch--saved-overriding-local-map
(nconc minor-mode-alist
(list '(isearch-mode isearch-mode))))
+;; We add an entry for `isearch-mode' to `minor-mode-map-alist' so
+;; that `isearch-menu-bar-map' can show on the menu bar.
+(or (assq 'isearch-mode minor-mode-map-alist)
+ (nconc minor-mode-map-alist
+ (list (cons 'isearch-mode isearch-mode-map))))
+
(defvar-local isearch-mode nil) ;; Name of the minor mode, if non-nil.
(define-key global-map "\C-s" 'isearch-forward)
@@ -978,6 +1169,10 @@ isearch-mode
isearch-original-minibuffer-message-timeout minibuffer-message-timeout
minibuffer-message-timeout nil)
+ (if (local-variable-p 'tool-bar-map)
+ (setq isearch-tool-bar-old-map tool-bar-map))
+ (setq-local tool-bar-map isearch-tool-bar-map)
+
;; We must bypass input method while reading key. When a user type
;; printable character, appropriate input method is turned on in
;; minibuffer to read multibyte characters.
@@ -1144,6 +1339,12 @@ isearch-done
(setq input-method-function isearch-input-method-function)
(kill-local-variable 'input-method-function))
+ (if isearch-tool-bar-old-map
+ (progn
+ (setq-local tool-bar-map isearch-tool-bar-old-map)
+ (setq isearch-tool-bar-old-map nil))
+ (kill-local-variable 'tool-bar-map))
+
(force-mode-line-update)
;; If we ended in the middle of some intangible text,
@@ -2486,7 +2687,10 @@ isearch-pre-command-hook
;; `set-transient-map' thingy like `universal-argument--mode'.
((not (eq overriding-terminal-local-map isearch--saved-overriding-local-map)))
;; Don't exit Isearch for isearch key bindings.
- ((commandp (lookup-key isearch-mode-map key nil)))
+ ((or (commandp (lookup-key isearch-mode-map key nil))
+ (commandp
+ (lookup-key
+ `(keymap (tool-bar menu-item nil ,isearch-tool-bar-map)) key))))
;; Optionally edit the search string instead of exiting.
((eq search-exit-option 'edit)
(setq this-command 'isearch-edit-string))
next prev parent reply other threads:[~2018-11-15 19:57 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-08 17:58 bug#32990: 26.1.50; isearch-forward + t-m-m/mark-active doc Charles A. Roelli
2018-10-08 20:07 ` Eli Zaretskii
2018-10-09 18:14 ` Charles A. Roelli
2018-10-09 18:21 ` Eli Zaretskii
2018-10-14 19:53 ` Charles A. Roelli
2018-10-15 15:02 ` Eli Zaretskii
2018-10-16 18:57 ` Charles A. Roelli
2018-10-20 9:59 ` Eli Zaretskii
2018-10-25 19:11 ` Charles A. Roelli
2018-10-28 10:06 ` Charles A. Roelli
2018-10-28 15:53 ` Eli Zaretskii
2018-10-28 17:09 ` Charles A. Roelli
2018-11-10 13:57 ` Charles A. Roelli
2018-11-10 14:05 ` Eli Zaretskii
2018-11-15 19:57 ` Charles A. Roelli [this message]
2018-11-15 20:07 ` Eli Zaretskii
2018-11-15 22:15 ` Juri Linkov
2018-11-16 8:53 ` martin rudalics
2018-11-16 16:00 ` Drew Adams
2018-11-17 9:29 ` martin rudalics
2018-11-17 21:32 ` Juri Linkov
2018-11-18 9:22 ` martin rudalics
2018-11-16 20:22 ` Charles A. Roelli
2018-11-17 21:01 ` Juri Linkov
2018-11-17 21:07 ` Juri Linkov
2018-11-18 1:49 ` Drew Adams
2018-11-18 20:24 ` Charles A. Roelli
2018-11-18 22:42 ` Juri Linkov
2018-11-19 20:14 ` Charles A. Roelli
2018-11-19 21:44 ` Juri Linkov
2018-11-20 19:49 ` Charles A. Roelli
2018-11-21 20:14 ` Charles A. Roelli
2018-11-21 22:31 ` Juri Linkov
2018-11-22 20:29 ` Charles A. Roelli
2018-11-22 21:59 ` Juri Linkov
2018-11-23 8:17 ` Eli Zaretskii
2018-11-24 11:25 ` Charles A. Roelli
2018-11-24 11:44 ` Eli Zaretskii
2018-11-24 12:51 ` Charles A. Roelli
2019-04-02 0:22 ` Noam Postavsky
2018-11-10 20:34 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2d0r6yuzr.fsf@aurox.ch \
--to=charles@aurox.ch \
--cc=32990@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).