1 ;; Override parts of files.el for VMS.
2 ;; Copyright (C) 1986 Free Software Foundation, Inc.
4 ;; This file is part of GNU Emacs.
6 ;; GNU Emacs is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 1, or (at your option)
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GNU Emacs; see the file COPYING. If not, write to
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 ;;; Functions that need redefinition
23 ;;; VMS file names are upper case, but buffer names are more
24 ;;; convenient in lower case.
26 (defun create-file-buffer (filename)
27 "Create a suitably named buffer for visiting FILENAME, and return it.
28 FILENAME (sans directory) is used unchanged if that name is free;
29 otherwise a string <2> or <3> or ... is appended to get an unused name."
30 (generate-new-buffer (downcase (file-name-nondirectory filename
))))
32 ;;; Given a string FN, return a similar name which is a legal VMS filename.
33 ;;; This is used to avoid invalid auto save file names.
34 (defun make-legal-file-name (fn)
35 (setq fn
(copy-sequence fn
))
36 (let ((dot nil
) (indx 0) (len (length fn
)) chr
)
38 (setq chr
(aref fn indx
))
40 ((eq chr ?.
) (if dot
(aset fn indx ?_
) (setq dot t
)))
41 ((not (or (and (>= chr ?a
) (<= chr ?z
)) (and (>= chr ?A
) (<= chr ?Z
))
42 (and (>= chr ?
0) (<= chr ?
9))
43 (eq chr ?$
) (eq chr ?_
) (and (eq chr ?-
) (> indx
0))))
45 (setq indx
(1+ indx
))))
48 ;;; Auto save filesnames start with _$ and end with $.
50 (defun make-auto-save-file-name ()
51 "Return file name to use for auto-saves of current buffer.
52 Does not consider auto-save-visited-file-name; that is checked
53 before calling this function.
54 This is a separate function so your .emacs file or site-init.el can redefine it.
55 See also auto-save-file-name-p."
57 (concat (file-name-directory buffer-file-name
)
59 (file-name-nondirectory buffer-file-name
)
61 (expand-file-name (concat "_$_" (make-legal-file-name (buffer-name)) "$"))))
63 (defun auto-save-file-name-p (filename)
64 "Return t if FILENAME can be yielded by make-auto-save-file-name.
65 FILENAME should lack slashes.
66 This is a separate function so your .emacs file or site-init.el can redefine it."
67 (string-match "^_\\$.*\\$" filename
))
69 (defun vms-suspend-resume-hook ()
70 "When resuming suspended Emacs, check for file to be found.
71 If the logical name `EMACS_FILE_NAME' is defined, `find-file' that file."
72 (let ((file (vms-system-info "LOGICAL" "EMACS_FILE_NAME")))
73 (if file
(find-file file
))))
75 (setq suspend-resume-hook
'vms-suspend-resume-hook
)
77 (defun vms-suspend-hook ()
78 "Don't allow suspending if logical name `DONT_SUSPEND_EMACS' is defined."
79 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
80 (error "Can't suspend this emacs"))
83 (setq suspend-hook
'vms-suspend-hook
)
85 (defun vms-read-directory (dirname switches buffer
)
88 (subprocess-command-to-buffer
89 (concat "DIRECTORY " switches
" " dirname
)
91 (goto-char (point-min))
92 ;; Remove all the trailing blanks.
93 (while (search-forward " \n")
95 (delete-horizontal-space))
96 (goto-char (point-min))))
98 (setq dired-listing-switches
99 "/SIZE/DATE/OWNER/WIDTH=(FILENAME=32,SIZE=5)")
101 (setq print-region-function
102 '(lambda (start end command ign1 ign2 ign3
&rest switches
)
103 (write-region start end
"sys$login:delete-me.txt")
104 (send-command-to-subprocess
107 " sys$login:delete-me.txt/name=""GNUprintbuffer"" "
108 (mapconcat 'identity switches
" "))