changeset 11556:a83ee7a1e0fd

Made sc-string-text to strip of text properties of buffer text, so string comparison wouldn't fail in sc-mail-fetch-field and sc-mail-append-field.
author Simon Marshall <simon@gnu.org>
date Tue, 25 Apr 1995 08:27:28 +0000
parents 4cc0a5e1bdac
children 63406705a7e2
files lisp/mail/supercite.el
diffstat 1 files changed, 29 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/supercite.el	Tue Apr 25 05:29:11 1995 +0000
+++ b/lisp/mail/supercite.el	Tue Apr 25 08:27:28 1995 +0000
@@ -503,26 +503,37 @@
       (read-string prompt initial-contents)
     (read-string prompt initial-contents)))
 
-(defun sc-submatch (matchnum &optional string)
-  "Returns `match-beginning' and `match-end' sub-expression for MATCHNUM.
+(if (fboundp 'match-string)
+    (defalias 'sc-submatch 'match-string)
+  (defun sc-submatch (matchnum &optional string)
+    "Returns `match-beginning' and `match-end' sub-expression for MATCHNUM.
 If optional STRING is provided, take sub-expression using `substring'
 of argument, otherwise use `buffer-substring' on current buffer.  Note
 that `match-data' must have already been generated and no error
 checking is performed by this function."
-  (if string
-      (substring string (match-beginning matchnum) (match-end matchnum))
-    (buffer-substring (match-beginning matchnum) (match-end matchnum))))
+    (if string
+	(substring string (match-beginning matchnum) (match-end matchnum))
+      (buffer-substring (match-beginning matchnum) (match-end matchnum)))))
 
-(defun sc-member (elt list)
-  "Like `memq', but uses `equal' instead of `eq'.
+(if (fboundp 'member)
+    (defalias 'sc-member 'member)
+  (defun sc-member (elt list)
+    "Like `memq', but uses `equal' instead of `eq'.
 Emacs19 has a builtin function `member' which does exactly this."
-  (catch 'elt-is-member
-    (while list
-      (if (equal elt (car list))
-	  (throw 'elt-is-member list))
-      (setq list (cdr list)))))
-(and (memq 'v19 sc-emacs-features)
-     (fset 'sc-member 'member))
+    (catch 'elt-is-member
+      (while list
+	(if (equal elt (car list))
+	    (throw 'elt-is-member list))
+	(setq list (cdr list))))))
+
+;; One day maybe Emacs will have this...
+(if (fboundp 'string-text)
+    (defalias 'sc-string-text 'string-text)
+  (defun sc-string-text (string)
+    "Return STRING with all text properties removed."
+    (let ((string (copy-sequence string)))
+      (set-text-properties 0 (length string) nil string)
+      string)))
 
 (defun sc-ask (alist)
   "Ask a question in the minibuffer requiring a single character answer.
@@ -645,8 +656,8 @@
 If optional ATTRIBS-P is non-nil, the key/value pair is placed in
 `sc-attributions' too."
   (if (string-match "^\\(\\S *\\)\\s *:\\s +\\(.*\\)$" curline)
-      (let* ((key (downcase (sc-submatch 1 curline)))
-	     (val (sc-submatch 2 curline))
+      (let* ((key (downcase (sc-string-text (sc-submatch 1 curline))))
+	     (val (sc-string-text (sc-submatch 2 curline)))
 	     (keyval (cons key val)))
 	(setq sc-mail-info (cons keyval sc-mail-info))
 	(if attribs-p
@@ -658,7 +669,8 @@
   "Append a continuation line onto the last fetched mail field's info."
   (let ((keyval (car sc-mail-info)))
     (if (and keyval (string-match "^\\s *\\(.*\\)$" curline))
-	(setcdr keyval (concat (cdr keyval) " " (sc-submatch 1 curline)))))
+	(setcdr keyval (concat (cdr keyval) " "
+			       (sc-string-text (sc-submatch 1 curline))))))
   nil)
 
 (defun sc-mail-error-in-mail-field ()