Mercurial > emacs
annotate lisp/vms-patch.el @ 15577:e369d2f12bc7
Load `gnus-score-mode' from "score-mode".
author | Lars Magne Ingebrigtsen <larsi@gnus.org> |
---|---|
date | Sun, 30 Jun 1996 18:19:19 +0000 |
parents | 83f275dcd93a |
children | 12e32a06de22 |
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 |
1174 | 3 ;; Copyright (C) 1986, 1992 Free Software Foundation, Inc. |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
812
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
5 ;; Maintainer: FSF |
812
485e82a8acb5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: vms |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
7 |
36 | 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 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 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 | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
36 | 24 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
25 ;;; Code: |
36 | 26 |
27 ;;; Functions that need redefinition | |
28 | |
29 ;;; VMS file names are upper case, but buffer names are more | |
30 ;;; convenient in lower case. | |
31 | |
32 (defun create-file-buffer (filename) | |
33 "Create a suitably named buffer for visiting FILENAME, and return it. | |
34 FILENAME (sans directory) is used unchanged if that name is free; | |
35 otherwise a string <2> or <3> or ... is appended to get an unused name." | |
36 (generate-new-buffer (downcase (file-name-nondirectory filename)))) | |
37 | |
38 ;;; Given a string FN, return a similar name which is a legal VMS filename. | |
39 ;;; This is used to avoid invalid auto save file names. | |
40 (defun make-legal-file-name (fn) | |
41 (setq fn (copy-sequence fn)) | |
42 (let ((dot nil) (indx 0) (len (length fn)) chr) | |
43 (while (< indx len) | |
44 (setq chr (aref fn indx)) | |
45 (cond | |
46 ((eq chr ?.) (if dot (aset fn indx ?_) (setq dot t))) | |
47 ((not (or (and (>= chr ?a) (<= chr ?z)) (and (>= chr ?A) (<= chr ?Z)) | |
48 (and (>= chr ?0) (<= chr ?9)) | |
49 (eq chr ?$) (eq chr ?_) (and (eq chr ?-) (> indx 0)))) | |
50 (aset fn indx ?_))) | |
51 (setq indx (1+ indx)))) | |
52 fn) | |
53 | |
54 ;;; Auto save filesnames start with _$ and end with $. | |
55 | |
56 (defun make-auto-save-file-name () | |
57 "Return file name to use for auto-saves of current buffer. | |
11045
b4bf1f2d99f8
(make-auto-save-file-name, auto-save-file-name-p): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
2864
diff
changeset
|
58 This function does not consider `auto-save-visited-file-name'; |
b4bf1f2d99f8
(make-auto-save-file-name, auto-save-file-name-p): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
2864
diff
changeset
|
59 the caller should check that before calling this function. |
b4bf1f2d99f8
(make-auto-save-file-name, auto-save-file-name-p): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
2864
diff
changeset
|
60 This is a separate function so that your `.emacs' file or the site's |
b4bf1f2d99f8
(make-auto-save-file-name, auto-save-file-name-p): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
2864
diff
changeset
|
61 `site-init.el' can redefine it. |
b4bf1f2d99f8
(make-auto-save-file-name, auto-save-file-name-p): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
2864
diff
changeset
|
62 See also `auto-save-file-name-p'." |
36 | 63 (if buffer-file-name |
64 (concat (file-name-directory buffer-file-name) | |
65 "_$" | |
66 (file-name-nondirectory buffer-file-name) | |
67 "$") | |
68 (expand-file-name (concat "_$_" (make-legal-file-name (buffer-name)) "$")))) | |
69 | |
70 (defun auto-save-file-name-p (filename) | |
11045
b4bf1f2d99f8
(make-auto-save-file-name, auto-save-file-name-p): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
2864
diff
changeset
|
71 "Return t if FILENAME can be yielded by `make-auto-save-file-name'. |
36 | 72 FILENAME should lack slashes. |
11045
b4bf1f2d99f8
(make-auto-save-file-name, auto-save-file-name-p): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
2864
diff
changeset
|
73 This is a separate function so that your `.emacs' file or the site's |
b4bf1f2d99f8
(make-auto-save-file-name, auto-save-file-name-p): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
2864
diff
changeset
|
74 `site-init.el' can redefine it." |
36 | 75 (string-match "^_\\$.*\\$" filename)) |
76 | |
1174 | 77 ;;; |
78 ;;; This goes along with kepteditor.com which defines these logicals | |
79 ;;; If EMACS_COMMAND_ARGS is defined, it supersedes EMACS_FILE_NAME, | |
80 ;;; which is probably set up incorrectly anyway. | |
81 ;;; The function command-line-again is a kludge, but it does the job. | |
82 ;;; | |
36 | 83 (defun vms-suspend-resume-hook () |
84 "When resuming suspended Emacs, check for file to be found. | |
85 If the logical name `EMACS_FILE_NAME' is defined, `find-file' that file." | |
1174 | 86 (let ((file (vms-system-info "LOGICAL" "EMACS_FILE_NAME")) |
87 (args (vms-system-info "LOGICAL" "EMACS_COMMAND_ARGS")) | |
88 (line (vms-system-info "LOGICAL" "EMACS_FILE_LINE"))) | |
89 (if (not args) | |
90 (if file | |
91 (progn (find-file file) | |
92 (if line (goto-line (string-to-int line))))) | |
93 (cd (file-name-directory file)) | |
94 (vms-command-line-again)))) | |
36 | 95 |
96 (setq suspend-resume-hook 'vms-suspend-resume-hook) | |
97 | |
98 (defun vms-suspend-hook () | |
99 "Don't allow suspending if logical name `DONT_SUSPEND_EMACS' is defined." | |
100 (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS") | |
101 (error "Can't suspend this emacs")) | |
102 nil) | |
103 | |
104 (setq suspend-hook 'vms-suspend-hook) | |
105 | |
1174 | 106 ;;; |
107 ;;; A kludge that allows reprocessing of the command line. This is mostly | |
108 ;;; to allow a spawned VMS mail process to do something reasonable when | |
109 ;;; used in conjunction with the modifications to sysdep.c that allow | |
110 ;;; Emacs to attach to a "foster" parent. | |
111 ;;; | |
112 (defun vms-command-line-again () | |
113 "Reprocess command line arguments. VMS specific. | |
114 Command line arguments are initialized from the logical EMACS_COMMAND_ARGS | |
115 which is defined by kepteditor.com. On VMS this allows attaching to a | |
116 spawned Emacs and doing things like \"emacs -l myfile.el -f doit\"" | |
117 (let* ((args (downcase (vms-system-info "LOGICAL" "EMACS_COMMAND_ARGS"))) | |
118 (command-line-args (list "emacs")) | |
119 (beg 0) | |
120 (end 0) | |
121 (len (length args)) | |
122 this-char) | |
123 (if args | |
124 (progn | |
125 ;;; replace non-printable stuff with spaces | |
126 (while (< beg (length args)) | |
127 (if (or (> 33 (setq this-char (aref args beg))) | |
128 (< 127 this-char)) | |
129 (aset args beg 32)) | |
130 (setq beg (1+ beg))) | |
131 (setq beg (1- (length args))) | |
132 (while (= 32 (aref args beg)) (setq beg (1- beg))) | |
133 (setq args (substring args 0 (1+ beg))) | |
134 (setq beg 0) | |
135 ;;; now start parsing args | |
136 (while (< beg (length args)) | |
137 (while (and (< beg (length args)) | |
138 (or (> 33 (setq this-char (aref args beg))) | |
139 (< 127 this-char)) | |
140 (setq beg (1+ beg)))) | |
141 (setq end (1+ beg)) | |
142 (while (and (< end (length args)) | |
143 (< 32 (setq this-char (aref args end))) | |
144 (> 127 this-char)) | |
145 (setq end (1+ end))) | |
146 (setq command-line-args (append | |
147 command-line-args | |
148 (list (substring args beg end)))) | |
149 (setq beg (1+ end))) | |
150 (command-line))))) | |
151 | |
36 | 152 (defun vms-read-directory (dirname switches buffer) |
153 (save-excursion | |
154 (set-buffer buffer) | |
155 (subprocess-command-to-buffer | |
156 (concat "DIRECTORY " switches " " dirname) | |
157 buffer) | |
158 (goto-char (point-min)) | |
159 ;; Remove all the trailing blanks. | |
160 (while (search-forward " \n") | |
161 (forward-char -1) | |
162 (delete-horizontal-space)) | |
163 (goto-char (point-min)))) | |
164 | |
165 (setq dired-listing-switches | |
166 "/SIZE/DATE/OWNER/WIDTH=(FILENAME=32,SIZE=5)") | |
156 | 167 |
168 (setq print-region-function | |
169 '(lambda (start end command ign1 ign2 ign3 &rest switches) | |
170 (write-region start end "sys$login:delete-me.txt") | |
171 (send-command-to-subprocess | |
172 1 | |
173 (concat command | |
2864
9c3bf565b354
* bibtex.el (bibtex-string): Use \" instead of "" to get a double
Jim Blandy <jimb@redhat.com>
parents:
1174
diff
changeset
|
174 " sys$login:delete-me.txt/name=\"GNUprintbuffer\" " |
156 | 175 (mapconcat 'identity switches " ")) |
176 nil nil nil))) | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
156
diff
changeset
|
177 |
1174 | 178 ;;; |
179 ;;; Fuctions for using Emacs as a VMS Mail editor | |
180 ;;; | |
181 (autoload 'vms-pmail-setup "vms-pmail" | |
182 "Set up file assuming use by VMS Mail utility. | |
183 The buffer is put into text-mode, auto-save is turned off and the | |
184 following bindings are established. | |
185 | |
186 \\[vms-pmail-save-and-exit] vms-pmail-save-and-exit | |
187 \\[vms-pmail-abort] vms-pmail-abort | |
188 | |
189 All other Emacs commands are still available." | |
190 t) | |
191 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
156
diff
changeset
|
192 ;;; vms-patch.el ends here |