annotate lisp/vms-patch.el @ 748:4714ad36583c

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Tue, 07 Jul 1992 18:36:02 +0000
parents fec3f9a1e3e5
children 4f28bd14272c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 156
diff changeset
1 ;;; vms-patch.el --- override parts of files.el for VMS.
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 156
diff changeset
2
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1986 Free Software Foundation, Inc.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
4
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
6
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
8 ;; it under the terms of the GNU General Public License as published by
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
9 ;; the Free Software Foundation; either version 1, or (at your option)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
10 ;; any later version.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
11
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is distributed in the hope that it will be useful,
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
15 ;; GNU General Public License for more details.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
16
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
20
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
21
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
22 ;;; Functions that need redefinition
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
23
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
24 ;;; VMS file names are upper case, but buffer names are more
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
25 ;;; convenient in lower case.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
26
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
27 (defun create-file-buffer (filename)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
28 "Create a suitably named buffer for visiting FILENAME, and return it.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
29 FILENAME (sans directory) is used unchanged if that name is free;
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
30 otherwise a string <2> or <3> or ... is appended to get an unused name."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
31 (generate-new-buffer (downcase (file-name-nondirectory filename))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
32
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
33 ;;; Given a string FN, return a similar name which is a legal VMS filename.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
34 ;;; This is used to avoid invalid auto save file names.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
35 (defun make-legal-file-name (fn)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
36 (setq fn (copy-sequence fn))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
37 (let ((dot nil) (indx 0) (len (length fn)) chr)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
38 (while (< indx len)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
39 (setq chr (aref fn indx))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
40 (cond
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
41 ((eq chr ?.) (if dot (aset fn indx ?_) (setq dot t)))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
42 ((not (or (and (>= chr ?a) (<= chr ?z)) (and (>= chr ?A) (<= chr ?Z))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
43 (and (>= chr ?0) (<= chr ?9))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
44 (eq chr ?$) (eq chr ?_) (and (eq chr ?-) (> indx 0))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
45 (aset fn indx ?_)))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
46 (setq indx (1+ indx))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
47 fn)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
48
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
49 ;;; Auto save filesnames start with _$ and end with $.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
50
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
51 (defun make-auto-save-file-name ()
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
52 "Return file name to use for auto-saves of current buffer.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
53 Does not consider auto-save-visited-file-name; that is checked
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
54 before calling this function.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
55 This is a separate function so your .emacs file or site-init.el can redefine it.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
56 See also auto-save-file-name-p."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
57 (if buffer-file-name
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
58 (concat (file-name-directory buffer-file-name)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
59 "_$"
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
60 (file-name-nondirectory buffer-file-name)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
61 "$")
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
62 (expand-file-name (concat "_$_" (make-legal-file-name (buffer-name)) "$"))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
63
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
64 (defun auto-save-file-name-p (filename)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
65 "Return t if FILENAME can be yielded by make-auto-save-file-name.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
66 FILENAME should lack slashes.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
67 This is a separate function so your .emacs file or site-init.el can redefine it."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
68 (string-match "^_\\$.*\\$" filename))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
69
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
70 (defun vms-suspend-resume-hook ()
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
71 "When resuming suspended Emacs, check for file to be found.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
72 If the logical name `EMACS_FILE_NAME' is defined, `find-file' that file."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
73 (let ((file (vms-system-info "LOGICAL" "EMACS_FILE_NAME")))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
74 (if file (find-file file))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
75
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
76 (setq suspend-resume-hook 'vms-suspend-resume-hook)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
77
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
78 (defun vms-suspend-hook ()
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
79 "Don't allow suspending if logical name `DONT_SUSPEND_EMACS' is defined."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
80 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
81 (error "Can't suspend this emacs"))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
82 nil)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
83
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
84 (setq suspend-hook 'vms-suspend-hook)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
85
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
86 (defun vms-read-directory (dirname switches buffer)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
87 (save-excursion
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
88 (set-buffer buffer)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
89 (subprocess-command-to-buffer
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
90 (concat "DIRECTORY " switches " " dirname)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
91 buffer)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
92 (goto-char (point-min))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
93 ;; Remove all the trailing blanks.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
94 (while (search-forward " \n")
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
95 (forward-char -1)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
96 (delete-horizontal-space))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
97 (goto-char (point-min))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
98
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
99 (setq dired-listing-switches
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
100 "/SIZE/DATE/OWNER/WIDTH=(FILENAME=32,SIZE=5)")
156
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
101
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
102 (setq print-region-function
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
103 '(lambda (start end command ign1 ign2 ign3 &rest switches)
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
104 (write-region start end "sys$login:delete-me.txt")
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
105 (send-command-to-subprocess
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
106 1
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
107 (concat command
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
108 " sys$login:delete-me.txt/name=""GNUprintbuffer"" "
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
109 (mapconcat 'identity switches " "))
29a528f78681 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 36
diff changeset
110 nil nil nil)))
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 156
diff changeset
111
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 156
diff changeset
112 ;;; vms-patch.el ends here