changeset 4501:c4fd85dd95bd

Add #'skip-chars-quote to subr.el 2008-08-09 Aidan Kehoe <kehoea@parhasard.net> * subr.el (skip-chars-quote): New. Given STRING, return a string that means that all characters in STRING will be skipped when passed to #'skip-chars-forward, #'skip-chars-backward.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 20 Aug 2008 17:39:56 +0200
parents c86a3c1b7416
children 8748a3f7ceb4
files lisp/ChangeLog lisp/subr.el
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Aug 20 17:36:27 2008 +0200
+++ b/lisp/ChangeLog	Wed Aug 20 17:39:56 2008 +0200
@@ -1,3 +1,10 @@
+2008-08-09  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* subr.el (skip-chars-quote): New.
+	Given STRING, return a string that means that all characters in
+	STRING will be skipped when passed to #'skip-chars-forward,
+	#'skip-chars-backward. 
+
 2008-08-09  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* mule/cyril-util.el: Remove. Use the version in packages instead.
--- a/lisp/subr.el	Wed Aug 20 17:36:27 2008 +0200
+++ b/lisp/subr.el	Wed Aug 20 17:39:56 2008 +0200
@@ -1722,4 +1722,25 @@
 
 ;; define-mail-user-agent is in simple.el.
 
+;; XEmacs; added. 
+(defun skip-chars-quote (string)
+  "Return a string that means all characters in STRING will be skipped,
+if passed to `skip-chars-forward' or `skip-chars-backward'.
+
+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) ?-))))
+    (apply #'string list)))
+
 ;;; subr.el ends here