Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] add option to posting styles
@ 2003-06-19 20:41 Jan Rychter
  2003-06-19 20:59 ` Jan Rychter
  0 siblings, 1 reply; 11+ messages in thread
From: Jan Rychter @ 2003-06-19 20:41 UTC (permalink / raw)



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

The following patch adds another option to posting styles, which allows
one to add custom functions to mesage-setup-hook. The existing 'eval'
functionality was not enough, because some functions expect the other
headers (and mail-header-separator) to already be there when they get
called, mml-secure-message-sign-pgpmime is an example.

Thanks to this I can now define

(setq gnus-posting-styles
      '((".*icm\\.misc"
	 (call mml-secure-message-sign-pgpmime))))

... and have all messages in the groups maching the regexp automatically
signed.

--J.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: gnus-call.diff --]
[-- Type: text/x-patch, Size: 3388 bytes --]

--- texi/gnus.texi.original	2003-06-19 13:27:45.000000000 -0700
+++ texi/gnus.texi	2003-06-19 13:35:05.000000000 -0700
@@ -11701,12 +11701,20 @@
 attribute name can be one of @code{signature}, @code{signature-file},
 @code{x-face-file}, @code{address} (overriding
 @code{user-mail-address}), @code{name} (overriding
-@code{(user-full-name)}) or @code{body}.  The attribute name can also
-be a string or a symbol.  In that case, this will be used as a header
-name, and the value will be inserted in the headers of the article; if
-the value is @code{nil}, the header name will be removed.  If the
-attribute name is @code{eval}, the form is evaluated, and the result
-is thrown away.
+@code{(user-full-name)}), @code{eval}, @code{call} or @code{body}.  The
+attribute name can also be a string or a symbol.  In that case, this
+will be used as a header name, and the value will be inserted in the
+headers of the article; if the value is @code{nil}, the header name will
+be removed.  If the attribute name is @code{eval}, the form is
+evaluated, and the result is thrown away. If the attribute name is
+@code{call}, the function supplied as @var{value} is called with no
+arguments as part of the message setup process. The difference between
+@code{eval} and @code{call} is that functions supplied as @code{eval}
+are called immediately, while those supplied by @code{call} are called
+as part of the @code{message-setup-hook}, after essential headers have
+been set up. This is important if the function being called expects
+things like @var{mail-header-separator} to be present in the message
+when it gets called.
 
 The attribute value can be a string (used verbatim), a function with
 zero arguments (the return value will be used), a variable (its value
@@ -11756,7 +11764,9 @@
                  (set-buffer gnus-article-buffer)
                  (message-fetch-field "to"))))
         ("^nn.+:"
-         (signature-file "~/.mail-signature"))))
+         (signature-file "~/.mail-signature"))
+        ("^comp\\.security.*"
+         (call mml-secure-message-sign-pgpmime))))
 @end lisp
 
 The @samp{nnml:.*} rule means that you use the @code{To} address as the
--- lisp/gnus-msg.el.original	2003-06-19 12:40:37.000000000 -0700
+++ lisp/gnus-msg.el	2003-06-19 12:57:35.000000000 -0700
@@ -1880,18 +1880,20 @@
 		   (t
 		    (car attribute))))
 	    ;; We get the value.
-	    (setq v
-		  (cond
-		   ((stringp value)
-		    value)
-		   ((or (symbolp value)
-			(functionp value))
-		    (cond ((functionp value)
-			   (funcall value))
-			  ((boundp value)
-			   (symbol-value value))))
-		   ((listp value)
-		    (eval value))))
+	    (if (eq element 'call)
+		(setq v value)
+		(setq v
+		      (cond
+			((stringp value)
+			 value)
+			((or (symbolp value)
+			     (functionp value))
+			 (cond ((functionp value)
+				(funcall value))
+			       ((boundp value)
+				(symbol-value value))))
+			((listp value)
+			 (eval value)))))
 	    ;; Translate obsolescent value.
 	    (cond
 	     ((eq element 'signature-file)
@@ -1937,6 +1939,8 @@
 			   (let ((message-signature ,(cdr result)))
 			     (when message-signature
 			       (message-insert-signature)))))))
+		   ((eq 'call (car result))
+		    (cdr result))
 		   (t
 		    (let ((header
 			   (if (symbolp (car result))

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

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

end of thread, other threads:[~2003-10-17 23:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-19 20:41 [PATCH] add option to posting styles Jan Rychter
2003-06-19 20:59 ` Jan Rychter
2003-06-20  7:19   ` Kai Großjohann
2003-06-20  8:05     ` Jan Rychter
2003-06-20 14:45       ` Kai Großjohann
2003-06-23 23:44       ` Lars Magne Ingebrigtsen
2003-06-27 13:17         ` Jan Rychter
2003-10-17 23:38           ` Lars Magne Ingebrigtsen
2003-06-23  8:29     ` Jan Rychter
2003-06-23 20:04       ` Kai Großjohann
2003-06-24  2:42         ` Jan Rychter

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