Mercurial > emacs
comparison lisp/mail/supercite.el @ 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 | 17734f1247d0 |
children | 771bd7ddd4cc |
comparison
equal
deleted
inserted
replaced
11555:4cc0a5e1bdac | 11556:a83ee7a1e0fd |
---|---|
501 (if (memq 'v19 sc-emacs-features) | 501 (if (memq 'v19 sc-emacs-features) |
502 ;; maybe future versions will take a `history' argument: | 502 ;; maybe future versions will take a `history' argument: |
503 (read-string prompt initial-contents) | 503 (read-string prompt initial-contents) |
504 (read-string prompt initial-contents))) | 504 (read-string prompt initial-contents))) |
505 | 505 |
506 (defun sc-submatch (matchnum &optional string) | 506 (if (fboundp 'match-string) |
507 "Returns `match-beginning' and `match-end' sub-expression for MATCHNUM. | 507 (defalias 'sc-submatch 'match-string) |
508 (defun sc-submatch (matchnum &optional string) | |
509 "Returns `match-beginning' and `match-end' sub-expression for MATCHNUM. | |
508 If optional STRING is provided, take sub-expression using `substring' | 510 If optional STRING is provided, take sub-expression using `substring' |
509 of argument, otherwise use `buffer-substring' on current buffer. Note | 511 of argument, otherwise use `buffer-substring' on current buffer. Note |
510 that `match-data' must have already been generated and no error | 512 that `match-data' must have already been generated and no error |
511 checking is performed by this function." | 513 checking is performed by this function." |
512 (if string | 514 (if string |
513 (substring string (match-beginning matchnum) (match-end matchnum)) | 515 (substring string (match-beginning matchnum) (match-end matchnum)) |
514 (buffer-substring (match-beginning matchnum) (match-end matchnum)))) | 516 (buffer-substring (match-beginning matchnum) (match-end matchnum))))) |
515 | 517 |
516 (defun sc-member (elt list) | 518 (if (fboundp 'member) |
517 "Like `memq', but uses `equal' instead of `eq'. | 519 (defalias 'sc-member 'member) |
520 (defun sc-member (elt list) | |
521 "Like `memq', but uses `equal' instead of `eq'. | |
518 Emacs19 has a builtin function `member' which does exactly this." | 522 Emacs19 has a builtin function `member' which does exactly this." |
519 (catch 'elt-is-member | 523 (catch 'elt-is-member |
520 (while list | 524 (while list |
521 (if (equal elt (car list)) | 525 (if (equal elt (car list)) |
522 (throw 'elt-is-member list)) | 526 (throw 'elt-is-member list)) |
523 (setq list (cdr list))))) | 527 (setq list (cdr list)))))) |
524 (and (memq 'v19 sc-emacs-features) | 528 |
525 (fset 'sc-member 'member)) | 529 ;; One day maybe Emacs will have this... |
530 (if (fboundp 'string-text) | |
531 (defalias 'sc-string-text 'string-text) | |
532 (defun sc-string-text (string) | |
533 "Return STRING with all text properties removed." | |
534 (let ((string (copy-sequence string))) | |
535 (set-text-properties 0 (length string) nil string) | |
536 string))) | |
526 | 537 |
527 (defun sc-ask (alist) | 538 (defun sc-ask (alist) |
528 "Ask a question in the minibuffer requiring a single character answer. | 539 "Ask a question in the minibuffer requiring a single character answer. |
529 This function is kind of an extension of `y-or-n-p' where a single | 540 This function is kind of an extension of `y-or-n-p' where a single |
530 letter is used to answer a question. Question is formed from ALIST | 541 letter is used to answer a question. Question is formed from ALIST |
643 (defun sc-mail-fetch-field (&optional attribs-p) | 654 (defun sc-mail-fetch-field (&optional attribs-p) |
644 "Insert a key and value into `sc-mail-info' alist. | 655 "Insert a key and value into `sc-mail-info' alist. |
645 If optional ATTRIBS-P is non-nil, the key/value pair is placed in | 656 If optional ATTRIBS-P is non-nil, the key/value pair is placed in |
646 `sc-attributions' too." | 657 `sc-attributions' too." |
647 (if (string-match "^\\(\\S *\\)\\s *:\\s +\\(.*\\)$" curline) | 658 (if (string-match "^\\(\\S *\\)\\s *:\\s +\\(.*\\)$" curline) |
648 (let* ((key (downcase (sc-submatch 1 curline))) | 659 (let* ((key (downcase (sc-string-text (sc-submatch 1 curline)))) |
649 (val (sc-submatch 2 curline)) | 660 (val (sc-string-text (sc-submatch 2 curline))) |
650 (keyval (cons key val))) | 661 (keyval (cons key val))) |
651 (setq sc-mail-info (cons keyval sc-mail-info)) | 662 (setq sc-mail-info (cons keyval sc-mail-info)) |
652 (if attribs-p | 663 (if attribs-p |
653 (setq sc-attributions (cons keyval sc-attributions))) | 664 (setq sc-attributions (cons keyval sc-attributions))) |
654 )) | 665 )) |
656 | 667 |
657 (defun sc-mail-append-field () | 668 (defun sc-mail-append-field () |
658 "Append a continuation line onto the last fetched mail field's info." | 669 "Append a continuation line onto the last fetched mail field's info." |
659 (let ((keyval (car sc-mail-info))) | 670 (let ((keyval (car sc-mail-info))) |
660 (if (and keyval (string-match "^\\s *\\(.*\\)$" curline)) | 671 (if (and keyval (string-match "^\\s *\\(.*\\)$" curline)) |
661 (setcdr keyval (concat (cdr keyval) " " (sc-submatch 1 curline))))) | 672 (setcdr keyval (concat (cdr keyval) " " |
673 (sc-string-text (sc-submatch 1 curline)))))) | |
662 nil) | 674 nil) |
663 | 675 |
664 (defun sc-mail-error-in-mail-field () | 676 (defun sc-mail-error-in-mail-field () |
665 "Issue warning that mail headers don't conform to RFC 822." | 677 "Issue warning that mail headers don't conform to RFC 822." |
666 (let* ((len (min (length curline) 10)) | 678 (let* ((len (min (length curline) 10)) |