annotate lisp/packages/gopher.el @ 30:ec9a17fef872 r19-15b98

Import from CVS: tag r19-15b98
author cvs
date Mon, 13 Aug 2007 08:52:29 +0200
parents 376386a54a3c
children 131b0175ea99
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 ;;; gopher.el --- an emacs gopher client
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992 scott snyder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: scott snyder <snyder@fnald0.fnal.gov>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Created: 29 Jun 1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Version: 1.03
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: gopher, comm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; gopher|scott snyder|snyder@fnald0.fnal.gov|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; An emacs gopher client.|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; 20-Apr-1993|1.02|~/interfaces/gopher.el.Z|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; This file is not part of GNU Emacs, but is distributed under the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; same conditions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY. No author or distributor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; accepts responsibility to anyone for the consequences of using it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; or for whether it serves any particular purpose or works at all,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; unless he says so in writing. Refer to the GNU Emacs General Public
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; License for full details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; Everyone is granted permission to copy, modify and redistribute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; GNU Emacs, but only under the conditions described in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; GNU Emacs General Public License. A copy of this license is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; supposed to have been given to you along with GNU Emacs so you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; can know your rights and responsibilities. It should be in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; file named COPYING. Among other things, the copyright notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; and this notice must be preserved on all copies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; An emacs gopher client. Currently supports directory, text, CSO,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; index, image, and telnet objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; Requires forms.el and background.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; Written by scott snyder <snyder@fnald0.fnal.gov>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; Some code borrowed from GNUS (by Masanobu UMEDA).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Some code (bookmarks, xterms, error handling) contributed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; by Stewart Clamen <clamen@cs.cmu.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; OPERATING INSTRUCTIONS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; To use, `M-x gopher'. To specify a different root server, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; `C-u M-x gopher'. If you want to use bookmarks, set the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; gopher-support-bookmarks appropriately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; The command `M-x gopher-atpoint' will attempt to interpret the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; around point as a gopher bookmark specification and will retrieve
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; that item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; Sample .emacs configuration:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; (autoload 'gopher "gopher")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; (autoload 'gopher-atpoint "gopher")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; (setq gopher-support-bookmarks t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; In directory mode:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; Space, return, `f', or `e' selects the line point is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; With a numeric prefix argument, select that object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; `q', `l', or `u' will return to the previous node.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; `n' and `p' to the next and previous lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; `a' will add an object to your bookmark list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; `v' will display your bookmark list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; `=' gives detailed information about an object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; In the bookmark list, all of the above (except `a'), plus:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; `C-k' will delete an object from the bookmark list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; `C-y' will yank the most recently deleted bookmark object back into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; the bookmark buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; `s' will save the bookmark list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; `Q' will quit gopher entirely, killing all gopher buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; All commands which operate on a specific object can take an optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; numeric prefix argument giving the index of the object on which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; to operate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; In document mode:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; Space pages forward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; Delete pages backward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; `q', `l' or `u' returns to the last node.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; In the CSO entry form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; `C-c RET' performs a look-up, based on the field contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; you've filed in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; `C-c l' returns to the previous node.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; Telnets:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; If you have an X server set, gopher will try to create an xterm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; running telnet. If not, the emacs-lisp telnet mode will be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; From the emacs-lisp telnet mode, use `C-c l' to kill the session
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; and return to the previous node.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; See also the variable gopher-telnet-command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; Images:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; Images are displayed using the command gopher-image-display-command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; The default setting for this variable uses xv.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; Note:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; If gopher consistently hangs while trying to retrieve an object,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; try turning on gopher-buggy-accept (which see).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; VMS notes:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; To use this on VMS, you'll need my emacs subprocess patches (recently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; posted on gnu.emacs.sources; if you can't find them, send me mail).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; To be able to run telnet in a separate decterm, you'll also need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; to (setq shell-file-name "docmd") and create the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; emacs_library:[etc]docmd.com containing the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; $ if p1 .eqs. "-C" then p1 = ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; $ deass sys$input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; $ 'p1 'p2 'p3 'p4 'p5 'p6 'p7 'p8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; $ eoj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; Change Log:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; Version 1.03 30-APR-1993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; * Add a buffer-local variable gopher-obj to all gopher buffers bound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; to the description of the object contained in that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; Version 1.02 20-APR-1993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; * Avoid using replace-regexp in gopher-clean-text. (Suggested by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; sbyrnes@rice.edu (Steven Byrnes)).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; * Added gopher-port-aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; * Print ports as strings in gopher-directory-show-object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; * Don't (ding) when the net stream closes unexpectedly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; * Added image display (based on code from beldar@MicroUnity.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; (Gardner Cohen)).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; * Attempt to improve error reporting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; * Reworked gopher-parse-bookmark to handle out-of-order fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; * Added gopher-atpoint.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; * Moved bookmark init stuff to gopher-read-bookmarks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; * Added gopher-quit (based on code from Thomas L|fgren
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;; <tde9104@abacus.hgs.se>).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; * Change usage of background for XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; (Patch from "William M. Perry" <wmperry@raisin.ucs.indiana.edu>).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; * Added a (provide 'gopher) at end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; * Added `f' and `e' bindings in directory mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; Version 1.01
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; * Added patch suggested by Humberto Ortiz-Zuazaga
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; <zuazaga@ucunix.san.uc.EDU> to allow null Path= items in .gopherrc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; Version 1.00 29-AUG-1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; * Added gopher-buggy-accept.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; * Reworked telnet stuff to use an arbitrary command string to start up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; the telnet process. This can be used to start the telnet in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; separate terminal window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; Based on code from Stewart Clamen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; * Stewart Clamen <clamen@cs.cmu.edu> added bookmarks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; * Added 's key binding to save bookmarks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; * Added a prefix argument to gopher-directory-buffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; gopher-add-bookmark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; * Added standard emacs-lisp header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; * Stewart Clamen <clamen@cs.cmu.edu> added some error trapping and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; recovery (gopher-retrieve-document-cleanly).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; * Appended node description to the node's buffer's name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; * Reformat bookmark buffers when returning to them via gopher-last-node
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; or when an item is deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; * Added gopher-yank-bookmark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; * Added gopher-bookmark-modified-tick to prevent reformatting bookmark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; buffers needlessly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;; Version 0.92 27-JUL-1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; * Added gopher-hostname-aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; Version 0.91 30-JUN-1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; * Deal with servers which send stuff after the CR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; * Prevent gopher-directory-show-object from clearing the read-only flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; * Allow specification of port number in `C-u M-x gopher'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; Version 0.9 29-JUN-1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; * Initial release.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (require 'electric)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (require 'forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; background has the same name as an epoch function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; Rename it to gopher-background...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; also, the version i got from the archive didn't have a provide...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (cond ((and (string-lessp "19" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (not (boundp 'epoch::version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; background is obsolete in emacs19: just add a & to shell-command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (defun gopher-background (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (shell-command (concat command "&"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; background has the same name as an epoch function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; Rename it to gopher-background...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; also, the version i got from the archive didn't have a provide...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (if (not (fboundp 'gopher-background))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (if (fboundp 'background)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (let ((old-background (symbol-function 'background)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (load-library "background")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (fset 'gopher-background (symbol-function 'background))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (fset 'background old-background))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (load-library "background")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (fset 'gopher-background (symbol-function 'background))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (defvar gopher-root-node (vector ?1 "root" "" "ucs_gopher" 70)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 "The root gopher server, as a gopher object.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (defvar gopher-directory-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 "*Invoked when entering a new gopher directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defvar gopher-directory-mode-map (make-keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 "Keymap for gopher-directory-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (defvar gopher-document-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 "*Invoked when showing gopher document.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defvar gopher-document-mode-map (make-keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 "Keymap for gopher-document-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defvar gopher-form-mode-hooks nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "*Invoked with entering a gopher form (i.e., for CSO).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defvar gopher-form-mode-map (make-keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Keymap for gopher-form-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (defvar gopher-tmp-buf nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "Buffer used to receive output from gopher.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defvar gopher-debug-read t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 "*If non-nil, show the current status about reading the gopher server output.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; On some systems (such as SGI Iris), accept-process-output doesn't seem
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; to return for the last packet received on a connection. Turn this on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; to work around the problem, but does anyone know what causes this?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defvar gopher-buggy-accept nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 "*If non-nil, use sit-for instead of accept-process-output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 If gopher consistently hangs while fetching an object, try turning this on.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defvar gopher-hostname-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 '(("128.230.33.31" . "oliver.syr.edu"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 "Emacs can't deal with raw IP addresses used as a hostname.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 Use this to work around...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defvar gopher-port-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 '(("whois_port" . 43))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 "Some losing hosts send a port name instead of a number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 Use this table to convert...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defvar gopher-support-bookmarks nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "*If nil, do not implement bookmarks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 If 'unix or t, read and write bookmarks to ~/.gopherrc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 If a filename, read and save vector from there directly (not implemented yet).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 If a vector, treat as a built-in directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (defconst gopher-bookmarks nil "Internal bookmark directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defconst gopher-bookmarks-modified nil "Do bookmarks need to be saved?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (defconst gopher-killed-bookmark nil "The last bookmark object to be killed")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defconst gopher-bookmark-directory-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "Is this buffer a bookmark directory? A buffer-local variable.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (defvar gopher-bookmark-modified-tick 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 "Counts each time the bookmark vector is modified.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defvar gopher-telnet-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (cond ((eq system-type 'vax-vms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (if (getenv "DECW$DISPLAY")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 "create/terminal/wait/window=(title=\"telnet\") telnet"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (if (getenv "DISPLAY")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 "xterm -e telnet"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "*Command to use to start a telnet session.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 If this is nil, the emacs-lisp telnet package will be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 The default setting is to create a terminal window running telnet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 if you've specified an X server, and to use the emacs-lisp telnet otherwise.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (defvar gopher-image-display-command "xv -geometry +200+200"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 "*The command used to try to display an image object.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defvar gopher-object-type-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 '(( ?0 "" gopher-document-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ( ?1 "/" gopher-directory-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ( ?2 " <CSO>" gopher-cso-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ( ?3 " <error>" gopher-unimplemented-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ( ?4 " <binhex>" gopher-binary-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ( ?5 " <DOS>" gopher-binary-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ( ?6 " <UU>" gopher-binary-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ( ?7 " <?>" gopher-index-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ( ?8 " <TEL>" gopher-telnet-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ( ?9 " <bin>" gopher-binary-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ( ?T " <T>" gopher-unimplemented-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ( ?s " <)" gopher-binary-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ( ?M " <MIME>" gopher-unimplemented-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ( ?h " <html>" gopher-unimplemented-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ( ?I " <image>" gopher-image-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ( ?c " <cal>" gopher-unimplemented-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ( ?g " <GIF>" gopher-image-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "*Alist describing the types of gopher objects this client know about.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 The keys are the gopher type characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 The second element in each list is the string to tag onto the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 of an object's description, to identify it to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 The third element is the function to use to retrieve the object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 It is called with two arguments: the gopher object to retrieve and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 the buffer which should be returned to when the user is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 with this object.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;;; The data structure describing a gopher object is a vector of five elements:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;;; [ TYPE DESCR SELECTOR HOST PORT ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;;; TYPE is the type character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;;; DESCR is the human-readable description of the object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;;; SELECTOR is the opaque selector to be sent to HOST to retrieve the obj.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;;; HOST is the name of the Internet host on which the object resides.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;;; PORT is the TCP/IP port on which the host is listening.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ;;; The following macros set and fetch elements of this structure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (defconst gopher-object-length 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defmacro gopher-object-type (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "Return the gopher type of OBJECT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (` (aref (, object) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (defmacro gopher-object-descr (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "Return the gopher description of OBJECT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (` (aref (, object) 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defmacro gopher-object-selector (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 "Return the gopher selector string for OBJECT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (` (aref (, object) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defmacro gopher-object-host (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 "Return the gopher hostname for OBJECT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (` (aref (, object) 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (defmacro gopher-object-port (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 "Return the gopher TCP port number for OBJECT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (` (aref (, object) 4)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (defmacro gopher-set-object-type (object type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 "Set the gopher type of OBJECT to TYPE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (` (aset (, object) 0 (, type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defmacro gopher-set-object-descr (object descr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Set the gopher description of OBJECT to DESCR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (` (aset (, object) 1 (, descr))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (defmacro gopher-set-object-selector (object selector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 "Set the gopher selector string for OBJECT to SELECTOR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (` (aset (, object) 2 (, selector))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (defmacro gopher-set-object-host (object host)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 "Set the gopher hostname for OBJECT to HOST."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (` (aset (, object) 3 (, host))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (defmacro gopher-set-object-port (object port)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 "Set the gopher TCP port number for OBJECT to PORT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (` (aset (, object) 4 (, port))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (defmacro gopher-retrieve-document-cleanly (args handle &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 "Call gopher-retrieve-document with condition-case wrapped around,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 applying HANDLE if appropriate."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (` (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (gopher-retrieve-document (,@ args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (error (, handle)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;; buffer-local variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; declared here to prevent warnings from the new byte-compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defvar gopher-dir nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defvar gopher-last nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (defvar gopher-obj nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defvar gopher-telnet-process-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defvar gopher-bookmark-buffer-tick nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defvar forms-accept-action nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;;;; main dispatching logic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defun gopher (&optional askserv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 "Start a gopher session. With C-u, prompt for a gopher server."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (if askserv
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (gopher-set-object-host
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 gopher-root-node
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (read-string "Gopher server: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (gopher-object-host gopher-root-node)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (let (portstr port)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (while (not (numberp port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (setq portstr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (read-string "Port: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (int-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (gopher-object-port gopher-root-node))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (setq port (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (car (read-from-string portstr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (if (not (numberp port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (message "Port must be numeric")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (sit-for 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (gopher-set-object-port gopher-root-node port))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (gopher-read-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (gopher-dispatch-object gopher-root-node nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (defun gopher-atpoint nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 "Try to interpret the text around point as a gopher bookmark, and dispatch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 to that object."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (let (bkmk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (re-search-backward "^#[ \t]*$\\|^[ \t]*$\\|\\`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq bkmk (gopher-parse-bookmark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if bkmk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (gopher-read-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (gopher-dispatch-object bkmk nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (error "Illformed bookmark"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (defun gopher-dispatch-object (obj lastbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 "Dispatch a gopher object depending on its type."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (let ((typedesc (assq (gopher-object-type obj) gopher-object-type-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (if typedesc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (funcall (nth 2 typedesc) obj lastbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (gopher-unimplemented-object obj lastbuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defun gopher-unimplemented-object (obj lastbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (error "unimplemented object type"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;;;; utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun gopher-next-field nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 "Returns as a string all chars between point and the next tab or newline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 Point is advanced to after the tab (or to the end-of-line)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (let ((beg (point)) s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (skip-chars-forward "^\t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (setq s (buffer-substring beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (if (eq (following-char) ?\t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (forward-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;; from GNUS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (defun gopher-make-local-vars (&rest pairs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; Take VARIABLE-VALUE pairs and makes local variables initialized to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;; value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (while pairs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (make-local-variable (car pairs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (set (car pairs) (car (cdr pairs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (setq pairs (cdr (cdr pairs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (defun gopher-get-tmp-buf nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 "Get a temporary buffer in which to receive gopher output."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (or (bufferp gopher-tmp-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (setq gopher-tmp-buf (get-buffer-create " *gopher-tmp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (buffer-flush-undo gopher-tmp-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 gopher-tmp-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (defun gopher-get-dir-buf (descr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 "Get a new buffer suitable for a gopher directory or document."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (let ((buf (generate-new-buffer (concat "*gopher*" descr))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (buffer-flush-undo buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (fset 'gopher-get-doc-buf (symbol-function 'gopher-get-dir-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (defun gopher-trim-blanks (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 "Remove leading and trailing blanks from STR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (string-match "\\`[ \t\n]*" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (substring str
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (string-match "[ \t\n]*\\'" str (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;;;; directory handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (defun gopher-directory-object (obj oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 "Retrieve and display a gopher directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (let ((tmpbuf (gopher-get-tmp-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (dirbuf (gopher-get-dir-buf (gopher-object-descr obj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;; Get the directory...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (gopher-retrieve-document-cleanly (tmpbuf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (gopher-object-selector obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (gopher-object-host obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (gopher-object-port obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (kill-buffer dirbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (error "Problems retrieving directory."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;; Parse it and store our internal representation in gopher-dir.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (switch-to-buffer dirbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (gopher-make-local-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 'gopher-dir (gopher-parse-directory tmpbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 'gopher-obj obj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 'gopher-last oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; Format it for your viewing pleasure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (gopher-format-directory gopher-dir dirbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (if (> (- (point-max) (point)) 7) (forward-char 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;; Turn on directory mode and put the description in the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (gopher-directory-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (setq mode-line-buffer-identification (concat "Gopher: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (gopher-object-descr obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (defun gopher-parse-directory (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 "Parse the gopher directory in buffer BUF into our internal representation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 Returns a vector of gopher objects."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (let* ((len (count-lines (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (dir (make-vector len nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (aset dir i (gopher-parse-directory-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (defun gopher-parse-directory-line nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 "Parse the line containing point as a gopher directory entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 Returns the corresponding gopher object."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (let (type descr selector host port)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (setq type (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq descr (gopher-next-field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (setq selector (gopher-next-field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (setq host (gopher-next-field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (setq port (gopher-next-field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (if (string-match "^[0-9]+$" port)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (setq port (string-to-int port)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (vector type descr selector host port)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (defun gopher-format-directory (dir buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 "Print the directory vector DIR into buffer BUF."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (len (length dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (gopher-format-directory-line (aref dir i) (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (defun gopher-format-directory-line (obj ndx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 "Insert a line describing the gopher object OBJ into the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 NDX is a numeric index to display to the left of the object description."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (let ((ndx-str (int-to-string ndx))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (typedesc (assq (gopher-object-type obj) gopher-object-type-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;; display the index number. use 5 digits, right-justified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (if (< (length ndx-str) 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (insert (make-string (- 5 (length ndx-str)) ? )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (insert ndx-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (insert ". ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;; add the object description.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (insert (gopher-object-descr obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; add a tag indicating the gopher object type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (insert (if typedesc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (nth 1 typedesc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (concat " ???" (char-to-string (gopher-object-type obj)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (insert "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (defun gopher-directory-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 "Gopher directory mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 \\{gopher-directory-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (use-local-map gopher-directory-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (setq major-mode 'gopher-directory-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (setq mode-name "gopher dir")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (run-hooks 'gopher-directory-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (require 'mode-motion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (make-local-variable 'mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (setq mode-motion-hook 'mode-motion-highlight-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;;; keymap for directory mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (suppress-keymap gopher-directory-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (define-key gopher-directory-mode-map "\r" 'gopher-directory-choose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (define-key gopher-directory-mode-map " " 'gopher-directory-choose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (define-key gopher-directory-mode-map "l" 'gopher-last-node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (define-key gopher-directory-mode-map "q" 'gopher-last-node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (define-key gopher-directory-mode-map "u" 'gopher-last-node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (define-key gopher-directory-mode-map "=" 'gopher-directory-show-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (define-key gopher-directory-mode-map "Q" 'gopher-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (define-key gopher-directory-mode-map "f" 'gopher-directory-choose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (define-key gopher-directory-mode-map "e" 'gopher-directory-choose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ; Virginia Peck <vapeck@cs> Mon Aug 10 1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (define-key gopher-directory-mode-map "n" 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (define-key gopher-directory-mode-map "p" 'previous-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ;;(define-key gopher-directory-mode-map "\C-xk" 'gopher-last-node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ; Stewart Clamen <clamen@cs.cmu.edu> Mon Aug 17 1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (define-key gopher-directory-mode-map "v" 'gopher-display-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (define-key gopher-directory-mode-map "a" 'gopher-add-bookmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (define-key gopher-directory-mode-map "\C-k" 'gopher-delete-bookmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (define-key gopher-directory-mode-map "s" 'gopher-directory-save-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (define-key gopher-directory-mode-map "\C-y" 'gopher-yank-bookmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (define-key gopher-directory-mode-map 'button2 'gopher-mouse-directory-choose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (define-key gopher-directory-mode-map 'button3 'gopher-directory-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (defvar gopher-directory-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 '("Gopher Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ["Select This Link" gopher-directory-choose t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ["Goto Last Node" gopher-last-node t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ["Show Object Internals" gopher-directory-show-object t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ["Quit" gopher-quit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (defun gopher-directory-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (popup-menu gopher-directory-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (defun gopher-mouse-directory-choose (event arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (interactive "e\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (gopher-directory-choose arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (defun gopher-directory-nth-obj (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 "Returns the Nth object (starting at 1) in a gopher directory buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (if (or (<= n 0) (> n (length gopher-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (error "Out of range."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (aref gopher-dir (1- n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (defun gopher-directory-n (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 "Return the index of the object specified by ARG (starting at 1).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 If ARG is nil, this is the index of the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 Otherwise, it is the value of ARG (as a prefix argument)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (prefix-numeric-value arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (if (eq (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (1+ (count-lines (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (count-lines (point-min) (1+ (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (defun gopher-directory-obj (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 "Return the gopher object given by prefix arg ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 If it is nil, return the object given by the line point is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 Otherwise, ARG is the index of the object."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (gopher-directory-nth-obj (gopher-directory-n arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (defun gopher-directory-choose (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 "Choose an item from the directory, and do whatever is appropriate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 based on the object's type. Default is to choose the object given by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 line the cursor is on. With numeric prefix argument N, choose object N."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (gopher-dispatch-object (gopher-directory-obj arg) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (defun gopher-directory-show-object (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 "Dump the internal information in a gopher object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 With numeric prefix argument N, show information about the Nth object."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (let* ((obj (gopher-directory-obj arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (type (gopher-object-type obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (typespec (assq type gopher-object-type-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (typetag (if typespec (nth 1 typespec) "?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (typeproc (if typespec (nth 2 typespec) "?")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (with-output-to-temp-buffer "*Gopher object*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (princ (format "Type : %c `%s' %s\n" type typetag typeproc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (princ (format "Description : %s\n" (gopher-object-descr obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (princ (format "Selector : %s\n" (gopher-object-selector obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (princ (format "Host : %s\n" (gopher-object-host obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (princ (format "Port : %s\n" (gopher-object-port obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (shrink-window-if-larger-than-buffer (get-buffer-window "*Gopher object*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 ;; shrink-window-if-larger-than-buffer screws these up...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (setq buffer-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (defun gopher-last-node nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 "Return to the previous gopher node.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 By convention, a gopher buffer has the local variable gopher-last which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 contains the buffer to which we should return."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (let ((oldbuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (if gopher-last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (switch-to-buffer gopher-last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (kill-buffer oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (and (gopher-bookmark-directory-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (> gopher-bookmark-modified-tick gopher-bookmark-buffer-tick)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (let ((ppos (1- (gopher-directory-n nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (gopher-format-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (forward-line ppos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (if (> (- (point-max) (point)) 7) (forward-char 7)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (if (and gopher-support-bookmarks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 gopher-bookmarks-modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 "Changes have been made to the Bookmark directory. Save? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (gopher-save-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (kill-buffer oldbuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (defun gopher-directory-save-bookmarks ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 "Save the bookmark list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (if (not (gopher-bookmark-directory-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (error "This isn't the bookmark directory."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (gopher-save-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 ;;; Gopher clean-up and quit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;;; Originally from Thomas L|fgren <tde9104@abacus.hgs.se>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (defun gopher-quit nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 "Quit gopher, and kill all gopher buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 If there are unsaved changes to your bookmark directory, you will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 asked if you want to save them"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (if (y-or-n-p "Do you really want to kill all gopher buffers? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (if (and gopher-support-bookmarks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 gopher-bookmarks-modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 "Changes have been made to the Bookmark directory. Save? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (gopher-save-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (let ((buflist (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (while buflist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (if (eq (string-match "\\*gopher" (buffer-name (car buflist))) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (kill-buffer (car buflist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (setq buflist (cdr buflist)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ;;;; bookmarks (Implemented originally by clamen@cs.cmu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (defun gopher-read-bookmarks ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (cond ((null gopher-support-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ((or (equal gopher-support-bookmarks 'unix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (equal gopher-support-bookmarks t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (setq gopher-bookmarks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (gopher-read-unix-bookmarks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ((stringp gopher-support-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (gopher-read-lisp-bookmarks gopher-support-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 ((vectorp gopher-support-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (setq gopher-bookmarks gopher-support-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (message "Illformed gopher-bookmarks, assuming none"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (defun gopher-read-unix-bookmarks ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 "Read bookmarks out of ~/.gopherrc file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (let ((rcfile "~/.gopherrc"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (if (file-exists-p rcfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (let* ((rcbuf (find-file-noselect rcfile))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (bkmks (gopher-parse-bookmark-buffer rcbuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (kill-buffer rcbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (setq gopher-bookmarks-modified nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (setq gopher-bookmark-modified-tick
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (1+ gopher-bookmark-modified-tick))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 bkmks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (message "No %s exists." rcfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (defun gopher-parse-bookmark-buffer (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 "Read buffer containing bookmarks, formatted like ~.gopherrc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 in UNIX gopher client."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (if (re-search-forward "^bookmarks:\n" (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (let (bkmk bkmks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (while (setq bkmk (gopher-parse-bookmark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (setq bkmks (cons bkmk bkmks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (apply 'vector (reverse bkmks))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (defun gopher-parse-bookmark-line (regexp end setf bkmk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (if (re-search-forward regexp end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (eval (list setf bkmk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (buffer-substring (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (defun gopher-parse-bookmark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 "Read next bookmark. Return a directory object."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (if (looking-at "^#$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (forward-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (let ((end (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (forward-line 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (bkmk (make-vector 5 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (and (gopher-parse-bookmark-line "^Type *= *\\(.+\\) *$" end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 'gopher-set-object-type bkmk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (gopher-parse-bookmark-line "^Name *= *\\(.*\\) *$" end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 'gopher-set-object-descr bkmk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (gopher-parse-bookmark-line "^Path *= *\\(.*\\) *$" end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 'gopher-set-object-selector bkmk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (gopher-parse-bookmark-line "^Host *= *\\(.+\\) *$" end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 'gopher-set-object-host bkmk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (gopher-parse-bookmark-line "^Port *= *\\(.+\\) *$" end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 'gopher-set-object-port bkmk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (gopher-set-object-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 bkmk (string-to-char (gopher-object-type bkmk)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (gopher-set-object-port
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 bkmk (string-to-int (gopher-object-port bkmk)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 bkmk))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (goto-char end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (defun gopher-format-bookmarks ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 "Make the current buffer (which is assumed to be a bookmark buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 contain an up-to-date listing of the bookmark list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (setq gopher-dir gopher-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 ;; Format it for your viewing pleasure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (gopher-format-directory gopher-dir (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (if (> (- (point-max) (point)) 7) (forward-char 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (setq gopher-bookmark-buffer-tick gopher-bookmark-modified-tick)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (defun gopher-display-bookmarks ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 "Retrieve and display the gopher bookmark directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (if (> (length gopher-bookmarks) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (let ((oldbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (dirbuf (gopher-get-dir-buf "*Gopher Bookmarks*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ;; Store our internal representation in gopher-dir.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (switch-to-buffer dirbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (gopher-make-local-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 'gopher-dir gopher-bookmarks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 'gopher-bookmark-directory-p t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 'gopher-bookmark-buffer-tick gopher-bookmark-modified-tick
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 'gopher-obj 'bookmark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 'gopher-last oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (gopher-format-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ;; Turn on directory mode and put the description in the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (gopher-directory-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (setq mode-line-buffer-identification (concat "Gopher: *Bookmarks*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (error "No bookmarks supported.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (defun gopher-save-bookmarks ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 "Save bookmarks."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ((or (equal gopher-support-bookmarks 'unix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (equal gopher-support-bookmarks t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (gopher-save-unix-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ((stringp gopher-support-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (gopher-save-lisp-bookmarks gopher-support-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (message "Illformed gopher-support-bookmarks, assuming none")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (setq gopher-bookmarks-modified nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (defun gopher-save-unix-bookmarks ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 "Save bookmarks out to ~/.gopherrc file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (let* ((rcfile "~/.gopherrc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (new-file-p (not (file-exists-p rcfile)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (rcbuf (find-file-noselect rcfile)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (set-buffer rcbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (if new-file-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (insert "bookmarks:\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (if (re-search-forward "^bookmarks:\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (insert "bookmarks:\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 ;; Now, insert defined bookmarks into file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (let ((obj-count 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (while (< obj-count (length gopher-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (let ((obj (aref gopher-bookmarks obj-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (insert "#"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 "\nType=" (gopher-object-type obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 "\nName=" (gopher-object-descr obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 "\nPath=" (gopher-object-selector obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 "\nHost=" (gopher-object-host obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 "\nPort=" (int-to-string (gopher-object-port obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (setq obj-count (1+ obj-count)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (write-file rcfile))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (defun gopher-add-bookmark (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 "Add current object to menu of bookmarks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 With numeric prefix argument N, add Nth object."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (if (gopher-bookmark-directory-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (error "That item is already a bookmark!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (let ((existing-bookmarks gopher-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (new-bookmarks (make-vector (1+ (length gopher-bookmarks)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (obj (copy-sequence (gopher-directory-obj arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (l (length gopher-bookmarks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (gopher-set-object-descr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 obj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (read-from-minibuffer "Node Name: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (gopher-object-descr obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (aset new-bookmarks l obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (while (> l 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (progn (setq l (1- l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (aset new-bookmarks l (aref existing-bookmarks l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (setq gopher-bookmarks new-bookmarks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 gopher-bookmarks-modified t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 gopher-bookmark-modified-tick (1+ gopher-bookmark-modified-tick))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (defun gopher-delete-bookmark (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 "Delete current bookmark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 With numeric prefix argument N, delete Nth bookmark."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (if (not (gopher-bookmark-directory-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (error "Can only delete object in Bookmark directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (let ((new-bookmarks (make-vector (1- (length gopher-bookmarks)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (pos (1- (gopher-directory-n arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (l (length gopher-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (while (< i pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (progn (aset new-bookmarks i (aref gopher-bookmarks i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (while (< i (1- l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (progn (aset new-bookmarks i (aref gopher-bookmarks (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (setq gopher-killed-bookmark (aref gopher-bookmarks pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 gopher-bookmarks new-bookmarks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 gopher-dir new-bookmarks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 gopher-bookmarks-modified t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 gopher-bookmark-modified-tick (1+ gopher-bookmark-modified-tick))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (let ((ppos (1- (gopher-directory-n nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (if (< pos ppos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (setq ppos (1- ppos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (gopher-format-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (forward-line ppos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (forward-char 7)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (if (= (point) (point-max)) (previous-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ; (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 ; (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 ; (kill-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 ; (if (= (point) (point-max)) (previous-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (if (zerop (length gopher-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (gopher-last-node))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (defun gopher-yank-bookmark (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 "Yank the most recently killed bookmark at the current position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 With numeric prefix argument N, yank into position N."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (cond ((not (gopher-bookmark-directory-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (error "Can only yank bookmark objects into bookmark directory."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 ((null gopher-killed-bookmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (error "No killed bookmark object"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (let* ((len (length gopher-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (new-bookmarks (make-vector (1+ len) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (pos (1- (gopher-directory-n arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (if (or (< pos 0) (> pos (length gopher-bookmarks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (error "Out of range."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (setq i (1- pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (while (>= i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (aset new-bookmarks i (aref gopher-bookmarks i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (setq i (1- i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (aset new-bookmarks pos gopher-killed-bookmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (setq i pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (aset new-bookmarks (1+ i) (aref gopher-bookmarks i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (setq gopher-bookmarks new-bookmarks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 gopher-bookmarks-modified t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 gopher-killed-bookmark nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 gopher-bookmark-modified-tick
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (1+ gopher-bookmark-modified-tick))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (let ((ppos (1- (gopher-directory-n nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (if (<= pos ppos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (setq ppos (1+ ppos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (gopher-format-bookmarks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (forward-line ppos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (forward-char 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (defun gopher-bookmark-directory-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 "Return T if currently displaying Bookmark directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 gopher-bookmark-directory-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 ; (equal gopher-dir gopher-bookmarks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (defun gopher-read-lisp-bookmarks (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 "currently unsupported"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (error "gopher-read-lisp-bookmark is not yet supported. Sorry."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (defun gopher-save-lisp-bookmarks (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 "currently unsupported"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (error "gopher-save-lisp-bookmark is not yet supported. Sorry."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 ;;;; gopher documents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (defun gopher-document-object (obj oldbuf &optional end-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 "Retrieve and display a gopher document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 Optional argument END-REGEXP is used if the data will not be ended by `.'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (let ((docbuf (gopher-get-doc-buf (gopher-object-descr obj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 ;; Snarf the data into the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (gopher-retrieve-document-cleanly (docbuf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (gopher-object-selector obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (gopher-object-host obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (gopher-object-port obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 end-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (kill-buffer docbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (error "Problems retrieving document."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ;; Turn on document mode and put the description in the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (switch-to-buffer docbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (gopher-make-local-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 'gopher-obj obj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 'gopher-last oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (gopher-document-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (setq mode-line-buffer-identification (concat "Gopher: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (gopher-object-descr obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 ;; keymap for document mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (suppress-keymap gopher-document-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 ;Virginia Peck <vapeck@cs> Mon Aug 10 21:44:35 1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 ;;(define-key gopher-document-mode-map "\C-xk" 'gopher-last-node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (define-key gopher-document-mode-map "l" 'gopher-last-node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (define-key gopher-document-mode-map "q" 'gopher-last-node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (define-key gopher-document-mode-map "u" 'gopher-last-node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (define-key gopher-document-mode-map " " 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (define-key gopher-document-mode-map "\C-?" 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (define-key gopher-document-mode-map "\r" 'gopher-scroll-one-line-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (defun gopher-document-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 "Gopher document mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 \\{gopher-document-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (use-local-map gopher-document-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (setq major-mode 'gopher-document-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (setq mode-name "gopher doc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (run-hooks 'gopher-document-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (setq buffer-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 ;; from gosmacs.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (defun gopher-scroll-one-line-up (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 "Scroll the selected window up (forward in the text) one line (or N lines)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (scroll-up (or arg 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 ;;;; CSO handling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;;;; uses a subset of forms mode to handle data entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (defun gopher-cso-object (obj oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 "Display a CSO lookup form."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;; The following will create a buffer displaying the form described
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 ;; by the list in the last argument (cf. forms-mode). When the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 ;; accepts the data in the form (by pressing `C-c RET'), the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ;; gopher-do-cso will be called with the data the user supplied.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (gopher-form (gopher-object-descr obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 'gopher-do-cso
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 '("====== phone directory lookup ======"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 "\n Press `C-c RET' to lookup, `C-c l' to return to the last gopher object."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 "\n (you must fill in at least one of the first three fields)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 "Name : " 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 "Phone : " 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 "E-Mail : " 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 "Address : " 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;; Record gopher-last so gopher-last-node knows where to go.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;; Record gopher-obj so gopher-do-cso knows what server to query.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (gopher-make-local-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 'gopher-last oldbuf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 'gopher-obj obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (defconst gopher-cso-fields '("name" "phone" "email" "address")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 "Field names to use in CSO queries.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (defun gopher-do-cso (vals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 "Make a CSO query. VALS is the data the user entered in the form,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 as a list of strings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 ;; Check that the required data was provided.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (if (zerop (+ (length (nth 0 vals))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (length (nth 1 vals))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (length (nth 2 vals))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (error "Must specify name, phone, or email."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (let ((query "query")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (fields gopher-cso-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (obj gopher-obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 ;; Form the query string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (while vals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (if (not (zerop (length (car vals))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (setq query (concat query " " (car fields) "=" (car vals))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (setq vals (cdr vals))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (setq fields (cdr fields)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 ;; Use this string as the object selector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (gopher-set-object-selector gopher-obj query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ;; Retrieve the data from the server. Unlike gopher, the CSO data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ;; does not use `.' as a terminator.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (gopher-document-object gopher-obj (current-buffer) "^[2-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 ;; Strip CSO control information from the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (gopher-clean-cso-buffer obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (defun gopher-clean-cso-buffer (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 "Strip CSO control information from the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (let ((req "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 beg nreq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (cond ((and (>= (following-char) ?3) (<= (following-char) ?9))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (delete-char 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (insert (concat (gopher-object-selector obj) "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 ((eq (following-char) ?-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (delete-char 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (skip-chars-forward "^:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (setq nreq (buffer-substring beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (or (string= req nreq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (insert (concat "--------------------------"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 "-----------------------------\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (setq req nreq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (skip-chars-forward "^:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (delete-region beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (delete-region beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (delete-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 ;;;; indices.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 ;;;; To query an index, the search string is appended to the selector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 ;;;; The index returns a gopher directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (defun gopher-index-object (obj oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 "Query a gopher directory object."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 ;; Get the search string from the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (let ((str (read-from-minibuffer "Key: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (newobj (copy-sequence obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 ;; Append it to the selector and retrieve the modified object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 ;; like a directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (setq str (gopher-trim-blanks str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (if (> (length str) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (gopher-set-object-selector newobj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (concat (gopher-object-selector obj) "\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (gopher-directory-object newobj (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 ;;;; telneting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (defun gopher-telnet-object (obj oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 "Start a telnet session to a gopher object.
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 0
diff changeset
1313 If gopher-telnet-command is non-nil, then that is a command to start
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 a telnet session in a subprocess. Otherwise, the emacs-lisp telnet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 package is used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 ;; make the telnet argument string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (let ((arg (gopher-object-host obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (port (gopher-object-port obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (if (not (zerop port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (setq arg (concat arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (if (eq system-type 'vax-vms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 "/port="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 port)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (if gopher-telnet-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 ;; start up telnet as a separate process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (gopher-background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (concat gopher-telnet-command " " arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 ;; use telnet-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (telnet arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 ;; set things up so we can get back to the last node.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (gopher-make-local-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 'gopher-obj obj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 'gopher-last oldbuf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 'gopher-telnet-process-name (concat arg "-telnet"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (local-set-key "\C-cl" 'gopher-telnet-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (local-set-key "\C-xk" 'gopher-telnet-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 ;; show the login info to the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (if (not (zerop (length (gopher-object-selector obj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (message (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 "Login as: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (gopher-object-selector obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (defun gopher-telnet-quit nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 "Clean up a telnet session and return to the previous gopher node."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (delete-process gopher-telnet-process-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (error t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (gopher-last-node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ;;;; Images/sounds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (defun gopher-image-object (obj oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 "Retrieve what we hope is an image and show it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (showit (y-or-n-p "Display this item? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (buf (gopher-get-doc-buf (gopher-object-descr obj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (if showit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (setq fname (make-temp-name "/tmp/gopherimg"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (setq fname(read-file-name "File to save in: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (gopher-retrieve-document-cleanly (buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (gopher-object-selector obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (gopher-object-host obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (gopher-object-port obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 'none)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (error "Problems retrieving object.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (kill-buffer buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (write-file fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (kill-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (if (and showit gopher-image-display-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 ;; Spawn a process to display the image.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 ;; But modify its sentinel so that the file we wrote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 ;; will get deleted when the process exits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (let ((p (gopher-background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (concat gopher-image-display-command " " fname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (set-process-sentinel p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (` (lambda (process msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 ((, (process-sentinel p)) process msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (if (not (eq (process-status process) 'run))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (delete-file (, fname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 ;;;; Various opaque objects. Just save them in a file for now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (defun gopher-binary-object (obj oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 "Retrieve a gopher object and save it to a file,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 without trying to interpret it in any way."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (let ((fname (read-file-name "File to save in: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (buf (gopher-get-doc-buf (gopher-object-descr obj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (gopher-retrieve-document-cleanly (buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (gopher-object-selector obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (gopher-object-host obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (gopher-object-port obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 'none)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (error "Problems retrieving object.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (kill-buffer buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (write-file fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (kill-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ;;;; forms stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 ;;;; Uses some of the internal routines from forms.el to present
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 ;;;; a form which is not associated with a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (defun gopher-form (form-name accept-action number-of-fields format-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 "Display a buffer containing a form for the user to enter data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 The form is described by NUMBER-OF-FIELDS and FORMAT-LIST (cf. forms-mode).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 FORM-NAME is a string to put in the modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 When the user accepts the data in the form by pressing `C-c RET', the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 function ACCEPT-ACTION is called with a list of the strings which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 the user entered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (switch-to-buffer (generate-new-buffer "*gopher form*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (gopher-make-local-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 'forms-format-list format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 'forms-number-of-fields number-of-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 'forms-field-sep "\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 'forms-read-only nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 'forms-multi-line nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 'forms--number-of-markers nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 'forms--markers nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 'forms--format nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 'forms--parser nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 'forms--dynamic-text nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 'forms-fields nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 'forms-the-record-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 'forms-accept-action accept-action
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (forms--process-format-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (forms--make-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (forms--make-parser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 ;; make local variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (make-local-variable 'forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (make-local-variable 'forms--total-records)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (make-local-variable 'forms--current-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (make-local-variable 'forms--the-record-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (make-local-variable 'forms--search-rexexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 ;; set the major mode indicator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (setq major-mode 'gopher-form-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (setq mode-name "gopher form")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (use-local-map gopher-form-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (forms--show-record (make-string (1- number-of-fields) ?\t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (run-hooks 'gopher-form-mode-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (defun gopher-form-accept nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (funcall forms-accept-action (forms--parse-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (define-key gopher-form-mode-map "\C-c\r" 'gopher-form-accept)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (define-key gopher-form-mode-map "\C-cl" 'gopher-last-node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 ;;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 ;;;; low-level communications routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (defun gopher-retrieve-document (buf sel host port &optional end-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 "Retrieve a gopher object into BUF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 The object is identified by a SEL HOST PORT triple.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 Optional argument END-REGEXP is used for data which is not `.'-terminated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 If END-REGEXP is non-nil and not a string, then it is assumed that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 the data is binary, and reading will continue until the sender disconnects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 Returns NIL if an error occured during the attempt to retrieve the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 document, otherwise T.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 ;; Default is single period termination.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (or end-regexp (setq end-regexp "^\\.\r$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (let ((h (assoc host gopher-hostname-aliases)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (if h (setq host (cdr h))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 ;; Open the connection to the server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 ;; If we get an unknown service error, try looking the port up in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 ;; gopher-port-aliases. If we find it there, try the connect again
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 ;; with that translation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (let (wait
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (gopher-server-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (let (p (try-again t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (while try-again
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (setq try-again nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (condition-case errinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (setq p (open-network-stream "gopher" (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 host port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (error (if (and (string-match "^Unknown service .*$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (nth 1 errinfo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (setq port (cdr (assoc port
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 gopher-port-aliases))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (setq try-again t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (message (format "%s: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (nth 0 errinfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (nth 1 errinfo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (cond (gopher-server-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 ;; keep the emacs end-of-process status line out of the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (set-process-sentinel gopher-server-process 'gopher-sentinel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 ;; send the selector to the server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (process-send-string gopher-server-process (concat sel "\r\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 ;; receive the response from the server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 ;; based on nntp.el from GNUS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (setq wait t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (while wait
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (if (stringp end-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (forward-line -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (if (and (stringp end-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (looking-at end-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (setq wait nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (if (not (memq (process-status gopher-server-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 '(open run)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (message "gopher: connection closed")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (setq wait nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (if gopher-debug-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (message "gopher: Reading..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (cond (gopher-buggy-accept
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (sit-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ((and (boundp 'epoch::version) epoch::version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (accept-process-output gopher-server-process 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (accept-process-output gopher-server-process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (if gopher-debug-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (message " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 ;; be sure the net connection has gone away...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (delete-process gopher-server-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (error t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 ;; clean up the text buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (if (stringp end-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (gopher-clean-text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 ;;; adapted from GNUS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (defun gopher-clean-text ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 "Decode text transmitted by gopher.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 0. Delete status line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 1. Delete `^M' at end of line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 2. Delete `.' at end of buffer (end of text mark).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 3. Delete `.' at beginning of line. (does gopher want this?)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 ;; Insert newline at end of buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 ;; Delete `^M' at end of line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (while (re-search-forward "\r[^\n]*$" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (replace-match ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 ; (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ; (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 ; (if (= (preceding-char) ?\r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 ; (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 ; (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 ; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 ;; Delete `.' at end of buffer (end of text mark).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (forward-line -1) ;(beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 (while (looking-at "^\\.$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (delete-region (point) (progn (forward-line 1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 ;; Replace `..' at beginning of line with `.'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 ;; (replace-regexp "^\\.\\." ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (while (search-forward "\n.." nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (defun gopher-sentinel (proc status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (provide 'gopher)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 ;;; gopher.el ends here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 ;;;(gopher.el) Local Variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 ;;;(gopher.el) eval: (put 'gopher-retrieve-document-cleanly 'lisp-indent-hook 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 ;;;(gopher.el) End:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655