Mercurial > emacs
annotate lisp/mail/mailalias.el @ 1717:aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'.
(FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New
accessors, for both the MULTI_FRAME and non-MULTI_FRAME.
(VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR,
WINDOW_VERTICAL_SCROLLBAR_COLUMN,
WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros.
* window.h (struct window): New field `vertical_scrollbar'.
* xterm.h (struct x_display): vertical_scrollbars,
judge_timestamp, vertical_scrollbar_extra: New fields.
(struct scrollbar): New struct.
(VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT,
VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER,
VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER,
CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH,
PIXEL_TO_CHAR_HEIGHT): New accessors and macros.
* frame.c (make_frame): Initialize the `can_have_scrollbars' and
`has_vertical_scrollbars' fields of the frame.
* term.c (term_init): Note that TERMCAP terminals don't support
scrollbars.
(mouse_position_hook): Document new args.
(set_vertical_scrollbar_hook, condemn_scrollbars_hook,
redeem_scrollbar_hook, judge_scrollbars_hook): New hooks.
* termhooks.h: Declare and document them.
(enum scrollbar_part): New type.
(struct input_event): Describe the new form of the scrollbar_click
event type. Change `part' from a Lisp_Object to an enum
scrollbar_part. Add a new field `scrollbar'.
* keyboard.c (kbd_buffer_get_event): Pass appropriate new
parameters to *mouse_position_hook, and make_lispy_movement.
* xfns.c (x_set_vertical_scrollbar): New function.
(x_figure_window_size): Use new macros to calculate frame size.
(Fx_create_frame): Note that X Windows frames do support scroll
bars. Default to "yes".
* xterm.c: #include <X11/cursorfont.h> and "window.h".
(x_vertical_scrollbar_cursor): New variable.
(x_term_init): Initialize it.
(last_mouse_bar, last_mouse_bar_frame, last_mouse_part,
last_mouse_scroll_range_start, last_mouse_scroll_range_end): New
variables.
(XTmouse_position): Use them to return scrollbar movement events.
Take new arguments, for that purpose.
(x_window_to_scrollbar, x_scrollbar_create,
x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move,
XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar,
XTjudge_scrollbars, x_scrollbar_expose,
x_scrollbar_background_expose, x_scrollbar_handle_click,
x_scrollbar_handle_motion): New functions to implement scrollbars.
(x_term_init): Set the termhooks.h hooks to point to them.
(x_set_window_size): Use new macros to calculate frame size. Set
vertical_scrollbar_extra field.
(x_make_frame_visible): Use the frame accessor
FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the
frame's subwindows as well.
(XTread_socket): Use new size-calculation macros from xterm.h when
processing ConfigureNotify events.
(x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and
PIXEL_TO_CHAR_HEIGHT macros.
* ymakefile (xdisp.o): This now depends on termhooks.h.
(xterm.o): This now depends on window.h.
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Thu, 24 Dec 1992 06:17:18 +0000 |
| parents | 99fb20ef1a17 |
| children | 10e417efb12a |
| rev | line source |
|---|---|
|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
474
diff
changeset
|
1 ;;; mailalias.el --- expand mailing address aliases defined in ~/.mailrc. |
|
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
474
diff
changeset
|
2 |
|
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
3 ;; Copyright (C) 1985, 1987 Free Software Foundation, Inc. |
|
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
5 ;; Maintainer: FSF |
|
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: mail |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
7 |
| 53 | 8 ;; This file is part of GNU Emacs. |
| 9 | |
| 10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 11 ;; it under the terms of the GNU General Public License as published by | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
| 53 | 13 ;; any later version. |
| 14 | |
| 15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 ;; GNU General Public License for more details. | |
| 19 | |
| 20 ;; You should have received a copy of the GNU General Public License | |
| 21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
| 22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 23 | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
24 ;;; Code: |
| 53 | 25 |
|
1448
99fb20ef1a17
(mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents:
1434
diff
changeset
|
26 (defvar mail-aliases t |
|
99fb20ef1a17
(mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents:
1434
diff
changeset
|
27 "Alias of mail address aliases, |
|
99fb20ef1a17
(mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents:
1434
diff
changeset
|
28 or t meaning should be initialized from `~/.mailrc'.") |
|
99fb20ef1a17
(mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents:
1434
diff
changeset
|
29 |
| 53 | 30 ;; Called from sendmail-send-it, or similar functions, |
| 31 ;; only if some mail aliases are defined. | |
| 32 (defun expand-mail-aliases (beg end &optional exclude) | |
| 33 "Expand all mail aliases in suitable header fields found between BEG and END. | |
|
221
ce8e0192266e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
219
diff
changeset
|
34 Suitable header fields are `To', `Cc' and `Bcc' and their `Resent-' variants. |
|
ce8e0192266e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
219
diff
changeset
|
35 Optional second arg EXCLUDE may be a regular expression defining text to be |
|
ce8e0192266e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
219
diff
changeset
|
36 removed from alias expansions." |
| 53 | 37 (if (eq mail-aliases t) |
| 38 (progn (setq mail-aliases nil) (build-mail-aliases))) | |
| 39 (goto-char beg) | |
| 40 (setq end (set-marker (make-marker) end)) | |
| 41 (let ((case-fold-search nil)) | |
| 42 (while (let ((case-fold-search t)) | |
| 219 | 43 (re-search-forward "^\\(to\\|cc\\|bcc\\|resent-to\\|resent-cc\\|resent-bcc\\):" end t)) |
| 53 | 44 (skip-chars-forward " \t") |
| 45 (let ((beg1 (point)) | |
| 46 end1 pos epos seplen | |
| 47 ;; DISABLED-ALIASES records aliases temporarily disabled | |
| 48 ;; while we scan text that resulted from expanding those aliases. | |
| 49 ;; Each element is (ALIAS . TILL-WHEN), where TILL-WHEN | |
| 50 ;; is where to reenable the alias (expressed as number of chars | |
| 51 ;; counting from END1). | |
| 52 (disabled-aliases nil)) | |
| 53 (re-search-forward "^[^ \t]" end 'move) | |
| 54 (beginning-of-line) | |
| 55 (skip-chars-backward " \t\n") | |
| 56 (setq end1 (point-marker)) | |
| 57 (goto-char beg1) | |
| 58 (while (< (point) end1) | |
| 59 (setq pos (point)) | |
| 60 ;; Reenable any aliases which were disabled for ranges | |
| 61 ;; that we have passed out of. | |
| 62 (while (and disabled-aliases (> pos (- end1 (cdr (car disabled-aliases))))) | |
| 63 (setq disabled-aliases (cdr disabled-aliases))) | |
| 64 ;; EPOS gets position of end of next name; | |
| 65 ;; SEPLEN gets length of whitespace&separator that follows it. | |
| 66 (if (re-search-forward "[ \t]*[\n,][ \t]*" end1 t) | |
| 67 (setq epos (match-beginning 0) | |
| 68 seplen (- (point) epos)) | |
| 69 (setq epos (marker-position end1) seplen 0)) | |
| 70 (let (translation | |
| 71 (string (buffer-substring pos epos))) | |
| 72 (if (and (not (assoc string disabled-aliases)) | |
| 73 (setq translation | |
| 74 (cdr (assoc string mail-aliases)))) | |
| 75 (progn | |
| 76 ;; This name is an alias. Disable it. | |
| 77 (setq disabled-aliases (cons (cons string (- end1 epos)) | |
| 78 disabled-aliases)) | |
| 79 ;; Replace the alias with its expansion | |
| 80 ;; then rescan the expansion for more aliases. | |
| 81 (goto-char pos) | |
| 82 (insert translation) | |
| 83 (if exclude | |
| 84 (let ((regexp | |
| 85 (concat "\\b\\(" exclude "\\)\\b")) | |
| 86 (end (point-marker))) | |
| 87 (goto-char pos) | |
| 88 (while (re-search-forward regexp end t) | |
| 89 (replace-match "")) | |
| 90 (goto-char end))) | |
| 91 (delete-region (point) (+ (point) (- epos pos))) | |
| 92 (goto-char pos)) | |
| 93 ;; Name is not an alias. Skip to start of next name. | |
| 94 (goto-char epos) | |
| 95 (forward-char seplen)))) | |
| 96 (set-marker end1 nil))) | |
| 97 (set-marker end nil))) | |
| 98 | |
| 99 ;; Called by mail-setup, or similar functions, only if ~/.mailrc exists. | |
| 100 (defun build-mail-aliases (&optional file) | |
| 1434 | 101 "Read mail aliases from `~/.mailrc' and set `mail-aliases'." |
| 53 | 102 (setq file (expand-file-name (or file "~/.mailrc"))) |
| 103 (let ((buffer nil) | |
| 104 (obuf (current-buffer))) | |
| 105 (unwind-protect | |
| 106 (progn | |
| 107 (setq buffer (generate-new-buffer "mailrc")) | |
| 108 (buffer-disable-undo buffer) | |
| 109 (set-buffer buffer) | |
| 110 (cond ((get-file-buffer file) | |
| 111 (insert (save-excursion | |
| 112 (set-buffer (get-file-buffer file)) | |
| 113 (buffer-substring (point-min) (point-max))))) | |
| 114 ((not (file-exists-p file))) | |
| 115 (t (insert-file-contents file))) | |
| 116 ;; Don't lose if no final newline. | |
| 117 (goto-char (point-max)) | |
| 118 (or (eq (preceding-char) ?\n) (newline)) | |
| 119 (goto-char (point-min)) | |
| 120 ;; handle "\\\n" continuation lines | |
| 121 (while (not (eobp)) | |
| 122 (end-of-line) | |
| 123 (if (= (preceding-char) ?\\) | |
| 124 (progn (delete-char -1) (delete-char 1) (insert ?\ )) | |
| 125 (forward-char 1))) | |
| 126 (goto-char (point-min)) | |
| 127 (while (or (re-search-forward "^a\\(lias\\|\\)[ \t]+" nil t) | |
| 128 (re-search-forward "^g\\(roup\\|\\)[ \t]+" nil t)) | |
| 129 (re-search-forward "[^ \t]+") | |
| 130 (let* ((name (buffer-substring (match-beginning 0) (match-end 0))) | |
| 131 (start (progn (skip-chars-forward " \t") (point)))) | |
| 132 (end-of-line) | |
| 133 (define-mail-alias | |
| 134 name | |
| 135 (buffer-substring start (point))))) | |
| 136 mail-aliases) | |
| 137 (if buffer (kill-buffer buffer)) | |
| 138 (set-buffer obuf)))) | |
| 139 | |
| 140 ;; Always autoloadable in case the user wants to define aliases | |
| 141 ;; interactively or in .emacs. | |
| 256 | 142 ;;;###autoload |
| 53 | 143 (defun define-mail-alias (name definition) |
|
221
ce8e0192266e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
219
diff
changeset
|
144 "Define NAME as a mail alias that translates to DEFINITION. |
| 53 | 145 This means that sending a message to NAME will actually send to DEFINITION. |
| 146 DEFINITION can be one or more mail addresses separated by commas." | |
| 147 (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ") | |
| 148 ;; Read the defaults first, if we have not done so. | |
| 149 (if (eq mail-aliases t) | |
| 150 (progn | |
| 151 (setq mail-aliases nil) | |
| 152 (if (file-exists-p "~/.mailrc") | |
| 153 (build-mail-aliases)))) | |
| 474 | 154 ;; Strip leading and trailing blanks. |
| 155 (if (string-match "^[ \t]+" definition) | |
| 156 (setq definition (substring definition (match-end 0)))) | |
| 157 (if (string-match "[ \t]+$" definition) | |
| 158 (setq definition (substring definition 0 (match-beginning 0)))) | |
| 159 (let ((first (aref definition 0)) | |
| 160 (last (aref definition (1- (length definition)))) | |
| 161 tem) | |
| 162 (if (and (= first last) (memq first '(?\' ?\"))) | |
| 163 ;; Strip quotation marks. | |
| 164 (setq definition (substring definition 1 (1- (length definition)))) | |
| 165 ;; ~/.mailrc contains addresses separated by spaces. | |
| 166 ;; mailers should expect addresses separated by commas. | |
| 167 (while (setq tem (string-match "[^ \t,][ \t,]+" definition tem)) | |
| 168 (if (= (match-end 0) (length definition)) | |
| 169 (setq definition (substring definition 0 (1+ tem))) | |
| 170 (setq definition (concat (substring definition | |
| 171 0 (1+ tem)) | |
| 172 ", " | |
| 173 (substring definition (match-end 0)))) | |
| 174 (setq tem (+ 3 tem))))) | |
| 53 | 175 (setq tem (assoc name mail-aliases)) |
| 176 (if tem | |
| 177 (rplacd tem definition) | |
| 178 (setq mail-aliases (cons (cons name definition) mail-aliases))))) | |
|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
474
diff
changeset
|
179 |
| 923 | 180 (provide 'mailalias) |
| 181 | |
|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
474
diff
changeset
|
182 ;;; mailalias.el ends here |
