unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* defmacros in net-utils.el
@ 2008-02-26  2:25 Juanma Barranquero
  0 siblings, 0 replies; only message in thread
From: Juanma Barranquero @ 2008-02-26  2:25 UTC (permalink / raw)
  To: Emacs Devel

Is there any point in net-utils-run-program and run-network-program
(from net-utils) being macros?

AFAICS, they work as well being defuns, with the added benefit that I
can advise them (which is easier than advising all net-utils wrapper
funcs, like netstat, traceroute, ping. etc.).

             Juanma


Index: lisp/net/net-utils.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/net/net-utils.el,v
retrieving revision 1.30
diff -u -2 -r1.30 net-utils.el
--- lisp/net/net-utils.el	24 Feb 2008 10:09:04 -0000	1.30
+++ lisp/net/net-utils.el	26 Feb 2008 02:18:51 -0000
@@ -322,15 +322,15 @@
       (set-buffer old-buffer))))

-(defmacro net-utils-run-program (name header program &rest args)
+(defun net-utils-run-program (name header program args)
   "Run a network information program."
-  ` (let ((buf (get-buffer-create (concat "*" ,name "*"))))
-      (set-buffer buf)
-      (erase-buffer)
-      (insert ,header "\n")
-      (set-process-filter
-       (apply 'start-process ,name buf ,program ,@args)
-       'net-utils-remove-ctrl-m-filter)
-      (display-buffer buf)
-      buf))
+  (let ((buf (get-buffer-create (concat "*" name "*"))))
+    (set-buffer buf)
+    (erase-buffer)
+    (insert header "\n")
+    (set-process-filter
+     (apply 'start-process name buf program args)
+     'net-utils-remove-ctrl-m-filter)
+    (display-buffer buf)
+    buf))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -625,25 +625,20 @@
 This list is not complete.")

-;; Workhorse macro
-(defmacro run-network-program (process-name host port
-					    &optional initial-string)
-  `(let ((tcp-connection)
-	 (buf))
-    (setq buf (get-buffer-create (concat "*" ,process-name "*")))
+;; Workhorse routine
+(defun run-network-program (process-name host port &optional initial-string)
+  (let ((tcp-connection)
+	(buf))
+    (setq buf (get-buffer-create (concat "*" process-name "*")))
     (set-buffer buf)
     (or
      (setq tcp-connection
-	   (open-network-stream
-	    ,process-name
-	    buf
-	    ,host
-	    ,port))
-     (error "Could not open connection to %s" ,host))
+	   (open-network-stream process-name buf host port))
+     (error "Could not open connection to %s" host))
     (erase-buffer)
     (set-marker (process-mark tcp-connection) (point-min))
     (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter)
-    (and ,initial-string
+    (and initial-string
 	 (process-send-string tcp-connection
-			      (concat ,initial-string "\r\n")))
+			      (concat initial-string "\r\n")))
     (display-buffer buf)))




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-26  2:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-26  2:25 defmacros in net-utils.el Juanma Barranquero

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).