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