From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Unquoted special characters in regexps Date: Sat, 25 Feb 2006 18:23:04 +0100 Message-ID: NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1140888059 30093 80.91.229.2 (25 Feb 2006 17:20:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 25 Feb 2006 17:20:59 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 25 18:20:58 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FD36E-0005kK-OS for ged-emacs-devel@m.gmane.org; Sat, 25 Feb 2006 18:20:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FD36G-00028P-I5 for ged-emacs-devel@m.gmane.org; Sat, 25 Feb 2006 12:20:56 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FD35R-0000ke-3l for emacs-devel@gnu.org; Sat, 25 Feb 2006 12:20:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FD35P-0000gi-6B for emacs-devel@gnu.org; Sat, 25 Feb 2006 12:20:04 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FD35O-0000gP-O0 for emacs-devel@gnu.org; Sat, 25 Feb 2006 12:20:02 -0500 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1FD35j-00082s-KV for emacs-devel@gnu.org; Sat, 25 Feb 2006 12:20:23 -0500 Original-Received: (qmail invoked by alias); 25 Feb 2006 17:19:57 -0000 Original-Received: from N839P023.adsl.highway.telekom.at (EHLO V357900157) [62.47.48.215] by mail.gmx.net (mp010) with SMTP; 25 Feb 2006 18:19:57 +0100 X-Authenticated: #14592706 Original-To: emacs-devel@gnu.org X-Y-GMX-Trusted: 0 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:50968 Archived-At: Section 34.3.1.1 (Special Characters in Regular Expressions) of the Elisp manual says: *Please note:* For historical compatibility, special characters are treated as ordinary ones if they are in contexts where their special meanings make no sense. ... It is poor practice to depend on this behavior; quote the special character anyway, regardless of where it appears. The three patches below eliminate spurious occurrences of such practice: * font-lock.el (lisp-font-lock-keywords-2) * emacs-lisp/rx.el (rx-check-any, rx-check-not) * generic-x.el (reg-generic-mode): Quote "]"s in regexps when they have no special meaning. ================================================================================ *** font-lock.el Wed Feb 1 10:17:44 2006 --- font-lock.el Thu Feb 16 20:24:48 2006 *************** *** 2120,2126 **** ;; Erroneous structures. ("(\\(abort\\|assert\\|warn\\|check-type\\|cerror\\|error\\|signal\\)\\>" 1 font-lock-warning-face) ;; Words inside \\[] tend to be for `substitute-command-keys'. ! ("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-constant-face prepend) ;; Words inside `' tend to be symbol names. ("`\\(\\sw\\sw+\\)'" 1 font-lock-constant-face prepend) ;; Constant values. --- 2120,2126 ---- ;; Erroneous structures. ("(\\(abort\\|assert\\|warn\\|check-type\\|cerror\\|error\\|signal\\)\\>" 1 font-lock-warning-face) ;; Words inside \\[] tend to be for `substitute-command-keys'. ! ("\\\\\\\\\\[\\(\\sw+\\)\\]" 1 font-lock-constant-face prepend) ;; Words inside `' tend to be symbol names. ("`\\(\\sw\\sw+\\)'" 1 font-lock-constant-face prepend) ;; Constant values. ================================================================================ *** rx.el Sat Nov 5 20:44:46 2005 --- rx.el Thu Feb 16 20:28:18 2006 *************** *** 371,378 **** (if (eq ?^ (aref arg 0)) (setq arg (concat "\\" arg))) ;; Remove ] and set flag for adding it to start of overall result. ! (when (string-match "]" arg) ! (setq arg (replace-regexp-in-string "]" "" arg) rx-bracket "]"))) (when (symbolp arg) (let ((translation (condition-case nil --- 371,378 ---- (if (eq ?^ (aref arg 0)) (setq arg (concat "\\" arg))) ;; Remove ] and set flag for adding it to start of overall result. ! (when (string-match "\\]" arg) ! (setq arg (replace-regexp-in-string "\\]" "" arg) rx-bracket "]"))) (when (symbolp arg) (let ((translation (condition-case nil *************** *** 404,410 **** (defun rx-check-not (arg) "Check arg ARG for Rx `not'." (unless (or (and (symbolp arg) ! (string-match "\\`\\[\\[:[-a-z]:]]\\'" (condition-case nil (rx-to-string arg 'no-group) (error "")))) --- 404,410 ---- (defun rx-check-not (arg) "Check arg ARG for Rx `not'." (unless (or (and (symbolp arg) ! (string-match "\\`\\[\\[:[-a-z]:\\]\\]\\'" (condition-case nil (rx-to-string arg 'no-group) (error "")))) ================================================================================ *** generic-x.el Sat Nov 5 20:44:28 2005 --- generic-x.el Sat Feb 25 17:22:58 2006 *************** *** 433,439 **** (define-generic-mode reg-generic-mode '(?\;) '("key" "classes_root" "REGEDIT" "REGEDIT4") ! '(("\\(\\[.*]\\)" 1 font-lock-constant-face) ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face)) '("\\.[rR][eE][gG]\\'") (list --- 433,439 ---- (define-generic-mode reg-generic-mode '(?\;) '("key" "classes_root" "REGEDIT" "REGEDIT4") ! '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face) ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face)) '("\\.[rR][eE][gG]\\'") (list ================================================================================