annotate etc/auctex/style/letter.el @ 50:ee648375d8d6 r19-16b91

Import from CVS: tag r19-16b91
author cvs
date Mon, 13 Aug 2007 08:56:41 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
1 ;;; letter.el - Special code for letter style.
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
2
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
3 ;; $Id: letter.el,v 1.1 1997/08/30 02:45:16 steve Exp $
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
4
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
5 ;;; Code:
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
6
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
7 ;; You may want to define this in tex-site.el to contain your
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
8 ;; organizations address.
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
9 (defvar LaTeX-letter-sender-address ""
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
10 "Initial value when prompting for a sender address in the letter style.")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
11
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
12 (TeX-add-style-hook "letter"
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
13 (function
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
14 (lambda ()
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
15 (LaTeX-add-environments
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
16 '("letter" LaTeX-env-recipient))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
17 (TeX-add-symbols
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
18 '("name" "Sender: ")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
19 '("address" "Sender address: ")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
20 '("signature" "Signature: ")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
21 '("opening" "Opening: ")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
22 '("closing" "Closing: ")))))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
23
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
24 (defun LaTeX-env-recipient (environment)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
25 "Insert ENVIRONMENT and prompt for recipient and address."
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
26 (let ((sender (read-input "Sender: " (user-full-name)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
27 (sender-address (read-input "Sender address: "
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
28 LaTeX-letter-sender-address))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
29 (recipient (read-input "Recipient: "))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
30 (address (read-input "Recipient address: "))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
31 (signature (read-input "Signature: "))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
32 (opening (read-input "Opening: "))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
33 (closing (read-input "Closing: "))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
34 (date (read-input "Date: " (LaTeX-today))))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
35
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
36 (insert TeX-esc "name" TeX-grop sender TeX-grcl)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
37 (newline-and-indent)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
38 (if (not (zerop (length sender-address)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
39 (progn
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
40 (setq LaTeX-letter-sender-address sender-address)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
41 (insert TeX-esc "address" TeX-grop sender-address TeX-grcl)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
42 (newline-and-indent)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
43 (if (not (zerop (length signature)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
44 (progn
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
45 (insert TeX-esc "signature" TeX-grop signature TeX-grcl)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
46 (newline-and-indent)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
47 (if (not (zerop (length date)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
48 (progn
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
49 (insert TeX-esc "def" TeX-esc "today" TeX-grop date TeX-grcl)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
50 (newline-and-indent)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
51 (newline-and-indent)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
52
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
53 (let ((indentation (current-column)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
54 (LaTeX-insert-environment
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
55 environment
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
56 (concat TeX-grop recipient
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
57 (if (not (zerop (length address)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
58 (concat
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
59 (if (not (zerop (length recipient)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
60 (concat " " TeX-esc TeX-esc " "))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
61 address))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
62 TeX-grcl))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
63 (save-excursion ; Fix indentation of address
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
64 (if (search-backward TeX-grcl nil 'move)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
65 (let ((addr-end (point-marker)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
66 (if (search-backward TeX-grop nil 'move)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
67 (let ((addr-column (current-column)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
68 (while (search-forward
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
69 (concat TeX-esc TeX-esc)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
70 (marker-position addr-end) 'move)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
71 (progn
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
72 (newline)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
73 (indent-to addr-column))))))))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
74 (insert "\n")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
75 (indent-to indentation))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
76 (insert TeX-esc "opening"
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
77 TeX-grop
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
78 (if (zerop (length opening))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
79 (concat TeX-esc " ")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
80 opening)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
81 TeX-grcl "\n")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
82
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
83 (indent-relative-maybe)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
84 (save-excursion
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
85 (insert "\n" TeX-esc "closing"
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
86 TeX-grop
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
87 (if (zerop (length closing))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
88 (concat TeX-esc " ")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
89 closing)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
90 TeX-grcl "\n")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
91 (indent-relative-maybe))))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
92
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
93 (defun LaTeX-today nil
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
94 "Return a string representing todays date according to flavor."
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
95 (interactive)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
96 (let ((ctime-string (current-time-string))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
97 (month-alist '(("Jan". "01")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
98 ("Feb" . "02")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
99 ("Mar" . "03")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
100 ("Apr" . "04")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
101 ("May" . "05")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
102 ("Jun" . "06")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
103 ("Jul" . "07")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
104 ("Aug" . "08")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
105 ("Sep" . "09")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
106 ("Oct" . "10")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
107 ("Nov" . "11")
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
108 ("Dec" . "12"))))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
109 (string-match
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
110 "^\\S-+\\s-+\\(\\S-+\\)\\s-+\\(\\S-+\\)\\s-+\\S-+\\s-+\\(\\S-+\\)"
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
111 ctime-string)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
112 (let ((year (substring ctime-string (match-beginning 3) (match-end 3)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
113 (month (substring ctime-string (match-beginning 1) (match-end 1)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
114 (day (substring ctime-string (match-beginning 2) (match-end 2))))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
115 (if (assoc month month-alist)
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
116 (progn
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
117 (setq month (cdr (assoc month month-alist)))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
118 (if (> 2 (length day))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
119 (setq day (concat "0" day)))))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
120 (format "%s-%s-%s" year month day))))
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
121
ee648375d8d6 Import from CVS: tag r19-16b91
cvs
parents:
diff changeset
122 ;;; letter.el ends here