all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Unquoted special characters in regexps
@ 2006-02-25 17:23 martin rudalics
  2006-02-25 18:42 ` Andreas Schwab
  0 siblings, 1 reply; 81+ messages in thread
From: martin rudalics @ 2006-02-25 17:23 UTC (permalink / raw)


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
================================================================================

^ permalink raw reply	[flat|nested] 81+ messages in thread

end of thread, other threads:[~2006-03-07  8:53 UTC | newest]

Thread overview: 81+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-25 17:23 Unquoted special characters in regexps martin rudalics
2006-02-25 18:42 ` Andreas Schwab
2006-02-25 19:18   ` martin rudalics
2006-02-25 19:31     ` Andreas Schwab
2006-02-25 20:18       ` martin rudalics
2006-02-25 22:09         ` Andreas Schwab
2006-02-26 11:32           ` martin rudalics
2006-02-26 11:50             ` Andreas Schwab
2006-02-26 13:28               ` martin rudalics
2006-02-25 22:13         ` Luc Teirlinck
2006-02-26 13:13           ` martin rudalics
2006-02-26 13:50             ` Andreas Schwab
2006-02-26 16:41               ` Luc Teirlinck
2006-02-26 17:53                 ` martin rudalics
2006-02-26 18:22                   ` Luc Teirlinck
2006-02-26 19:26                     ` martin rudalics
2006-02-26 17:10               ` martin rudalics
2006-02-26 17:42                 ` Luc Teirlinck
2006-02-26 19:06                   ` martin rudalics
2006-02-26 17:56                 ` Andreas Schwab
2006-02-26 19:08                   ` martin rudalics
2006-02-27 19:03                     ` Richard Stallman
2006-02-27 19:36                       ` Andreas Schwab
2006-02-27 20:03                         ` martin rudalics
2006-02-27 20:32                           ` Andreas Schwab
2006-02-27 21:43                             ` martin rudalics
2006-02-27 22:11                               ` Andreas Schwab
2006-02-28  6:19                                 ` Richard Stallman
2006-02-28 10:28                                 ` martin rudalics
2006-02-28  0:30                       ` Luc Teirlinck
2006-02-28 10:27                         ` martin rudalics
2006-02-28 22:57                           ` Luc Teirlinck
2006-03-01 13:00                             ` martin rudalics
2006-03-01 17:54                         ` Richard Stallman
2006-03-02  4:06                           ` Luc Teirlinck
2006-03-02 19:43                             ` Richard Stallman
2006-03-02  4:54                           ` Luc Teirlinck
2006-03-02 18:40                           ` martin rudalics
2006-03-02 23:26                             ` Luc Teirlinck
2006-03-03  7:42                               ` martin rudalics
2006-03-03 13:51                                 ` Luc Teirlinck
2006-03-03 14:09                                 ` Luc Teirlinck
2006-03-03 18:52                                   ` martin rudalics
2006-03-03 22:41                                     ` Luc Teirlinck
2006-03-03 23:00                                     ` Luc Teirlinck
2006-03-03 10:25                             ` Richard Stallman
2006-03-03 15:20                               ` martin rudalics
2006-03-04 13:37                                 ` Richard Stallman
2006-03-04 14:40                                   ` martin rudalics
2006-03-06  0:48                                     ` Richard Stallman
2006-03-03 10:25                             ` Richard Stallman
2006-03-03 15:51                               ` martin rudalics
2006-03-03 23:48                                 ` Luc Teirlinck
2006-03-04  9:58                                   ` martin rudalics
2006-03-04 23:16                                 ` Luc Teirlinck
2006-03-05  2:54                               ` Luc Teirlinck
2006-03-06  0:49                                 ` Richard Stallman
2006-02-28  0:44                       ` Luc Teirlinck
2006-03-04 21:07                         ` Thien-Thi Nguyen
2006-03-05  3:37                           ` Luc Teirlinck
2006-03-05 11:10                             ` martin rudalics
2006-03-05 15:32                               ` Luc Teirlinck
2006-03-06  7:41                                 ` martin rudalics
2006-03-05 17:04                               ` Luc Teirlinck
2006-03-05 11:54                             ` martin rudalics
2006-03-05 15:35                               ` Andreas Schwab
2006-03-06  8:19                                 ` martin rudalics
2006-03-05 18:36                               ` Luc Teirlinck
2006-03-05 19:14                                 ` Luc Teirlinck
2006-03-06  8:17                                   ` martin rudalics
2006-02-28  0:59                       ` Luc Teirlinck
2006-03-06 12:52                         ` Richard Stallman
2006-03-07  5:52                           ` Luc Teirlinck
2006-03-07  8:53                             ` martin rudalics
2006-02-25 22:34         ` Luc Teirlinck
2006-02-25 22:59           ` Andreas Schwab
2006-02-26 13:20           ` martin rudalics
2006-02-26 16:53             ` Luc Teirlinck
2006-02-26 18:01               ` martin rudalics
2006-02-26 17:19             ` Luc Teirlinck
2006-02-26 18:13               ` martin rudalics

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.