From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: `Q' in Dired - be able to skip the rest of one file and move onto the next Date: Tue, 15 Jul 2008 03:27:32 +0300 Organization: JURTA Message-ID: <87vdz8yp9f.fsf@jurta.org> References: <871w8ybpz8.fsf@jurta.org> <87prwigx01.fsf@bzg.ath.cx> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1216082465 28226 80.91.229.12 (15 Jul 2008 00:41:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Jul 2008 00:41:05 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 15 02:41:53 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KIYc4-0000R5-Gd for ged-emacs-devel@m.gmane.org; Tue, 15 Jul 2008 02:41:52 +0200 Original-Received: from localhost ([127.0.0.1]:36390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KIYbC-0001fQ-4g for ged-emacs-devel@m.gmane.org; Mon, 14 Jul 2008 20:40:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KIYb7-0001fC-J5 for emacs-devel@gnu.org; Mon, 14 Jul 2008 20:40:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KIYb6-0001f0-Dv for emacs-devel@gnu.org; Mon, 14 Jul 2008 20:40:52 -0400 Original-Received: from [199.232.76.173] (port=49159 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KIYb6-0001ex-9A for emacs-devel@gnu.org; Mon, 14 Jul 2008 20:40:52 -0400 Original-Received: from relay02.kiev.sovam.com ([62.64.120.197]:58664) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KIYb5-0005Bf-NK for emacs-devel@gnu.org; Mon, 14 Jul 2008 20:40:52 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay02.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1KIYb3-000Bdp-Kj for emacs-devel@gnu.org; Tue, 15 Jul 2008 03:40:49 +0300 In-Reply-To: <87prwigx01.fsf@bzg.ath.cx> (Bastien's message of "Fri, 04 Jan 2008 03:11:58 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: 38ca23b554dc5d6e0aef191240598eef X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Trusted X-SpamTest-Info: Profiles 4315 [July 15 2008] X-SpamTest-Info: {received from trusted relay: common white list} X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: white ip list X-SpamTest-Rate: 10 X-SpamTest-Status: Trusted X-SpamTest-Status-Extended: trusted X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:100705 Archived-At: >>> Even so, it might not be bad to provide a key to skip to the next file >>> without exiting query-replace. >> >> Another problem I have with `Q' is that it requires typing `!' in every >> file to replace all occurrences. So if I want to replace all occurrences >> in ALL marked files at once without a query, I need typing `!' as many times >> as there are marked files. >> >> Maybe, when started by `Q', query-replace should apply `!' to all marked files, >> and a new key `Y' should replace all remaining occurrences in the current file, >> and a new key `N' should skip the current file as Miles has already proposed. > > Agreed. I see that this useful feature is not yet implemented, so I have made a patch that implements multi-file query-replace UI. It defines a new keymap `multi-query-replace-map' that inherits from `query-replace-map' and defines two multi-file keys "Y" and "N". "Y" means to replace all remaining matches in all remaining buffers, (this key is better than redefining the old behavior of "!"). And "N" skips remaining matches in the current buffer and continues with the next buffer (so in addition to "No for this file" it also has "Next file" mnemonics). Index: lisp/replace.el =================================================================== RCS file: /sources/emacs/emacs/lisp/replace.el,v retrieving revision 1.273 diff -c -r1.273 replace.el *** lisp/replace.el 29 Jun 2008 16:09:08 -0000 1.273 --- lisp/replace.el 15 Jul 2008 00:27:02 -0000 *************** *** 1372,1377 **** --- 1372,1391 ---- `exit', `act-and-exit', `edit', `delete-and-edit', `recenter', `automatic', `backup', `exit-prefix', and `help'.") + (defvar multi-query-replace-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map query-replace-map) + (define-key map "Y" 'automatic-all) + (define-key map "N" 'exit-current) + map) + "Keymap that defines additional bindings for multi-buffer operations. + It extends its parent map `query-replace-map' with new bindings to + operate on a set of buffers/files. The difference with its parent map + is the additional answers `automatic-all' to replace all remaining + matches in all remaining buffers with no more questions, and + `exit-current' to skip remaining matches in the current buffer + and to continue with the next buffer in the sequence.") + (defun replace-match-string-symbols (n) "Process a list (and any sub-lists), expanding certain symbols. Symbol Expands To *************** *** 1702,1708 **** query-replace-help))) (with-current-buffer standard-output (help-mode)))) ! ((eq def 'exit) (setq keep-going nil) (setq done t)) ((eq def 'backup) --- 1716,1722 ---- query-replace-help))) (with-current-buffer standard-output (help-mode)))) ! ((or (eq def 'exit) (eq def 'exit-current)) (setq keep-going nil) (setq done t)) ((eq def 'backup) *************** *** 1744,1750 **** real-match-data (replace-match-data t real-match-data) replaced t))) ! ((eq def 'automatic) (or replaced (setq noedit (replace-match-maybe-edit --- 1758,1764 ---- real-match-data (replace-match-data t real-match-data) replaced t))) ! ((or (eq def 'automatic) (eq def 'automatic-all)) (or replaced (setq noedit (replace-match-maybe-edit Index: lisp/progmodes/etags.el =================================================================== RCS file: /sources/emacs/emacs/lisp/progmodes/etags.el,v retrieving revision 1.211 diff -c -r1.211 etags.el *** lisp/progmodes/etags.el 7 Jun 2008 02:37:37 -0000 1.211 --- lisp/progmodes/etags.el 15 Jul 2008 00:27:08 -0000 *************** *** 1865,1872 **** ;; to the beginning of it so perform-replace ;; will see it. (goto-char (match-beginning 0)))) ! tags-loop-operate `(perform-replace ',from ',to t t ',delimited)) (tags-loop-continue (or file-list-form t))) (defun tags-complete-tags-table-file (string predicate what) ; Doc string? (save-excursion --- 1865,1896 ---- ;; to the beginning of it so perform-replace ;; will see it. (goto-char (match-beginning 0)))) ! tags-loop-operate `(tags-query-replace-loop-operate ! ',from ',to ',delimited)) (tags-loop-continue (or file-list-form t))) + + (defun tags-query-replace-loop-operate (from to delimited) + "Call `perform-replace' with the logic of multi-file operations. + Used for `tags-loop-operate' in `tags-query-replace'." + (let* ( + ;; def-pre is a key typed in the previous call of perform-replace + (def-pre (lookup-key multi-query-replace-map + (vector last-input-char))) + ;; If the last typed key was automatic-all, don't ask + ;; more questions in next files + (query-flag (not (eq def-pre 'automatic-all))) + (ret (perform-replace from to query-flag t delimited nil + multi-query-replace-map)) + ;; def-post is a key typed in the new call of perform-replace + (def-post (lookup-key multi-query-replace-map + (vector last-input-char)))) + (or + ;; Return non-nil exit code from `perform-replace' + ret + ;; Or return t if a multi-file operation key was typed + (eq def-post 'exit-current) + (eq def-post 'automatic-all)))) + (defun tags-complete-tags-table-file (string predicate what) ; Doc string? (save-excursion -- Juri Linkov http://www.jurta.org/emacs/