1 ;;; vms-pmail.el --- use Emacs as the editor within VMS mail.
3 ;; Copyright (C) 1992 Free Software Foundation, Inc.
5 ;; Author: Roland B Roberts <roberts@panix.com>
8 ;; This file is part of GNU Emacs.
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
12 ;; the Free Software Foundation; either version 2, or (at your option)
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.
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 the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
28 ;;; Quick hack to use emacs as mail editor. There are a *bunch* of
29 ;;; changes scattered throughout emacs to make this work, namely:
30 ;;; (1) mod to sysdep.c to allow emacs to attach to a process other
31 ;;; than the one that originally spawned it.
32 ;;; (2) mod to kepteditor.com to define the logical emacs_parent_pid
33 ;;; which is what sysdep.c looks for, and define the logical
34 ;;; emacs_command_args which contains the command line
35 ;;; (3) mod to re-parse command line arguments from emacs_command_args
36 ;;; then execute them as though emacs were just starting up.
38 (defun vms-pmail-save-and-exit ()
39 "Save current buffer and exit emacs.
40 If this emacs cannot be suspended, you will be prompted about modified
41 buffers other than the mail buffer. BEWARE --- suspending emacs without
42 saving your mail buffer causes mail to abort the send (potentially useful
43 since the mail buffer is still here)."
46 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
50 (kill-buffer (current-buffer))
53 (defun vms-pmail-abort ()
54 "Mark buffer as unmodified and exit emacs.
55 When the editor is exited without saving its buffer, VMS mail does not
56 send a message. If you have other modified buffers you will be
57 prompted for what to do with them."
59 (if (not (yes-or-no-p "Really abort mail? "))
62 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
66 (kill-buffer (current-buffer))
69 (defun vms-pmail-setup ()
70 "Set up file assuming use by VMS MAIL utility.
71 The buffer is put into text-mode, auto-save is turned off and the
72 following bindings are established.
74 \\[vms-pmail-save-and-exit] vms-pmail-save-and-exit
75 \\[vms-pmail-abort] vms-pmail-abort
77 All other emacs commands are still available."
81 (let ((default (vms-system-info "LOGICAL" "SYS$SCRATCH"))
82 (directory (file-name-directory (buffer-file-name)))
83 (filename (file-name-nondirectory (buffer-file-name))))
84 (if (string= directory
"SYS$SCRATCH:")
87 (setq buffer-file-name
(concat default filename
))))
88 (use-local-map (copy-keymap (current-local-map)))
89 (local-set-key "\C-c\C-c" 'vms-pmail-save-and-exit
)
90 (local-set-key "\C-c\C-g" 'vms-pmail-abort
)))
92 (defun indicate-mail-reply-text ()
93 "Prepares received mail for re-sending by placing >'s on each line."
95 (goto-char (point-min))
100 (set-buffer-modified-p nil
)
101 (goto-char (point-min)))
103 (defun insert-signature ()
104 "Moves to the end of the buffer and inserts a \"signature\" file.
105 First try the file indicated by environment variable MAIL$TRAILER.
106 If that fails, try the file \"~/.signature\".
107 If neither file exists, fails quietly."
111 (if (vms-system-info "LOGICAL" "MAIL$TRAILER")
112 (if (file-attributes (vms-system-info "LOGICAL" "MAIL$TRAILER"))
113 (insert-file-contents (vms-system-info "LOGICAL" "MAIL$TRAILER"))
114 (if (file-attributes "~/.signature")
115 (insert-file-contents "~/.signature")))))
119 ;;; vms-pmail.el ends here