* [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
* Re: [PATCH] add option to posting styles
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
0 siblings, 1 reply; 11+ messages in thread
From: Jan Rychter @ 2003-06-19 20:59 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1434 bytes --]
>>>>> "Jan" == Jan Rychter <jan@rychter.com> writes:
Jan> The following patch adds another option to posting styles, which
Jan> allows one to add custom functions to mesage-setup-hook. The
Jan> existing 'eval' functionality was not enough, because some
Jan> functions expect the other headers (and mail-header-separator) to
Jan> already be there when they get called,
Jan> mml-secure-message-sign-pgpmime is an example.
Jan> Thanks to this I can now define
Jan> (setq gnus-posting-styles '((".*icm\\.misc" (call
Jan> mml-secure-message-sign-pgpmime))))
Jan> ... and have all messages in the groups maching the regexp
Jan> automatically signed.
[time passes]
Well, that won't really work. It works for new messages, but doesn't
work for replies. The reason is that posting styles get applied very
early in the process, so after mml-secure-message-sign-pgpmime inserts
<\#secure method=pgpmime mode=sign>, supercite happily inserts the cited
text and cites the mml marker as well.
What I'm trying to do is somewhat similar to what
gnus-summary-handle-replysign does. But I noticed that
gnus-summary-reply cheats and runs gnus-summary-handle-replysign at the
very end, after everything else is done. There is no way I can do this
with posting styles, right?
Hmm. Or can we call gnus-configure-posting-styles after the message has
been set up? What would be a good solution here?
--J.
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] add option to posting styles
2003-06-19 20:59 ` Jan Rychter
@ 2003-06-20 7:19 ` Kai Großjohann
2003-06-20 8:05 ` Jan Rychter
2003-06-23 8:29 ` Jan Rychter
0 siblings, 2 replies; 11+ messages in thread
From: Kai Großjohann @ 2003-06-20 7:19 UTC (permalink / raw)
Jan Rychter <jan@rychter.com> writes:
> Well, that won't really work. It works for new messages, but doesn't
> work for replies. The reason is that posting styles get applied very
> early in the process, so after mml-secure-message-sign-pgpmime inserts
> <\#secure method=pgpmime mode=sign>, supercite happily inserts the cited
> text and cites the mml marker as well.
Two ideas:
* Have the posting styles add a function buffer-locally to a hook
that is run at a suitable time.
* Have the posting styles set a variable and put a function into a
hook run at the right time that looks at the variable and then DTRT.
What do you think?
--
This line is not blank.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] add option to posting styles
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-23 8:29 ` Jan Rychter
1 sibling, 2 replies; 11+ messages in thread
From: Jan Rychter @ 2003-06-20 8:05 UTC (permalink / raw)
>>>>> "Kai" == Kai Großjohann <kai.grossjohann@gmx.net> writes:
Kai> Jan Rychter <jan@rychter.com> writes:
>> Well, that won't really work. It works for new messages, but doesn't
>> work for replies. The reason is that posting styles get applied very
>> early in the process, so after mml-secure-message-sign-pgpmime
>> inserts <\#secure method=pgpmime mode=sign>, supercite happily
>> inserts the cited text and cites the mml marker as well.
Kai> Two ideas:
Kai> * Have the posting styles add a function buffer-locally to a hook
Kai> that is run at a suitable time.
Kai> * Have the posting styles set a variable and put a function into a
Kai> hook run at the right time that looks at the variable and then
Kai> DTRT.
Kai> What do you think?
Hmm. The first idea looks simpler. It's still hairy, but clearer than
the second one.
Is there a reason why posting styles have to be applied so early?
--J.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] add option to posting styles
2003-06-20 8:05 ` Jan Rychter
@ 2003-06-20 14:45 ` Kai Großjohann
2003-06-23 23:44 ` Lars Magne Ingebrigtsen
1 sibling, 0 replies; 11+ messages in thread
From: Kai Großjohann @ 2003-06-20 14:45 UTC (permalink / raw)
Jan Rychter <jan@rychter.com> writes:
> Is there a reason why posting styles have to be applied so early?
Dunno. Anyone?
--
This line is not blank.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] add option to posting styles
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
1 sibling, 1 reply; 11+ messages in thread
From: Lars Magne Ingebrigtsen @ 2003-06-23 23:44 UTC (permalink / raw)
Jan Rychter <jan@rychter.com> writes:
> Is there a reason why posting styles have to be applied so early?
Posting styles work (partly) by setting Message variables (locally),
so it has to be run before Message does it's nefarious work.
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] add option to posting styles
2003-06-23 23:44 ` Lars Magne Ingebrigtsen
@ 2003-06-27 13:17 ` Jan Rychter
2003-10-17 23:38 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 11+ messages in thread
From: Jan Rychter @ 2003-06-27 13:17 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 2897 bytes --]
>>>>> "Lars" == Lars Magne Ingebrigtsen <larsi@quimbies.gnus.org>:
Lars> Jan Rychter <jan@rychter.com> writes:
>> Is there a reason why posting styles have to be applied so early?
Lars> Posting styles work (partly) by setting Message variables
Lars> (locally), so it has to be run before Message does it's nefarious
Lars> work.
Silly me. Of course! Thanks for the hint. I feel enlightened.
Would the following be more acceptable? (it works for me)
It allows me to add to my posting styles things like:
(".*icm\\.misc"
(sign))
(".*icm\\.secret"
(sign)
(encrypt))
... and have all messages (including replies) properly signed in groups
matching that regexp.
Should I bother to submit a proper patch including an update to the
manual, or is it just me that needs this functionality?
--J.
diff -u /home/jwr/Mail/.software/gnus/lisp/gnus-msg.el.original /home/jwr/Mail/.software/gnus/lisp/gnus-msg.el
--- /home/jwr/Mail/.software/gnus/lisp/gnus-msg.el.original 2003-06-26 21:23:07.000000000 -0700
+++ /home/jwr/Mail/.software/gnus/lisp/gnus-msg.el 2003-06-26 21:23:08.000000000 -0700
@@ -314,6 +314,9 @@
(defvar gnus-msg-force-broken-reply-to nil)
+(defvar gnus-message-sign nil)
+(defvar gnus-message-encrypt nil)
+
(defconst gnus-bug-message
"Sending a bug report to the Gnus Towers.
========================================
@@ -1155,18 +1158,19 @@
(defun gnus-summary-handle-replysign ()
"Check the various replysign variables and take action accordingly."
- (when (or gnus-message-replysign gnus-message-replyencrypt)
+ (when (or gnus-message-replysign gnus-message-replyencrypt
+ gnus-message-sign gnus-message-encrypt)
(let (signed encrypted)
(save-excursion
(set-buffer gnus-article-buffer)
(setq signed (memq 'signed gnus-article-wash-types))
(setq encrypted (memq 'encrypted gnus-article-wash-types)))
- (cond ((and gnus-message-replyencrypt encrypted)
+ (cond ((or gnus-message-encrypt (and gnus-message-replyencrypt encrypted))
(mml-secure-message mml-default-encrypt-method
(if gnus-message-replysignencrypted
'signencrypt
'encrypt)))
- ((and gnus-message-replysign signed)
+ ((or gnus-message-sign (and gnus-message-replysign signed))
(mml-secure-message mml-default-sign-method 'sign))))))
(defun gnus-summary-reply-with-original (n &optional wide)
@@ -1937,6 +1940,12 @@
(let ((message-signature ,(cdr result)))
(when message-signature
(message-insert-signature)))))))
+ ((eq 'encrypt (car result))
+ `(lambda ()
+ (set (make-local-variable 'gnus-message-encrypt) t)))
+ ((eq 'sign (car result))
+ `(lambda ()
+ (set (make-local-variable 'gnus-message-sign) t)))
(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
* Re: [PATCH] add option to posting styles
2003-06-27 13:17 ` Jan Rychter
@ 2003-10-17 23:38 ` Lars Magne Ingebrigtsen
0 siblings, 0 replies; 11+ messages in thread
From: Lars Magne Ingebrigtsen @ 2003-10-17 23:38 UTC (permalink / raw)
Jan Rychter <jan@rychter.com> writes:
> It allows me to add to my posting styles things like:
>
> (".*icm\\.misc"
> (sign))
> (".*icm\\.secret"
> (sign)
> (encrypt))
This seems like it would be useful, but it's new functionality.
Could you submit a new patch after No Gnus has started, as well as a
patch to the manual?
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] add option to posting styles
2003-06-20 7:19 ` Kai Großjohann
2003-06-20 8:05 ` Jan Rychter
@ 2003-06-23 8:29 ` Jan Rychter
2003-06-23 20:04 ` Kai Großjohann
1 sibling, 1 reply; 11+ messages in thread
From: Jan Rychter @ 2003-06-23 8:29 UTC (permalink / raw)
>>>>> "Kai" == Kai Großjohann <kai.grossjohann@gmx.net> writes:
Kai> Jan Rychter <jan@rychter.com> writes:
>> Well, that won't really work. It works for new messages, but doesn't
>> work for replies. The reason is that posting styles get applied very
>> early in the process, so after mml-secure-message-sign-pgpmime
>> inserts <\#secure method=pgpmime mode=sign>, supercite happily
>> inserts the cited text and cites the mml marker as well.
Kai> Two ideas:
Kai> * Have the posting styles add a function buffer-locally to a hook
Kai> that is run at a suitable time.
I've looked around some more. Is there such a hook?
What I need is a hook that is run just before the user starts editing
the message, but after the text to be cited (being replied to) has been
properly inserted.
mail-citation-hook is close, but seems to be designed for something
else.
--J.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] add option to posting styles
2003-06-23 8:29 ` Jan Rychter
@ 2003-06-23 20:04 ` Kai Großjohann
2003-06-24 2:42 ` Jan Rychter
0 siblings, 1 reply; 11+ messages in thread
From: Kai Großjohann @ 2003-06-23 20:04 UTC (permalink / raw)
Jan Rychter <jan@rychter.com> writes:
> What I need is a hook that is run just before the user starts editing
> the message, but after the text to be cited (being replied to) has been
> properly inserted.
>
> mail-citation-hook is close, but seems to be designed for something
> else.
Ayee. Maybe message-cite-function is what you need. But it's not
the right thing to use. Argh.
So maybe what the world needs is another hook, message-after-yank-hook?
--
This line is not blank.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] add option to posting styles
2003-06-23 20:04 ` Kai Großjohann
@ 2003-06-24 2:42 ` Jan Rychter
0 siblings, 0 replies; 11+ messages in thread
From: Jan Rychter @ 2003-06-24 2:42 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1958 bytes --]
>>>>> "Kai" == Kai Großjohann <kai.grossjohann@gmx.net>:
Kai> Jan Rychter <jan@rychter.com> writes:
>> What I need is a hook that is run just before the user starts
>> editing the message, but after the text to be cited (being replied
>> to) has been properly inserted.
>>
>> mail-citation-hook is close, but seems to be designed for something
>> else.
Kai> Ayee. Maybe message-cite-function is what you need. But it's not
Kai> the right thing to use. Argh.
Kai> So maybe what the world needs is another hook,
Kai> message-after-yank-hook?
That's how I see it -- unless there is something I'm missing.
I'll try to summarize the discussion:
-- I would like to be able to specify in gnus-posting-styles that I
want certain messages to be PGP signed, which can't be done at
present,
-- I have added a "call" option to gnus-posting-styles, that permits
one to supply a function that will be added to the appropriate
hook,
-- then I found out that there is no "appropriate hook": because of
the way MML is designed, it wants to insert a line into the message
being written _no earlier than_ after the cited text has been
yanked. If we insert the MML tag earlier, it will get cited,
-- an additional constraint is that the MML tag should be there when
I'm composing the message: I'd like to be sure the message is going
to be signed. So message-send and similar hooks won't do.
There are some options:
-- fix supercite (and everything else people might be using for citing
text) to recognize MML tags and work around them,
-- hack MML to do something special about some special headers,
-- make a "mml-something-hook" that will be designed specifically for
the purpose of letting MML know about things,
-- add another hook to message, as Kai described.
I do not think I'm knowledgeable enough to decide which is better.
--J.
[-- 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).