Mercurial > emacs
annotate lisp/vmsproc.el @ 45132:c26266baaba5
(filesets-browse-dir-function): Renamed from ...-fn.
(filesets-open-file-function, filesets-save-buffer-function): Likewise.
(filesets-tree-max-level): Doc fix.
(filesets-commands, filesets-external-viewers)
(filesets-ingroup-patterns): Mark as risky.
(filesets-cache-hostname-flag): Doc fix.
(filesets-menu-cache-file): Doc fix. Mark as risky.
(filesets-menu-before, filesets-menu-path, filesets-menu-in-menu):
Don't defcustom them if running in Emacs.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 05 May 2002 01:55:25 +0000 |
parents | 253f761ad37b |
children | 695cf19ef79e d7ddb3e565de |
rev | line source |
---|---|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
1 ;;; vmsproc.el --- run asynchronous VMS subprocesses under Emacs |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
2 |
841 | 3 ;; Copyright (C) 1986 Free Software Foundation, Inc. |
4 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
5 ;; Author: Mukesh Prasad |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
6 ;; Maintainer: FSF |
812
485e82a8acb5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: vms |
656
d74e65773062
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
8 |
35 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; 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
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
35 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
35 | 25 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
14169
diff
changeset
|
26 ;;; Commentary: |
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
14169
diff
changeset
|
27 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
28 ;;; Code: |
35 | 29 |
30 (defvar display-subprocess-window nil | |
14015
51621fd8598f
(display-subprocess-window): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
31 "If non-nil, the subprocess window is displayed whenever input is received.") |
35 | 32 |
33 (defvar command-prefix-string "$ " | |
34 "String to insert to distinguish commands entered by user.") | |
35 | |
36 (defvar subprocess-running nil) | |
37 (defvar command-mode-map nil) | |
38 | |
39 (if command-mode-map | |
40 nil | |
41 (setq command-mode-map (make-sparse-keymap)) | |
42 (define-key command-mode-map "\C-m" 'command-send-input) | |
43 (define-key command-mode-map "\C-u" 'command-kill-line)) | |
44 | |
45 (defun subprocess-input (name str) | |
46 "Handles input from a subprocess. Called by Emacs." | |
47 (if display-subprocess-window | |
48 (display-buffer subprocess-buf)) | |
49 (let ((old-buffer (current-buffer))) | |
50 (set-buffer subprocess-buf) | |
51 (goto-char (point-max)) | |
52 (insert str) | |
53 (insert ?\n) | |
54 (set-buffer old-buffer))) | |
55 | |
56 (defun subprocess-exit (name) | |
57 "Called by Emacs upon subprocess exit." | |
58 (setq subprocess-running nil)) | |
59 | |
60 (defun start-subprocess () | |
61 "Spawns an asynchronous subprocess with output redirected to | |
62 the buffer *COMMAND*. Within this buffer, use C-m to send | |
63 the last line to the subprocess or to bring another line to | |
64 the end." | |
65 (if subprocess-running | |
66 (return t)) | |
67 (setq subprocess-buf (get-buffer-create "*COMMAND*")) | |
68 (save-excursion | |
69 (set-buffer subprocess-buf) | |
70 (use-local-map command-mode-map)) | |
71 (setq subprocess-running (spawn-subprocess 1 'subprocess-input | |
72 'subprocess-exit)) | |
73 ;; Initialize subprocess so it doesn't panic and die upon | |
74 ;; encountering the first error. | |
75 (and subprocess-running | |
76 (send-command-to-subprocess 1 "ON SEVERE_ERROR THEN CONTINUE"))) | |
77 | |
78 (defun subprocess-command-to-buffer (command buffer) | |
79 "Execute COMMAND and redirect output into BUFFER." | |
80 (let (cmd args) | |
81 (setq cmd (substring command 0 (string-match " " command))) | |
82 (setq args (substring command (string-match " " command))) | |
83 (call-process cmd nil buffer nil "*dcl*" args))) | |
84 ;BUGS: only the output up to the end of the first image activation is trapped. | |
85 ; (if (not subprocess-running) | |
86 ; (start-subprocess)) | |
87 ; (save-excursion | |
88 ; (set-buffer buffer) | |
89 ; (let ((output-filename (concat "SYS$SCRATCH:OUTPUT-FOR-" | |
90 ; (getenv "USER") ".LISTING"))) | |
91 ; (while (file-exists-p output-filename) | |
92 ; (delete-file output-filename)) | |
93 ; (define-logical-name "SYS$OUTPUT" (concat output-filename "-NEW")) | |
94 ; (send-command-to-subprocess 1 command) | |
95 ; (send-command-to-subprocess 1 (concat | |
96 ; "RENAME " output-filename | |
97 ; "-NEW " output-filename)) | |
98 ; (while (not (file-exists-p output-filename)) | |
99 ; (sleep-for 1)) | |
100 ; (define-logical-name "SYS$OUTPUT" nil) | |
101 ; (insert-file output-filename) | |
102 ; (delete-file output-filename)))) | |
103 | |
104 (defun subprocess-command () | |
105 "Starts asynchronous subprocess if not running and switches to its window." | |
106 (interactive) | |
107 (if (not subprocess-running) | |
108 (start-subprocess)) | |
109 (and subprocess-running | |
110 (progn (pop-to-buffer subprocess-buf) (goto-char (point-max))))) | |
111 | |
112 (defun command-send-input () | |
113 "If at last line of buffer, sends the current line to | |
114 the spawned subprocess. Otherwise brings back current | |
115 line to the last line for resubmission." | |
116 (interactive) | |
117 (beginning-of-line) | |
118 (let ((current-line (buffer-substring (point) | |
119 (progn (end-of-line) (point))))) | |
120 (if (eobp) | |
121 (progn | |
122 (if (not subprocess-running) | |
123 (start-subprocess)) | |
124 (if subprocess-running | |
125 (progn | |
126 (beginning-of-line) | |
127 (send-command-to-subprocess 1 current-line) | |
128 (if command-prefix-string | |
129 (progn (beginning-of-line) (insert command-prefix-string))) | |
130 (next-line 1)))) | |
131 ;; else -- if not at last line in buffer | |
132 (end-of-buffer) | |
133 (backward-char) | |
134 (next-line 1) | |
135 (if (string-equal command-prefix-string | |
136 (substring current-line 0 (length command-prefix-string))) | |
137 (insert (substring current-line (length command-prefix-string))) | |
138 (insert current-line))))) | |
139 | |
140 (defun command-kill-line() | |
141 "Kills the current line. Used in command mode." | |
142 (interactive) | |
143 (beginning-of-line) | |
144 (kill-line)) | |
145 | |
146 (define-key esc-map "$" 'subprocess-command) | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
656
diff
changeset
|
147 |
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
656
diff
changeset
|
148 ;;; vmsproc.el ends here |