emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

defmacros in net-utils.el


From: Juanma Barranquero
Subject: defmacros in net-utils.el
Date: Tue, 26 Feb 2008 03:25:24 +0100

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]