aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love1997-10-23 13:43:14 +0000
committerDave Love1997-10-23 13:43:14 +0000
commit837984b11bfe8e25965b89fcfad0112f1f4c52dc (patch)
treec2d653783d2ee469a993e762f32668c5b82a05dd
parent7c552ae840da9acaa9e897c68620504f3b753fa8 (diff)
downloademacs-837984b11bfe8e25965b89fcfad0112f1f4c52dc.tar.gz
emacs-837984b11bfe8e25965b89fcfad0112f1f4c52dc.zip
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so args works properly. (browse-url-maybe-new-window): New function. (browse-url-netscape, browse-url-mosaic, browse-url-cci, browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it. (browse-url-lynx-emacs): Don't call term-term-name. (browse-url-lynx-input-field, browse-url-lynx-input-delay, browse-url-lynx-input-attempts): New variables. (browse-url-lynx-emacs): Use any existing Lynx buffer; take care to move off input fields. (After Vladimir Alexiev <vladimir@cs.ualberta.ca>.) (browse-url-mosaic-program): New variable. (browse-url-mosaic): Use browse-url-mosaic-program and browse-url-new-window-p. (browse-url-at-mouse): Use browse-url-new-window-p.
-rw-r--r--lisp/browse-url.el158
1 files changed, 118 insertions, 40 deletions
diff --git a/lisp/browse-url.el b/lisp/browse-url.el
index 743c08329ee..967b1abebbc 100644
--- a/lisp/browse-url.el
+++ b/lisp/browse-url.el
@@ -40,7 +40,7 @@
40 40
41;; Function Browser Earliest version 41;; Function Browser Earliest version
42;; browse-url-netscape Netscape 1.1b1 42;; browse-url-netscape Netscape 1.1b1
43;; browse-url-mosaic XMosaic <= 2.4 43;; browse-url-mosaic XMosaic/mMosaic <= 2.4
44;; browse-url-cci XMosaic 2.5 44;; browse-url-cci XMosaic 2.5
45;; browse-url-w3 w3 0 45;; browse-url-w3 w3 0
46;; browse-url-w3-gnudoit w3 remotely 46;; browse-url-w3-gnudoit w3 remotely
@@ -96,10 +96,11 @@
96;; Free graphical browsers that could be used by `browse-url-generic' 96;; Free graphical browsers that could be used by `browse-url-generic'
97;; include Chimera <URL:ftp://ftp.cs.unlv.edu/pub/chimera> and 97;; include Chimera <URL:ftp://ftp.cs.unlv.edu/pub/chimera> and
98;; <URL:http://www.unlv.edu/chimera/>, Arena 98;; <URL:http://www.unlv.edu/chimera/>, Arena
99;; <URL:ftp://ftp.yggdrasil.com/pub/dist/web/arena>, Amaya 99;; <URL:ftp://ftp.yggdrasil.com/pub/dist/web/arena> and Amaya
100;; <URL:ftp://ftp.w3.org/pub/amaya>, mMosaic 100;; <URL:ftp://ftp.w3.org/pub/amaya>. mMosaic
101;; <URL:ftp://sig.enst.fr/pub/multicast/mMosaic/> (the latter with 101;; <URL:ftp://sig.enst.fr/pub/multicast/mMosaic/> (with development
102;; development support for Java applets). 102;; support for Java applets and multicast) can be used like Mosaic by
103;; setting `browse-url-mosaic-program' appropriately.
103 104
104;; I [Denis Howe] recommend Nelson Minar <nelson@santafe.edu>'s excellent 105;; I [Denis Howe] recommend Nelson Minar <nelson@santafe.edu>'s excellent
105;; html-helper-mode.el for editing HTML and thank Nelson for 106;; html-helper-mode.el for editing HTML and thank Nelson for
@@ -254,7 +255,7 @@ regexp should probably be \".\" to specify a default browser."
254 :group 'browse-url) 255 :group 'browse-url)
255 256
256(defcustom browse-url-netscape-startup-arguments browse-url-netscape-arguments 257(defcustom browse-url-netscape-startup-arguments browse-url-netscape-arguments
257 "*A list of strings to pass to Netscape when it starts up. 258 "*A list of strings to pass to Netscape when it start up.
258Defaults to the value of `browse-url-netscape-arguments' at the time 259Defaults to the value of `browse-url-netscape-arguments' at the time
259`browse-url' is loaded." 260`browse-url' is loaded."
260 :type '(repeat (string :tag "Argument")) 261 :type '(repeat (string :tag "Argument"))
@@ -262,17 +263,23 @@ Defaults to the value of `browse-url-netscape-arguments' at the time
262 263
263(defcustom browse-url-new-window-p nil 264(defcustom browse-url-new-window-p nil
264 "*If non-nil, always open a new browser window. 265 "*If non-nil, always open a new browser window.
265Passing an interactive argument to \\[browse-url-netscape] or 266Passing an interactive argument to \\[browse-url-netscape],
266\\[browse-url-cci] reverses the effect of this variable. Requires 267\\[browse-url-mosaic] or \\[browse-url-cci] reverses the effect of
267Netscape version 1.1N or later or XMosaic version 2.5 or later." 268this variable. Requires Netscape version 1.1N or later or XMosaic
269version 2.5 or later."
268 :type 'boolean 270 :type 'boolean
269 :group 'browse-url) 271 :group 'browse-url)
270 272
271(defcustom browse-url-netscape-display nil 273(defcustom browse-url-netscape-display nil
272 "*The X display for running Netscape, if not same as Emacs's." 274 "*The X display for running Netscape, if not same as Emacs'."
273 :type '(choice string (const nil)) 275 :type '(choice string (const nil))
274 :group 'browse-url) 276 :group 'browse-url)
275 277
278(defcustom browse-url-mosaic-program "xmosaic"
279 "*The name by which to invoke Mosaic (or mMosaic)."
280 :type 'string
281 :group 'browse-url)
282
276(defcustom browse-url-mosaic-arguments nil 283(defcustom browse-url-mosaic-arguments nil
277 "*A list of strings to pass to Mosaic as arguments." 284 "*A list of strings to pass to Mosaic as arguments."
278 :type '(repeat (string :tag "Argument")) 285 :type '(repeat (string :tag "Argument"))
@@ -320,8 +327,7 @@ For example, to map EFS filenames to URLs:
320Used by the `browse-url-of-file' command.") 327Used by the `browse-url-of-file' command.")
321 328
322(defvar browse-url-of-file-hook nil 329(defvar browse-url-of-file-hook nil
323 "A hook to be run with run-hook after `browse-url-of-file' has asked 330 "Run after `browse-url-of-file' has asked a browser to load a file.
324a browser to load a file.
325 331
326Set this to `browse-url-netscape-reload' to force Netscape to load the 332Set this to `browse-url-netscape-reload' to force Netscape to load the
327file rather than displaying a cached copy.") 333file rather than displaying a cached copy.")
@@ -383,9 +389,10 @@ These might set the port, for instance."
383 389
384(defcustom browse-url-temp-dir 390(defcustom browse-url-temp-dir
385 (or (getenv "TMPDIR") "/tmp") 391 (or (getenv "TMPDIR") "/tmp")
386 "*The name of a directory in which to store temporary files 392 "*The name of a directory for browse-url's temporary files.
387generated by functions like `browse-url-of-region'. You might want to 393Such files are generated by functions like `browse-url-of-region'.
388set this to somewhere with restricted read permissions for privacy's sake." 394You might want to set this to somewhere with restricted read permissions
395for privacy's sake."
389 :type 'string 396 :type 'string
390 :group 'browse-url) 397 :group 'browse-url)
391 398
@@ -397,6 +404,21 @@ incompatibly at version 4."
397 :type 'number 404 :type 'number
398 :group 'browse-url) 405 :group 'browse-url)
399 406
407(defvar browse-url-lynx-input-field 'avoid
408 "*Action on selecting an existing Lynx buffer at an input field.
409What to do when sending a new URL to an existing Lynx buffer in Emacs
410if the Lynx cursor is on an input field (in which case the `g' command
411would be entered as data). Such fields are recognized by the
412underlines ____. Allowed values: nil: disregard it, 'warn: warn the
413user and don't emit the URL, 'avoid: try to avoid the field by moving
414down (this *won't* always work).")
415
416(defvar browse-url-lynx-input-attempts 10
417 "*How many times to try to move down from a series of lynx input fields.")
418
419(defvar browse-url-lynx-input-delay 0.2
420 "*How many seconds to wait for lynx between moves down from an input field.")
421
400(defvar browse-url-temp-file-list '()) 422(defvar browse-url-temp-file-list '())
401 423
402;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 424;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -423,6 +445,11 @@ negation if a prefix argument was given."
423 (not (eq (null browse-url-new-window-p) 445 (not (eq (null browse-url-new-window-p)
424 (null current-prefix-arg))))) 446 (null current-prefix-arg)))))
425 447
448(defun browse-url-maybe-new-window (arg)
449 (if (interactive-p)
450 arg
451 browse-url-new-window-p))
452
426;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 453;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
427;; Browse current buffer 454;; Browse current buffer
428 455
@@ -550,7 +577,7 @@ Prompts for a URL, defaulting to the URL at or before point. Variable
550`browse-url-browser-function' says which browser to use." 577`browse-url-browser-function' says which browser to use."
551 (interactive (browse-url-interactive-arg "URL: ")) 578 (interactive (browse-url-interactive-arg "URL: "))
552 (if (consp browse-url-browser-function) 579 (if (consp browse-url-browser-function)
553 (browse-url-choose-browser args) 580 (apply browse-url-choose-browser args)
554 (apply browse-url-browser-function args))) 581 (apply browse-url-browser-function args)))
555 582
556(defun browse-url-choose-browser (url &rest args) 583(defun browse-url-choose-browser (url &rest args)
@@ -571,7 +598,7 @@ This is done according to the association list in variable
571;;;###autoload 598;;;###autoload
572(defun browse-url-at-point () 599(defun browse-url-at-point ()
573 "Ask a WWW browser to load the URL at or before point. 600 "Ask a WWW browser to load the URL at or before point.
574Doesn't let you edit the URL like browse-url. Variable 601Doesn't let you edit the URL like `browse-url'. Variable
575`browse-url-browser-function' says which browser to use." 602`browse-url-browser-function' says which browser to use."
576 (interactive) 603 (interactive)
577 (browse-url (browse-url-url-at-point))) 604 (browse-url (browse-url-url-at-point)))
@@ -587,7 +614,7 @@ Doesn't let you edit the URL like browse-url. Variable
587 "Ask a WWW browser to load a URL clicked with the mouse. 614 "Ask a WWW browser to load a URL clicked with the mouse.
588The URL is the one around or before the position of the mouse click 615The URL is the one around or before the position of the mouse click
589but point is not changed. Doesn't let you edit the URL like 616but point is not changed. Doesn't let you edit the URL like
590browse-url. Variable `browse-url-browser-function' says which browser 617`browse-url'. Variable `browse-url-browser-function' says which browser
591to use." 618to use."
592 (interactive "e") 619 (interactive "e")
593 (save-excursion 620 (save-excursion
@@ -596,7 +623,7 @@ to use."
596 (let ((url (browse-url-url-at-point))) 623 (let ((url (browse-url-url-at-point)))
597 (if (string-equal url "") 624 (if (string-equal url "")
598 (error "No URL found")) 625 (error "No URL found"))
599 (browse-url url)))) 626 (browse-url url browse-url-new-window-p))))
600 627
601;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 628;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
602;; Browser-specific commands 629;; Browser-specific commands
@@ -615,7 +642,7 @@ environment, otherwise just use the current environment."
615 642
616(defun browse-url-emacs-display () 643(defun browse-url-emacs-display ()
617 "Return the X display Emacs is running on. 644 "Return the X display Emacs is running on.
618This nil if the display is the same as the DISPLAY environment variable. 645This is nil if the display is the same as the DISPLAY environment variable.
619 646
620Actually Emacs could be using several screens on several displays, as 647Actually Emacs could be using several screens on several displays, as
621listed by (emacs-display-list) and (x-display-screens DISPLAY), this 648listed by (emacs-display-list) and (x-display-screens DISPLAY), this
@@ -657,7 +684,9 @@ used instead of `browse-url-new-window-p'."
657 (if new-window '("-noraise")) 684 (if new-window '("-noraise"))
658 (list "-remote" 685 (list "-remote"
659 (concat "openURL(" url 686 (concat "openURL(" url
660 (if new-window ",new-window") 687 (if (browse-url-maybe-new-window
688 new-window)
689 ",new-window")
661 ")"))))))) 690 ")")))))))
662 (set-process-sentinel process 691 (set-process-sentinel process
663 (list 'lambda '(process change) 692 (list 'lambda '(process change)
@@ -674,7 +703,8 @@ used instead of `browse-url-new-window-p'."
674 (append browse-url-netscape-startup-arguments (list url)))))) 703 (append browse-url-netscape-startup-arguments (list url))))))
675 704
676(defun browse-url-netscape-reload () 705(defun browse-url-netscape-reload ()
677 "Ask Netscape to reload its current document." 706 "Ask Netscape to reload its current document.
707How depends on `browse-url-netscape-version'."
678 (interactive) 708 (interactive)
679 ;; Backwards incompatibility reported by 709 ;; Backwards incompatibility reported by
680 ;; <peter.kruse@psychologie.uni-regensburg.de>. 710 ;; <peter.kruse@psychologie.uni-regensburg.de>.
@@ -696,7 +726,19 @@ used instead of `browse-url-new-window-p'."
696(defun browse-url-mosaic (url &optional new-window) 726(defun browse-url-mosaic (url &optional new-window)
697 ;; new-window ignored 727 ;; new-window ignored
698 "Ask the XMosaic WWW browser to load URL. 728 "Ask the XMosaic WWW browser to load URL.
699Default to the URL around or before point." 729
730Default to the URL around or before point. The strings in variable
731`browse-url-mosaic-arguments' are also passed to Mosaic and the
732program is invoked according to the variable
733`browse-url-mosaic-program'.
734
735When called interactively, if variable `browse-url-new-window-p' is
736non-nil, load the document in a new Mosaic window, otherwise use a
737random existing one. A non-nil interactive prefix argument reverses
738the effect of `browse-url-new-window-p'.
739
740When called non-interactively, optional second argument NEW-WINDOW is
741used instead of `browse-url-new-window-p'."
700 (interactive (browse-url-interactive-arg "Mosaic URL: ")) 742 (interactive (browse-url-interactive-arg "Mosaic URL: "))
701 (let ((pidfile (expand-file-name "~/.mosaicpid")) 743 (let ((pidfile (expand-file-name "~/.mosaicpid"))
702 pid pidbuf) 744 pid pidbuf)
@@ -710,7 +752,10 @@ Default to the URL around or before point."
710 (save-excursion 752 (save-excursion
711 (find-file (format "/tmp/Mosaic.%d" pid)) 753 (find-file (format "/tmp/Mosaic.%d" pid))
712 (erase-buffer) 754 (erase-buffer)
713 (insert "goto\n" url "\n") 755 (insert (if (browse-url-maybe-new-window new-window)
756 "newwin\n"
757 "goto\n")
758 url "\n")
714 (save-buffer) 759 (save-buffer)
715 (kill-buffer nil) 760 (kill-buffer nil)
716 ;; Send signal SIGUSR to Mosaic 761 ;; Send signal SIGUSR to Mosaic
@@ -722,7 +767,7 @@ Default to the URL around or before point."
722 ) 767 )
723 ;; Mosaic not running - start it 768 ;; Mosaic not running - start it
724 (message "Starting Mosaic...") 769 (message "Starting Mosaic...")
725 (apply 'start-process "xmosaic" nil "xmosaic" 770 (apply 'start-process "xmosaic" nil browse-url-mosaic-program
726 (append browse-url-mosaic-arguments (list url))) 771 (append browse-url-mosaic-arguments (list url)))
727 (message "Starting Mosaic...done")))) 772 (message "Starting Mosaic...done"))))
728 773
@@ -771,7 +816,11 @@ used instead of `browse-url-new-window-p'."
771 ;; Todo: start browser if fails 816 ;; Todo: start browser if fails
772 (process-send-string "browse-url" 817 (process-send-string "browse-url"
773 (concat "get url (" url ") output " 818 (concat "get url (" url ") output "
774 (if new-window "new" "current") "\r\n")) 819 (if (browse-url-maybe-new-window
820 new-window)
821 "new"
822 "current")
823 "\r\n"))
775 (process-send-string "browse-url" "disconnect\r\n") 824 (process-send-string "browse-url" "disconnect\r\n")
776 (delete-process "browse-url")) 825 (delete-process "browse-url"))
777 826
@@ -794,7 +843,9 @@ Default to the URL around or before point."
794 "Ask the w3 WWW browser to load URL. 843 "Ask the w3 WWW browser to load URL.
795Default to the URL around or before point." 844Default to the URL around or before point."
796 (interactive (browse-url-interactive-arg "W3 URL: ")) 845 (interactive (browse-url-interactive-arg "W3 URL: "))
797 (w3-fetch url)) 846 (if (browse-url-maybe-new-window new-window)
847 (w3-fetch-other-window)
848 (w3-fetch url)))
798 849
799;;;###autoload 850;;;###autoload
800(defun browse-url-w3-gnudoit (url &optional new-window) 851(defun browse-url-w3-gnudoit (url &optional new-window)
@@ -823,20 +874,47 @@ with possible additional arguments `browse-url-xterm-args'."
823;; --- Lynx in an Emacs "term" window --- 874;; --- Lynx in an Emacs "term" window ---
824 875
825;;;###autoload 876;;;###autoload
826(defun browse-url-lynx-emacs (url &optional new-window) 877(defun browse-url-lynx-emacs (url &optional new-buffer)
827 ;; new-window ignored
828 "Ask the Lynx WWW browser to load URL. 878 "Ask the Lynx WWW browser to load URL.
829Default to the URL around or before point. Run a new Lynx process in 879Default to the URL around or before point. With a prefix argument, run
830an Emacs buffer." 880a new Lynx process in a new buffer."
831 (interactive (browse-url-interactive-arg "Lynx URL: ")) 881 (interactive (browse-url-interactive-arg "Lynx URL: "))
832 (let ((system-uses-terminfo t)) ; Lynx uses terminfo 882 (let* ((system-uses-terminfo t) ; Lynx uses terminfo
833 (if (fboundp 'make-term) 883 ;; (term-term-name "vt100") ; ??
834 (let ((term-term-name "vt100")) 884 (buf (get-buffer "*lynx*"))
835 (set-buffer (make-term "browse-url" "lynx" nil url)) 885 (proc (and buf (get-buffer-process buf)))
836 (term-mode) 886 (n browse-url-lynx-input-attempts))
837 (term-char-mode) 887 (if (and (browse-url-maybe-new-window new-buffer) buf)
838 (switch-to-buffer "*browse-url*")) 888 ;; Rename away the OLD buffer. This isn't very polite, but
839 (terminal-emulator "*browse-url*" "lynx" (list url))))) 889 ;; term insists on working in a buffer named *lynx* and would
890 ;; choke on *lynx*<1>
891 (progn (set-buffer buf)
892 (rename-uniquely)))
893 (if (or (browse-url-maybe-new-window new-buffer)
894 (not buf)
895 (not proc)
896 (not (memq (process-status proc) '(run stop))))
897 ;; start a new lynx
898 (progn (switch-to-buffer (make-term "lynx" "lynx" nil url))
899 (term-char-mode))
900 ;; send the url to lynx in the old buffer
901 (let ((win (get-buffer-window buf t)))
902 (if win
903 (select-window win)
904 (switch-to-buffer buf)))
905 (if (eq (following-char) ?_)
906 (cond ((eq browse-url-lynx-input-field 'warn)
907 (error "Please move out of the input field first."))
908 ((eq browse-url-lynx-input-field 'avoid)
909 (while (and (eq (following-char) ?_) (> n 0))
910 (term-send-down) ; down arrow
911 (sit-for browse-url-lynx-input-delay))
912 (if (eq (following-char) ?_)
913 (error "Cannot move out of the input field, sorry.")))))
914 (term-send-string proc (concat "g" ; goto
915 "\C-u" ; kill default url
916 url
917 "\r")))))
840 918
841;; --- MMM --- 919;; --- MMM ---
842 920
@@ -868,7 +946,7 @@ will cause the mail to be composed in another window rather than the
868current one." 946current one."
869 (interactive (browse-url-interactive-arg "Mailto URL: ")) 947 (interactive (browse-url-interactive-arg "Mailto URL: "))
870 (save-excursion 948 (save-excursion
871 (let ((func (if new-window 949 (let ((func (if (browse-url-maybe-new-window new-window)
872 'compose-mail-other-window 950 'compose-mail-other-window
873 'compose-mail)) 951 'compose-mail))
874 (to (if (string-match "^mailto:" url) 952 (to (if (string-match "^mailto:" url)