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: Sun, 20 Jul 2008 03:33:54 +0300 Organization: JURTA Message-ID: <87wsjhgzrh.fsf@jurta.org> References: <871w8ybpz8.fsf@jurta.org> <87prwigx01.fsf@bzg.ath.cx> <87vdz8yp9f.fsf@jurta.org> <487C53DF.9010808@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1216514552 22198 80.91.229.12 (20 Jul 2008 00:42:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Jul 2008 00:42:32 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Lennart Borgman \(gmail\)" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 20 02:43:20 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 1KKN1D-0006SJ-KC for ged-emacs-devel@m.gmane.org; Sun, 20 Jul 2008 02:43:20 +0200 Original-Received: from localhost ([127.0.0.1]:48123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KKN0K-0005NH-PJ for ged-emacs-devel@m.gmane.org; Sat, 19 Jul 2008 20:42:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KKMzQ-0004PG-7Y for emacs-devel@gnu.org; Sat, 19 Jul 2008 20:41:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KKMzO-0004Mt-O4 for emacs-devel@gnu.org; Sat, 19 Jul 2008 20:41:27 -0400 Original-Received: from [199.232.76.173] (port=58406 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KKMzO-0004Mm-IT for emacs-devel@gnu.org; Sat, 19 Jul 2008 20:41:26 -0400 Original-Received: from relay03.kiev.sovam.com ([62.64.120.201]:63511) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KKMzN-0007mC-QM for emacs-devel@gnu.org; Sat, 19 Jul 2008 20:41:26 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay03.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1KKMzL-000I76-Jn; Sun, 20 Jul 2008 03:41:23 +0300 In-Reply-To: <487C53DF.9010808@gmail.com> (Lennart Borgman's message of "Tue, 15 Jul 2008 09:38:07 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: b60427ab34266e83f0b0ef42c1089f3d X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Trusted X-SpamTest-Info: Profiles 4369 [July 20 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:101001 Archived-At: >> I see that this useful feature is not yet implemented, so I have >> made a patch that implements multi-file query-replace UI. > > Thanks for implementing this. I now have a better patch where all multi-file processing was moved to `perform-replace', so external packages like etags.el only need to add `multi-query-replace-map' as the `map' argument of `perform-replace'. 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 20 Jul 2008 00:27:14 -0000 *************** *** 1865,1871 **** ;; 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? --- 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 ! nil multi-query-replace-map)) (tags-loop-continue (or file-list-form t))) (defun tags-complete-tags-table-file (string predicate what) ; Doc string? 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 20 Jul 2008 00:32:42 -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 *************** *** 1527,1532 **** --- 1541,1547 ---- (stack nil) (replace-count 0) (nonempty-match nil) + (multi-file nil) ;; If non-nil, it is marker saying where in the buffer to stop. (limit nil) *************** *** 1548,1553 **** --- 1563,1573 ---- (goto-char (min start end)) (deactivate-mark)) + ;; If last typed key in previous call of multi-file perform-replace + ;; was `automatic-all', don't ask more questions in next files + (when (eq (lookup-key map (vector last-input-char)) 'automatic-all) + (setq query-flag nil multi-file t)) + ;; REPLACEMENTS is either a string, a list of strings, or a cons cell ;; containing a function and its first argument. The function is ;; called to generate each replacement like this: *************** *** 1705,1710 **** --- 1725,1732 ---- ((eq def 'exit) (setq keep-going nil) (setq done t)) + ((eq def 'exit-current) + (setq multi-file t keep-going nil done t)) ((eq def 'backup) (if stack (let ((elt (pop stack))) *************** *** 1744,1757 **** real-match-data (replace-match-data t real-match-data) replaced t))) ! ((eq def 'automatic) (or replaced (setq noedit (replace-match-maybe-edit next-replacement nocasify literal noedit real-match-data) replace-count (1+ replace-count))) ! (setq done t query-flag nil replaced t)) ((eq def 'skip) (setq done t)) ((eq def 'recenter) --- 1766,1780 ---- 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 next-replacement nocasify literal noedit real-match-data) replace-count (1+ replace-count))) ! (setq done t query-flag nil replaced t) ! (if (eq def 'automatic-all) (setq multi-file t))) ((eq def 'skip) (setq done t)) ((eq def 'recenter) *************** *** 1838,1844 **** (message "Replaced %d occurrence%s" replace-count (if (= replace-count 1) "" "s"))) ! (and keep-going stack))) (defvar replace-overlay nil) --- 1861,1867 ---- (message "Replaced %d occurrence%s" replace-count (if (= replace-count 1) "" "s"))) ! (or (and keep-going stack) multi-file))) (defvar replace-overlay nil) -- Juri Linkov http://www.jurta.org/emacs/