Commit a38de16e authored by Michaël Cadilhac's avatar Michaël Cadilhac
Browse files

(browse-url-elinks-new-window): New function.

(browse-url-elinks): Use browse-url-elinks-new-window.  Accept
optional second argument `new-window'.  Fix typo in doc-string.
(browse-url-elinks-sentinel): Use browse-url-elinks-new-window.
Improve error message.
parent 59c4e1da
2007-09-19 Johannes Weiner <hannes@saeurebad.de>
* net/browse-url.el (browse-url-elinks-new-window): New function.
(browse-url-elinks): Use browse-url-elinks-new-window. Accept
optional second argument `new-window'. Fix typo in doc-string.
(browse-url-elinks-sentinel): Use browse-url-elinks-new-window.
Improve error message.
2007-09-19 Micha,Ak(Bl Cadilhac <michael@cadilhac.name> 2007-09-19 Micha,Ak(Bl Cadilhac <michael@cadilhac.name>
* net/browse-url.el (browse-url-url-encode-chars): Use the right * net/browse-url.el (browse-url-url-encode-chars): Use the right
......
...@@ -1517,8 +1517,17 @@ Default to the URL around or before point." ...@@ -1517,8 +1517,17 @@ Default to the URL around or before point."
(apply #'start-process (concat "KDE " url) nil browse-url-kde-program (apply #'start-process (concat "KDE " url) nil browse-url-kde-program
(append browse-url-kde-args (list url)))) (append browse-url-kde-args (list url))))
(defun browse-url-elinks-new-window (url)
"Ask the Elinks WWW browser to load URL in a new window."
(let ((process-environment (browse-url-process-environment)))
(apply #'start-process
(append (list (concat "elinks:" url)
nil)
browse-url-elinks-wrapper
(list "elinks" url)))))
;;;###autoload ;;;###autoload
(defun browse-url-elinks (url) (defun browse-url-elinks (url &optional new-window)
"Ask the Elinks WWW browser to load URL. "Ask the Elinks WWW browser to load URL.
Default to the URL around the point. Default to the URL around the point.
...@@ -1526,36 +1535,36 @@ The document is loaded in a new tab of a running Elinks or, if ...@@ -1526,36 +1535,36 @@ The document is loaded in a new tab of a running Elinks or, if
none yet running, a newly started instance. none yet running, a newly started instance.
The Elinks command will be prepended by the program+arguments The Elinks command will be prepended by the program+arguments
from `elinks-browse-url-wrapper'." from `browse-url-elinks-wrapper'."
(interactive (browse-url-interactive-arg "URL: ")) (interactive (browse-url-interactive-arg "URL: "))
(setq url (browse-url-encode-url url)) (setq url (browse-url-encode-url url))
(let ((process-environment (browse-url-process-environment)) (if new-window
(elinks-ping-process (start-process "elinks-ping" nil (browse-url-elinks-new-window url)
"elinks" "-remote" "ping()"))) (let ((process-environment (browse-url-process-environment))
(set-process-sentinel elinks-ping-process (elinks-ping-process (start-process "elinks-ping" nil
`(lambda (process change) "elinks" "-remote" "ping()")))
(browse-url-elinks-sentinel process ,url))))) (set-process-sentinel elinks-ping-process
`(lambda (process change)
(browse-url-elinks-sentinel process ,url))))))
(defun browse-url-elinks-sentinel (process url) (defun browse-url-elinks-sentinel (process url)
"Determines if Elinks is running or a new one has to be started." "Determines if Elinks is running or a new one has to be started."
(let ((exit-status (process-exit-status process)) (let ((exit-status (process-exit-status process)))
(process-environment (browse-url-process-environment)))
;; Try to determine if an instance is running or if we have to ;; Try to determine if an instance is running or if we have to
;; create a new one. ;; create a new one.
(case exit-status (case exit-status
(5 (5
;; No instance, start a new one. ;; No instance, start a new one.
(apply #'start-process (browse-url-elinks-new-window url))
(append (list (concat "elinks:" url) nil)
browse-url-elinks-wrapper
(list "elinks" url))))
(0 (0
;; Found an instance, open URL in new tab. ;; Found an instance, open URL in new tab.
(start-process (concat "elinks:" url) nil (let ((process-environment (browse-url-process-environment)))
"elinks" "-remote" (start-process (concat "elinks:" url) nil
(concat "openURL(\"" url "\",new-tab)"))) "elinks" "-remote"
(concat "openURL(\"" url "\",new-tab)"))))
(otherwise (otherwise
(error "Undefined exit-code of process `elinks'"))))) (error "Unrecognized exit-code %d of process `elinks'"
exit-status)))))
(provide 'browse-url) (provide 'browse-url)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment