Mercurial > emacs
comparison lisp/mail/mail-extr.el @ 111423:e0d9a22430d9
Silence mail-extr compilation.
* lisp/mail/mail-extr.el (mail-extract-address-components): Give dynamic
local variables `cbeg' and `cend' a prefix.
(mail-extr-voodoo): Update for above name change.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 06 Nov 2010 12:28:44 -0700 |
parents | 280c8ae2476d |
children | 417b1e4d63cd |
comparison
equal
deleted
inserted
replaced
111422:2eee976277c5 | 111423:e0d9a22430d9 |
---|---|
1 ;;; mail-extr.el --- extract full name and address from RFC 822 mail header -*- coding: utf-8 -*- | 1 ;;; mail-extr.el --- extract full name and address from RFC 822 mail header -*- coding: utf-8 -*- |
2 | 2 |
3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1997, 2001, 2002, 2003, 2004, | 3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1997, 2001, 2002, 2003, 2004, |
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 |
5 ;; Free Software Foundation, Inc. | |
5 | 6 |
6 ;; Author: Joe Wells <jbw@cs.bu.edu> | 7 ;; Author: Joe Wells <jbw@cs.bu.edu> |
7 ;; Maintainer: FSF | 8 ;; Maintainer: FSF |
8 ;; Keywords: mail | 9 ;; Keywords: mail |
9 ;; Package: mail-utils | 10 ;; Package: mail-utils |
689 ;; | 690 ;; |
690 ;; The main function to grind addresses | 691 ;; The main function to grind addresses |
691 ;; | 692 ;; |
692 | 693 |
693 (defvar disable-initial-guessing-flag) ; dynamic assignment | 694 (defvar disable-initial-guessing-flag) ; dynamic assignment |
694 (defvar cbeg) ; dynamic assignment | 695 (defvar mailextr-cbeg) ; dynamic assignment |
695 (defvar cend) ; dynamic assignment | 696 (defvar mailextr-cend) ; dynamic assignment |
696 (defvar mail-extr-all-top-level-domains) ; Defined below. | 697 (defvar mail-extr-all-top-level-domains) ; Defined below. |
697 | 698 |
698 ;;;###autoload | 699 ;;;###autoload |
699 (defun mail-extract-address-components (address &optional all) | 700 (defun mail-extract-address-components (address &optional all) |
700 "Given an RFC-822 address ADDRESS, extract full name and canonical address. | 701 "Given an RFC-822 address ADDRESS, extract full name and canonical address. |
760 <-pos >-pos @-pos colon-pos comma-pos !-pos %-pos \;-pos | 761 <-pos >-pos @-pos colon-pos comma-pos !-pos %-pos \;-pos |
761 group-:-pos group-\;-pos route-addr-:-pos | 762 group-:-pos group-\;-pos route-addr-:-pos |
762 record-pos-symbol | 763 record-pos-symbol |
763 first-real-pos last-real-pos | 764 first-real-pos last-real-pos |
764 phrase-beg phrase-end | 765 phrase-beg phrase-end |
765 cbeg cend ; dynamically set from -voodoo | 766 ;; Dynamically set in mail-extr-voodoo. |
767 mailextr-cbeg mailextr-cend | |
766 quote-beg quote-end | 768 quote-beg quote-end |
767 atom-beg atom-end | 769 atom-beg atom-end |
768 mbox-beg mbox-end | 770 mbox-beg mbox-end |
769 \.-ends-name | 771 \.-ends-name |
770 temp | 772 temp |
794 (cond | 796 (cond |
795 ;; comment | 797 ;; comment |
796 ((eq char ?\() | 798 ((eq char ?\() |
797 (set-syntax-table mail-extr-address-comment-syntax-table) | 799 (set-syntax-table mail-extr-address-comment-syntax-table) |
798 ;; only record the first non-empty comment's position | 800 ;; only record the first non-empty comment's position |
799 (if (and (not cbeg) | 801 (if (and (not mailextr-cbeg) |
800 (save-excursion | 802 (save-excursion |
801 (forward-char 1) | 803 (forward-char 1) |
802 (mail-extr-skip-whitespace-forward) | 804 (mail-extr-skip-whitespace-forward) |
803 (not (eq ?\) (char-after (point)))))) | 805 (not (eq ?\) (char-after (point)))))) |
804 (setq cbeg (point))) | 806 (setq mailextr-cbeg (point))) |
805 ;; TODO: don't record if unbalanced | 807 ;; TODO: don't record if unbalanced |
806 (or (mail-extr-safe-move-sexp 1) | 808 (or (mail-extr-safe-move-sexp 1) |
807 (forward-char 1)) | 809 (forward-char 1)) |
808 (set-syntax-table mail-extr-address-syntax-table) | 810 (set-syntax-table mail-extr-address-syntax-table) |
809 (if (and cbeg | 811 (if (and mailextr-cbeg |
810 (not cend)) | 812 (not mailextr-cend)) |
811 (setq cend (point)))) | 813 (setq mailextr-cend (point)))) |
812 ;; quoted text | 814 ;; quoted text |
813 ((eq char ?\") | 815 ((eq char ?\") |
814 ;; only record the first non-empty quote's position | 816 ;; only record the first non-empty quote's position |
815 (if (and (not quote-beg) | 817 (if (and (not quote-beg) |
816 (save-excursion | 818 (save-excursion |
992 (mail-extr-nuke-outside-range comma-pos group-:-pos group-\;-pos t) | 994 (mail-extr-nuke-outside-range comma-pos group-:-pos group-\;-pos t) |
993 (and last-real-pos | 995 (and last-real-pos |
994 (> last-real-pos (1+ group-\;-pos)) | 996 (> last-real-pos (1+ group-\;-pos)) |
995 (setq last-real-pos (1+ group-\;-pos))) | 997 (setq last-real-pos (1+ group-\;-pos))) |
996 ;; *** This may be wrong: | 998 ;; *** This may be wrong: |
997 (and cend | 999 (and mailextr-cend |
998 (> cend group-\;-pos) | 1000 (> mailextr-cend group-\;-pos) |
999 (setq cend nil | 1001 (setq mailextr-cend nil |
1000 cbeg nil)) | 1002 mailextr-cbeg nil)) |
1001 (and quote-end | 1003 (and quote-end |
1002 (> quote-end group-\;-pos) | 1004 (> quote-end group-\;-pos) |
1003 (setq quote-end nil | 1005 (setq quote-end nil |
1004 quote-beg nil)) | 1006 quote-beg nil)) |
1005 ;; This was both wrong and unnecessary: | 1007 ;; This was both wrong and unnecessary: |
1226 ;; Example: First Last <fml@foo.bar.dom> | 1228 ;; Example: First Last <fml@foo.bar.dom> |
1227 (phrase-beg | 1229 (phrase-beg |
1228 (narrow-to-region phrase-beg phrase-end)) | 1230 (narrow-to-region phrase-beg phrase-end)) |
1229 | 1231 |
1230 ;; Example: fml@foo.bar.dom (First M. Last) | 1232 ;; Example: fml@foo.bar.dom (First M. Last) |
1231 (cbeg | 1233 (mailextr-cbeg |
1232 (narrow-to-region (1+ cbeg) (1- cend)) | 1234 (narrow-to-region (1+ mailextr-cbeg) (1- mailextr-cend)) |
1233 (mail-extr-undo-backslash-quoting (point-min) (point-max)) | 1235 (mail-extr-undo-backslash-quoting (point-min) (point-max)) |
1234 | 1236 |
1235 ;; Deal with spacing problems | 1237 ;; Deal with spacing problems |
1236 (goto-char (point-min)) | 1238 (goto-char (point-min)) |
1237 ;;; (cond ((not (search-forward " " nil t)) | 1239 ;;; (cond ((not (search-forward " " nil t)) |
1470 (re-search-forward mail-extr-disable-voodoo nil t)))) | 1472 (re-search-forward mail-extr-disable-voodoo nil t)))) |
1471 (let ((word-count 0) | 1473 (let ((word-count 0) |
1472 (case-fold-search nil) | 1474 (case-fold-search nil) |
1473 mixed-case-flag lower-case-flag ;;upper-case-flag | 1475 mixed-case-flag lower-case-flag ;;upper-case-flag |
1474 suffix-flag last-name-comma-flag | 1476 suffix-flag last-name-comma-flag |
1475 ;;cbeg cend | |
1476 initial | 1477 initial |
1477 begin-again-flag | 1478 begin-again-flag |
1478 drop-this-word-if-trailing-flag | 1479 drop-this-word-if-trailing-flag |
1479 drop-last-word-if-trailing-flag | 1480 drop-last-word-if-trailing-flag |
1480 word-found-flag | 1481 word-found-flag |
1616 ;;((eq ?, (following-char)) | 1617 ;;((eq ?, (following-char)) |
1617 ;; (setq name-done-flag t)) | 1618 ;; (setq name-done-flag t)) |
1618 | 1619 |
1619 ;; Delete parenthesized/quoted comment/nickname | 1620 ;; Delete parenthesized/quoted comment/nickname |
1620 ((memq (following-char) '(?\( ?\{ ?\[ ?\" ?\' ?\`)) | 1621 ((memq (following-char) '(?\( ?\{ ?\[ ?\" ?\' ?\`)) |
1621 (setq cbeg (point)) | 1622 (setq mailextr-cbeg (point)) |
1622 (set-syntax-table mail-extr-address-text-comment-syntax-table) | 1623 (set-syntax-table mail-extr-address-text-comment-syntax-table) |
1623 (cond ((memq (following-char) '(?\' ?\`)) | 1624 (cond ((memq (following-char) '(?\' ?\`)) |
1624 (or (search-forward "'" nil t | 1625 (or (search-forward "'" nil t |
1625 (if (eq ?\' (following-char)) 2 1)) | 1626 (if (eq ?\' (following-char)) 2 1)) |
1626 (delete-char 1))) | 1627 (delete-char 1))) |
1627 (t | 1628 (t |
1628 (or (mail-extr-safe-move-sexp 1) | 1629 (or (mail-extr-safe-move-sexp 1) |
1629 (goto-char (point-max))))) | 1630 (goto-char (point-max))))) |
1630 (set-syntax-table mail-extr-address-text-syntax-table) | 1631 (set-syntax-table mail-extr-address-text-syntax-table) |
1631 (setq cend (point)) | 1632 (setq mailextr-cend (point)) |
1632 (cond | 1633 (cond |
1633 ;; Handle case of entire name being quoted | 1634 ;; Handle case of entire name being quoted |
1634 ((and (eq word-count 0) | 1635 ((and (eq word-count 0) |
1635 (looking-at " *\\'") | 1636 (looking-at " *\\'") |
1636 (>= (- cend cbeg) 2)) | 1637 (>= (- mailextr-cend mailextr-cbeg) 2)) |
1637 (narrow-to-region (1+ cbeg) (1- cend)) | 1638 (narrow-to-region (1+ mailextr-cbeg) (1- mailextr-cend)) |
1638 (goto-char (point-min))) | 1639 (goto-char (point-min))) |
1639 (t | 1640 (t |
1640 ;; Handle case of quoted initial | 1641 ;; Handle case of quoted initial |
1641 (if (and (or (= 3 (- cend cbeg)) | 1642 (if (and (or (= 3 (- mailextr-cend mailextr-cbeg)) |
1642 (and (= 4 (- cend cbeg)) | 1643 (and (= 4 (- mailextr-cend mailextr-cbeg)) |
1643 (eq ?. (char-after (+ 2 cbeg))))) | 1644 (eq ?. (char-after (+ 2 mailextr-cbeg))))) |
1644 (not (looking-at " *\\'"))) | 1645 (not (looking-at " *\\'"))) |
1645 (setq initial (char-after (1+ cbeg))) | 1646 (setq initial (char-after (1+ mailextr-cbeg))) |
1646 (setq initial nil)) | 1647 (setq initial nil)) |
1647 (delete-region cbeg cend) | 1648 (delete-region mailextr-cbeg mailextr-cend) |
1648 (if initial | 1649 (if initial |
1649 (insert initial ". "))))) | 1650 (insert initial ". "))))) |
1650 | 1651 |
1651 ;; Handle *Stupid* VMS date stamps | 1652 ;; Handle *Stupid* VMS date stamps |
1652 ((looking-at mail-extr-stupid-vms-date-stamp-pattern) | 1653 ((looking-at mail-extr-stupid-vms-date-stamp-pattern) |
2172 ; all)))) | 2173 ; all)))) |
2173 | 2174 |
2174 | 2175 |
2175 (provide 'mail-extr) | 2176 (provide 'mail-extr) |
2176 | 2177 |
2177 ;; arch-tag: 7785fade-1073-4ed6-b4f6-28db34a7982d | |
2178 ;;; mail-extr.el ends here | 2178 ;;; mail-extr.el ends here |