Rename multifile.el to fileloop.el

* lisp/multifile.el: Rename to fileloop.el as discussed in
https://lists.gnu.org/archive/html/emacs-devel/2018-12/msg00475.html.
Update symbol prefixes and all callers
This commit is contained in:
Dmitry Gutov 2019-02-07 12:20:09 +03:00
parent 1289ae999b
commit 5e627fa5f5
8 changed files with 87 additions and 87 deletions

View file

@ -1990,7 +1990,7 @@ table.
@item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET}
Perform a @code{query-replace-regexp} on each file in the selected tags table.
@item M-x multifile-continue
@item M-x fileloop-continue
Restart one of the last 2 commands above, from the current location of point.
@end table
@ -2026,9 +2026,9 @@ you can follow its progress. As soon as it finds an occurrence,
@code{tags-search} returns. This command requires tags tables to be
available (@pxref{Tags Tables}).
@findex multifile-continue
@findex fileloop-continue
Having found one match with @code{tags-search}, you probably want to
find all the rest. @kbd{M-x multifile-continue} resumes the
find all the rest. @kbd{M-x fileloop-continue} resumes the
@code{tags-search}, finding one more match. This searches the rest of
the current buffer, followed by the remaining files of the tags table.
@ -2051,10 +2051,10 @@ default is to use the same setting as the value of
single invocation of @kbd{M-x tags-query-replace}. But often it is
useful to exit temporarily, which you can do with any input event that
has no special query replace meaning. You can resume the query
replace subsequently by typing @kbd{M-x multifile-continue}; this
replace subsequently by typing @kbd{M-x fileloop-continue}; this
command resumes the last tags search or replace command that you did.
For instance, to skip the rest of the current file, you can type
@w{@kbd{M-> M-x multifile-continue}}.
@w{@kbd{M-> M-x fileloop-continue}}.
Note that the commands described above carry out much broader
searches than the @code{xref-find-definitions} family. The

View file

@ -394,11 +394,11 @@ The mode is automatically enabled in files that start with the
*** 'next-file' is now an obsolete alias of 'tags-next-file'.
*** 'tags-loop-revert-buffers' is an obsolete alias of
'multifile-revert-buffers'.
'fileloop-revert-buffers'.
*** The 'tags-loop-continue' function along with the
'tags-loop-operate' and 'tags-loop-scan' variables are now obsolete;
use the new 'multifile-initialize' and 'multifile-continue' functions
use the new 'fileloop-initialize' and 'fileloop-continue' functions
instead.
** bibtex
@ -1085,7 +1085,7 @@ indicator instead of just the indicator (which is sometimes cryptic).
* New Modes and Packages in Emacs 27.1
** multifile.el lets one setup multifile operations like search&replace.
** fileloop.el lets one setup multifile operations like search&replace.
+++
** Emacs can now visit files in archives as if they were directories.

View file

@ -2859,11 +2859,11 @@ is part of a file name (i.e., has the text property `dired-filename')."
Stops when a match is found.
To continue searching for next match, use command \\[tags-loop-continue]."
(interactive "sSearch marked files (regexp): ")
(multifile-initialize-search
(fileloop-initialize-search
regexp
(dired-get-marked-files nil nil #'dired-nondirectory-p)
'default)
(multifile-continue))
(fileloop-continue))
;;;###autoload
(defun dired-do-query-replace-regexp (from to &optional delimited)
@ -2881,11 +2881,11 @@ with the command \\[tags-loop-continue]."
(if (and buffer (with-current-buffer buffer
buffer-read-only))
(error "File `%s' is visited read-only" file))))
(multifile-initialize-replace
(fileloop-initialize-replace
from to (dired-get-marked-files nil nil #'dired-nondirectory-p)
(if (equal from (downcase from)) nil 'default)
delimited)
(multifile-continue))
(fileloop-continue))
(declare-function xref--show-xrefs "xref")
(declare-function xref-query-replace-in-results "xref")

View file

@ -1,4 +1,4 @@
;;; multifile.el --- Operations on multiple files -*- lexical-binding: t; -*-
;;; fileloop.el --- Operations on multiple files -*- lexical-binding: t; -*-
;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
@ -24,11 +24,11 @@
;; version of etags.el.
;; TODO:
;; - Maybe it would make sense to replace the multifile--* vars with a single
;; - Maybe it would make sense to replace the fileloop--* vars with a single
;; global var holding a struct, and then stash those structs into a history
;; of past operations, so you can perform a multifile-search while in the
;; middle of a multifile-replace and later go back to that
;; multifile-replace.
;; of past operations, so you can perform a fileloop-search while in the
;; middle of a fileloop-replace and later go back to that
;; fileloop-replace.
;; - Make multi-isearch work on top of this library (might require changes
;; to this library, of course).
@ -36,12 +36,12 @@
(require 'generator)
(defgroup multifile nil
(defgroup fileloop nil
"Operations on multiple files."
:group 'tools)
(defcustom multifile-revert-buffers 'silent
"Whether to revert files during multifile operation.
(defcustom fileloop-revert-buffers 'silent
"Whether to revert files during fileloop operation.
`silent' means to only do it if `revert-without-query' is applicable;
t means to offer to do it for all applicable files;
nil means never to do it"
@ -49,17 +49,17 @@
;; FIXME: This already exists in GNU ELPA's iterator.el. Maybe it should move
;; to generator.el?
(iter-defun multifile--list-to-iterator (list)
(iter-defun fileloop--list-to-iterator (list)
(while list (iter-yield (pop list))))
(defvar multifile--iterator iter-empty)
(defvar multifile--scan-function
(defvar fileloop--iterator iter-empty)
(defvar fileloop--scan-function
(lambda () (user-error "No operation in progress")))
(defvar multifile--operate-function #'ignore)
(defvar multifile--freshly-initialized nil)
(defvar fileloop--operate-function #'ignore)
(defvar fileloop--freshly-initialized nil)
;;;###autoload
(defun multifile-initialize (files scan-function operate-function)
(defun fileloop-initialize (files scan-function operate-function)
"Initialize a new round of operation on several files.
FILES can be either a list of file names, or an iterator (used with `iter-next')
which returns a file name at each step.
@ -69,18 +69,18 @@ OPERATE-FUNCTION is a function called with no argument; it is expected
to perform the operation on the current file buffer and when done
should return non-nil to mean that we should immediately continue
operating on the next file and nil otherwise."
(setq multifile--iterator
(setq fileloop--iterator
(if (and (listp files) (not (functionp files)))
(multifile--list-to-iterator files)
(fileloop--list-to-iterator files)
files))
(setq multifile--scan-function scan-function)
(setq multifile--operate-function operate-function)
(setq multifile--freshly-initialized t))
(setq fileloop--scan-function scan-function)
(setq fileloop--operate-function operate-function)
(setq fileloop--freshly-initialized t))
(defun multifile-next-file (&optional novisit)
(defun fileloop-next-file (&optional novisit)
;; FIXME: Should we provide an interactive command, like tags-next-file?
(let ((next (condition-case nil
(iter-next multifile--iterator)
(iter-next fileloop--iterator)
(iter-end-of-sequence nil))))
(unless next
(and novisit
@ -91,9 +91,9 @@ operating on the next file and nil otherwise."
(new (not buffer)))
;; Optionally offer to revert buffers
;; if the files have changed on disk.
(and buffer multifile-revert-buffers
(and buffer fileloop-revert-buffers
(not (verify-visited-file-modtime buffer))
(if (eq multifile-revert-buffers 'silent)
(if (eq fileloop-revert-buffers 'silent)
(and (not (buffer-modified-p buffer))
(let ((revertible nil))
(dolist (re revert-without-query)
@ -118,7 +118,7 @@ operating on the next file and nil otherwise."
(insert-file-contents new nil))
new)))
(defun multifile-continue ()
(defun fileloop-continue ()
"Continue last multi-file operation."
(interactive)
(let (new
@ -131,10 +131,10 @@ operating on the next file and nil otherwise."
(progn
;; Scan files quickly for the first or next interesting one.
;; This starts at point in the current buffer.
(while (or multifile--freshly-initialized file-finished
(while (or fileloop--freshly-initialized file-finished
(save-restriction
(widen)
(not (funcall multifile--scan-function))))
(not (funcall fileloop--scan-function))))
;; If nothing was found in the previous file, and
;; that file isn't in a temp buffer, restore point to
;; where it was.
@ -142,17 +142,17 @@ operating on the next file and nil otherwise."
(goto-char original-point))
(setq file-finished nil)
(setq new (multifile-next-file t))
(setq new (fileloop-next-file t))
;; If NEW is non-nil, we got a temp buffer,
;; and NEW is the file name.
(when (or messaged
(and (not multifile--freshly-initialized)
(and (not fileloop--freshly-initialized)
(> baud-rate search-slow-speed)
(setq messaged t)))
(message "Scanning file %s..." (or new buffer-file-name)))
(setq multifile--freshly-initialized nil)
(setq fileloop--freshly-initialized nil)
(setq original-point (if new nil (point)))
(goto-char (point-min)))
@ -172,13 +172,13 @@ operating on the next file and nil otherwise."
;; If value is non-nil, continue to scan the next file.
(save-restriction
(widen)
(funcall multifile--operate-function)))
(funcall fileloop--operate-function)))
(setq file-finished t))))
;;;###autoload
(defun multifile-initialize-search (regexp files case-fold)
(defun fileloop-initialize-search (regexp files case-fold)
(let ((last-buffer (current-buffer)))
(multifile-initialize
(fileloop-initialize
files
(lambda ()
(let ((case-fold-search
@ -191,16 +191,16 @@ operating on the next file and nil otherwise."
nil))))
;;;###autoload
(defun multifile-initialize-replace (from to files case-fold &optional delimited)
(defun fileloop-initialize-replace (from to files case-fold &optional delimited)
"Initialize a new round of query&replace on several files.
FROM is a regexp and TO is the replacement to use.
FILES describes the file, as in `multifile-initialize'.
FILES describes the file, as in `fileloop-initialize'.
CASE-FOLD can be t, nil, or `default', the latter one meaning to obey
the default setting of `case-fold-search'.
DELIMITED if non-nil means replace only word-delimited matches."
;; FIXME: Not sure how the delimited-flag interacts with the regexp-flag in
;; `perform-replace', so I just try to mimic the old code.
(multifile-initialize
(fileloop-initialize
files
(lambda ()
(let ((case-fold-search
@ -213,5 +213,5 @@ DELIMITED if non-nil means replace only word-delimited matches."
(lambda ()
(perform-replace from to t t delimited nil multi-query-replace-map))))
(provide 'multifile)
;;; multifile.el ends here
(provide 'fileloop)
;;; fileloop.el ends here

View file

@ -11493,7 +11493,7 @@ argument is passed to `next-file', which see).
\(fn &optional FIRST-TIME)" t nil)
(make-obsolete 'tags-loop-continue 'multifile-continue '"27.1")
(make-obsolete 'tags-loop-continue 'fileloop-continue '"27.1")
(autoload 'tags-search "etags" "\
Search through all files listed in tags table for match for REGEXP.
@ -11512,7 +11512,7 @@ Do `query-replace-regexp' of FROM with TO on all files listed in tags table.
Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
with the command \\[tags-loop-continue].
For non-interactive use, superceded by `multifile-initialize-replace'.
For non-interactive use, superceded by `fileloop-initialize-replace'.
\(fn FROM TO &optional DELIMITED FILES)" t nil)
@ -22298,10 +22298,10 @@ QUALITY can be:
;;;***
;;;### (autoloads nil "multifile" "multifile.el" (0 0 0 0))
;;; Generated autoloads from multifile.el
;;;### (autoloads nil "fileloop" "fileloop.el" (0 0 0 0))
;;; Generated autoloads from fileloop.el
(autoload 'multifile-initialize "multifile" "\
(autoload 'fileloop-initialize "fileloop" "\
Initialize a new round of operation on several files.
FILES can be either a list of file names, or an iterator (used with `iter-next')
which returns a file name at each step.
@ -22314,22 +22314,22 @@ operating on the next file and nil otherwise.
\(fn FILES SCAN-FUNCTION OPERATE-FUNCTION)" nil nil)
(autoload 'multifile-initialize-search "multifile" "\
(autoload 'fileloop-initialize-search "fileloop" "\
\(fn REGEXP FILES CASE-FOLD)" nil nil)
(autoload 'multifile-initialize-replace "multifile" "\
(autoload 'fileloop-initialize-replace "fileloop" "\
Initialize a new round of query&replace on several files.
FROM is a regexp and TO is the replacement to use.
FILES describes the file, as in `multifile-initialize'.
FILES describes the file, as in `fileloop-initialize'.
CASE-FOLD can be t, nil, or `default', the latter one meaning to obey
the default setting of `case-fold-search'.
DELIMITED if non-nil means replace only word-delimited matches.
\(fn FROM TO FILES CASE-FOLD &optional DELIMITED)" nil nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "multifile" '("multifile-")))
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "fileloop" '("fileloop-")))
;;;***
@ -26455,14 +26455,14 @@ recognized.
(autoload 'project-search "project" "\
Search for REGEXP in all the files of the project.
Stops when a match is found.
To continue searching for next match, use command \\[multifile-continue].
To continue searching for next match, use command \\[fileloop-continue].
\(fn REGEXP)" t nil)
(autoload 'project-query-replace "project" "\
Search for REGEXP in all the files of the project.
Stops when a match is found.
To continue searching for next match, use command \\[multifile-continue].
To continue searching for next match, use command \\[fileloop-continue].
\(fn FROM TO)" t nil)

View file

@ -309,7 +309,7 @@
menu-bar-separator)
(bindings--define-key menu [tags-continue]
'(menu-item "Continue Tags Search" multifile-continue
'(menu-item "Continue Tags Search" fileloop-continue
:help "Continue last tags search operation"))
(bindings--define-key menu [tags-srch]
'(menu-item "Search Tagged Files..." tags-search
@ -358,7 +358,7 @@
(defvar menu-bar-replace-menu
(let ((menu (make-sparse-keymap "Replace")))
(bindings--define-key menu [tags-repl-continue]
'(menu-item "Continue Replace" multifile-continue
'(menu-item "Continue Replace" fileloop-continue
:help "Continue last tags replace operation"))
(bindings--define-key menu [tags-repl]
'(menu-item "Replace in Tagged Files..." tags-query-replace

View file

@ -36,7 +36,7 @@
(require 'ring)
(require 'button)
(require 'xref)
(require 'multifile)
(require 'fileloop)
;;;###autoload
(defvar tags-file-name nil
@ -1693,12 +1693,12 @@ Point should be just after a string that matches TAG."
(let ((bol (point)))
(and (search-forward "\177" (line-end-position) t)
(re-search-backward re bol t)))))
(define-obsolete-variable-alias 'tags-loop-revert-buffers 'multifile-revert-buffers "27.1")
(define-obsolete-variable-alias 'tags-loop-revert-buffers 'fileloop-revert-buffers "27.1")
;;;###autoload
(defalias 'next-file 'tags-next-file)
(make-obsolete 'next-file
"use tags-next-file or multifile-initialize and multifile-next-file instead" "27.1")
"use tags-next-file or fileloop-initialize and fileloop-next-file instead" "27.1")
;;;###autoload
(defun tags-next-file (&optional initialize novisit)
"Select next file among files in current tags table.
@ -1716,7 +1716,7 @@ if the file was newly read in, the value is the filename."
(interactive (list (if current-prefix-arg t)))
(when initialize ;; Not the first run.
(tags--compat-initialize initialize))
(multifile-next-file novisit)
(fileloop-next-file novisit)
(switch-to-buffer (current-buffer)))
(defun tags--all-files ()
@ -1742,11 +1742,11 @@ if the file was newly read in, the value is the filename."
(mapcar #'expand-file-name (tags-table-files)))))
files)))
(make-obsolete-variable 'tags-loop-operate 'multifile-initialize "27.1")
(make-obsolete-variable 'tags-loop-operate 'fileloop-initialize "27.1")
(defvar tags-loop-operate nil
"Form for `tags-loop-continue' to eval to change one file.")
(make-obsolete-variable 'tags-loop-scan 'multifile-initialize "27.1")
(make-obsolete-variable 'tags-loop-scan 'fileloop-initialize "27.1")
(defvar tags-loop-scan
'(user-error "%s"
(substitute-command-keys
@ -1775,7 +1775,7 @@ Bind `case-fold-search' during the evaluation, depending on the value of
(eval files))))
(defun tags--compat-initialize (initialize)
(multifile-initialize
(fileloop-initialize
(tags--compat-files initialize)
(if tags-loop-operate
(lambda () (tags-loop-eval tags-loop-operate))
@ -1792,11 +1792,11 @@ argument is passed to `next-file', which see)."
;; interesting (it returns non-nil if so) and `tags-loop-operate' is a form to
;; evaluate to operate on an interesting file. If the latter evaluates to
;; nil, we exit; otherwise we scan the next file.
(declare (obsolete multifile-continue "27.1"))
(declare (obsolete fileloop-continue "27.1"))
(interactive)
(when first-time ;; Backward compatibility.
(tags--compat-initialize first-time))
(multifile-continue))
(fileloop-continue))
;; We use it to detect when the last loop was a tags-search.
(defvar tags--last-search-operate-function nil)
@ -1813,18 +1813,18 @@ The search will be restricted to these files.
Also see the documentation of the `tags-file-name' variable."
(interactive "sTags search (regexp): ")
(unless (and (equal regexp "")
;; FIXME: If some other multifile operation took place,
;; FIXME: If some other fileloop operation took place,
;; rather than search for "", we should repeat the last search!
(eq multifile--operate-function
(eq fileloop--operate-function
tags--last-search-operate-function))
(multifile-initialize-search
(fileloop-initialize-search
regexp
(tags--compat-files (or files t))
tags-case-fold-search)
;; Store it, so we can detect if some other multifile operation took
;; Store it, so we can detect if some other fileloop operation took
;; place since the last search!
(setq tags--last-search-operate-function multifile--operate-function))
(multifile-continue))
(setq tags--last-search-operate-function fileloop--operate-function))
(fileloop-continue))
;;;###autoload
(defun tags-query-replace (from to &optional delimited files)
@ -1832,15 +1832,15 @@ Also see the documentation of the `tags-file-name' variable."
Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
with the command \\[tags-loop-continue].
For non-interactive use, superceded by `multifile-initialize-replace'."
For non-interactive use, superceded by `fileloop-initialize-replace'."
(declare (advertised-calling-convention (from to &optional delimited) "27.1"))
(interactive (query-replace-read-args "Tags query replace (regexp)" t t))
(multifile-initialize-replace
(fileloop-initialize-replace
from to
(tags--compat-files (or files t))
(if (equal from (downcase from)) nil 'default)
delimited)
(multifile-continue))
(fileloop-continue))
(defun tags-complete-tags-table-file (string predicate what) ; Doc string?
(save-excursion

View file

@ -511,30 +511,30 @@ recognized."
inherit-input-method)))
(concat common-parent-directory res)))
(declare-function multifile-continue "multifile" ())
(declare-function fileloop-continue "fileloop" ())
;;;###autoload
(defun project-search (regexp)
"Search for REGEXP in all the files of the project.
Stops when a match is found.
To continue searching for next match, use command \\[multifile-continue]."
To continue searching for next match, use command \\[fileloop-continue]."
(interactive "sSearch (regexp): ")
(multifile-initialize-search
(fileloop-initialize-search
regexp (project-files (project-current t)) 'default)
(multifile-continue))
(fileloop-continue))
;;;###autoload
(defun project-query-replace (from to)
"Search for REGEXP in all the files of the project.
Stops when a match is found.
To continue searching for next match, use command \\[multifile-continue]."
To continue searching for next match, use command \\[fileloop-continue]."
(interactive
(pcase-let ((`(,from ,to)
(query-replace-read-args "Query replace (regexp)" t t)))
(list from to)))
(multifile-initialize-replace
(fileloop-initialize-replace
from to (project-files (project-current t)) 'default)
(multifile-continue))
(fileloop-continue))
(provide 'project)
;;; project.el ends here