comparison lisp/subr.el @ 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 5c651a4e8ed3
children b82fdf7305ee
comparison
equal deleted inserted replaced
4500:c86a3c1b7416 4501:c4fd85dd95bd
1720 1720
1721 ;; play-sound is built-in. 1721 ;; play-sound is built-in.
1722 1722
1723 ;; define-mail-user-agent is in simple.el. 1723 ;; define-mail-user-agent is in simple.el.
1724 1724
1725 ;; XEmacs; added.
1726 (defun skip-chars-quote (string)
1727 "Return a string that means all characters in STRING will be skipped,
1728 if passed to `skip-chars-forward' or `skip-chars-backward'.
1729
1730 Ranges and carets are not treated specially. This implementation is
1731 in Lisp; do not use it in performance-critical code."
1732 (let ((list (delete-duplicates (string-to-list string) :test #'=)))
1733 (when (equal list '((?- ?\[) (?\[ ?\-)))
1734 (error 'invalid-argument
1735 "Cannot create `skip-chars-forward' arg from string"
1736 string))
1737 (when (memq ?\] list)
1738 (setq list (cons ?\] (delq ?\] list))))
1739 (when (eq ?^ (car list))
1740 (setq list (nconc (cdr list) '(?^))))
1741 (when (memq ?- list)
1742 (setq list (delq ?- list)
1743 list (nconc list (list (second list) ?- (second list) ?-))))
1744 (apply #'string list)))
1745
1725 ;;; subr.el ends here 1746 ;;; subr.el ends here