--- /usr/share/emacs/21.3/lisp/net/browse-url.el 2003-10-27 14:35:16.000000000 +0100 +++ /home/rrt/elisp/browse-url.el 2004-01-19 19:18:12.000000000 +0100 @@ -215,7 +215,7 @@ ;; To invoke different browsers for different URLs: ;; (setq browse-url-browser-function '(("^mailto:" . browse-url-mail) -;; ("." . browse-url-netscape))) +;; ("." . browse-url-netscape))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Code: @@ -226,6 +226,7 @@ (eval-when-compile (require 'thingatpt) (require 'term) (require 'dired) + (require 'cl) (require 'w3-auto nil t)) (defgroup browse-url nil @@ -788,7 +789,7 @@ When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." - (interactive (browse-url-interactive-arg "URL: ")) + (interactive (browse-url-interactive-arg "URL: ")) (apply 'start-process (concat "gnome-moz-remote " url) nil "gnome-moz-remote" @@ -1079,16 +1080,42 @@ (defun browse-url-generic (url &optional new-window) ;; new-window ignored "Ask the WWW browser defined by `browse-url-generic-program' to load URL. -Default to the URL around or before point. A fresh copy of the -browser is started up in a new process with possible additional arguments -`browse-url-generic-args'. This is appropriate for browsers which -don't offer a form of remote control." +Default to the URL around or before point. A fresh copy of the browser +is started up in a new process with possible additional arguments +`browse-url-generic-args', in which the URL is substituted for +`__URL__' if it exists, or added as a final argument if not." (interactive (browse-url-interactive-arg "URL: ")) - (if (not browse-url-generic-program) + (unless browse-url-generic-program (error "No browser defined (`browse-url-generic-program')")) - (apply 'start-process (concat browse-url-generic-program url) nil - browse-url-generic-program - (append browse-url-generic-args (list url)))) + (let (found-tok) + (let ((args + (mapcar + (lambda (s) + (if (string-match "__URL__" s) + (progn + (setq found-tok t) + (replace-match url t t s)) + s)) + browse-url-generic-args))) + (unless found-tok + (setq args (append args (list url)))) + (apply 'start-process (concat browse-url-generic-program " " "some url") nil + browse-url-generic-program + args)))) + +; Values for browse-url-generic-args +; +; These could be put in a list indexed by browser name to allow common +; browsers to be chosen from a list and the method of starting the URL +; (same window, new window, new tab) to be an option. +; +; Browser Same window New window New tab +; +; Opera "" -remote openURL(__URL__,new-window) -remote openURL(__URL__,new-page) +; Konqueror ?? "" ?? +; Mozilla -remote openURL(__URL__) -remote openURL(__URL__,new-window) -remote openURL(__URL__,new-tab) +; gnome-moz-remote --raise __URL__ --raise --newwin __URL__ --raise --remote=openURL(__URL__,new-tab) +; lynx-xterm n/a xterm -e lynx __URL__ n/a ;;;###autoload (defun browse-url-kde (url &optional new-window)