From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#60815: 28.2; Hard-coded M-sff key binding in dired-aux.el Date: Tue, 17 Jan 2023 20:47:32 +0200 Organization: LINKOV.NET Message-ID: <86tu0p0zi3.fsf@mail.linkov.net> References: <83fscd6l0v.fsf@gnu.org> <83edrx6jah.fsf@gnu.org> <86tu0p6wrc.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29382"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 60815@debbugs.gnu.org To: Evgeni Pandurski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 17 19:50:52 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHr2q-0007YU-Ih for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Jan 2023 19:50:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHr28-0005r6-OS; Tue, 17 Jan 2023 13:50:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHr23-0005iJ-7M for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2023 13:50:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHr22-0001mJ-U1 for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2023 13:50:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pHr22-0006nk-7l for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2023 13:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Jan 2023 18:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60815 X-GNU-PR-Package: emacs Original-Received: via spool by 60815-submit@debbugs.gnu.org id=B60815.167398137026096 (code B ref 60815); Tue, 17 Jan 2023 18:50:02 +0000 Original-Received: (at 60815) by debbugs.gnu.org; 17 Jan 2023 18:49:30 +0000 Original-Received: from localhost ([127.0.0.1]:38261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHr1W-0006mq-Am for submit@debbugs.gnu.org; Tue, 17 Jan 2023 13:49:30 -0500 Original-Received: from relay2-d.mail.gandi.net ([217.70.183.194]:58751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHr1U-0006mY-Lu; Tue, 17 Jan 2023 13:49:29 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 7CE3740004; Tue, 17 Jan 2023 18:49:17 +0000 (UTC) In-Reply-To: (Evgeni Pandurski's message of "Tue, 17 Jan 2023 20:14:02 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253577 Archived-At: --=-=-= Content-Type: text/plain reopen 60815 thanks >> Then I guess this report can be closed, done. > > I think so. Your patch would allow me to just change the value of > dired-isearch-filenames-toggle-key, instead of monkey-patching the > whole function in my .emacs. > > But it seems that some key-bindings are much harder to change than > another. "M-s", is such an example, because many modes decide to > override it in their keymaps. Just an idea: Wouldn't it be nice, if > there were an configuration that defines what is the key sequence for > "the M-s search" (M-s by default), and if major modes want to override > the "M-s search commands", they would respect what the configuration > says. Indeed, there is already such variable: `search-map'. So you can do: (define-key global-map [f6] search-map) > For example, If I rebind "M-s" to say "M-6", then the > dired-isearch-filenames-setup function would define the "M-6ff" > binding, instead of "M-sff". I am not sure if this is a good idea, but > this seems like a good approach to me. > > So basically, I propose, instead of the > "dired-isearch-filenames-toggle-key" configuration ("M-sfff by > default), to have, say "global-search-key-sequence" ("M-s" by > default), which all major modes can use when building their local > keymaps. This way, I would not need to fix this binding in every major > mode which overrides it, wrongly believing that M-s is my "search > prefix". The problem is that isearch doesn't use the global "M-s" keymap, but hard-codes "M-s" used in isearch-map. The patch below adds a new variable for the isearch's keymap "M-s" that you can customize with e.g.: (define-key isearch-mode-map [f6] isearch-mode-search-map) Needless to say this patch is for master. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=isearch-mode-search-map.patch 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/isearch.el b/lisp/isearch.el index 8efafd0a2d0..e2273ab7fb9 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 "\M-s" 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. --=-=-=--