From: Juri Linkov <juri@linkov.net>
To: Evgeni Pandurski <epandurski@gmail.com>
Cc: 60815@debbugs.gnu.org
Subject: bug#60815: 28.2; Hard-coded M-sff key binding in dired-aux.el
Date: Tue, 17 Jan 2023 21:27:15 +0200 [thread overview]
Message-ID: <865yd5ufl8.fsf@mail.linkov.net> (raw)
In-Reply-To: <CA+MLsgN4R5WZDDzMvcT+GpmdctxA5hXpiy8wrD3nerWAQdkOnQ@mail.gmail.com> (Evgeni Pandurski's message of "Tue, 17 Jan 2023 21:01:43 +0200")
[-- Attachment #1: Type: text/plain, Size: 681 bytes --]
> The problem that remains is that I should do the equivalent of:
>
> (define-key isearch-mode-map [f6] isearch-mode-search-map)
> (define-key isearch-mode-map (kbd "M-s") other-window)
>
> for several other minor (and probably some minor modes). To name a
> few: minibuffer-local-map, Buffer-menu-mode-map, and dired-mode-map
> all shadow my M-s redefinition, and I can not go to other window in
> these modes. It would be very nice if those major modes are more
> clever, clever when overriding global bindings.
This is possible too where you can additionally use
(setq search-prefix [f6])
If this works, then minibuffer-local-map could be made customizable
later as well:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: search-prefix.patch --]
[-- Type: text/x-diff, Size: 6149 bytes --]
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 99189d2e570..c8ce376e5d4 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -1139,7 +1139,8 @@ search-map
"h u" #'unhighlight-regexp
"h f" #'hi-lock-find-patterns
"h w" #'hi-lock-write-interactive-patterns)
-(define-key esc-map "s" search-map)
+(defvar search-prefix "\M-s")
+(define-key global-map search-prefix search-map)
(put 'highlight-regexp :advertised-binding [?\M-s ?h ?r])
(put 'highlight-phrase :advertised-binding [?\M-s ?h ?p])
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 29c981c1364..241c9d85e98 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -110,6 +110,12 @@ Buffer-menu-filter-predicate
(defvar-local Buffer-menu-buffer-list nil
"The current list of buffers or function to return buffers.")
+(defvar-keymap Buffer-menu-mode-search-map
+ :doc "Local keymap for search keys in `Buffer-menu-mode-map'."
+ "a C-s" #'Buffer-menu-isearch-buffers
+ "a C-M-s" #'Buffer-menu-isearch-buffers-regexp
+ "a C-o" #'Buffer-menu-multi-occur)
+
(defvar-keymap Buffer-menu-mode-map
:doc "Local keymap for `Buffer-menu-mode' buffers."
:parent tabulated-list-mode-map
@@ -140,9 +146,7 @@ Buffer-menu-mode-map
"V" #'Buffer-menu-view
"O" #'Buffer-menu-view-other-window
"T" #'Buffer-menu-toggle-files-only
- "M-s a C-s" #'Buffer-menu-isearch-buffers
- "M-s a C-M-s" #'Buffer-menu-isearch-buffers-regexp
- "M-s a C-o" #'Buffer-menu-multi-occur
+ (key-description search-prefix) Buffer-menu-mode-search-map
"<mouse-2>" #'Buffer-menu-mouse-select
"<follow-link>" 'mouse-face)
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index c390017e190..a840a027553 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -3537,13 +3537,13 @@ dired-isearch-filenames-setup
(when (or (eq dired-isearch-filenames t)
(and (eq dired-isearch-filenames 'dwim)
(get-text-property (point) 'dired-filename)))
- (define-key isearch-mode-map "\M-sff" 'dired-isearch-filenames-mode)
+ (define-key isearch-mode-search-map "ff" 'dired-isearch-filenames-mode)
(dired-isearch-filenames-mode 1)
(add-hook 'isearch-mode-end-hook #'dired-isearch-filenames-end nil t)))
(defun dired-isearch-filenames-end ()
"Clean up the Dired file name search after terminating isearch."
- (define-key isearch-mode-map "\M-sff" nil)
+ (define-key isearch-mode-search-map "ff" nil)
(dired-isearch-filenames-mode -1)
(remove-hook 'isearch-mode-end-hook #'dired-isearch-filenames-end t)
(unless isearch-suspended
diff --git a/lisp/dired.el b/lisp/dired.el
index 1f7dca802fd..8986fd96bc5 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2130,6 +2130,13 @@ dired-uncache
\f
;;; Dired mode key bindings and menus
+(defvar-keymap dired-mode-search-map
+ :doc "Local keymap for search keys in `dired-mode-map'."
+ "a C-s" #'dired-do-isearch
+ "a C-M-s" #'dired-do-isearch-regexp
+ "f C-s" #'dired-isearch-filenames
+ "f C-M-s" #'dired-isearch-filenames-regexp)
+
(defvar-keymap dired-mode-map
:doc "Local keymap for Dired mode buffers."
:full t
@@ -2248,10 +2255,7 @@ dired-mode-map
"M-$" #'dired-hide-all
"(" #'dired-hide-details-mode
;; isearch
- "M-s a C-s" #'dired-do-isearch
- "M-s a C-M-s" #'dired-do-isearch-regexp
- "M-s f C-s" #'dired-isearch-filenames
- "M-s f C-M-s" #'dired-isearch-filenames-regexp
+ (key-description search-prefix) dired-mode-search-map
;; misc
"<remap> <read-only-mode>" #'dired-toggle-read-only
"?" #'dired-summary
diff --git a/lisp/isearch.el b/lisp/isearch.el
index bb46c89ae20..ef59e103a5c 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -560,6 +560,21 @@ isearch-menu-bar-commands
'(isearch-tmm-menubar tmm-menubar menu-bar-open mouse-minor-mode-menu)
"List of commands that can open a menu during Isearch.")
+(defvar-keymap isearch-mode-search-map
+ :doc "Keymap for the M-s prefix keys used during Isearch."
+ ;; More toggles defined by `isearch-define-mode-toggle'.
+ "C-e" #'isearch-yank-line
+ "M-<" #'isearch-beginning-of-buffer
+ "M->" #'isearch-end-of-buffer
+ "e" #'isearch-edit-string
+ "o" #'isearch-occur
+ "h r" #'isearch-highlight-regexp
+ "h l" #'isearch-highlight-lines-matching-regexp)
+
+(put 'isearch-toggle-case-fold :advertised-binding "\M-sc")
+(put 'isearch-toggle-regexp :advertised-binding "\M-sr")
+(put 'isearch-edit-string :advertised-binding "\M-se")
+
;; Note: Before adding more key bindings to this map, please keep in
;; mind that any unbound key exits Isearch and runs the command bound
;; to it in the local or global map. So in effect every key unbound
@@ -618,10 +633,6 @@ isearch-mode-map
(define-key map "\M-\C-y" 'isearch-yank-char)
(define-key map "\C-y" 'isearch-yank-kill)
(define-key map "\M-\C-z" 'isearch-yank-until-char)
- (define-key map "\M-s\C-e" 'isearch-yank-line)
-
- (define-key map "\M-s\M-<" 'isearch-beginning-of-buffer)
- (define-key map "\M-s\M->" 'isearch-end-of-buffer)
(define-key map (char-to-string help-char) isearch-help-map)
(define-key map [help] isearch-help-map)
@@ -659,18 +670,10 @@ isearch-mode-map
(define-key map "\M-r" 'isearch-toggle-regexp)
(define-key map "\M-e" 'isearch-edit-string)
- (put 'isearch-toggle-case-fold :advertised-binding "\M-sc")
- (put 'isearch-toggle-regexp :advertised-binding "\M-sr")
- (put 'isearch-edit-string :advertised-binding "\M-se")
-
- (define-key map "\M-se" 'isearch-edit-string)
- ;; More toggles defined by `isearch-define-mode-toggle'.
-
(define-key map [?\M-%] 'isearch-query-replace)
(define-key map [?\C-\M-%] 'isearch-query-replace-regexp)
- (define-key map "\M-so" 'isearch-occur)
- (define-key map "\M-shr" 'isearch-highlight-regexp)
- (define-key map "\M-shl" 'isearch-highlight-lines-matching-regexp)
+
+ (define-key map search-prefix isearch-mode-search-map)
;; The key translations defined in the C-x 8 prefix should add
;; characters to the search string. See iso-transl.el.
next prev parent reply other threads:[~2023-01-17 19:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-14 16:44 bug#60815: 28.2; Hard-coded M-sff key binding in dired-aux.el Evgeni Pandurski
2023-01-14 18:14 ` Eli Zaretskii
[not found] ` <CA+MLsgOSFS0h45qMpDv3p8WFVpo3oju19uS49RvxfTMAmZRJ5Q@mail.gmail.com>
[not found] ` <CA+MLsgOj1qyYT0xrM9kWfTHuo_qxQ6czhGtUtqoc=GYV9Hwf-g@mail.gmail.com>
2023-01-14 18:52 ` Eli Zaretskii
2023-01-17 17:24 ` Juri Linkov
2023-01-17 18:30 ` Evgeni Pandurski
2023-01-17 18:43 ` Eli Zaretskii
[not found] ` <CA+MLsgMSDroUBLYfkwcDxyf6=jMSZR0NxZExuWSvrg07+uDrHA@mail.gmail.com>
2023-01-17 18:47 ` Juri Linkov
2023-01-17 19:01 ` Evgeni Pandurski
2023-01-17 19:27 ` Juri Linkov [this message]
2023-01-17 19:44 ` Evgeni Pandurski
2023-01-14 18:19 ` 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=865yd5ufl8.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=60815@debbugs.gnu.org \
--cc=epandurski@gmail.com \
/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).