diff lisp/subr.el @ 4504:b82fdf7305ee

Correct the implementation, add a few basic tests for #'skip-chars-quote. tests/ChangeLog addition: 2008-08-27 Aidan Kehoe <kehoea@parhasard.net> * automated/regexp-tests.el: Add a few basic #'skip-chars-forward, #'skip-chars-backward tests. lisp/ChangeLog addition: 2008-08-27 Aidan Kehoe <kehoea@parhasard.net> * subr.el (skip-chars-quote): Correct the implementation, following the docstring of #'skip-char-forward more closely rather than the documentation of character classes in the Lispref.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 27 Aug 2008 21:47:21 +0200
parents c4fd85dd95bd
children e96f3aca4d63
line wrap: on
line diff
--- a/lisp/subr.el	Wed Aug 27 00:39:09 2008 +0200
+++ b/lisp/subr.el	Wed Aug 27 21:47:21 2008 +0200
@@ -1730,17 +1730,15 @@
 Ranges and carets are not treated specially.  This implementation is
 in Lisp; do not use it in performance-critical code."
   (let ((list (delete-duplicates (string-to-list string) :test #'=)))
-    (when (equal list '((?- ?\[) (?\[ ?\-)))
-      (error 'invalid-argument
-	     "Cannot create `skip-chars-forward' arg from string"
-	     string))
-    (when (memq ?\] list)
-      (setq list (cons ?\] (delq ?\] list))))
-    (when (eq ?^ (car list))
-      (setq list (nconc (cdr list) '(?^))))
-    (when (memq ?- list)
-      (setq list (delq ?- list)
-	    list (nconc list (list (second list) ?- (second list) ?-))))
+    (when (/= 1 (length list)) ;; No quoting needed in a string of length 1.
+      (when (eq ?^ (car list))
+        (setq list (nconc (cdr list) '(?^))))
+      (when (memq ?\\ list)
+        (setq list (delq ?\\ list)
+              list (nconc (list ?\\ ?\\) list)))
+      (when (memq ?- list)
+        (setq list (delq ?- list)
+              list (nconc list '(?\\ ?-)))))
     (apply #'string list)))
 
 ;;; subr.el ends here