From 5b879501339b9426661fbf2a783287ad0949e3d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 16 Aug 2023 13:33:48 +0200 Subject: [PATCH] Remedy wrong-looking \(:?...\) regexp constructs 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 | 4 ++-- lisp/emacs-lisp/cl-indent.el | 2 +- lisp/progmodes/sql.el | 2 +- lisp/term.el | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/comint.el b/lisp/comint.el index 5161d01515c..777795bcb46 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -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)) diff --git a/lisp/emacs-lisp/cl-indent.el b/lisp/emacs-lisp/cl-indent.el index 8920579755e..ee50f572157 100644 --- a/lisp/emacs-lisp/cl-indent.el +++ b/lisp/emacs-lisp/cl-indent.el @@ -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))) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 89d62ab3a61..279285b9326 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -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 diff --git a/lisp/term.el b/lisp/term.el index 5d43ea56791..a80db33aab5 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -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)) -- 2.39.2