comparison lisp/browse-url.el @ 20460:9bef2b27cdaa

(browse-url-lynx-emacs): Add sentinel to kill the buffer when lynx exits. Doc fix. (browse-url-browser-function): Better customization. (browse-url-filename-alist, browse-url-netscape-display, browse-url-filename-alist, browse-url-generic-program): Likewise. (browse-url-new-window-p, browse-url-w3, browse-url-mail): Doc fix. (browse-url-save-file): Customize.
author Dave Love <fx@gnu.org>
date Fri, 12 Dec 1997 17:43:13 +0000
parents dfd02d692b0c
children b0d79b1edeb6
comparison
equal deleted inserted replaced
20459:90f306f86f5d 20460:9bef2b27cdaa
164 ;; (global-set-key "\C-c\C-zb" 'browse-url-of-buffer) 164 ;; (global-set-key "\C-c\C-zb" 'browse-url-of-buffer)
165 ;; (global-set-key "\C-c\C-zr" 'browse-url-of-region) 165 ;; (global-set-key "\C-c\C-zr" 'browse-url-of-region)
166 ;; (global-set-key "\C-c\C-zu" 'browse-url) 166 ;; (global-set-key "\C-c\C-zu" 'browse-url)
167 ;; (global-set-key "\C-c\C-zv" 'browse-url-of-file) 167 ;; (global-set-key "\C-c\C-zv" 'browse-url-of-file)
168 ;; (add-hook 'dired-mode-hook 168 ;; (add-hook 'dired-mode-hook
169 ;; (function (lambda () 169 ;; (lambda ()
170 ;; (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file)))) 170 ;; (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file)))
171 171
172 ;; Browse URLs in mail messages by clicking mouse-2: 172 ;; Browse URLs in mail messages by clicking mouse-2:
173 ;; (add-hook 'rmail-mode-hook (function (lambda () ; rmail-mode startup 173 ;; (add-hook 'rmail-mode-hook (lambda () ; rmail-mode startup
174 ;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse)))) 174 ;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse)))
175 175
176 ;; Browse URLs in Usenet messages by clicking mouse-2: 176 ;; Browse URLs in Usenet messages by clicking mouse-2:
177 ;; (eval-after-load "gnus" 177 ;; (eval-after-load "gnus"
178 ;; '(define-key gnus-article-mode-map [mouse-2] 'browse-url-at-mouse)) 178 ;; '(define-key gnus-article-mode-map [mouse-2] 'browse-url-at-mouse))
179 ;; [The current version of Gnus provides a standard feature to 179 ;; [The current version of Gnus provides a standard feature to
191 ;; write-file in html-helper-mode make Netscape reload the document: 191 ;; write-file in html-helper-mode make Netscape reload the document:
192 ;; 192 ;;
193 ;; (autoload 'browse-url-netscape-reload "browse-url" 193 ;; (autoload 'browse-url-netscape-reload "browse-url"
194 ;; "Ask a WWW browser to redisplay the current file." t) 194 ;; "Ask a WWW browser to redisplay the current file." t)
195 ;; (add-hook 'html-helper-mode-hook 195 ;; (add-hook 'html-helper-mode-hook
196 ;; (function (lambda () 196 ;; (lambda ()
197 ;; (add-hook 'local-write-file-hooks 197 ;; (add-hook 'local-write-file-hooks
198 ;; (function (lambda () 198 ;; (lambda ()
199 ;; (let ((local-write-file-hooks)) 199 ;; (let ((local-write-file-hooks))
200 ;; (save-buffer)) 200 ;; (save-buffer))
201 ;; (browse-url-netscape-reload) 201 ;; (browse-url-netscape-reload)
202 ;; t)) ; => file written by hook 202 ;; t) ; => file written by hook
203 ;; t)))) ; append to l-w-f-hooks 203 ;; t))) ; append to l-w-f-hooks
204 ;; 204 ;;
205 ;; OR have browse-url-of-file ask Netscape to load and then reload the 205 ;; OR have browse-url-of-file ask Netscape to load and then reload the
206 ;; file: 206 ;; file:
207 ;; 207 ;;
208 ;; (add-hook 'browse-url-of-file-hook 'browse-url-netscape-reload) 208 ;; (add-hook 'browse-url-of-file-hook 'browse-url-netscape-reload)
240 If the value is not a function it should be a list of pairs 240 If the value is not a function it should be a list of pairs
241 (REGEXP.FUNCTION). In this case the function called will be the one 241 (REGEXP.FUNCTION). In this case the function called will be the one
242 associated with the first REGEXP which matches the current URL. The 242 associated with the first REGEXP which matches the current URL. The
243 function is passed the URL and any other args of `browse-url'. The last 243 function is passed the URL and any other args of `browse-url'. The last
244 regexp should probably be \".\" to specify a default browser." 244 regexp should probably be \".\" to specify a default browser."
245 :type 'function 245 :type '(choice
246 (function-item :tag "Emacs W3" :value browse-url-w3)
247 (function-item :tag "W3 in another Emacs via `gnudoit'"
248 :value browse-url-w3-gnudoit)
249 (function-item :tag "Netscape" :value browse-url-netscape)
250 (function-item :tag "Mosaic" :value browse-url-mosaic)
251 (function-item :tag "Mosaic using CCI" :value browse-url-cci)
252 (function-item :tag "IXI Mosaic" :value browse-url-iximosaic)
253 (function-item :tag "Lynx in an xterm window"
254 :value browse-url-lynx-xterm)
255 (function-item :tag "Lynx in an Emacs window"
256 :value browse-url-lynx-emacs)
257 (function-item :tag "Grail" :value browse-url-grail)
258 (function-item :tag "MMM" :value browse-url-mmm)
259 (function-item :tag "Specified by `Browse Url Generic Program'"
260 :value browse-url-generic)
261 (function :tag "Your own function"))
246 :group 'browse-url) 262 :group 'browse-url)
247 263
248 (defcustom browse-url-netscape-program "netscape" 264 (defcustom browse-url-netscape-program "netscape"
249 "*The name by which to invoke Netscape." 265 "*The name by which to invoke Netscape."
250 :type 'string 266 :type 'string
261 `browse-url' is loaded." 277 `browse-url' is loaded."
262 :type '(repeat (string :tag "Argument")) 278 :type '(repeat (string :tag "Argument"))
263 :group 'browse-url) 279 :group 'browse-url)
264 280
265 (defcustom browse-url-new-window-p nil 281 (defcustom browse-url-new-window-p nil
266 "*If non-nil, always open a new browser window. 282 "*If non-nil, always open a new browser window with appropriate browsers.
267 Passing an interactive argument to \\[browse-url-netscape], 283 Passing an interactive argument to \\[browse-url], or specific browser
268 \\[browse-url-mosaic] or \\[browse-url-cci] reverses the effect of 284 commands reverses the effect of this variable. Requires Netscape version
269 this variable. Requires Netscape version 1.1N or later or XMosaic 285 1.1N or later or XMosaic version 2.5 or later if using those browsers."
270 version 2.5 or later."
271 :type 'boolean 286 :type 'boolean
272 :group 'browse-url) 287 :group 'browse-url)
273 288
274 (defcustom browse-url-netscape-display nil 289 (defcustom browse-url-netscape-display nil
275 "*The X display for running Netscape, if not same as Emacs'." 290 "*The X display for running Netscape, if not same as Emacs'."
276 :type '(choice string (const nil)) 291 :type '(choice string (const :tag "Default" nil))
277 :group 'browse-url) 292 :group 'browse-url)
278 293
279 (defcustom browse-url-mosaic-program "xmosaic" 294 (defcustom browse-url-mosaic-program "xmosaic"
280 "*The name by which to invoke Mosaic (or mMosaic)." 295 "*The name by which to invoke Mosaic (or mMosaic)."
281 :type 'string 296 :type 'string
321 '((\"/webmaster@webserver:/home/www/html/\" . 336 '((\"/webmaster@webserver:/home/www/html/\" .
322 \"http://www.acme.co.uk/\") 337 \"http://www.acme.co.uk/\")
323 (\"^/+\" . \"file:/\"))) 338 (\"^/+\" . \"file:/\")))
324 " 339 "
325 :type '(repeat (cons :format "%v" 340 :type '(repeat (cons :format "%v"
326 (string :tag "Regexp") 341 (regexp :tag "Regexp")
327 (string :tag "Replacement"))) 342 (string :tag "Replacement")))
328 :group 'browse-url) 343 :group 'browse-url)
329 344
330 (defcustom browse-url-save-file nil 345 (defcustom browse-url-save-file nil
331 "*If non-nil, save the buffer before displaying its file. 346 "*If non-nil, save the buffer before displaying its file.
390 :type '(repeat (string :tag "Argument")) 405 :type '(repeat (string :tag "Argument"))
391 :group 'browse-url) 406 :group 'browse-url)
392 407
393 (defcustom browse-url-generic-program nil 408 (defcustom browse-url-generic-program nil
394 "*The name of the browser program used by `browse-url-generic'." 409 "*The name of the browser program used by `browse-url-generic'."
395 :type '(choice string (const nil)) 410 :type '(choice string (const :tag "None" nil))
396 :group 'browse-url) 411 :group 'browse-url)
397 412
398 (defcustom browse-url-generic-args nil 413 (defcustom browse-url-generic-args nil
399 "*A list of strings defining options for `browse-url-generic-program'." 414 "*A list of strings defining options for `browse-url-generic-program'."
400 :type '(repeat (string :tag "Argument")) 415 :type '(repeat (string :tag "Argument"))
858 873
859 ;; --- W3 --- 874 ;; --- W3 ---
860 875
861 ;;;###autoload 876 ;;;###autoload
862 (defun browse-url-w3 (url &optional new-window) 877 (defun browse-url-w3 (url &optional new-window)
863 ;; new-window ignored
864 "Ask the w3 WWW browser to load URL. 878 "Ask the w3 WWW browser to load URL.
865 Default to the URL around or before point." 879 Default to the URL around or before point.
880
881 When called interactively, if variable `browse-url-new-window-p' is
882 non-nil, load the document in a new window. A non-nil interactive
883 prefix argument reverses the effect of `browse-url-new-window-p'.
884
885 When called non-interactively, optional second argument NEW-WINDOW is
886 used instead of `browse-url-new-window-p'."
866 (interactive (browse-url-interactive-arg "W3 URL: ")) 887 (interactive (browse-url-interactive-arg "W3 URL: "))
867 (if (browse-url-maybe-new-window new-window) 888 (if (browse-url-maybe-new-window new-window)
868 (w3-fetch-other-window) 889 (w3-fetch-other-window)
869 (w3-fetch url))) 890 (w3-fetch url)))
870 891
896 917
897 ;;;###autoload 918 ;;;###autoload
898 (defun browse-url-lynx-emacs (url &optional new-buffer) 919 (defun browse-url-lynx-emacs (url &optional new-buffer)
899 "Ask the Lynx WWW browser to load URL. 920 "Ask the Lynx WWW browser to load URL.
900 Default to the URL around or before point. With a prefix argument, run 921 Default to the URL around or before point. With a prefix argument, run
901 a new Lynx process in a new buffer." 922 a new Lynx process in a new buffer.
923
924 When called interactively, if variable `browse-url-new-window-p' is
925 non-nil, load the document in a new lynx in a new term window,
926 otherwise use any existing one. A non-nil interactive prefix argument
927 reverses the effect of `browse-url-new-window-p'.
928
929 When called non-interactively, optional second argument NEW-WINDOW is
930 used instead of `browse-url-new-window-p'."
902 (interactive (browse-url-interactive-arg "Lynx URL: ")) 931 (interactive (browse-url-interactive-arg "Lynx URL: "))
903 (let* ((system-uses-terminfo t) ; Lynx uses terminfo 932 (let* ((system-uses-terminfo t) ; Lynx uses terminfo
904 ;; (term-term-name "vt100") ; ?? 933 ;; (term-term-name "vt100") ; ??
905 (buf (get-buffer "*lynx*")) 934 (buf (get-buffer "*lynx*"))
906 (proc (and buf (get-buffer-process buf))) 935 (proc (and buf (get-buffer-process buf)))
914 (if (or (browse-url-maybe-new-window new-buffer) 943 (if (or (browse-url-maybe-new-window new-buffer)
915 (not buf) 944 (not buf)
916 (not proc) 945 (not proc)
917 (not (memq (process-status proc) '(run stop)))) 946 (not (memq (process-status proc) '(run stop))))
918 ;; start a new lynx 947 ;; start a new lynx
919 (progn (switch-to-buffer (make-term "lynx" "lynx" nil url)) 948 (progn (setq buf (make-term "lynx" "lynx" nil url))
920 (term-char-mode)) 949 (switch-to-buffer buf)
950 (term-char-mode)
951 (set-process-sentinel
952 (get-buffer-process buf)
953 ;; Don't leave around a dead one (especially because
954 ;; of its munged keymap.)
955 (lambda (process event)
956 (if (not (memq (process-status process) '(run stop)))
957 (let ((buf (process-buffer process)))
958 (if buf (kill-buffer buf)))))))
921 ;; send the url to lynx in the old buffer 959 ;; send the url to lynx in the old buffer
922 (let ((win (get-buffer-window buf t))) 960 (let ((win (get-buffer-window buf t)))
923 (if win 961 (if win
924 (select-window win) 962 (select-window win)
925 (switch-to-buffer buf))) 963 (switch-to-buffer buf)))
962 (defun browse-url-mail (url &optional new-window) 1000 (defun browse-url-mail (url &optional new-window)
963 "Open a new mail message buffer within Emacs. 1001 "Open a new mail message buffer within Emacs.
964 Default to using the mailto: URL around or before point as the 1002 Default to using the mailto: URL around or before point as the
965 recipient's address. Supplying a non-nil interactive prefix argument 1003 recipient's address. Supplying a non-nil interactive prefix argument
966 will cause the mail to be composed in another window rather than the 1004 will cause the mail to be composed in another window rather than the
967 current one." 1005 current one.
1006
1007 When called interactively, if variable `browse-url-new-window-p' is
1008 non-nil use `compose-mail-other-window', otherwise `compose-mail'. A
1009 non-nil interactive prefix argument reverses the effect of
1010 `browse-url-new-window-p'.
1011
1012 When called non-interactively, optional second argument NEW-WINDOW is
1013 used instead of `browse-url-new-window-p'."
968 (interactive (browse-url-interactive-arg "Mailto URL: ")) 1014 (interactive (browse-url-interactive-arg "Mailto URL: "))
969 (save-excursion 1015 (save-excursion
970 (let ((func (if (browse-url-maybe-new-window new-window) 1016 (let ((func (if (browse-url-maybe-new-window new-window)
971 'compose-mail-other-window 1017 'compose-mail-other-window
972 'compose-mail)) 1018 'compose-mail))