Gnus development mailing list
 help / color / mirror / Atom feed
* s/defmacro/defsubst/ in mm-decode.el
@ 2006-07-25 21:05 Magnus Henoch
  2006-08-01 11:02 ` Reiner Steib
  0 siblings, 1 reply; 2+ messages in thread
From: Magnus Henoch @ 2006-07-25 21:05 UTC (permalink / raw)


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

The following patch changes some macros in mm-decode.el to inline
functions, thereby making W3 happy, which tries to use them as
functions.

Magnus


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mm-decode.el.patch --]
[-- Type: text/x-patch, Size: 2737 bytes --]

--- orig/lisp/mm-decode.el
+++ mod/lisp/mm-decode.el
@@ -59,10 +59,10 @@
 
 ;;; Convenience macros.
 
-(defmacro mm-handle-buffer (handle)
-  `(nth 0 ,handle))
-(defmacro mm-handle-type (handle)
-  `(nth 1 ,handle))
+(defsubst mm-handle-buffer (handle)
+  (nth 0 handle))
+(defsubst mm-handle-type (handle)
+  (nth 1 handle))
 (defsubst mm-handle-media-type (handle)
   (if (stringp (car handle))
       (car handle)
@@ -71,34 +71,34 @@
   (car (split-string (mm-handle-media-type handle) "/")))
 (defsubst mm-handle-media-subtype (handle)
   (cadr (split-string (mm-handle-media-type handle) "/")))
-(defmacro mm-handle-encoding (handle)
-  `(nth 2 ,handle))
-(defmacro mm-handle-undisplayer (handle)
-  `(nth 3 ,handle))
-(defmacro mm-handle-set-undisplayer (handle function)
-  `(setcar (nthcdr 3 ,handle) ,function))
-(defmacro mm-handle-disposition (handle)
-  `(nth 4 ,handle))
-(defmacro mm-handle-description (handle)
-  `(nth 5 ,handle))
-(defmacro mm-handle-cache (handle)
-  `(nth 6 ,handle))
-(defmacro mm-handle-set-cache (handle contents)
-  `(setcar (nthcdr 6 ,handle) ,contents))
-(defmacro mm-handle-id (handle)
-  `(nth 7 ,handle))
-(defmacro mm-handle-multipart-original-buffer (handle)
-  `(get-text-property 0 'buffer (car ,handle)))
-(defmacro mm-handle-multipart-from (handle)
-  `(get-text-property 0 'from (car ,handle)))
-(defmacro mm-handle-multipart-ctl-parameter (handle parameter)
-  `(get-text-property 0 ,parameter (car ,handle)))
+(defsubst mm-handle-encoding (handle)
+  (nth 2 handle))
+(defsubst mm-handle-undisplayer (handle)
+  (nth 3 handle))
+(defsubst mm-handle-set-undisplayer (handle function)
+  (setcar (nthcdr 3 handle) function))
+(defsubst mm-handle-disposition (handle)
+  (nth 4 handle))
+(defsubst mm-handle-description (handle)
+  (nth 5 handle))
+(defsubst mm-handle-cache (handle)
+  (nth 6 handle))
+(defsubst mm-handle-set-cache (handle contents)
+  (setcar (nthcdr 6 handle) contents))
+(defsubst mm-handle-id (handle)
+  (nth 7 handle))
+(defsubst mm-handle-multipart-original-buffer (handle)
+  (get-text-property 0 'buffer (car handle)))
+(defsubst mm-handle-multipart-from (handle)
+  (get-text-property 0 'from (car handle)))
+(defsubst mm-handle-multipart-ctl-parameter (handle parameter)
+  (get-text-property 0 parameter (car handle)))
 
-(defmacro mm-make-handle (&optional buffer type encoding undisplayer
+(defsubst mm-make-handle (&optional buffer type encoding undisplayer
 				    disposition description cache
 				    id)
-  `(list ,buffer ,type ,encoding ,undisplayer
-	 ,disposition ,description ,cache ,id))
+  (list buffer type encoding undisplayer
+	 disposition description cache id))
 
 (defcustom mm-text-html-renderer
   (cond ((locate-library "w3") 'w3)

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

* Re: s/defmacro/defsubst/ in mm-decode.el
  2006-07-25 21:05 s/defmacro/defsubst/ in mm-decode.el Magnus Henoch
@ 2006-08-01 11:02 ` Reiner Steib
  0 siblings, 0 replies; 2+ messages in thread
From: Reiner Steib @ 2006-08-01 11:02 UTC (permalink / raw)


On Tue, Jul 25 2006, Magnus Henoch wrote:

> The following patch changes some macros in mm-decode.el to inline
> functions, thereby making W3 happy, which tries to use them as
> functions.

Shouldn't this be fixed in w3 instead?  (Is w3 still alive?)
Could you point us to the relevant w3 code?  
Are you sure that this change can't break any existing (Gnus) code?

(I'm no expert, but I seem to recall that s/defmacro/defsubst/ might
make a difference WRT to the expansion of the arguments.  CMIIW.)

> --- orig/lisp/mm-decode.el
> +++ mod/lisp/mm-decode.el
> @@ -59,10 +59,10 @@
>  
>  ;;; Convenience macros.
>  
> -(defmacro mm-handle-buffer (handle)
> -  `(nth 0 ,handle))
> -(defmacro mm-handle-type (handle)
> -  `(nth 1 ,handle))
> +(defsubst mm-handle-buffer (handle)
> +  (nth 0 handle))
> +(defsubst mm-handle-type (handle)
> +  (nth 1 handle))
>  (defsubst mm-handle-media-type (handle)
>    (if (stringp (car handle))
>        (car handle)
[...]

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

end of thread, other threads:[~2006-08-01 11:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-25 21:05 s/defmacro/defsubst/ in mm-decode.el Magnus Henoch
2006-08-01 11:02 ` Reiner Steib

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 NNTP newsgroup(s).