]> git.eshelyaron.com Git - emacs.git/commitdiff
Remedy wrong-looking \(:?...\) regexp constructs
authorMattias Engdegård <mattiase@acm.org>
Wed, 16 Aug 2023 11:33:48 +0000 (13:33 +0200)
committerMattias Engdegård <mattiase@acm.org>
Wed, 16 Aug 2023 14:55:38 +0000 (16:55 +0200)
When we see \(:?...\) in a regexp it very much looks like a typo
for a \(?:...\) construct and often is, so do something about
all of these (one of which being another mistake).
Doing so silences an optional relint check.

* lisp/comint.el (comint-replace-by-expanded-history-before-point):
* lisp/term.el (term-replace-by-expanded-history-before-point):
Move :? out from capturing group where it does not need to be,
to avoid confusion.
* lisp/emacs-lisp/cl-indent.el (common-lisp-loop-part-indentation):
A capturing group isn't needed here; turn it into simple bracketing.
* lisp/progmodes/sql.el (sql--completion-table):
Change :? into ?: which was clearly meant here.

lisp/comint.el
lisp/emacs-lisp/cl-indent.el
lisp/progmodes/sql.el
lisp/term.el

index 5161d01515c01e238effa934d286fbdfac3becb1..777795bcb46505806d0dd755525ee8744382be5c 100644 (file)
@@ -1440,7 +1440,7 @@ actual side-effect."
                (if dry-run (throw dry-run 'message))
               (goto-char (match-end 0))
               (message "Absolute reference cannot be expanded"))
-             ((looking-at "!-\\([0-9]+\\)\\(:?[0-9^$*-]+\\)?")
+             ((looking-at "!-\\([0-9]+\\):?\\([0-9^$*-]+\\)?")
               ;; Just a number of args from `number' lines backward.
                (if dry-run (throw dry-run 'history))
               (let ((number (1- (string-to-number
@@ -1464,7 +1464,7 @@ actual side-effect."
                              t t)
               (message "History item: previous"))
              ((looking-at
-               "!\\??\\({\\(.+\\)}\\|\\(\\sw+\\)\\)\\(:?[0-9^$*-]+\\)?")
+               "!\\??\\({\\(.+\\)}\\|\\(\\sw+\\)\\):?\\([0-9^$*-]+\\)?")
               ;; Most recent input starting with or containing (possibly
               ;; protected) string, maybe just a number of args.  Phew.
                (if dry-run (throw dry-run 'expand))
index 8920579755ebede0c6d67154d9299bb04faa7b22..ee50f572157fa462590da7938f0e4393e23a0d40 100644 (file)
@@ -192,7 +192,7 @@ the standard Lisp indent package."
     (list
      (cond ((not (lisp-extended-loop-p (elt state 1)))
            (+ loop-indentation lisp-simple-loop-indentation))
-          ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)")
+          ((looking-at "^\\s-*\\(?::?\\sw+\\|;\\)")
            (+ loop-indentation lisp-loop-keyword-indentation))
           (t
            (+ loop-indentation lisp-loop-forms-indentation)))
index 89d62ab3a61feca5d0a4911eda71dff58fb028d1..279285b93263a2d1be616dcfbade94d2ef7777af 100644 (file)
@@ -4033,7 +4033,7 @@ The list is maintained in SQL interactive buffers.")
 (defun sql--completion-table (string pred action)
   (when sql-completion-sqlbuf
     (with-current-buffer sql-completion-sqlbuf
-      (let ((schema (and (string-match "\\`\\(\\sw\\(:?\\sw\\|\\s_\\)*\\)[.]" string)
+      (let ((schema (and (string-match "\\`\\(\\sw\\(?:\\sw\\|\\s_\\)*\\)[.]" string)
                          (downcase (match-string 1 string)))))
 
         ;; If we haven't loaded any object name yet, load local schema
index 5d43ea56791b4b2a6d73a6ebd33a360766df84ae..a80db33aab5987e5b3e2e088b202be343be6fba3 100644 (file)
@@ -2067,7 +2067,7 @@ See `term-replace-by-expanded-history'.  Returns t if successful."
               ;; We cannot know the interpreter's idea of input line numbers.
               (goto-char (match-end 0))
               (message "Absolute reference cannot be expanded"))
-             ((looking-at "!-\\([0-9]+\\)\\(:?[0-9^$*-]+\\)?")
+             ((looking-at "!-\\([0-9]+\\):?\\([0-9^$*-]+\\)?")
               ;; Just a number of args from `number' lines backward.
               (let ((number (1- (string-to-number
                                  (buffer-substring (match-beginning 1)
@@ -2090,7 +2090,7 @@ See `term-replace-by-expanded-history'.  Returns t if successful."
                t t)
               (message "History item: previous"))
              ((looking-at
-               "!\\??\\({\\(.+\\)}\\|\\(\\sw+\\)\\)\\(:?[0-9^$*-]+\\)?")
+               "!\\??\\({\\(.+\\)}\\|\\(\\sw+\\)\\):?\\([0-9^$*-]+\\)?")
               ;; Most recent input starting with or containing (possibly
               ;; protected) string, maybe just a number of args.  Phew.
               (let* ((mb1 (match-beginning 1)) (me1 (match-end 1))