Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
4503:af95657e0bfd | 4504:b82fdf7305ee |
---|---|
1728 if passed to `skip-chars-forward' or `skip-chars-backward'. | 1728 if passed to `skip-chars-forward' or `skip-chars-backward'. |
1729 | 1729 |
1730 Ranges and carets are not treated specially. This implementation is | 1730 Ranges and carets are not treated specially. This implementation is |
1731 in Lisp; do not use it in performance-critical code." | 1731 in Lisp; do not use it in performance-critical code." |
1732 (let ((list (delete-duplicates (string-to-list string) :test #'=))) | 1732 (let ((list (delete-duplicates (string-to-list string) :test #'=))) |
1733 (when (equal list '((?- ?\[) (?\[ ?\-))) | 1733 (when (/= 1 (length list)) ;; No quoting needed in a string of length 1. |
1734 (error 'invalid-argument | 1734 (when (eq ?^ (car list)) |
1735 "Cannot create `skip-chars-forward' arg from string" | 1735 (setq list (nconc (cdr list) '(?^)))) |
1736 string)) | 1736 (when (memq ?\\ list) |
1737 (when (memq ?\] list) | 1737 (setq list (delq ?\\ list) |
1738 (setq list (cons ?\] (delq ?\] list)))) | 1738 list (nconc (list ?\\ ?\\) list))) |
1739 (when (eq ?^ (car list)) | 1739 (when (memq ?- list) |
1740 (setq list (nconc (cdr list) '(?^)))) | 1740 (setq list (delq ?- list) |
1741 (when (memq ?- list) | 1741 list (nconc list '(?\\ ?-))))) |
1742 (setq list (delq ?- list) | |
1743 list (nconc list (list (second list) ?- (second list) ?-)))) | |
1744 (apply #'string list))) | 1742 (apply #'string list))) |
1745 | 1743 |
1746 ;;; subr.el ends here | 1744 ;;; subr.el ends here |