unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] lisp/browse-url.el: Revisiting my elinks addition
@ 2007-09-14 10:51 Johannes Weiner
  2007-09-17 12:48 ` [PATCH] lisp/net/browse-url.el: Bugfixes regarding Elinks support (improved resend) Johannes Weiner
  2007-09-17 12:50 ` [PATCH] lisp/browse-url.el: Revisiting my elinks addition Michaël Cadilhac
  0 siblings, 2 replies; 6+ messages in thread
From: Johannes Weiner @ 2007-09-14 10:51 UTC (permalink / raw)
  To: Emacs development discussions


[-- Attachment #1.1.1: Type: text/plain, Size: 162 bytes --]

Hi,

attached is a patch that fixes some issues with the new elinks support in
browse-url.el.  Please see the patch, it includes a lisp/ChangeLog entry.

	Hannes

[-- Attachment #1.1.2: emacs-browse-url-elinks-fixes.patch --]
[-- Type: text/x-diff, Size: 3842 bytes --]

Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.11743
diff -u -r1.11743 ChangeLog
--- lisp/ChangeLog	14 Sep 2007 08:10:15 -0000	1.11743
+++ lisp/ChangeLog	14 Sep 2007 10:50:15 -0000
@@ -1,3 +1,11 @@
+2007-09-14  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'.
+	(browse-url-elinks-sentinel): Use browse-url-elinks-new-window.
+	Improved error message.
+
 2007-09-14  Glenn Morris  <rgm@gnu.org>
 
 	* startup.el (fancy-startup-text, fancy-about-text): Fix face
Index: lisp/net/browse-url.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/browse-url.el,v
retrieving revision 1.62
diff -u -r1.62 browse-url.el
--- lisp/net/browse-url.el	12 Sep 2007 11:48:22 -0000	1.62
+++ lisp/net/browse-url.el	14 Sep 2007 10:50:15 -0000
@@ -1512,8 +1512,16 @@
   (apply #'start-process (concat "KDE " url) nil browse-url-kde-program
 	                 (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
-(defun browse-url-elinks (url)
+(defun browse-url-elinks (url &optional new-window)
   "Ask the Elinks WWW browser to load URL.
 Default to the URL around the point.
 
@@ -1524,33 +1532,31 @@
 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)))))
+  (if new-window
+      (browse-url-elinks-new-window 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.
+  (let ((exit-status (process-exit-status process)))
     (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))))
+       (browse-url-elinks-new-window url))
       (0
        ;; Found an instance, open URL in new tab.
-       (start-process (concat "elinks:" url) nil
-		      "elinks" "-remote"
-		      (concat "openURL(\"" url "\",new-tab)")))
+       (let ((process-environment (browse-url-process-environment)))
+	 (start-process (concat "elinks:" url) nil
+			"elinks" "-remote"
+			(concat "openURL(\"" url "\",new-tab)"))))
       (otherwise
-       (error "Undefined exit-code of process `elinks'.")))))
+       (error "Unrecognized exit-code %d of process `elinks'."
+	      exit-status)))))
 
 (provide 'browse-url)
 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] lisp/net/browse-url.el: Bugfixes regarding Elinks support (improved resend)
  2007-09-14 10:51 [PATCH] lisp/browse-url.el: Revisiting my elinks addition Johannes Weiner
@ 2007-09-17 12:48 ` Johannes Weiner
       [not found]   ` <87zlzjj7ta.fsf@cadilhac.name>
  2007-09-17 12:50 ` [PATCH] lisp/browse-url.el: Revisiting my elinks addition Michaël Cadilhac
  1 sibling, 1 reply; 6+ messages in thread
From: Johannes Weiner @ 2007-09-17 12:48 UTC (permalink / raw)
  To: Emacs development discussions

[-- Attachment #1: Type: text/plain, Size: 243 bytes --]

Hi,

here is an improved revision of the patch that fixes several tiny mistakes in
lisp/net/browse-url.el regarding the new Elinks support.

The current browse-url-elinks function is broken!

Patch including ChangeLog entry attached.

	Hannes

[-- Attachment #2: emacs-browse-url-elinks-fixes-r1.patch --]
[-- Type: text/x-diff, Size: 3923 bytes --]

Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.11766
diff -u -r1.11766 ChangeLog
--- lisp/ChangeLog	17 Sep 2007 07:02:35 -0000	1.11766
+++ lisp/ChangeLog	17 Sep 2007 12:43:49 -0000
@@ -1,3 +1,11 @@
+2007-09-17  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.
+	Improved error message.
+
 2007-09-17  Glenn Morris  <rgm@gnu.org>
 
 	* textmodes/tex-mode.el (tex-compilation-parse-errors): Prefer the
Index: lisp/net/browse-url.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/browse-url.el,v
retrieving revision 1.62
diff -u -r1.62 browse-url.el
--- lisp/net/browse-url.el	12 Sep 2007 11:48:22 -0000	1.62
+++ lisp/net/browse-url.el	17 Sep 2007 12:43:50 -0000
@@ -1512,8 +1512,16 @@
   (apply #'start-process (concat "KDE " url) nil browse-url-kde-program
 	                 (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
-(defun browse-url-elinks (url)
+(defun browse-url-elinks (url &optional new-window)
   "Ask the Elinks WWW browser to load URL.
 Default to the URL around the point.
 
@@ -1521,36 +1529,34 @@
 none yet running, a newly started instance.
 
 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: "))
   (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)))))
+  (if new-window
+      (browse-url-elinks-new-window 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.
+  (let ((exit-status (process-exit-status process)))
     (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))))
+       (browse-url-elinks-new-window url))
       (0
        ;; Found an instance, open URL in new tab.
-       (start-process (concat "elinks:" url) nil
-		      "elinks" "-remote"
-		      (concat "openURL(\"" url "\",new-tab)")))
+       (let ((process-environment (browse-url-process-environment)))
+	 (start-process (concat "elinks:" url) nil
+			"elinks" "-remote"
+			(concat "openURL(\"" url "\",new-tab)"))))
       (otherwise
-       (error "Undefined exit-code of process `elinks'.")))))
+       (error "Unrecognized exit-code %d of process `elinks'."
+	      exit-status)))))
 
 (provide 'browse-url)
 

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] lisp/browse-url.el: Revisiting my elinks addition
  2007-09-14 10:51 [PATCH] lisp/browse-url.el: Revisiting my elinks addition Johannes Weiner
  2007-09-17 12:48 ` [PATCH] lisp/net/browse-url.el: Bugfixes regarding Elinks support (improved resend) Johannes Weiner
@ 2007-09-17 12:50 ` Michaël Cadilhac
  2007-09-17 12:54   ` Johannes Weiner
  1 sibling, 1 reply; 6+ messages in thread
From: Michaël Cadilhac @ 2007-09-17 12:50 UTC (permalink / raw)
  To: Emacs development discussions


[-- Attachment #1.1: Type: text/plain, Size: 727 bytes --]

Johannes Weiner <hannes@saeurebad.de> writes:

> Hi,
>
> attached is a patch that fixes some issues with the new elinks support in
> browse-url.el.  Please see the patch, it includes a lisp/ChangeLog entry.
>
> 	Hannes

This patch seems good.  If nobody complains, I'll install it tomorrow.
Johannes, do you have legal papers for Emacs, or should I flag this
change as a ``tiny change''?

-- 
 |   Michaël `Micha' Cadilhac       |    Le copillage-collage                |
 |   http://michael.cadilhac.name   |       tue le programmeur.              |
 |   JID/MSN:                       |           -- Dictons LRDE              |
 `----  michael.cadilhac@gmail.com  |                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] lisp/browse-url.el: Revisiting my elinks addition
  2007-09-17 12:50 ` [PATCH] lisp/browse-url.el: Revisiting my elinks addition Michaël Cadilhac
@ 2007-09-17 12:54   ` Johannes Weiner
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Weiner @ 2007-09-17 12:54 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: Emacs development discussions


[-- Attachment #1.1: Type: text/plain, Size: 396 bytes --]

Hi Micha,

On Mon, Sep 17, 2007 at 02:50:19PM +0200, Michaël Cadilhac wrote:
> This patch seems good.  If nobody complains, I'll install it tomorrow.
> Johannes, do you have legal papers for Emacs, or should I flag this
> change as a ``tiny change''?

I have legal papers for Emacs.  Please use the revised patch which fixes also
a typo in the docstring of browse-url-elinks.

	Hannes

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] lisp/net/browse-url.el: Bugfixes regarding Elinks support (improved resend)
       [not found]   ` <87zlzjj7ta.fsf@cadilhac.name>
@ 2007-09-19 11:13     ` Johannes Weiner
  2007-09-19 11:32       ` Michaël Cadilhac
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Weiner @ 2007-09-19 11:13 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: Emacs development discussions


[-- Attachment #1.1.1: Type: text/plain, Size: 617 bytes --]

Hi Micha,

On Wed, Sep 19, 2007 at 11:58:09AM +0200, Michaël Cadilhac wrote:
> Johannes Weiner <hannes@saeurebad.de> writes:
> > The current browse-url-elinks function is broken!
> >
> > Patch including ChangeLog entry attached.
> 
>   Can you please send me this patch updated against the current CVS
> repository?

Yes.  Patch attached.

	Hannes

PS: You renamed the first argument in browse-url-url-encode-chars to `text'
but the function body still refers to `url'.  It works thanks to dynamic
scoping, but I think this is not what you intended (since `text' is never used
at all in the body).

[-- Attachment #1.1.2: emacs-browse-url-elinks-fixes-r2.patch --]
[-- Type: text/x-diff, Size: 3971 bytes --]

Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.11774
diff -u -r1.11774 ChangeLog
--- lisp/ChangeLog	19 Sep 2007 07:52:19 -0000	1.11774
+++ lisp/ChangeLog	19 Sep 2007 11:09:20 -0000
@@ -1,3 +1,11 @@
+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.
+	Improved error message.
+
 2007-09-19  Glenn Morris  <rgm@gnu.org>
 
 	* net/socks.el (socks-open-network-stream): Signal an explicit
Index: lisp/net/browse-url.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/browse-url.el,v
retrieving revision 1.63
diff -u -r1.63 browse-url.el
--- lisp/net/browse-url.el	17 Sep 2007 15:59:41 -0000	1.63
+++ lisp/net/browse-url.el	19 Sep 2007 11:09:20 -0000
@@ -1517,8 +1517,17 @@
   (apply #'start-process (concat "KDE " url) nil browse-url-kde-program
 	 (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
-(defun browse-url-elinks (url)
+(defun browse-url-elinks (url &optional new-window)
   "Ask the Elinks WWW browser to load URL.
 Default to the URL around the point.
 
@@ -1526,36 +1535,36 @@
 none yet running, a newly started instance.
 
 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: "))
   (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)))))
+  (if new-window
+      (browse-url-elinks-new-window 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)))
+  (let ((exit-status (process-exit-status process)))
     ;; 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))))
+	   (browse-url-elinks-new-window url))
 	  (0
 	   ;; Found an instance, open URL in new tab.
-	   (start-process (concat "elinks:" url) nil
-			  "elinks" "-remote"
-			  (concat "openURL(\"" url "\",new-tab)")))
+	   (let ((process-environment (browse-url-process-environment)))
+	     (start-process (concat "elinks:" url) nil
+			    "elinks" "-remote"
+			    (concat "openURL(\"" url "\",new-tab)"))))
 	  (otherwise
-	   (error "Undefined exit-code of process `elinks'")))))
+	   (error "Unrecognized exit-code %d of process `elinks'"
+		  exit-status)))))
 
 (provide 'browse-url)
 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] lisp/net/browse-url.el: Bugfixes regarding Elinks support (improved resend)
  2007-09-19 11:13     ` Johannes Weiner
@ 2007-09-19 11:32       ` Michaël Cadilhac
  0 siblings, 0 replies; 6+ messages in thread
From: Michaël Cadilhac @ 2007-09-19 11:32 UTC (permalink / raw)
  To: Emacs development discussions


[-- Attachment #1.1: Type: text/plain, Size: 1233 bytes --]

Johannes Weiner <hannes@saeurebad.de> writes:

> On Wed, Sep 19, 2007 at 11:58:09AM +0200, Michaël Cadilhac wrote:
>> Johannes Weiner <hannes@saeurebad.de> writes:
>> > The current browse-url-elinks function is broken!
>> >
>> > Patch including ChangeLog entry attached.
>> 
>>   Can you please send me this patch updated against the current CVS
>> repository?
>
> Yes.  Patch attached.

Thank you, perfect, installed!  (Except that a period should be followed
by two spaces when it ends a sentence, and that one entry of the
ChangeLog didn't use the imperative.)

> PS: You renamed the first argument in browse-url-url-encode-chars to
> `text' but the function body still refers to `url'.  It works thanks
> to dynamic scoping, but I think this is not what you intended (since
> `text' is never used at all in the body).

Yek, dash it!  You're utterly right, thanks for the report.

-- 
 |   Michaël `Micha' Cadilhac       |  Libertude,                            |
 |   http://michael.cadilhac.name   |        Égalitude,                      |
 |   JID/MSN:                       |             Fraternitude.              |
 `----  michael.cadilhac@gmail.com  |          -- À peu près S.R.       -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-09-19 11:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-14 10:51 [PATCH] lisp/browse-url.el: Revisiting my elinks addition Johannes Weiner
2007-09-17 12:48 ` [PATCH] lisp/net/browse-url.el: Bugfixes regarding Elinks support (improved resend) Johannes Weiner
     [not found]   ` <87zlzjj7ta.fsf@cadilhac.name>
2007-09-19 11:13     ` Johannes Weiner
2007-09-19 11:32       ` Michaël Cadilhac
2007-09-17 12:50 ` [PATCH] lisp/browse-url.el: Revisiting my elinks addition Michaël Cadilhac
2007-09-17 12:54   ` Johannes Weiner

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).