Mercurial > emacs
diff lisp/mh-e/mh-utils.el @ 69221:7db1bc48b98c
* mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
(mh-narrow-to-subject, mh-narrow-to-to): Fix inability to narrow to
subjects with special characters by quoting regular expression
characters in pick expression derived from existing subjects and other
fields (closes SF #1432548).
* mh-utils.el (mh-pick-regexp-chars, mh-quote-pick-expr): New variable
and function for quoting pick regular expression characters (closes SF
#1432548).
author | Bill Wohler <wohler@newt.com> |
---|---|
date | Wed, 01 Mar 2006 05:33:18 +0000 |
parents | ef5cd9601f14 |
children | f3bbf5f32462 |
line wrap: on
line diff
--- a/lisp/mh-e/mh-utils.el Wed Mar 01 02:45:05 2006 +0000 +++ b/lisp/mh-e/mh-utils.el Wed Mar 01 05:33:18 2006 +0000 @@ -159,6 +159,23 @@ (funcall function (car list)) (setq list (cdr list)))) +(defvar mh-pick-regexp-chars ".*$[" + "List of special characters in pick regular expressions.") + +;;;###mh-autoload +(defun mh-quote-pick-expr (pick-expr) + "Quote `mh-pick-regexp-chars' in PICK-EXPR. +PICK-EXPR is a list of strings. Return nil if PICK-EXPR is nil." + (let ((quoted-pick-expr)) + (dolist (string pick-expr) + (when (and string + (not (string-equal string ""))) + (loop for i from 0 to (1- (length mh-pick-regexp-chars)) do + (let ((s (string ?\\ (aref mh-pick-regexp-chars i)))) + (setq string (mh-replace-regexp-in-string s s string t t)))) + (setq quoted-pick-expr (append quoted-pick-expr (list string))))) + quoted-pick-expr)) + ;;;###mh-autoload (defun mh-replace-string (old new) "Replace all occurrences of OLD with NEW in the current buffer.