]> code.delx.au - gnu-emacs/blobdiff - lisp/filesets.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / filesets.el
index 2d6cb5f0f74dabd68a3d2f3a51ca3da53ae03840..d5e79c0bd93e28622924b02950c6ca70e716f981 100644 (file)
@@ -1,10 +1,9 @@
 ;;; filesets.el --- handle group of files
 
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
-;; Author: Thomas Link <t.link@gmx.at>
-;; Maintainer: FSF
+;; Author: Thomas Link <sanobast-emacs@yahoo.de>
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: filesets convenience
 
 ;; This file is part of GNU Emacs.
@@ -36,7 +35,7 @@
 ;; inclusion group (i.e. a base file including other files).
 
 ;; Usage:
-;; 1. Put (require 'filesets) and (filesets-init) in your .emacs file.
+;; 1. Put (require 'filesets) and (filesets-init) in your init file.
 ;; 2. Type ;; M-x filesets-edit or choose "Edit Filesets" from the menu.
 ;; 3. Save your customizations.
 
@@ -52,7 +51,7 @@
 ;; programs.  See `filesets-external-viewers'.
 
 ;; BTW, if you close a fileset, files, which have been changed, will
-;; be silently saved.  Change this behaviour by setting
+;; be silently saved.  Change this behavior by setting
 ;; `filesets-save-buffer-fn'.
 
 ;;; Supported modes for inclusion groups (`filesets-ingroup-patterns'):
@@ -89,9 +88,7 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl))
-
+(eval-when-compile (require 'cl-lib))
 
 ;;; Some variables
 
@@ -143,16 +140,16 @@ put \"(setq filesets-menu-ensure-use-cached VALUE)\" into your startup
 file -- before loading filesets.el.
 
 So, when should you think about setting this value to t? If filesets.el
-is loaded before user customizations.  Thus, if (require 'filesets)
-precedes the custom-set-variables command or, for XEmacs, if init.el is
-loaded before custom.el, set this variable to t.")
+is loaded before user customizations.  Thus, if (require \\='filesets)
+precedes the `custom-set-variables' command or, for XEmacs, if init.el
+is loaded before custom.el, set this variable to t.")
 
 
 ;;; utils
 (defun filesets-filter-list (lst cond-fn)
   "Remove all elements not conforming to COND-FN from list LST.
 COND-FN takes one argument: the current element."
-;  (remove* 'dummy lst :test (lambda (dummy elt)
+;  (cl-remove 'dummy lst :test (lambda (dummy elt)
 ;                            (not (funcall cond-fn elt)))))
   (let ((rv nil))
     (dolist (elt lst rv)
@@ -178,7 +175,7 @@ Like `some', return the first value of FSS-PRED that is non-nil."
       (let ((fss-rv (funcall fss-pred fss-this)))
        (when fss-rv
          (throw 'exit fss-rv))))))
-;(fset 'filesets-some 'some) ;; or use the cl function
+;(fset 'filesets-some 'cl-some) ;; or use the cl function
 
 (defun filesets-member (fsm-item fsm-lst &rest fsm-keys)
   "Find the first occurrence of FSM-ITEM in FSM-LST.
@@ -189,7 +186,7 @@ key is supported."
     (filesets-ormap (lambda (fsm-this)
                      (funcall fsm-test fsm-item fsm-this))
                    fsm-lst)))
-;(fset 'filesets-member 'member*) ;; or use the cl function
+;(fset 'filesets-member 'cl-member) ;; or use the cl function
 
 (defun filesets-sublist (lst beg &optional end)
   "Get the sublist of LST from BEG to END - 1."
@@ -217,8 +214,8 @@ key is supported."
 
 (defun filesets-which-command-p (cmd)
   "Call \"which CMD\" and return non-nil if the command was found."
-  (when (string-match (format "\\(/[^/]+\\)?/%s" cmd)
-                     (filesets-which-command cmd))
+  (when (string-match-p (format "\\(/[^/]+\\)?/%s" cmd)
+                       (filesets-which-command cmd))
     cmd))
 
 (defun filesets-message (level &rest args)
@@ -268,12 +265,12 @@ SYM to VAL and return t.  If INIT-FLAG is non-nil, set with
     (not ignore-flag)))
 
 (defun filesets-set-default! (sym val)
-  "Call `filestes-set-default' and reset cached data (i.e. rebuild menu)."
+  "Call `filesets-set-default' and reset cached data (i.e. rebuild menu)."
   (when (filesets-set-default sym val)
     (filesets-reset-fileset)))
 
 (defun filesets-set-default+ (sym val)
-  "Call `filestes-set-default' and reset filesets' standard menu."
+  "Call `filesets-set-default' and reset filesets' standard menu."
   (when (filesets-set-default sym val)
     (setq filesets-has-changed-flag t)))
 ;    (filesets-reset-fileset nil t)))
@@ -307,21 +304,25 @@ SYM to VAL and return t.  If INIT-FLAG is non-nil, set with
 (defcustom filesets-menu-name "Filesets"
   "Filesets' menu name."
   :set (function filesets-set-default)
-  :type 'sexp
+  :type 'string
   :group 'filesets)
 
-(defcustom filesets-menu-path nil
+(defcustom filesets-menu-path '("File")        ; cf recentf-menu-path
   "The menu under which the filesets menu should be inserted.
 See `add-submenu' for documentation."
   :set (function filesets-set-default)
-  :type 'sexp
+  :type '(choice (const :tag "Top Level" nil)
+                (sexp :tag "Menu Path"))
+  :version "23.1"                      ; was nil
   :group 'filesets)
 
-(defcustom filesets-menu-before "File"
+(defcustom filesets-menu-before "Open File..." ; cf recentf-menu-before
   "The name of a menu before which this menu should be added.
 See `add-submenu' for documentation."
   :set (function filesets-set-default)
-  :type 'sexp
+  :type '(choice (string :tag "Name")
+                 (const :tag "Last" nil))
+  :version "23.1"                      ; was "File"
   :group 'filesets)
 
 (defcustom filesets-menu-in-menu nil
@@ -344,15 +345,13 @@ See `add-submenu' for documentation."
   :group 'filesets)
 
 ;;(defcustom filesets-menu-cnvfp-flag nil
-;;  "*Non-nil means show \"Convert :pattern to :files\" entry for :pattern menus."
+;;  "Non-nil means show \"Convert :pattern to :files\" entry for :pattern menus."
 ;;  :set (function filesets-set-default!)
 ;;  :type 'boolean
 ;;  :group 'filesets)
 
 (defcustom filesets-menu-cache-file
-  (if (featurep 'xemacs)
-      "~/.xemacs/filesets-cache.el"
-    (concat user-emacs-directory "filesets-cache.el"))
+  (locate-user-emacs-file "filesets-cache.el")
   "File to be used for saving the filesets menu between sessions.
 Set this to \"\", to disable caching of menus.
 Don't forget to check out `filesets-menu-ensure-use-cached'."
@@ -404,8 +403,10 @@ Don't forget to check out `filesets-menu-ensure-use-cached'."
                  (sexp :tag "Other" :value nil)))
   :group 'filesets)
 
-(defcustom filesets-cache-fill-content-hooks nil
-  "Hooks to run when writing the contents of filesets' cache file.
+(define-obsolete-variable-alias 'filesets-cache-fill-content-hooks
+  'filesets-cache-fill-content-hook "24.3")
+(defcustom filesets-cache-fill-content-hook nil
+  "Hook run when writing the contents of filesets' cache file.
 
 The hook is called with the cache file as current buffer and the cursor
 at the last position.  I.e. each hook has to make sure that the cursor is
@@ -414,10 +415,10 @@ at the last position.
 Possible uses: If you don't want to save `filesets-data' in your normal
 configuration file, you can add a something like this
 
-       \(lambda ()
-             \(insert (format \"(setq-default filesets-data '%S)\"
+       (lambda ()
+             (insert (format \"(setq-default filesets-data \\='%S)\"
                              filesets-data))
-             \(newline 2))
+             (newline 2))
 
 to this hook.
 
@@ -452,7 +453,7 @@ will not be rewrapped if their length exceeds this value."
   :group 'filesets)
 
 (defcustom filesets-max-entry-length 50
-  "Truncate names of splitted submenus to this length."
+  "Truncate names of split submenus to this length."
   :set (function filesets-set-default)
   :type 'integer
   :group 'filesets)
@@ -517,7 +518,7 @@ Caveat: Changes will take effect after rebuilding the menu."
 This is for calls via `filesets-find-or-display-file'
 or `filesets-find-file'.
 
-Set this to 0, if you don't use XEmacs' buffer tabs."
+Set this to 0, if you don't use XEmacs's buffer tabs."
   :set (function filesets-set-default)
   :type 'number
   :group 'filesets)
@@ -549,14 +550,14 @@ will be recursively added to the menu.  `filesets-tree-max-level' tells up
 to which level the directory structure should be scanned/listed,
 i.e. how deep the menu should be.  Try something like
 
-       \(\"HOME -- only one level\"
-        \(:tree \"~\" \"^[^.].*[^~]$\")
-        \(:tree-max-level 1)
-        \(:filter-dirs-flag t))
-       \(\"HOME -- up to 3 levels\"
-        \(:tree \"~\" \"^[^.].*[^~]$\")
-        \(:tree-max-level 3)
-        \(:filter-dirs-flag t))
+       (\"HOME -- only one level\"
+        (:tree \"~\" \"^[^.].*[^~]$\")
+        (:tree-max-level 1)
+        (:filter-dirs-flag t))
+       (\"HOME -- up to 3 levels\"
+        (:tree \"~\" \"^[^.].*[^~]$\")
+        (:tree-max-level 3)
+        (:filter-dirs-flag t))
 
 and it should become clear what this option is about.  In any case,
 including directory trees to the menu can take a lot of memory."
@@ -565,12 +566,18 @@ including directory trees to the menu can take a lot of memory."
   :group 'filesets)
 
 (defcustom filesets-commands
-  `(("Query Replace"
-     query-replace
+  `(("Isearch"
+     multi-isearch-files
+     (filesets-cmd-isearch-getargs))
+    ("Isearch (regexp)"
+     multi-isearch-files-regexp
+     (filesets-cmd-isearch-getargs))
+    ("Query Replace"
+     perform-replace
      (filesets-cmd-query-replace-getargs))
     ("Query Replace (regexp)"
-     query-replace-regexp
-     (filesets-cmd-query-replace-getargs))
+     perform-replace
+     (filesets-cmd-query-replace-regexp-getargs))
     ("Grep <<selection>>"
      "grep"
      ("-n " filesets-get-quoted-selection " " "<<file-name>>"))
@@ -672,20 +679,20 @@ variables my-ps-viewer, my-pdf-viewer, my-dvi-viewer, my-pic-viewer.
 In order to view pdf or rtf files in an Emacs buffer, you could use these:
 
 
-      \(\"^.+\\\\.pdf\\\\'\" \"pdftotext\"
-       \((:capture-output t)
-       \(:args (\"%S - | fmt -w \" window-width))
-       \(:ignore-on-read-text t)
-       \(:constraintp (lambda ()
-                       \(and \(filesets-which-command-p \"pdftotext\")
-                            \(filesets-which-command-p \"fmt\"))))))
-      \(\"^.+\\\\.rtf\\\\'\" \"rtf2htm\"
-       \((:capture-output t)
-       \(:args (\"%S 2> /dev/null | w3m -dump -T text/html\"))
-       \(:ignore-on-read-text t)
-       \(:constraintp (lambda ()
-                       \(and (filesets-which-command-p \"rtf2htm\")
-                            \(filesets-which-command-p \"w3m\"))))))"
+      (\"^.+\\\\.pdf\\\\\\='\" \"pdftotext\"
+       ((:capture-output t)
+       (:args (\"%S - | fmt -w \" window-width))
+       (:ignore-on-read-text t)
+       (:constraintp (lambda ()
+                       (and (filesets-which-command-p \"pdftotext\")
+                            (filesets-which-command-p \"fmt\"))))))
+      (\"^.+\\\\.rtf\\\\\\='\" \"rtf2htm\"
+       ((:capture-output t)
+       (:args (\"%S 2> /dev/null | w3m -dump -T text/html\"))
+       (:ignore-on-read-text t)
+       (:constraintp (lambda ()
+                       (and (filesets-which-command-p \"rtf2htm\")
+                            (filesets-which-command-p \"w3m\"))))))"
   :set (function filesets-set-default)
   :type '(repeat :tag "Viewer"
                 (list :tag "Definition"
@@ -749,7 +756,7 @@ In order to view pdf or rtf files in an Emacs buffer, you could use these:
 (defcustom filesets-ingroup-patterns
   '(("^.+\\.tex$" t
      (((:name "Package")
-       (:pattern "\\\\usepackage\\W*\\(\\[[^\]]*\\]\\W*\\)?{\\W*\\(.+\\)\\W*}")
+       (:pattern "\\\\usepackage\\W*\\(\\[[^]]*\\]\\W*\\)?{\\W*\\(.+\\)\\W*}")
        (:match-number 2)
        (:stub-flag t)
        (:get-file-name (lambda (master file)
@@ -798,8 +805,8 @@ In order to view pdf or rtf files in an Emacs buffer, you could use these:
        (:match-number 2)
        (:get-file-name (lambda (master file)
                         (filesets-which-file master file load-path))))))
-    ("^\\([A-ZÄÖÜ][a-zäöüß]+\\([A-ZÄÖÜ][a-zäöüß]+\\)+\\)$" t
-     (((:pattern "\\<\\([A-ZÄÖÜ][a-zäöüß]+\\([A-ZÄÖÜ][a-zäöüß]+\\)+\\)\\>")
+    ("^\\([A-ZÄÖÜ][a-zäöüß]+\\([A-ZÄÖÜ][a-zäöüß]+\\)+\\)$" t
+     (((:pattern "\\<\\([A-ZÄÖÜ][a-zäöüß]+\\([A-ZÄÖÜ][a-zäöüß]+\\)+\\)\\>")
        (:scan-depth 5)
        (:stubp (lambda (a b) (not (filesets-files-in-same-directory-p a b))))
        (:case-sensitive t)
@@ -841,10 +848,10 @@ subfile can't be found.
 in the pattern holding the subfile's name.  0 refers the whole
 match, 1 to the first group.
 
-:stubp FUNCTION ... if (FUNCTION MASTER INCLUDED-FILE) returns non-nil,
+:stubp FUNCTION ... If (FUNCTION MASTER INCLUDED-FILE) returns non-nil,
 INCLUDED-FILE is a stub -- see below.
 
-:stub-flag ... files of this type are stubs -- see below.
+:stub-flag ... Files of this type are stubs -- see below.
 
 :scan-depth INTEGER (default: 0) ... Whether included files should be
 rescanned.  Set this to 0 to disable re-scanning of included file.
@@ -944,18 +951,18 @@ variable will take effect after rebuilding the menu.
 Caveat: Fileset names have to be unique.
 
 Example definition:
-      '\(\(\"My Wiki\"
-        \(:ingroup \"~/Etc/My-Wiki/WikiContents\"))
-       \(\"My Homepage\"
-        \(:pattern \"~/public_html/\" \"^.+\\\\.html$\")
-        \(:open filesets-find-file))
-       \(\"User Configuration\"
-        \(:files \"~/.xinitrc\"
+      \\='((\"My Wiki\"
+        (:ingroup \"~/Etc/My-Wiki/WikiContents\"))
+       (\"My Homepage\"
+        (:pattern \"~/public_html/\" \"^.+\\\\.html$\")
+        (:open filesets-find-file))
+       (\"User Configuration\"
+        (:files \"~/.xinitrc\"
                 \"~/.bashrc\"
                 \"~/.bash_profile\"))
-       \(\"HOME\"
-        \(:tree \"~\" \"^[^.].*[^~]$\")
-        \(:filter-dirs-flag t)))
+       (\"HOME\"
+        (:tree \"~\" \"^[^.].*[^~]$\")
+        (:filter-dirs-flag t)))
 
 `filesets-data' is a list of (NAME-AS-STRING . DEFINITION), DEFINITION
 being an association list with the fields:
@@ -966,9 +973,11 @@ being an association list with the fields:
 
 :tree ROOT-DIR PATTERN ... a base directory and a file pattern
 
-:pattern DIR PATTERN ... PATTERN is a regular expression comprising path
-and file pattern -- e.g. 'PATH/^REGEXP$'.  Note the `^' at the beginning
-of the file name pattern.
+:pattern DIR PATTERN ... a base directory and a regexp matching
+                         files in that directory.  Usually,
+                         PATTERN has the form `^REGEXP$'.  Unlike
+                         :tree, this form does not descend
+                         recursively into subdirectories.
 
 :filter-dirs-flag BOOLEAN ... is only used in conjunction with :tree.
 
@@ -1073,7 +1082,7 @@ defined in `filesets-ingroup-patterns'."
 
     (require 'easymenu)
 
-    (defun filesets-error (class &rest args)
+    (defun filesets-error (_class &rest args)
       "`error' wrapper."
       (error "%s" (mapconcat 'identity args " ")))
 
@@ -1084,10 +1093,10 @@ defined in `filesets-ingroup-patterns'."
 If NEGATIVE is non-nil, remove all directory names."
   (filesets-filter-list lst
                        (lambda (x)
-                         (and (not (string-match "^\\.+/$" x))
+                         (and (not (string-match-p "^\\.+/$" x))
                               (if negative
-                                  (not (string-match "[:/\\]$" x))
-                                (string-match "[:/\\]$" x))))))
+                                  (not (string-match-p "[:/\\]$" x))
+                                (string-match-p "[:/\\]$" x))))))
 
 (defun filesets-conditional-sort (lst &optional access-fn)
   "Return a sorted copy of LST, LST being a list of strings.
@@ -1121,18 +1130,18 @@ Return full path if FULL-FLAG is non-nil."
          (dirs  nil))
       (dolist (this (file-name-all-completions "" dir))
        (cond
-        ((string-match "^\\.+/$" this)
+        ((string-match-p "^\\.+/$" this)
          nil)
-        ((string-match "[:/\\]$" this)
+        ((string-match-p "[:/\\]$" this)
          (when (or (not match-dirs-flag)
                    (not pattern)
-                   (string-match pattern this))
+                   (string-match-p pattern this))
            (filesets-message 5 "Filesets: matched dir %S with pattern %S"
                              this pattern)
            (setq dirs (cons this dirs))))
         (t
          (when (or (not pattern)
-                   (string-match pattern this))
+                   (string-match-p pattern this))
            (filesets-message 5 "Filesets: matched file %S with pattern %S"
                              this pattern)
            (setq files (cons (if full-flag
@@ -1240,7 +1249,7 @@ Return full path if FULL-FLAG is non-nil."
   (let ((filename (file-name-nondirectory file)))
     (filesets-some
      (lambda (entry)
-       (when (and (string-match (nth 0 entry) filename)
+       (when (and (string-match-p (nth 0 entry) filename)
                  (filesets-eviewer-constraint-p entry))
         entry))
      filesets-external-viewers)))
@@ -1268,20 +1277,20 @@ the \"Grep <<selection>>\" command
 
 on-capture-output (:capture-output) ... Capture output of an external viewer
 
-on-ls ... not used
+on-ls ... Not used
 
-on-cmd ... not used
+on-cmd ... Not used
 
-on-close-all ... not used"
+on-close-all ... Not used"
   (let ((def (filesets-eviewer-get-props
              (or entry
                  (filesets-get-external-viewer filename)))))
     (filesets-alist-get def
-                       (case event
-                         ((on-open-all)       ':ignore-on-open-all)
-                         ((on-grep)           ':ignore-on-read-text)
-                         ((on-cmd) nil)
-                         ((on-close-all) nil))
+                       (pcase event
+                         (`on-open-all       ':ignore-on-open-all)
+                         (`on-grep           ':ignore-on-read-text)
+                         (`on-cmd nil)
+                         (`on-close-all nil))
                        nil t)))
 
 (defun filesets-filetype-get-prop (property filename &optional entry)
@@ -1542,8 +1551,7 @@ First, save the buffer's contents using SAVE-FUNCTION.  Then, kill buffer
 if `buffer-modified-p' returns nil.
 
 SAVE-FUNCTION takes no argument, but works on the current buffer."
-  (save-excursion
-    (set-buffer buffer)
+  (with-current-buffer buffer
     (if (buffer-modified-p)
        (funcall save-function))
     (if (not (buffer-modified-p))
@@ -1551,11 +1559,9 @@ SAVE-FUNCTION takes no argument, but works on the current buffer."
 
 (defun filesets-get-fileset-from-name (name &optional mode)
   "Get fileset definition for NAME."
-  (case mode
-    ((:ingroup :tree)
-     name)
-    (t
-     (assoc name filesets-data))))
+  (pcase mode
+    ((or `:ingroup `:tree) name)
+    (_ (assoc name filesets-data))))
 
 
 ;;; commands
@@ -1623,38 +1629,40 @@ Replace <file-name> or <<file-name>> with filename."
        (when files
          (let ((fn   (filesets-cmd-get-fn cmd-name))
                (args (filesets-cmd-get-args cmd-name)))
-           (dolist (this files nil)
-             (save-excursion
-               (save-restriction
-                 (let ((buffer (filesets-find-file this)))
-                   (when buffer
-                     (goto-char (point-min))
-                     (let ()
-                       (cond
-                        ((stringp fn)
-                         (let* ((args
-                                 (let ((txt ""))
-                                   (dolist (this args txt)
-                                     (setq txt
-                                           (concat txt
-                                                   (filesets-run-cmd--repl-fn
-                                                    this
-                                                    (lambda (this)
-                                                      (if (equal txt "") "" " ")
-                                                      (format "%s" this))))))))
-                                (cmd (concat fn " " args)))
-                           (filesets-cmd-show-result
-                            cmd (shell-command-to-string cmd))))
-                        ((symbolp fn)
-                         (let ((args
-                                (let ((argl nil))
-                                  (dolist (this args argl)
-                                    (setq argl
-                                          (append argl
-                                                  (filesets-run-cmd--repl-fn
-                                                   this
-                                                   'list)))))))
-                           (apply fn args))))))))))))))))
+           (if (memq fn '(multi-isearch-files multi-isearch-files-regexp))
+               (apply fn args)
+             (dolist (this files nil)
+               (save-excursion
+                 (save-restriction
+                   (let ((buffer (filesets-find-file this)))
+                     (when buffer
+                       (goto-char (point-min))
+                       (progn
+                         (cond
+                          ((stringp fn)
+                           (let* ((args
+                                   (let ((txt ""))
+                                     (dolist (this args txt)
+                                       (setq txt
+                                             (concat txt
+                                                     (filesets-run-cmd--repl-fn
+                                                      this
+                                                      (lambda (this)
+                                                        (if (equal txt "") "" " ")
+                                                        (format "%s" this))))))))
+                                  (cmd (concat fn " " args)))
+                             (filesets-cmd-show-result
+                              cmd (shell-command-to-string cmd))))
+                          ((symbolp fn)
+                           (let ((args
+                                  (let ((argl nil))
+                                    (dolist (this args argl)
+                                      (setq argl
+                                            (append argl
+                                                    (filesets-run-cmd--repl-fn
+                                                     this
+                                                     'list)))))))
+                             (apply fn args)))))))))))))))))
 
 (defun filesets-get-cmd-menu ()
   "Create filesets command menu."
@@ -1668,16 +1676,19 @@ Replace <file-name> or <<file-name>> with filename."
 ;;; sample commands
 (defun filesets-cmd-query-replace-getargs ()
   "Get arguments for `query-replace' and `query-replace-regexp'."
-  (let* ((from-string (read-string "Filesets query replace: "
-                                  ""
-                                  'query-replace-history))
-        (to-string  (read-string
-                     (format "Filesets query replace %s with: " from-string)
-                     ""
-                     'query-replace-history))
-        (delimited  (y-or-n-p
-                     "Filesets query replace: respect word boundaries? ")))
-    (list from-string to-string delimited)))
+  (let ((common (query-replace-read-args "Filesets query replace" nil t)))
+    (list (nth 0 common) (nth 1 common) t nil (nth 2 common) nil
+         multi-query-replace-map)))
+
+(defun filesets-cmd-query-replace-regexp-getargs ()
+  "Get arguments for `query-replace' and `query-replace-regexp'."
+  (let ((common (query-replace-read-args "Filesets query replace" t t)))
+    (list (nth 0 common) (nth 1 common) t t (nth 2 common) nil
+         multi-query-replace-map)))
+
+(defun filesets-cmd-isearch-getargs ()
+  "Get arguments for `multi-isearch-files' and `multi-isearch-files-regexp'."
+  (and (boundp 'files) (list files)))
 
 (defun filesets-cmd-shell-command-getargs ()
   "Get arguments for `filesets-cmd-shell-command'."
@@ -1707,22 +1718,22 @@ Replace <file-name> or <<file-name>> with filename."
 Assume MODE (see `filesets-entry-mode'), if provided."
   (let* ((mode (or mode
                   (filesets-entry-mode entry)))
-        (fl (case mode
-              ((:files)
+        (fl (pcase mode
+              (:files
                (filesets-entry-get-files entry))
-              ((:file)
+              (:file
                (list (filesets-entry-get-file entry)))
-              ((:ingroup)
+              (:ingroup
                (let ((entry (expand-file-name
                              (if (stringp entry)
                                  entry
                                (filesets-entry-get-master entry)))))
                  (cons entry (filesets-ingroup-cache-get entry))))
-              ((:tree)
+              (:tree
                (let ((dir  (nth 0 entry))
                      (patt (nth 1 entry)))
                  (filesets-directory-files dir patt ':files t)))
-              ((:pattern)
+              (:pattern
                (let ((dirpatt (filesets-entry-get-pattern entry)))
                  (if dirpatt
                      (let ((dir (filesets-entry-get-pattern--dir dirpatt))
@@ -1756,7 +1767,7 @@ Use LOOKUP-NAME for searching additional data if provided."
                                    n name)))
              (dolist (this files nil)
                (filesets-file-open open-function this))
-           (message "Filesets: cancelled")))
+           (message "Filesets: canceled")))
       (filesets-error 'error "Filesets: Unknown fileset: " name))))
 
 (defun filesets-close (&optional mode name lookup-name)
@@ -1788,7 +1799,7 @@ User will be queried, if no fileset name is provided."
                     (current-buffer)))
         (name   (or name
                     (completing-read
-                     (format "Add '%s' to fileset: " buffer)
+                     (format-message "Add `%s' to fileset: " buffer)
                      filesets-data nil)))
          (entry  (or (assoc name filesets-data)
                      (when (y-or-n-p
@@ -1797,7 +1808,8 @@ User will be queried, if no fileset name is provided."
                        (progn
       (add-to-list 'filesets-data (list name '(:files)))
       (message
-       "Fileset %s created.  Call `M-x filesets-save-config' to save."
+       (substitute-command-keys
+        "Fileset %s created.  Call `\\[filesets-save-config]' to save.")
        name)
       (car filesets-data))))))
     (if entry
@@ -1807,13 +1819,13 @@ User will be queried, if no fileset name is provided."
                                        :test 'filesets-files-equalp)))
          (cond
           (inlist
-           (message "Filesets: '%s' is already in '%s'" this name))
+           (message "Filesets: `%s' is already in `%s'" this name))
           ((and (equal (filesets-entry-mode entry) ':files)
                 this)
            (filesets-entry-set-files entry (cons this files) t)
            (filesets-set-config name 'filesets-data filesets-data))
           (t
-           (message "Filesets: Can't add '%s' to fileset '%s'" this name)))))))
+           (message "Filesets: Can't add `%s' to fileset `%s'" this name)))))))
 
 (defun filesets-remove-buffer (&optional name buffer)
   "Remove BUFFER (or current buffer) to fileset NAME.
@@ -1823,7 +1835,7 @@ User will be queried, if no fileset name is provided."
                     (current-buffer)))
         (name   (or name
                     (completing-read
-                     (format "Remove '%s' from fileset: " buffer)
+                     (format-message "Remove `%s' from fileset: " buffer)
                      filesets-data nil t)))
                 (entry (assoc name filesets-data)))
     (if entry
@@ -1836,7 +1848,7 @@ User will be queried, if no fileset name is provided."
              (let ((new (list (cons ':files (delete (car inlist) files)))))
                (setcdr entry new)
                (filesets-set-config name 'filesets-data filesets-data))
-           (message "Filesets: Can't remove '%s' from fileset '%s'"
+           (message "Filesets: Can't remove `%s' from fileset `%s'"
                     this
                     name))))))
 
@@ -1891,12 +1903,12 @@ User will be queried, if no fileset name is provided."
       (let* ((result  nil)
             (factor (ceiling (/ (float bl)
                                 filesets-max-submenu-length))))
-       (do ((data  submenu-body (cdr data))
-            (n     1            (+ n 1))
-            (count 0            (+ count factor)))
+       (cl-do ((data  submenu-body (cdr data))
+                (n     1            (+ n 1))
+                (count 0            (+ count factor)))
            ((or (> count bl)
                 (null data)))
-;        (let ((sl (subseq submenu-body count
+         ;; (let ((sl (subseq submenu-body count
          (let ((sl (filesets-sublist submenu-body count
                                      (let ((x (+ count factor)))
                                        (if (>= bl x)
@@ -1913,7 +1925,7 @@ User will be queried, if no fileset name is provided."
                       `((,(concat
                            (filesets-get-shortcut n)
                            (let ((rv ""))
-                             (do ((x sl (cdr x)))
+                             (cl-do ((x sl (cdr x)))
                                  ((null x))
                                (let ((y (concat (elt (car x) 0)
                                                 (if (null (cdr x))
@@ -1939,8 +1951,8 @@ User will be queried, if no fileset name is provided."
   "Get submenu epilog for SOMETHING (usually a fileset).
 If mode is :tree or :ingroup, SOMETHING is some weird construct and
 LOOKUP-NAME is used as lookup name for retrieving fileset specific settings."
-  (case mode
-    ((:tree)
+  (pcase mode
+    (:tree
      `("---"
        ["Close all files" (filesets-close ',mode ',something ',lookup-name)]
        ["Run Command"     (filesets-run-cmd nil ',something ',mode)]
@@ -1949,14 +1961,14 @@ LOOKUP-NAME is used as lookup name for retrieving fileset specific settings."
        ,@(when rebuild-flag
           `(["Rebuild this submenu"
              (filesets-rebuild-this-submenu ',lookup-name)]))))
-    ((:ingroup)
+    (:ingroup
      `("---"
        ["Close all files" (filesets-close ',mode ',something ',lookup-name)]
        ["Run Command"     (filesets-run-cmd nil ',something ',mode)]
        ,@(when rebuild-flag
           `(["Rebuild this submenu"
              (filesets-rebuild-this-submenu ',lookup-name)]))))
-    ((:pattern)
+    (:pattern
      `("---"
        ["Close all files" (filesets-close ',mode ',something)]
        ["Run Command"     (filesets-run-cmd nil ',something ',mode)]
@@ -1973,7 +1985,7 @@ LOOKUP-NAME is used as lookup name for retrieving fileset specific settings."
        ,@(when rebuild-flag
           `(["Rebuild this submenu"
              (filesets-rebuild-this-submenu ',lookup-name)]))))
-    ((:files)
+    (:files
      `("---"
        [,(concat "Close all files") (filesets-close ',mode ',something)]
        ["Run Command"               (filesets-run-cmd nil ',something ',mode)]
@@ -1984,7 +1996,7 @@ LOOKUP-NAME is used as lookup name for retrieving fileset specific settings."
        ,@(when rebuild-flag
           `(["Rebuild this submenu"
              (filesets-rebuild-this-submenu ',lookup-name)]))))
-    (t
+    (_
      (filesets-error 'error "Filesets: malformed definition of " something))))
 
 (defun filesets-ingroup-get-data (master pos &optional fun)
@@ -1993,7 +2005,7 @@ LOOKUP-NAME is used as lookup name for retrieving fileset specific settings."
        (fn (or fun (lambda (a b)
                      (and (stringp a)
                           (stringp b)
-                          (string-match a b))))))
+                          (string-match-p a b))))))
     (filesets-some (lambda (x)
                     (if (funcall fn (car x) masterfile)
                         (nth pos x)
@@ -2236,15 +2248,15 @@ Construct a shortcut from COUNT."
          (filesets-verbosity (filesets-entry-get-verbosity entry))
          (this-lookup-name (concat (filesets-get-shortcut count)
                                    lookup-name)))
-      (case mode
-       ((:file)
+      (pcase mode
+       (:file
         (let* ((file (filesets-entry-get-file entry)))
           `[,this-lookup-name
             (filesets-file-open nil ',file ',lookup-name)]))
-       (t
+       (_
         `(,this-lookup-name
-          ,@(case mode
-              ((:pattern)
+          ,@(pcase mode
+              (:pattern
                (let* ((files    (filesets-get-filelist entry mode 'on-ls))
                       (dirpatt  (filesets-entry-get-pattern entry))
                       (pattname (apply 'concat (cons "Pattern: " dirpatt)))
@@ -2263,7 +2275,7 @@ Construct a shortcut from COUNT."
                        files))
                    ,@(filesets-get-menu-epilog lookup-name mode
                                                lookup-name t))))
-              ((:ingroup)
+              (:ingroup
                (let* ((master (filesets-entry-get-master entry)))
                  ;;(filesets-message 3 "Filesets: parsing %S" master)
                  `([,(concat "Inclusion Group: "
@@ -2275,12 +2287,12 @@ Construct a shortcut from COUNT."
                    ,@(filesets-wrap-submenu
                       (filesets-build-ingroup-submenu lookup-name master))
                    ,@(filesets-get-menu-epilog master mode lookup-name t))))
-              ((:tree)
+              (:tree
                (let* ((dirpatt (filesets-entry-get-tree entry))
                       (dir     (car dirpatt))
                       (patt    (cadr dirpatt)))
                  (filesets-build-dir-submenu entry lookup-name dir patt)))
-              ((:files)
+              (:files
                (let ((files (filesets-get-filelist entry mode 'on-open-all))
                      (count 0))
                  `([,(concat "Files: " lookup-name)
@@ -2318,9 +2330,9 @@ bottom up, set `filesets-submenus' to nil, first.)"
     (setq filesets-has-changed-flag nil)
     (setq filesets-updated-buffers nil)
     (setq filesets-update-cache-file-flag t)
-    (do ((data  (filesets-conditional-sort filesets-data (function car))
-               (cdr data))
-        (count 1 (+ count 1)))
+    (cl-do ((data  (filesets-conditional-sort filesets-data (function car))
+                   (cdr data))
+            (count 1 (+ count 1)))
        ((null data))
       (let* ((this    (car data))
             (name    (filesets-data-get-name this))
@@ -2405,7 +2417,7 @@ fileset thinks this is necessary or not."
       (when filesets-cache-hostname-flag
        (insert (format "(setq filesets-cache-hostname %S)" (system-name)))
        (newline 2))
-      (run-hooks 'filesets-cache-fill-content-hooks)
+      (run-hooks 'filesets-cache-fill-content-hook)
       (write-file filesets-menu-cache-file))
     (setq filesets-has-changed-flag nil)
     (setq filesets-update-cache-file-flag nil)))
@@ -2425,11 +2437,11 @@ fileset thinks this is necessary or not."
   (filesets-menu-cache-file-load))
 
 (defun filesets-update-pre010505 ()
-  (let ((msg
+  (let ((msg (format-message
 "Filesets: manual editing of user data required!
 
 Filesets has detected that you were using an older version before,
-which requires some manual updating. Type 'y' for editing the startup
+which requires some manual updating. Type `y' for editing the startup
 file now.
 
 The layout of `filesets-data' has changed. Please delete your cache file
@@ -2438,13 +2450,13 @@ and edit your startup file as shown below:
 1. `filesets-data': Edit all :pattern filesets in your startup file and
 transform all entries as shown in this example:
 
-       \(\"Test\" (:pattern \"~/dir/^pattern$\"))
-       --> \(\"Test\" (:pattern \"~/dir/\" \"^pattern$\"))
+       (\"Test\" (:pattern \"~/dir/^pattern$\"))
+       --> (\"Test\" (:pattern \"~/dir/\" \"^pattern$\"))
 
 2. `filesets-data': Change all occurrences of \":document\" to \":ingroup\":
 
-      \(\(\"Test\" \(:document \"~/dir/file\"))
-      --> \(\(\"Test\" \(:ingroup \"~/dir/file\"))
+      ((\"Test\" (:document \"~/dir/file\"))
+      --> ((\"Test\" (:ingroup \"~/dir/file\"))
 
 3. `filesets-subdocument-patterns': If you already modified the variable
 previously called `filesets-subdocument-patterns', change its name to
@@ -2456,7 +2468,7 @@ variable, change the entry `filesets-subdocument--cache' to
 
 5. Type M-x filesets-update-cleanup and restart Emacs.
 
-We apologize for the inconvenience."))
+We apologize for the inconvenience.")))
     (let* ((cf (or custom-file user-init-file)))
       (switch-to-buffer-other-frame "*Filesets update*")
       (insert msg)
@@ -2520,5 +2532,4 @@ Set up hooks, load the cache file -- if existing -- and build the menu."
 ;; sentence-end-double-space:t
 ;; End:
 
-;; arch-tag: 2c03f85f-c3df-4cec-b0a3-b46fd5592d70
 ;;; filesets.el ends here