*** empty log message ***
[bpt/emacs.git] / lisp / vms-patch.el
CommitLineData
d501f516
ER
1;;; vms-patch.el --- override parts of files.el for VMS.
2
e5167999
ER
3;; Maintainer: FSF
4;; Last-Modified: 06 May 1992
5
a2535589
JA
6;; Copyright (C) 1986 Free Software Foundation, Inc.
7
8;; This file is part of GNU Emacs.
9
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
e5167999 12;; the Free Software Foundation; either version 2, or (at your option)
a2535589
JA
13;; any later version.
14
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.
19
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
22;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
e5167999 24;;; Code:
a2535589
JA
25
26;;; Functions that need redefinition
27
28;;; VMS file names are upper case, but buffer names are more
29;;; convenient in lower case.
30
31(defun create-file-buffer (filename)
32 "Create a suitably named buffer for visiting FILENAME, and return it.
33FILENAME (sans directory) is used unchanged if that name is free;
34otherwise a string <2> or <3> or ... is appended to get an unused name."
35 (generate-new-buffer (downcase (file-name-nondirectory filename))))
36
37;;; Given a string FN, return a similar name which is a legal VMS filename.
38;;; This is used to avoid invalid auto save file names.
39(defun make-legal-file-name (fn)
40 (setq fn (copy-sequence fn))
41 (let ((dot nil) (indx 0) (len (length fn)) chr)
42 (while (< indx len)
43 (setq chr (aref fn indx))
44 (cond
45 ((eq chr ?.) (if dot (aset fn indx ?_) (setq dot t)))
46 ((not (or (and (>= chr ?a) (<= chr ?z)) (and (>= chr ?A) (<= chr ?Z))
47 (and (>= chr ?0) (<= chr ?9))
48 (eq chr ?$) (eq chr ?_) (and (eq chr ?-) (> indx 0))))
49 (aset fn indx ?_)))
50 (setq indx (1+ indx))))
51 fn)
52
53;;; Auto save filesnames start with _$ and end with $.
54
55(defun make-auto-save-file-name ()
56 "Return file name to use for auto-saves of current buffer.
57Does not consider auto-save-visited-file-name; that is checked
58before calling this function.
59This is a separate function so your .emacs file or site-init.el can redefine it.
60See also auto-save-file-name-p."
61 (if buffer-file-name
62 (concat (file-name-directory buffer-file-name)
63 "_$"
64 (file-name-nondirectory buffer-file-name)
65 "$")
66 (expand-file-name (concat "_$_" (make-legal-file-name (buffer-name)) "$"))))
67
68(defun auto-save-file-name-p (filename)
69 "Return t if FILENAME can be yielded by make-auto-save-file-name.
70FILENAME should lack slashes.
71This is a separate function so your .emacs file or site-init.el can redefine it."
72 (string-match "^_\\$.*\\$" filename))
73
74(defun vms-suspend-resume-hook ()
75 "When resuming suspended Emacs, check for file to be found.
76If the logical name `EMACS_FILE_NAME' is defined, `find-file' that file."
77 (let ((file (vms-system-info "LOGICAL" "EMACS_FILE_NAME")))
78 (if file (find-file file))))
79
80(setq suspend-resume-hook 'vms-suspend-resume-hook)
81
82(defun vms-suspend-hook ()
83 "Don't allow suspending if logical name `DONT_SUSPEND_EMACS' is defined."
84 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
85 (error "Can't suspend this emacs"))
86 nil)
87
88(setq suspend-hook 'vms-suspend-hook)
89
90(defun vms-read-directory (dirname switches buffer)
91 (save-excursion
92 (set-buffer buffer)
93 (subprocess-command-to-buffer
94 (concat "DIRECTORY " switches " " dirname)
95 buffer)
96 (goto-char (point-min))
97 ;; Remove all the trailing blanks.
98 (while (search-forward " \n")
99 (forward-char -1)
100 (delete-horizontal-space))
101 (goto-char (point-min))))
102
103(setq dired-listing-switches
104 "/SIZE/DATE/OWNER/WIDTH=(FILENAME=32,SIZE=5)")
86581d96
JB
105
106(setq print-region-function
107 '(lambda (start end command ign1 ign2 ign3 &rest switches)
108 (write-region start end "sys$login:delete-me.txt")
109 (send-command-to-subprocess
110 1
111 (concat command
112 " sys$login:delete-me.txt/name=""GNUprintbuffer"" "
113 (mapconcat 'identity switches " "))
114 nil nil nil)))
d501f516
ER
115
116;;; vms-patch.el ends here