comparison lisp/net/browse-url.el @ 84650:96e533633b62

(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.
author Michaël Cadilhac <michael.cadilhac@lrde.org>
date Wed, 19 Sep 2007 11:26:46 +0000
parents ea4647942299
children 289916e64e8b bdb3fe0ba9fa
comparison
equal deleted inserted replaced
84649:d001e127665c 84650:96e533633b62
1515 (interactive (browse-url-interactive-arg "KDE URL: ")) 1515 (interactive (browse-url-interactive-arg "KDE URL: "))
1516 (message "Sending URL to KDE...") 1516 (message "Sending URL to KDE...")
1517 (apply #'start-process (concat "KDE " url) nil browse-url-kde-program 1517 (apply #'start-process (concat "KDE " url) nil browse-url-kde-program
1518 (append browse-url-kde-args (list url)))) 1518 (append browse-url-kde-args (list url))))
1519 1519
1520 ;;;###autoload 1520 (defun browse-url-elinks-new-window (url)
1521 (defun browse-url-elinks (url) 1521 "Ask the Elinks WWW browser to load URL in a new window."
1522 (let ((process-environment (browse-url-process-environment)))
1523 (apply #'start-process
1524 (append (list (concat "elinks:" url)
1525 nil)
1526 browse-url-elinks-wrapper
1527 (list "elinks" url)))))
1528
1529 ;;;###autoload
1530 (defun browse-url-elinks (url &optional new-window)
1522 "Ask the Elinks WWW browser to load URL. 1531 "Ask the Elinks WWW browser to load URL.
1523 Default to the URL around the point. 1532 Default to the URL around the point.
1524 1533
1525 The document is loaded in a new tab of a running Elinks or, if 1534 The document is loaded in a new tab of a running Elinks or, if
1526 none yet running, a newly started instance. 1535 none yet running, a newly started instance.
1527 1536
1528 The Elinks command will be prepended by the program+arguments 1537 The Elinks command will be prepended by the program+arguments
1529 from `elinks-browse-url-wrapper'." 1538 from `browse-url-elinks-wrapper'."
1530 (interactive (browse-url-interactive-arg "URL: ")) 1539 (interactive (browse-url-interactive-arg "URL: "))
1531 (setq url (browse-url-encode-url url)) 1540 (setq url (browse-url-encode-url url))
1532 (let ((process-environment (browse-url-process-environment)) 1541 (if new-window
1533 (elinks-ping-process (start-process "elinks-ping" nil 1542 (browse-url-elinks-new-window url)
1534 "elinks" "-remote" "ping()"))) 1543 (let ((process-environment (browse-url-process-environment))
1535 (set-process-sentinel elinks-ping-process 1544 (elinks-ping-process (start-process "elinks-ping" nil
1536 `(lambda (process change) 1545 "elinks" "-remote" "ping()")))
1537 (browse-url-elinks-sentinel process ,url))))) 1546 (set-process-sentinel elinks-ping-process
1547 `(lambda (process change)
1548 (browse-url-elinks-sentinel process ,url))))))
1538 1549
1539 (defun browse-url-elinks-sentinel (process url) 1550 (defun browse-url-elinks-sentinel (process url)
1540 "Determines if Elinks is running or a new one has to be started." 1551 "Determines if Elinks is running or a new one has to be started."
1541 (let ((exit-status (process-exit-status process)) 1552 (let ((exit-status (process-exit-status process)))
1542 (process-environment (browse-url-process-environment)))
1543 ;; Try to determine if an instance is running or if we have to 1553 ;; Try to determine if an instance is running or if we have to
1544 ;; create a new one. 1554 ;; create a new one.
1545 (case exit-status 1555 (case exit-status
1546 (5 1556 (5
1547 ;; No instance, start a new one. 1557 ;; No instance, start a new one.
1548 (apply #'start-process 1558 (browse-url-elinks-new-window url))
1549 (append (list (concat "elinks:" url) nil)
1550 browse-url-elinks-wrapper
1551 (list "elinks" url))))
1552 (0 1559 (0
1553 ;; Found an instance, open URL in new tab. 1560 ;; Found an instance, open URL in new tab.
1554 (start-process (concat "elinks:" url) nil 1561 (let ((process-environment (browse-url-process-environment)))
1555 "elinks" "-remote" 1562 (start-process (concat "elinks:" url) nil
1556 (concat "openURL(\"" url "\",new-tab)"))) 1563 "elinks" "-remote"
1564 (concat "openURL(\"" url "\",new-tab)"))))
1557 (otherwise 1565 (otherwise
1558 (error "Undefined exit-code of process `elinks'"))))) 1566 (error "Unrecognized exit-code %d of process `elinks'"
1567 exit-status)))))
1559 1568
1560 (provide 'browse-url) 1569 (provide 'browse-url)
1561 1570
1562 ;; arch-tag: d2079573-5c06-4097-9598-f550fba19430 1571 ;; arch-tag: d2079573-5c06-4097-9598-f550fba19430
1563 ;;; browse-url.el ends here 1572 ;;; browse-url.el ends here