diff options
| author | Stefan Monnier | 2001-04-02 22:49:38 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2001-04-02 22:49:38 +0000 |
| commit | 7a9ebd0b8e3b96447e5e901379baedd697b2bebd (patch) | |
| tree | d60579a05668ed8d955f89f429bac221bba8d6b8 | |
| parent | 2b9083424de38fb5ccc8e3f714b34b59e9957fac (diff) | |
| download | emacs-7a9ebd0b8e3b96447e5e901379baedd697b2bebd.tar.gz emacs-7a9ebd0b8e3b96447e5e901379baedd697b2bebd.zip | |
(mail-extr-delete-char, mail-extr-safe-move-sexp)
(mail-extr-skip-whitespace-forward, mail-extr-nuke-char-at)
(mail-extr-skip-whitespace-backward, mail-extr-undo-backslash-quoting):
Use `defsubst' rather than a macro to ease debugging.
(mail-extr-last): Remove (use `last' instead).
(mail-extract-address-components): Properly reset the syntax-table
after parsing an address. Use `last' rather than mail-extr-last.
Make sure the end marker stays at the very end.
| -rw-r--r-- | lisp/mail/mail-extr.el | 95 |
1 files changed, 42 insertions, 53 deletions
diff --git a/lisp/mail/mail-extr.el b/lisp/mail/mail-extr.el index 7a58699e095..5e693dc11f4 100644 --- a/lisp/mail/mail-extr.el +++ b/lisp/mail/mail-extr.el | |||
| @@ -618,37 +618,36 @@ by translating things like \"foo!bar!baz@host\" into \"baz@bar.UUCP\"." | |||
| 618 | ;; Utility functions and macros. | 618 | ;; Utility functions and macros. |
| 619 | ;; | 619 | ;; |
| 620 | 620 | ||
| 621 | (defmacro mail-extr-delete-char (n) | 621 | (defsubst mail-extr-delete-char (n) |
| 622 | ;; in v19, delete-char is compiled as a function call, but delete-region | 622 | ;; in v19, delete-char is compiled as a function call, but delete-region |
| 623 | ;; is byte-coded, so it's much much faster. | 623 | ;; is byte-coded, so it's much much faster. |
| 624 | (list 'delete-region '(point) (list '+ '(point) n))) | 624 | (delete-region (point) (+ (point) n))) |
| 625 | 625 | ||
| 626 | (defmacro mail-extr-skip-whitespace-forward () | 626 | (defsubst mail-extr-skip-whitespace-forward () |
| 627 | ;; v19 fn skip-syntax-forward is more tasteful, but not byte-coded. | 627 | ;; v19 fn skip-syntax-forward is more tasteful, but not byte-coded. |
| 628 | '(skip-chars-forward " \t\n\r\240")) | 628 | (skip-chars-forward " \t\n\r\240")) |
| 629 | 629 | ||
| 630 | (defmacro mail-extr-skip-whitespace-backward () | 630 | (defsubst mail-extr-skip-whitespace-backward () |
| 631 | ;; v19 fn skip-syntax-backward is more tasteful, but not byte-coded. | 631 | ;; v19 fn skip-syntax-backward is more tasteful, but not byte-coded. |
| 632 | '(skip-chars-backward " \t\n\r\240")) | 632 | (skip-chars-backward " \t\n\r\240")) |
| 633 | 633 | ||
| 634 | |||
| 635 | (defmacro mail-extr-undo-backslash-quoting (beg end) | ||
| 636 | (`(save-excursion | ||
| 637 | (save-restriction | ||
| 638 | (narrow-to-region (, beg) (, end)) | ||
| 639 | (goto-char (point-min)) | ||
| 640 | ;; undo \ quoting | ||
| 641 | (while (search-forward "\\" nil t) | ||
| 642 | (mail-extr-delete-char -1) | ||
| 643 | (or (eobp) | ||
| 644 | (forward-char 1)) | ||
| 645 | ))))) | ||
| 646 | 634 | ||
| 647 | (defmacro mail-extr-nuke-char-at (pos) | 635 | (defsubst mail-extr-undo-backslash-quoting (beg end) |
| 648 | (` (save-excursion | 636 | (save-excursion |
| 649 | (goto-char (, pos)) | 637 | (save-restriction |
| 650 | (mail-extr-delete-char 1) | 638 | (narrow-to-region beg end) |
| 651 | (insert ?\ )))) | 639 | (goto-char (point-min)) |
| 640 | ;; undo \ quoting | ||
| 641 | (while (search-forward "\\" nil t) | ||
| 642 | (mail-extr-delete-char -1) | ||
| 643 | (or (eobp) | ||
| 644 | (forward-char 1)))))) | ||
| 645 | |||
| 646 | (defsubst mail-extr-nuke-char-at (pos) | ||
| 647 | (save-excursion | ||
| 648 | (goto-char pos) | ||
| 649 | (mail-extr-delete-char 1) | ||
| 650 | (insert ?\ ))) | ||
| 652 | 651 | ||
| 653 | (put 'mail-extr-nuke-outside-range | 652 | (put 'mail-extr-nuke-outside-range |
| 654 | 'edebug-form-spec '(symbolp &optional form form atom)) | 653 | 'edebug-form-spec '(symbolp &optional form form atom)) |
| @@ -693,26 +692,18 @@ by translating things like \"foo!bar!baz@host\" into \"baz@bar.UUCP\"." | |||
| 693 | pos | 692 | pos |
| 694 | (copy-marker pos))) | 693 | (copy-marker pos))) |
| 695 | 694 | ||
| 696 | (defmacro mail-extr-last (list) | 695 | (defsubst mail-extr-safe-move-sexp (arg) |
| 697 | ;; Returns last element of LIST. | ||
| 698 | ;; Could be a subst. | ||
| 699 | (` (let ((list (, list))) | ||
| 700 | (while (not (null (cdr list))) | ||
| 701 | (setq list (cdr list))) | ||
| 702 | (car list)))) | ||
| 703 | |||
| 704 | (defmacro mail-extr-safe-move-sexp (arg) | ||
| 705 | ;; Safely skip over one balanced sexp, if there is one. Return t if success. | 696 | ;; Safely skip over one balanced sexp, if there is one. Return t if success. |
| 706 | (` (condition-case error | 697 | (condition-case error |
| 707 | (progn | 698 | (progn |
| 708 | (goto-char (or (scan-sexps (point) (, arg)) (point))) | 699 | (goto-char (or (scan-sexps (point) arg) (point))) |
| 709 | t) | 700 | t) |
| 710 | (error | 701 | (error |
| 711 | ;; #### kludge kludge kludge kludge kludge kludge kludge !!! | 702 | ;; #### kludge kludge kludge kludge kludge kludge kludge !!! |
| 712 | (if (string-equal (nth 1 error) "Unbalanced parentheses") | 703 | (if (string-equal (nth 1 error) "Unbalanced parentheses") |
| 713 | nil | 704 | nil |
| 714 | (while t | 705 | (while t |
| 715 | (signal (car error) (cdr error)))))))) | 706 | (signal (car error) (cdr error))))))) |
| 716 | 707 | ||
| 717 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 708 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 718 | ;; | 709 | ;; |
| @@ -735,7 +726,7 @@ the form ((FULL-NAME CANONICAL-ADDRESS) ...) with one element for | |||
| 735 | each recipient. If ALL is nil, then if ADDRESS contains more than | 726 | each recipient. If ALL is nil, then if ADDRESS contains more than |
| 736 | one recipients, all but the first is ignored. | 727 | one recipients, all but the first is ignored. |
| 737 | 728 | ||
| 738 | ADDRESS may be a string or a buffer. If it is a buffer, the visible | 729 | ADDRESS may be a string or a buffer. If it is a buffer, the visible |
| 739 | (narrowed) portion of the buffer will be interpreted as the address. | 730 | (narrowed) portion of the buffer will be interpreted as the address. |
| 740 | (This feature exists so that the clever caller might be able to avoid | 731 | (This feature exists so that the clever caller might be able to avoid |
| 741 | consing a string.)" | 732 | consing a string.)" |
| @@ -743,8 +734,7 @@ ADDRESS may be a string or a buffer. If it is a buffer, the visible | |||
| 743 | (extraction-buffer (get-buffer-create " *extract address components*")) | 734 | (extraction-buffer (get-buffer-create " *extract address components*")) |
| 744 | value-list) | 735 | value-list) |
| 745 | 736 | ||
| 746 | (save-excursion | 737 | (with-current-buffer (get-buffer-create extraction-buffer) |
| 747 | (set-buffer extraction-buffer) | ||
| 748 | (fundamental-mode) | 738 | (fundamental-mode) |
| 749 | (buffer-disable-undo extraction-buffer) | 739 | (buffer-disable-undo extraction-buffer) |
| 750 | (set-syntax-table mail-extr-address-syntax-table) | 740 | (set-syntax-table mail-extr-address-syntax-table) |
| @@ -766,11 +756,9 @@ ADDRESS may be a string or a buffer. If it is a buffer, the visible | |||
| 766 | 756 | ||
| 767 | (set-text-properties (point-min) (point-max) nil) | 757 | (set-text-properties (point-min) (point-max) nil) |
| 768 | 758 | ||
| 769 | (save-excursion | 759 | (with-current-buffer (get-buffer-create canonicalization-buffer) |
| 770 | (set-buffer canonicalization-buffer) | ||
| 771 | (fundamental-mode) | 760 | (fundamental-mode) |
| 772 | (buffer-disable-undo canonicalization-buffer) | 761 | (buffer-disable-undo canonicalization-buffer) |
| 773 | (set-syntax-table mail-extr-address-syntax-table) | ||
| 774 | (setq case-fold-search nil)) | 762 | (setq case-fold-search nil)) |
| 775 | 763 | ||
| 776 | 764 | ||
| @@ -804,6 +792,7 @@ ADDRESS may be a string or a buffer. If it is a buffer, the visible | |||
| 804 | ;; mailbox-name-processed-flag | 792 | ;; mailbox-name-processed-flag |
| 805 | disable-initial-guessing-flag) ; dynamically set from -voodoo | 793 | disable-initial-guessing-flag) ; dynamically set from -voodoo |
| 806 | 794 | ||
| 795 | (set-syntax-table mail-extr-address-syntax-table) | ||
| 807 | (goto-char (point-min)) | 796 | (goto-char (point-min)) |
| 808 | 797 | ||
| 809 | ;; Insert extra space at beginning to allow later replacement with < | 798 | ;; Insert extra space at beginning to allow later replacement with < |
| @@ -868,12 +857,12 @@ ADDRESS may be a string or a buffer. If it is a buffer, the visible | |||
| 868 | ;; BUG FIX: This test was reversed. Thanks to the | 857 | ;; BUG FIX: This test was reversed. Thanks to the |
| 869 | ;; brilliant Rod Whitby <rwhitby@research.canon.oz.au> | 858 | ;; brilliant Rod Whitby <rwhitby@research.canon.oz.au> |
| 870 | ;; for discovering this! | 859 | ;; for discovering this! |
| 871 | (< (mail-extr-last <-pos) (car >-pos))))) | 860 | (< (car (last <-pos)) (car >-pos))))) |
| 872 | ;; The argument contains more than one address. | 861 | ;; The argument contains more than one address. |
| 873 | ;; Temporarily hide everything after this one. | 862 | ;; Temporarily hide everything after this one. |
| 874 | (setq end-of-address (copy-marker (1+ (point)))) | 863 | (setq end-of-address (copy-marker (1+ (point)) t)) |
| 875 | (narrow-to-region (point-min) (1+ (point))) | 864 | (narrow-to-region (point-min) (1+ (point))) |
| 876 | (mail-extr-delete-char 1) | 865 | (delete-char 1) |
| 877 | (setq char ?\() ; HAVE I NO SHAME?? | 866 | (setq char ?\() ; HAVE I NO SHAME?? |
| 878 | ) | 867 | ) |
| 879 | ;; record the position of various interesting chars, determine | 868 | ;; record the position of various interesting chars, determine |
| @@ -1145,7 +1134,7 @@ ADDRESS may be a string or a buffer. If it is a buffer, the visible | |||
| 1145 | (mail-extr-@-binds-tighter-than-! | 1134 | (mail-extr-@-binds-tighter-than-! |
| 1146 | (setq insert-point (point-max))) | 1135 | (setq insert-point (point-max))) |
| 1147 | (%-pos | 1136 | (%-pos |
| 1148 | (setq insert-point (mail-extr-last %-pos) | 1137 | (setq insert-point (car (last %-pos)) |
| 1149 | saved-%-pos (mapcar 'mail-extr-markerize %-pos) | 1138 | saved-%-pos (mapcar 'mail-extr-markerize %-pos) |
| 1150 | %-pos nil | 1139 | %-pos nil |
| 1151 | @-pos (mail-extr-markerize @-pos))) | 1140 | @-pos (mail-extr-markerize @-pos))) |