]> git.eshelyaron.com Git - emacs.git/commitdiff
Deprecate 'completion-regexp-list'
authorEshel Yaron <me@eshelyaron.com>
Sat, 2 Mar 2024 10:53:15 +0000 (11:53 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sat, 2 Mar 2024 10:53:15 +0000 (11:53 +0100)
This variable doesn't provide any distinct functionality,
because the completion predicate supports regular expression
matching as a special case.  It's also unused except for one
command, where it causes bugs (see Bug#69501).  All in all,
'completion-regexp-list' doesn't carry its own weight.

14 files changed:
doc/lispref/minibuf.texi
lisp/cus-edit.el
lisp/custom.el
lisp/emacs-lisp/regexp-opt.el
lisp/files.el
lisp/minibuffer.el
lisp/net/tramp-crypt.el
lisp/net/tramp.el
lisp/progmodes/idlwave.el
src/dired.c
src/minibuf.c
test/lisp/net/tramp-archive-tests.el
test/lisp/net/tramp-tests.el
test/src/minibuf-tests.el

index 7d5e6678cbb970f05c074379dcad4a5a9ffd9ece..c7e445af5178330b46447c5004f9c3117a08d716 100644 (file)
@@ -854,11 +854,6 @@ name) from the obarray.  If @var{collection} is a hash table,
 @var{predicate} is called with two arguments, the string key and the
 associated value.
 
-In addition, to be acceptable, a completion must also match all the
-regular expressions in @code{completion-regexp-list}.  (Unless
-@var{collection} is a function, in which case that function has to
-handle @code{completion-regexp-list} itself.)
-
 In the first of the following examples, the string @samp{foo} is
 matched by three of the alist @sc{car}s.  All of the matches begin with
 the characters @samp{fooba}, so that is the result.  In the second
@@ -911,20 +906,10 @@ too short).  Both of those begin with the string @samp{foobar}.
 @end smallexample
 @end defun
 
-@c Removed obsolete argument nospace.
 @defun all-completions string collection &optional predicate
 This function returns a list of all possible completions of
 @var{string}.  The arguments to this function
-@c (aside from @var{nospace})
-are the same as those of @code{try-completion}, and it
-uses @code{completion-regexp-list} in the same way that
-@code{try-completion} does.
-
-@ignore
-The optional argument @var{nospace} is obsolete.  If it is
-non-@code{nil}, completions that start with a space are ignored unless
-@var{string} starts with a space.
-@end ignore
+are the same as those of @code{try-completion}.
 
 If @var{collection} is a function, it is called with three arguments:
 @var{string}, @var{predicate} and @code{t}; then @code{all-completions}
@@ -959,9 +944,6 @@ completion alternative specified by @var{collection} and
 strings, this is true if @var{string} appears in the list and
 @var{predicate} is satisfied.
 
-This function uses @code{completion-regexp-list} in the same
-way that @code{try-completion} does.
-
 If @var{predicate} is non-@code{nil} and if @var{collection} contains
 several strings that are equal to each other, as determined by
 @code{compare-strings} according to @code{completion-ignore-case},
@@ -1010,19 +992,6 @@ Names}); within @code{read-buffer}, it is overridden by
 Completion}).
 @end defvar
 
-@defvar completion-regexp-list
-This is a list of regular expressions.  The completion functions only
-consider a completion acceptable if it matches all regular expressions
-in this list, with @code{case-fold-search} (@pxref{Searching and Case})
-bound to the value of @code{completion-ignore-case}.
-
-Do not set this variable to a non-@code{nil} value globally, as that
-is not safe and will probably cause errors in completion commands.
-This variable should be only let-bound to non-@code{nil} values around
-calls to basic completion functions: @code{try-completion},
-@code{test-completion}, and @code{all-completions}.
-@end defvar
-
 @defmac lazy-completion-table var fun
 This macro provides a way to initialize the variable @var{var} as a
 collection for completion in a lazy way, not computing its actual
index 8717133674393b278e4b9ede6dc140e5f28fc7ef..50453d96252a68bcfa5b9fd126392acab6f4cb76 100644 (file)
@@ -1163,8 +1163,7 @@ argument or if the current major mode has no known group, prompt
 for the MODE to customize."
   (interactive
    (list
-    (let ((completion-regexp-list '("-mode\\'"))
-         (group (custom-group-of-mode major-mode)))
+    (let ((group (custom-group-of-mode major-mode)))
       (if (and group (not current-prefix-arg))
          major-mode
        (intern
index a19b14aaf8a0788fe2471d886c2882aa1ac01566..3808165fca8ebb6bbb163da0db35aa9e6077772c 100644 (file)
@@ -554,11 +554,10 @@ If there already is an entry for OPTION and WIDGET, nothing is done."
   "Return the custom group corresponding to the major or minor MODE.
 If no such group is found, return nil."
   (or (get mode 'custom-mode-group)
-      (if (or (get mode 'custom-group)
-             (and (string-match "-mode\\'" (symbol-name mode))
-                  (get (setq mode (intern (substring (symbol-name mode)
-                                                     0 (match-beginning 0))))
-                       'custom-group)))
+      (if (and (string-match "-mode\\'" (symbol-name mode))
+              (get (setq mode (intern (substring (symbol-name mode)
+                                                 0 (match-beginning 0))))
+                   'custom-group))
          mode)))
 
 ;;; Properties.
index 59c1b7d8e103c6c40a16ee3b45566afc06d50363..793c130f437e1c4b155f9ea351dd7215e3e3b60e 100644 (file)
@@ -135,7 +135,6 @@ usually more efficient than that of a simplified version:
     ;; Recurse on the sorted list.
     (let* ((max-lisp-eval-depth 10000)
           (completion-ignore-case nil)
-          (completion-regexp-list nil)
           (open (cond ((stringp paren) paren) (paren "\\(")))
           (re (if strings
                    (regexp-opt-group
index 543ef6c3615ef920a0dec60bdc0bd2031a629cf1..8bcce8e4971c09ba5befa482ae90ddd8a58e460a 100644 (file)
@@ -1099,12 +1099,11 @@ one or more of those symbols."
                 (push file names)
               (push file fullnames)
               (push (substring file 0 (match-beginning 0)) names)))))
-      ;; Switching from names to names+fullnames creates a non-monotonicity
-      ;; which can cause problems with things like partial-completion.
-      ;; To minimize the problem, filter out completion-regexp-list, so that
-      ;; M-x load-library RET t/x.e TAB finds some files.  Also remove elements
-      ;; from `names' that matched `string' only when they still had
-      ;; their suffix.
+      ;; Switching from names to names+fullnames creates a
+      ;; non-monotonicity which can cause problems with things like
+      ;; partial-completion.  To minimize the problem, filter out
+      ;; elements from `names' that matched `string' only when they
+      ;; still had their suffix.
       (setq names (all-completions string-file names))
       ;; Remove duplicates of the first element, so that we can easily check
       ;; if `names' really contains only a single element.
index d4aa002e35a7651a37f1624c85ad051501064f33..d8fa1100c2f155f75ae108758d84c6e9561d270c 100644 (file)
@@ -684,9 +684,8 @@ METADATA takes precedence over any metadata that TABLE provides."
   (when completions
     (pcase-let*
         ((prefix
-          (let ((completion-regexp-list nil))
-            (try-completion "" (cons (substring ustring boundary)
-                                     completions))))
+          (try-completion "" (cons (substring ustring boundary)
+                                   completions)))
          (`(,qfullpos . ,qfun)
           (funcall requote (+ boundary (length prefix)) string))
          (qfullprefix (substring string 0 qfullpos))
@@ -4564,18 +4563,14 @@ PATTERN is as returned by `completion-pcm--string->pattern'."
     (let* (;; Convert search pattern to a standard regular expression.
           (regex (completion-pcm--pattern->regex pattern))
            (case-fold-search completion-ignore-case)
-           (completion-regexp-list (cons regex completion-regexp-list))
           (compl (all-completions
                    (concat prefix
                            (if (stringp (car pattern)) (car pattern) ""))
                   table pred)))
-      (if (not (functionp table))
-         ;; The internal functions already obeyed completion-regexp-list.
-         compl
-       (let ((poss ()))
-         (dolist (c compl)
-           (when (string-match-p regex c) (push c poss)))
-         (nreverse poss))))))
+      (let ((poss ()))
+       (dolist (c compl)
+         (when (string-match-p regex c) (push c poss)))
+       (nreverse poss)))))
 
 (defvar flex-score-match-tightness 3
   "Controls how the `flex' completion style scores its matches.
@@ -6022,6 +6017,8 @@ This applies to `completions-auto-update-mode', which see."
     (remove-hook 'minibuffer-setup-hook #'completions-auto-update-setup)
     (remove-hook 'minibuffer-exit-hook #'completions-auto-update-exit)))
 
-(provide 'minibuffer)
+(defvar completion-regexp-list nil "Unused obsolete variable.")
+(make-obsolete-variable 'completion-regexp-list nil "30.1")
 
+(provide 'minibuffer)
 ;;; minibuffer.el ends here
index a7af64bff5c73cac4dfe965dcc3bf4a6f2a07496..5a605d7a72843c7714685e1e647496eb11342641 100644 (file)
@@ -744,8 +744,7 @@ absolute file names."
   (tramp-skeleton-file-name-all-completions filename directory
     (all-completions
      filename
-     (let* (completion-regexp-list
-           tramp-crypt-enabled
+     (let* (tramp-crypt-enabled
            (directory (file-name-as-directory directory))
            (enc-dir (tramp-crypt-encrypt-file-name directory)))
        (mapcar
index 4aceb7ea356c925261f338064b92c850c3f7dc97..6e74ec320b41d315c329487199d26b8b2548d627 100644 (file)
@@ -2766,16 +2766,7 @@ BODY is the backend specific code."
           (dolist (elt '(".." "."))
             (when (string-prefix-p ,filename elt)
               (setq result (cons (concat elt "/") result)))))
-        (if (consp completion-regexp-list)
-            ;; Discriminate over `completion-regexp-list'.
-            (mapcar
-             (lambda (x)
-               (when (stringp x)
-                 (catch 'match
-                   (dolist (elt completion-regexp-list x)
-                     (unless (string-match-p elt x) (throw 'match nil))))))
-             result)
-          result))))))
+        result)))))
 
 (defvar tramp--last-hop-directory nil
   "Tracks the directory from which to run login programs.")
index 30442fa0d3442f866b62309c24be3f9a38b71cc5..b9766bdbeb72bd578a1093726bbbc657ec47a295 100644 (file)
@@ -5726,9 +5726,6 @@ Possible values are:
 As a special case, the universal argument \\[universal-argument] forces completion of
 function names in places where the default would be a keyword.
 
-Two prefix argument, \\[universal-argument] \\[universal-argument], prompts for a regexp by which to limit
-completion.
-
 For Lisp programmers only:
 When we force a keyword, optional argument MODULE can contain the module name.
 When we force a method or a method keyword, CLASS can specify the class."
@@ -5741,10 +5738,7 @@ When we force a method or a method keyword, CLASS can specify the class."
              (idlwave-make-force-complete-where-list arg module class)
            (idlwave-where)))
         (what (nth 2 where-list))
-        (idlwave-force-class-query (equal arg '(4)))
-        (completion-regexp-list
-         (if (equal arg '(16))
-             (list (read-string (concat "Completion Regexp: "))))))
+        (idlwave-force-class-query (equal arg '(4))))
 
     (if (and module (string-match "::" module))
        (setq class (substring module 0 (match-beginning 0))
index 9a372201ae0b5c349368d9d40db519d59c0692ca..0f2872c64700ee74cc4461ae0204b31150d177ce 100644 (file)
@@ -442,10 +442,8 @@ Returns nil if DIRECTORY contains no name starting with FILE.
 If PREDICATE is non-nil, call PREDICATE with each possible
 completion (in absolute form) and ignore it if PREDICATE returns nil.
 
-This function ignores some of the possible completions as determined
-by the variables `completion-regexp-list' and
-`completion-ignored-extensions', which see.  `completion-regexp-list'
-is matched against file and directory names relative to DIRECTORY.  */)
+This function ignores some of the possible completions as determined by
+the variable `completion-ignored-extensions', which see.  */)
   (Lisp_Object file, Lisp_Object directory, Lisp_Object predicate)
 {
   Lisp_Object handler;
@@ -469,11 +467,7 @@ is matched against file and directory names relative to DIRECTORY.  */)
 DEFUN ("file-name-all-completions", Ffile_name_all_completions,
        Sfile_name_all_completions, 2, 2, 0,
        doc: /* Return a list of all completions of file name FILE in directory DIRECTORY.
-These are all file names in directory DIRECTORY which begin with FILE.
-
-This function ignores some of the possible completions as determined
-by `completion-regexp-list', which see.  `completion-regexp-list'
-is matched against file and directory names relative to DIRECTORY.  */)
+These are all file names in directory DIRECTORY which begin with FILE.  */)
   (Lisp_Object file, Lisp_Object directory)
 {
   Lisp_Object handler;
@@ -730,17 +724,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
            }
        }
 
-      Lisp_Object regexps, table = (completion_ignore_case
-                                   ? Vascii_canon_table : Qnil);
-
-      /* Ignore this element if it fails to match all the regexps.  */
-      for (regexps = Vcompletion_regexp_list; CONSP (regexps);
-          regexps = XCDR (regexps))
-       if (fast_string_match_internal (XCAR (regexps), name, table) < 0)
-         break;
-
-      if (CONSP (regexps))
-       continue;
+      Lisp_Object table = (completion_ignore_case ? Vascii_canon_table : Qnil);
 
       /* This is a possible completion */
       if (directoryp)
index d59d74addbec55f57cba6c04dde7fd97e28c7dd0..d02e87e417b499fd89fdd565747c4d812139eebe 100644 (file)
@@ -1544,27 +1544,6 @@ behavior.  */)
   return unbind_to (count, result);
 }
 \f
-static bool
-match_regexps (Lisp_Object string, Lisp_Object regexps,
-              bool ignore_case)
-{
-  ptrdiff_t val;
-  for (; CONSP (regexps); regexps = XCDR (regexps))
-    {
-      CHECK_STRING (XCAR (regexps));
-
-      val = fast_string_match_internal
-       (XCAR (regexps), string,
-        (ignore_case ? BVAR (current_buffer, case_canon_table) : Qnil));
-
-      if (val == -2)
-       error ("Stack overflow in regexp matcher");
-      if (val < 0)
-       return false;
-    }
-  return true;
-}
-
 DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0,
        doc: /* Return longest common substring of all completions of STRING in COLLECTION.
 
@@ -1599,10 +1578,6 @@ car is a string) from the alist, or a symbol from the obarray.
 If COLLECTION is a hash-table, PREDICATE is called with two arguments:
 the string key and the associated value.
 
-To be acceptable, a possible completion must also match all the regexps
-in `completion-regexp-list' (unless COLLECTION is a function, in
-which case that function should itself handle `completion-regexp-list').
-
 If `completion-ignore-case' is non-nil, possible completions are matched
 while ignoring letter-case, but no guarantee is made about the letter-case
 of the return value, except that it comes either from the user's input
@@ -1687,11 +1662,6 @@ or from one of the possible completions.  */)
                                      completion_ignore_case ? Qt : Qnil),
              EQ (Qt, tem)))
        {
-         /* Ignore this element if it fails to match all the regexps.  */
-         if (!match_regexps (eltstring, Vcompletion_regexp_list,
-                             completion_ignore_case))
-           continue;
-
          /* Ignore this element if there is a predicate
             and the predicate doesn't like it.  */
 
@@ -1832,10 +1802,6 @@ car is a string) from the alist, or a symbol from the obarray.
 If COLLECTION is a hash-table, PREDICATE is called with two arguments:
 the string key and the associated value.
 
-To be acceptable, a possible completion must also match all the regexps
-in `completion-regexp-list' (unless COLLECTION is a function, in
-which case that function should itself handle `completion-regexp-list').
-
 An obsolete optional fourth argument HIDE-SPACES is still accepted for
 backward compatibility.  If non-nil, strings in COLLECTION that start
 with a space are ignored unless STRING itself starts with a space.  */)
@@ -1917,11 +1883,6 @@ with a space are ignored unless STRING itself starts with a space.  */)
                                      completion_ignore_case ? Qt : Qnil),
              EQ (Qt, tem)))
        {
-         /* Ignore this element if it fails to match all the regexps.  */
-         if (!match_regexps (eltstring, Vcompletion_regexp_list,
-                             completion_ignore_case))
-           continue;
-
          /* Ignore this element if there is a predicate
             and the predicate doesn't like it.  */
 
@@ -2096,11 +2057,6 @@ the values STRING, PREDICATE and `lambda'.  */)
   else
     return call3 (collection, string, predicate, Qlambda);
 
-  /* Reject this element if it fails to match all the regexps.  */
-  if (!match_regexps (string, Vcompletion_regexp_list,
-                     completion_ignore_case))
-    return Qnil;
-
   /* Finally, check the predicate.  */
   if (!NILP (predicate))
     {
@@ -2381,20 +2337,6 @@ is added with
 Some uses of the echo area also raise that frame (since they use it too).  */);
   minibuffer_auto_raise = 0;
 
-  DEFVAR_LISP ("completion-regexp-list", Vcompletion_regexp_list,
-              doc: /* List of regexps that should restrict possible completions.
-The basic completion functions only consider a completion acceptable
-if it matches all regular expressions in this list, with
-`case-fold-search' bound to the value of `completion-ignore-case'.
-See Info node `(elisp)Basic Completion', for a description of these
-functions.
-
-Do not set this variable to a non-nil value globally, as that is not
-safe and will probably cause errors in completion commands.  This
-variable should be only let-bound to non-nil values around calls to
-basic completion functions like `try-completion' and `all-completions'.  */);
-  Vcompletion_regexp_list = Qnil;
-
   DEFVAR_BOOL ("minibuffer-allow-text-properties",
               minibuffer_allow_text_properties,
               doc: /* Whether `read-from-minibuffer' preserves text properties.  */);
index 1ca2fa9b9b394b8206ee31af160640c87de51adf..b11292dc774dbea25d83a6d98d760cb0355b20f1 100644 (file)
@@ -808,45 +808,6 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
       ;; Cleanup.
       (tramp-archive-cleanup-hash))))
 
-(ert-deftest tramp-archive-test26-file-name-completion ()
-  "Check `file-name-completion' and `file-name-all-completions'."
-  :tags '(:expensive-test)
-  (skip-unless tramp-archive-enabled)
-
-  (let ((tmp-name tramp-archive-test-archive))
-    (unwind-protect
-       (progn
-         ;; Local files.
-         (should (equal (file-name-completion "fo" tmp-name) "foo."))
-         (should (equal (file-name-completion "foo.txt" tmp-name) t))
-         (should (equal (file-name-completion "b" tmp-name) "ba"))
-         (should-not (file-name-completion "a" tmp-name))
-         (should
-          (equal
-           (file-name-completion "b" tmp-name #'file-directory-p) "bar/"))
-         (should
-          (equal
-           (sort (file-name-all-completions "fo" tmp-name) #'string-lessp)
-           '("foo.hrd" "foo.lnk" "foo.txt")))
-         (should
-          (equal
-           (sort (file-name-all-completions "b" tmp-name) #'string-lessp)
-           '("bar/" "baz.tar")))
-         (should-not (file-name-all-completions "a" tmp-name))
-         ;; `completion-regexp-list' restricts the completion to
-         ;; files which match all expressions in this list.
-         (let ((completion-regexp-list
-                `(,directory-files-no-dot-files-regexp "b")))
-           (should
-            (equal (file-name-completion "" tmp-name) "ba"))
-           (should
-            (equal
-             (sort (file-name-all-completions "" tmp-name) #'string-lessp)
-             '("bar/" "baz.tar")))))
-
-      ;; Cleanup.
-      (tramp-archive-cleanup-hash))))
-
 (ert-deftest tramp-archive-test40-make-nearby-temp-file ()
   "Check `make-nearby-temp-file' and `temporary-file-directory'."
   (skip-unless tramp-archive-enabled)
index cdd2a1efdb29c164380c0bfb313fc2176da8f743..7a062071f70772c0e3293ed74cba9f39612803ef 100644 (file)
@@ -4813,20 +4813,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
               (equal
                (sort (file-name-all-completions "b" tmp-name) #'string-lessp)
                '("bold" "boz/")))
-             (should-not (file-name-all-completions "a" tmp-name))
-             ;; `completion-regexp-list' restricts the completion to
-             ;; files which match all expressions in this list.
-             ;; Ange-FTP does not complete "".
-             (unless (tramp--test-ange-ftp-p)
-               (let ((completion-regexp-list
-                      `(,directory-files-no-dot-files-regexp "b")))
-                 (should
-                  (equal (file-name-completion "" tmp-name) "bo"))
-                 (should
-                  (equal
-                   (sort
-                    (file-name-all-completions "" tmp-name) #'string-lessp)
-                   '("bold" "boz/")))))
+             (should-not (file-name-all-completions "a" tmp-name))))
              ;; `file-name-completion' ignores file names that end in
              ;; any string in `completion-ignored-extensions'.
              (let ((completion-ignored-extensions '(".ext")))
index b790c7fa02a7d0fbc9a3913f52a5b9990a432bb5..2712ffb1a3ade3b69a27427db0cd18116a770887 100644 (file)
     (should-not (try-completion "abc" +abba #'ignore))
     (should-not (try-completion "abcd" +abba #'ignore))))
 
-(defun minibuf-tests--try-completion-regexp (xform-collection)
-  (let ((abcdef (funcall xform-collection '("abc" "def")))
-        (+abba  (funcall xform-collection '("abc" "abba" "def"))))
-    (let ((completion-regexp-list '(".")))
-      (should (equal (try-completion "a" abcdef) "abc"))
-      (should (equal (try-completion "a" +abba) "ab"))
-      (should (equal (try-completion "abc" +abba) t))
-      (should (equal (try-completion "abcd" +abba) nil)))
-    (let ((completion-regexp-list '("X")))
-      (should-not (try-completion "a" abcdef))
-      (should-not (try-completion "a" +abba))
-      (should-not (try-completion "abc" +abba))
-      (should-not (try-completion "abcd" +abba)))))
-
 (defun minibuf-tests--all-completions (xform-collection)
   (let* ((abcdef (funcall xform-collection '("abc" "def")))
          (+abba  (funcall xform-collection '("abc" "abba" "def"))))
     (should-not (all-completions "abc" +abba #'ignore))
     (should-not (all-completions "abcd" +abba #'ignore))))
 
-(defun minibuf-tests--all-completions-regexp (xform-collection)
-  (let ((abcdef (funcall xform-collection '("abc" "def")))
-        (+abba  (funcall xform-collection '("abc" "abba" "def"))))
-    (let ((completion-regexp-list '(".")))
-      (should (equal (all-completions "a" abcdef) '("abc")))
-      (should (minibuf-tests--set-equal (all-completions "a" +abba)
-                                        '("abc" "abba")))
-      (should (equal (all-completions "abc" +abba) '("abc")))
-      (should (equal (all-completions "abcd" +abba) nil)))
-    (let ((completion-regexp-list '("X")))
-      (should-not (all-completions "a" abcdef))
-      (should-not (all-completions "a" +abba))
-      (should-not (all-completions "abc" +abba))
-      (should-not (all-completions "abcd" +abba)))))
-
 (defun minibuf-tests--test-completion (xform-collection)
   (let* ((abcdef (funcall xform-collection '("abc" "def")))
          (+abba  (funcall xform-collection '("abc" "abba" "def"))))
     (should-not (test-completion "abba" +abba #'ignore))
     (should-not (test-completion "abcd" +abba #'ignore))))
 
-(defun minibuf-tests--test-completion-regexp (xform-collection)
-  (let ((abcdef (funcall xform-collection '("abc" "def")))
-        (+abba  (funcall xform-collection '("abc" "abba" "def"))))
-    (let ((completion-regexp-list '(".")))
-      (should (test-completion "abc" abcdef))
-      (should (test-completion "def" +abba))
-      (should (test-completion "abba" +abba))
-      (should-not (test-completion "abcd" +abba)))
-    (let ((completion-regexp-list '("X")))
-      (should-not (test-completion "abc" abcdef))
-      (should-not (test-completion "def" +abba))
-      (should-not (test-completion "abba" +abba))
-      (should-not (test-completion "abcd" +abba)))))
-
 \f
 ;;; Tests for `try-completion'.
 (ert-deftest try-completion-string-list ()