1190
|
1 ;;; vms-pmail.el -- use Emacs as the editor within VMS mail.
|
|
2 ;; Copyright (C) 1992 Free Software Foundation, Inc.
|
|
3
|
|
4 ;; Author: Roland B Roberts <roberts@nsrl31.nsrl.rochester.edu>
|
|
5
|
|
6 ;; This file is part of GNU Emacs.
|
|
7
|
|
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
9 ;; it under the terms of the GNU General Public License as published by
|
|
10 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
11 ;; any later version.
|
|
12
|
|
13 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 ;; GNU General Public License for more details.
|
|
17
|
|
18 ;; You should have received a copy of the GNU General Public License
|
|
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
21
|
|
22 ;;; Code:
|
|
23
|
|
24 ;;;
|
|
25 ;;; Quick hack to use emacs as mail editor. There are a *bunch* of
|
|
26 ;;; changes scattered throughout emacs to make this work, namely:
|
|
27 ;;; (1) mod to sysdep.c to allow emacs to attach to a process other
|
|
28 ;;; than the one that originally spawned it.
|
|
29 ;;; (2) mod to kepteditor.com to define the logical emacs_parent_pid
|
|
30 ;;; which is what sysdep.c looks for, and define the logical
|
|
31 ;;; emacs_command_args which contains the command line
|
|
32 ;;; (3) mod to re-parse command line arguments from emacs_command_args
|
|
33 ;;; then execute them as though emacs were just starting up.
|
|
34 ;;;
|
|
35 (defun vms-pmail-save-and-exit ()
|
|
36 "Save current buffer and exit emacs.
|
|
37 If this emacs cannot be suspended, you will be prompted about modified
|
|
38 buffers other than the mail buffer. BEWARE --- suspending emacs without
|
|
39 saving your mail buffer causes mail to abort the send (potentially useful
|
|
40 since the mail buffer is still here)."
|
|
41 (interactive)
|
|
42 (basic-save-buffer)
|
|
43 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
|
|
44 (progn
|
|
45 (save-some-buffers)
|
|
46 (kill-emacs 1))
|
|
47 (kill-buffer (current-buffer))
|
|
48 (suspend-emacs)))
|
|
49
|
|
50 (defun vms-pmail-abort ()
|
|
51 "Mark buffer as unmodified and exit emacs.
|
|
52 When the editor is exited without saving its buffer, VMS mail does not
|
|
53 send a message. If you have other modified buffers you will be
|
|
54 prompted for what to do with them."
|
|
55 (interactive)
|
|
56 (if (not (yes-or-no-p "Really abort mail? "))
|
|
57 (ding)
|
|
58 (not-modified)
|
|
59 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
|
|
60 (progn
|
|
61 (save-some-buffers)
|
|
62 (kill-emacs 1))
|
|
63 (kill-buffer (current-buffer))
|
|
64 (suspend-emacs))))
|
|
65
|
|
66 (defun vms-pmail-setup ()
|
|
67 "Set up file assuming use by VMS MAIL utility.
|
|
68 The buffer is put into text-mode, auto-save is turned off and the
|
|
69 following bindings are established.
|
|
70
|
|
71 \\[vms-pmail-save-and-exit] vms-pmail-save-and-exit
|
|
72 \\[vms-pmail-abort] vms-pmail-abort
|
|
73
|
|
74 All other emacs commands are still available."
|
|
75 (interactive)
|
|
76 (auto-save-mode -1)
|
|
77 (text-mode)
|
|
78 (let ((default (vms-system-info "LOGICAL" "SYS$SCRATCH"))
|
|
79 (directory (file-name-directory (buffer-file-name)))
|
|
80 (filename (file-name-nondirectory (buffer-file-name))))
|
|
81 (if (string= directory "SYS$SCRATCH:")
|
|
82 (progn
|
|
83 (cd default)
|
|
84 (setq buffer-file-name (concat default filename))))
|
|
85 (use-local-map (copy-keymap (current-local-map)))
|
|
86 (local-set-key "\C-c\C-c" 'vms-pmail-save-and-exit)
|
|
87 (local-set-key "\C-c\C-g" 'vms-pmail-abort)))
|
|
88
|
|
89 (defun indicate-mail-reply-text ()
|
|
90 "Prepares received mail for re-sending by placing >'s on each line."
|
|
91 (interactive)
|
|
92 (goto-char (point-min))
|
|
93 (while (not (eobp))
|
|
94 (insert ">")
|
|
95 (beginning-of-line)
|
|
96 (forward-line 1))
|
|
97 (set-buffer-modified-p nil)
|
|
98 (goto-char (point-min)))
|
|
99
|
|
100 (defun insert-signature ()
|
|
101 "Moves to the end of the buffer and inserts a \"signature\" file.
|
|
102 First try the file indicated by environment variable MAIL$TRAILER.
|
|
103 If that fails, try the file \"~/.signature\".
|
|
104 If neither file exists, fails quietly."
|
|
105 (interactive)
|
|
106 (end-of-buffer)
|
|
107 (newline)
|
|
108 (if (vms-system-info "LOGICAL" "MAIL$TRAILER")
|
|
109 (if (file-attributes (vms-system-info "LOGICAL" "MAIL$TRAILER"))
|
|
110 (insert-file-contents (vms-system-info "LOGICAL" "MAIL$TRAILER"))
|
|
111 (if (file-attributes "~/.signature")
|
|
112 (insert-file-contents "~/.signature")))))
|
|
113
|