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