1 ;;; vms-pmail.el --- use Emacs as the editor within VMS mail
3 ;; Copyright (C) 1992, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 ;; Author: Roland B Roberts <roberts@panix.com>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
31 ;;; Quick hack to use emacs as mail editor. There are a *bunch* of
32 ;;; changes scattered throughout emacs to make this work, namely:
33 ;;; (1) mod to sysdep.c to allow emacs to attach to a process other
34 ;;; than the one that originally spawned it.
35 ;;; (2) mod to kepteditor.com to define the logical emacs_parent_pid
36 ;;; which is what sysdep.c looks for, and define the logical
37 ;;; emacs_command_args which contains the command line
38 ;;; (3) mod to re-parse command line arguments from emacs_command_args
39 ;;; then execute them as though emacs were just starting up.
41 (defun vms-pmail-save-and-exit ()
42 "Save current buffer and exit emacs.
43 If this emacs cannot be suspended, you will be prompted about modified
44 buffers other than the mail buffer. BEWARE --- suspending emacs without
45 saving your mail buffer causes mail to abort the send (potentially useful
46 since the mail buffer is still here)."
49 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
53 (kill-buffer (current-buffer))
56 (defun vms-pmail-abort ()
57 "Mark buffer as unmodified and exit emacs.
58 When the editor is exited without saving its buffer, VMS mail does not
59 send a message. If you have other modified buffers you will be
60 prompted for what to do with them."
62 (if (not (yes-or-no-p "Really abort mail? "))
65 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
69 (kill-buffer (current-buffer))
72 (defun vms-pmail-setup ()
73 "Set up file assuming use by VMS MAIL utility.
74 The buffer is put into text-mode, auto-save is turned off and the
75 following bindings are established.
77 \\[vms-pmail-save-and-exit] vms-pmail-save-and-exit
78 \\[vms-pmail-abort] vms-pmail-abort
80 All other emacs commands are still available."
84 (let ((default (vms-system-info "LOGICAL" "SYS$SCRATCH"))
85 (directory (file-name-directory (buffer-file-name)))
86 (filename (file-name-nondirectory (buffer-file-name))))
87 (if (string= directory
"SYS$SCRATCH:")
90 (setq buffer-file-name
(concat default filename
))))
91 (use-local-map (copy-keymap (current-local-map)))
92 (local-set-key "\C-c\C-c" 'vms-pmail-save-and-exit
)
93 (local-set-key "\C-c\C-g" 'vms-pmail-abort
)))
95 (defun indicate-mail-reply-text ()
96 "Prepares received mail for re-sending by placing >'s on each line."
98 (goto-char (point-min))
103 (set-buffer-modified-p nil
)
104 (goto-char (point-min)))
106 (defun insert-signature ()
107 "Moves to the end of the buffer and inserts a \"signature\" file.
108 First try the file indicated by environment variable MAIL$TRAILER.
109 If that fails, try the file \"~/.signature\".
110 If neither file exists, fails quietly."
114 (if (vms-system-info "LOGICAL" "MAIL$TRAILER")
115 (if (file-attributes (vms-system-info "LOGICAL" "MAIL$TRAILER"))
116 (insert-file-contents (vms-system-info "LOGICAL" "MAIL$TRAILER"))
117 (if (file-attributes "~/.signature")
118 (insert-file-contents "~/.signature")))))
122 ;;; arch-tag: 336850fc-7812-4663-8e4d-b9c13f47dce1
123 ;;; vms-pmail.el ends here