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