From: Johannes Weiner <hannes@saeurebad.de>
To: Emacs development discussions <emacs-devel@gnu.org>
Subject: [PATCH 2/2] browse-url.el: elinks support
Date: Wed, 22 Aug 2007 03:19:08 +0200 [thread overview]
Message-ID: <20070822011908.GC1945@saeurebad.de> (raw)
In-Reply-To: <20070822011418.GA1945@saeurebad.de>
[-- Attachment #1: Type: text/plain, Size: 51 bytes --]
Hi,
this patch adds `browse-url-elinks'.
Hannes
[-- Attachment #2: emacs-browse-url-elinks.patch --]
[-- Type: text/x-diff, Size: 3167 bytes --]
diff -Naur emacs.orig/lisp/net/browse-url.el emacs/lisp/net/browse-url.el
--- emacs.orig/lisp/net/browse-url.el 2007-08-22 02:40:40.000000000 +0200
+++ emacs/lisp/net/browse-url.el 2007-08-22 02:57:32.000000000 +0200
@@ -55,6 +55,7 @@
;; browse-url-default-macosx-browser Mac OS X browser
;; browse-url-gnome-moz GNOME interface to Mozilla
;; browse-url-kde KDE konqueror (kfm)
+;; browse-url-elinks Elinks Don't know (tried with 0.12.GIT)
;; [A version of the Netscape browser is now free software
;; <URL:http://www.mozilla.org/>, albeit not GPLed, so it is
@@ -263,6 +264,7 @@
(function-item :tag "Grail" :value browse-url-grail)
(function-item :tag "MMM" :value browse-url-mmm)
(function-item :tag "KDE" :value browse-url-kde)
+ (function-item :tag "Elinks" :value browse-url-elinks)
(function-item :tag "Specified by `Browse Url Generic Program'"
:value browse-url-generic)
(function-item :tag "Default Windows browser"
@@ -611,6 +613,11 @@
:type '(repeat (string :tag "Argument"))
:group 'browse-url)
+(defcustom browse-url-elinks-wrapper '("xterm" "-e")
+ "*Wrapper command prepended to the Elinks command-line."
+ :type '(repeat (string :tag "Wrapper"))
+ :group 'browse-url)
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; URL encoding
@@ -1493,6 +1500,46 @@
(apply #'start-process (concat "KDE " url) nil browse-url-kde-program
(append browse-url-kde-args (list url))))
+;;;###autoload
+(defun browse-url-elinks (url)
+ "Ask the Elinks WWW browser to load URL.
+Default to the URL around the point.
+
+The document is loaded in a new tab of a running Elinks or, if
+none yet running, a newly started instance.
+
+The Elinks command will be prepended by the program+arguments
+from `elinks-browse-url-wrapper'."
+ (interactive (browse-url-interactive-arg "URL: "))
+ (setq url (browse-url-encode-url url))
+ (let ((process-environment (browse-url-process-environment))
+ (elinks-ping-process (start-process "elinks-ping" nil
+ "elinks" "-remote" "ping()")))
+ (set-process-sentinel elinks-ping-process
+ `(lambda (process change)
+ (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."
+ (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
+ ;; create a new one.
+ (case exit-status
+ (5
+ ;; No instance, start a new one.
+ (apply #'start-process
+ (append (list (concat "elinks:" url) nil)
+ browse-url-elinks-wrapper
+ (list "elinks" url))))
+ (0
+ ;; Found an instance, open URL in new tab.
+ (start-process (concat "elinks:" url) nil
+ "elinks" "-remote"
+ (concat "openURL(\"" url "\",new-tab)")))
+ (otherwise
+ (error "Undefined exit-code of process `elinks'.")))))
+
(provide 'browse-url)
;;; arch-tag: d2079573-5c06-4097-9598-f550fba19430
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2007-08-22 1:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-22 1:14 [PATCH 0/2] browse-url.el: cleanup & elinks support Johannes Weiner
2007-08-22 1:16 ` [PATCH 1/2] browse-url.el: cleanup Johannes Weiner
2007-08-22 1:35 ` Magnus Henoch
2007-08-22 1:52 ` Johannes Weiner
2007-08-22 21:27 ` Richard Stallman
2007-09-07 4:41 ` Glenn Morris
2007-08-22 1:19 ` Johannes Weiner [this message]
2007-08-22 21:27 ` [PATCH 2/2] browse-url.el: elinks support Richard Stallman
2007-09-07 4:40 ` Glenn Morris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070822011908.GC1945@saeurebad.de \
--to=hannes@saeurebad.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.