annotate lisp/hm--html-menus/html-view.el @ 203:850242ba4a81 r20-3b28

Import from CVS: tag r20-3b28
author cvs
date Mon, 13 Aug 2007 10:02:21 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; html-view.el --- routines for communicating with a NCSA Mosaic process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Some routines for communicating with a NCSA Mosaic process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; Copyright (C) 1993 Ron Tapia tapia@hydra.unm.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; Copyright (C) 1994, 1995 Heiko Münkel muenkel@tnt.uni-hannover.de
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; VERSION: 1.10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; LAST MODIFIED: 20/07/95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; Keywords: comm unix wp help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; Adapted to the lemacs: 19.07.1993 Heiko Muenkel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; (muenkel@tnt.uni-hannover.de)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; Changed: 19.07.1993 by Heiko Muenkel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; Changed: 28.12.1993 by Heiko Muenkel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; Changed (signal-process id 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; to (signal-process id html-sigusr1-signal-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; Addapted the file for the new Mosaic-2.1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; Thanks to Neal Becker, who has reported this problem.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; The file now requires the package hm--html-menus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; But you can also delete the line (require 'hm--html) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; add a line like (setq html-sigusr1-signal-value 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Changed: 10.01.1994 by Heiko Muenkel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Fixed a bug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Changed: 16.12.1994 by Heiko Münkel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Addapted the file for Mosaic-2.4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Changed: 03.02.1995 by Heiko Münkel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; The "view-buffer" is now different from the original buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; So the name of the original buffer isn't change anymore.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Changed: 02.04.1995 by Heiko Münkel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Integrated the changes from the XEmacs distribution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Changed: 20.07.1995 by Heiko Münkel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Fixed a bug in html-view-goto-url.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; This program is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; modify it under the terms of the GNU General Public License as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; published by the Free Software Foundation; either version 2, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; To use, just set the value of html-view-mosaic-command to whatever you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; use to run NCSA Mosaic. You may have to set html-view-tmp-file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;; Type M-x html-view-start-mosaic <ret>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; Afterwards, view files/buffers with html-view-view-file/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; html-view-view-buffer. There's also a command, of dubious utility,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; for jumping to particular documents: html-view-goto-url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; If you have any questions or comments mail to tapia@hydra.unm.edu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (require 'hm--html)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defvar html-view-mosaic-process nil "The NCSA Mosaic Process")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defvar html-view-mosaic-command "mosaic"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 "The command that runs Mosaic on your system")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defvar html-view-mosaic-tmp-file-prefix "/tmp/Mosaic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 "Prefix for the temp files, which are used by Mosaic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 For old versions this must be \"/tmp/xmosaic.\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 For new versions it is \"/tmp/Mosaic.\".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defvar html-view-tmp-file (concat "/tmp/mosaic.html-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (user-login-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (emacs-pid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 "File where buffers are saved for viewing by Mosaic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defvar html-view-display nil "The display that Mosaic is using.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defvar html-view-wait-counter 100000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "*Counter for a wait loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 The wait loop is beween the start of the Mosaic and the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 `set-process-sentinel'. If Mosaic don't start, then you must set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 this value higher. You can try to set it to a lower number otherwise.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defun html-view-start-mosaic ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "Start Mosaic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (or (stringp html-view-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (call-interactively 'html-view-get-display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (or (and (processp html-view-mosaic-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (eq (process-status html-view-mosaic-process) 'run))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (progn (setq html-view-mosaic-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (start-process "mosaic" "mosaic"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 html-view-mosaic-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "-display" html-view-display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (let ((i html-view-wait-counter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (while (> i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (setq i (1- i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (set-process-sentinel html-view-mosaic-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 'html-view-mosaic-process-sentinel))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defun html-view-view-file (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "View an html file with Mosaic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (interactive "fFile to view: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (or (and (processp html-view-mosaic-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (eq (process-status html-view-mosaic-process) 'run))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (html-view-start-mosaic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (if (and (processp html-view-mosaic-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (eq (process-status html-view-mosaic-process) 'run))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (let ((buffer (process-buffer html-view-mosaic-process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (id (process-id html-view-mosaic-process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (setq file (format "%s%s" html-view-mosaic-tmp-file-prefix id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (set-visited-file-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; (set-visited-file-name (concat "/tmp/Mosaic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; (number-to-string id)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (insert-before-markers "goto\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (insert-before-markers (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 "file://"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (expand-file-name filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (signal-process id html-sigusr1-signal-value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (message "Can't start mosaic process.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defun html-view-view-buffer (&optional buffer-to-view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 "View html buffer with Mosaic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 If BUFFER-TO-VIEW is nil, then the current buffer is used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (or (bufferp buffer-to-view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (setq buffer-to-view (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (find-file html-view-tmp-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (insert-buffer buffer-to-view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (write-file html-view-tmp-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (html-view-view-file html-view-tmp-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defun html-view-goto-url (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 "Goto an URL in Mosaic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (interactive "sURL: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (or (processp html-view-mosaic-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (html-view-start-mosaic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (if (processp html-view-mosaic-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (let ((buffer (process-buffer html-view-mosaic-process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (id (process-id html-view-mosaic-process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; (setq file (format "%s%s" "/tmp/xmosaic." id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (setq file (format "%s%s" html-view-mosaic-tmp-file-prefix id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (set-visited-file-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; (set-visited-file-name (concat "/tmp/Mosaic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; (number-to-string id)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (insert-before-markers "goto\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (insert-before-markers url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (signal-process id html-sigusr1-signal-value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (message "Can't start mosaic process.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defun html-view-get-display (display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "Get the display for Mosaic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (interactive "sDisplay: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (setq html-view-display display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (defun html-view-mosaic-process-sentinel (proc, event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (cond ((or (string-match "exited abnormally with code" event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (string-match "finished" event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (message event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (setq html-view-mosaic-process nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (t (message event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (provide 'html-view)