Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* How to create/add-to-existing headers in a posting style?
@ 2012-07-14 18:51 Adam Sjøgren
  2012-07-15  9:05 ` Tassilo Horn
  0 siblings, 1 reply; 14+ messages in thread
From: Adam Sjøgren @ 2012-07-14 18:51 UTC (permalink / raw)
  To: info-gnus-english

I have a group parameter set on a group where I set cc to something.

This overwrites any Cc that is added by a wide reply in that group,
which isn't quite what I want.

Is there a way to have the posting style add to the Cc-list if a
Cc-header already exists, and otherwise create it?


  Best regards,

     Adam

-- 
 "Godnat og sov rigtigt godt eller, subsidiært, hop op        Adam Sjøgren
  og ned og hav det rigtigt af helvede til."             asjo@koldfront.dk

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-14 18:51 How to create/add-to-existing headers in a posting style? Adam Sjøgren
@ 2012-07-15  9:05 ` Tassilo Horn
  2012-07-15 14:06   ` Adam Sjøgren
  0 siblings, 1 reply; 14+ messages in thread
From: Tassilo Horn @ 2012-07-15  9:05 UTC (permalink / raw)
  To: info-gnus-english

asjo@koldfront.dk (Adam Sjøgren) writes:

Hi Adam,

> I have a group parameter set on a group where I set cc to something.
>
> This overwrites any Cc that is added by a wide reply in that group,
> which isn't quite what I want.
>
> Is there a way to have the posting style add to the Cc-list if a
> Cc-header already exists, and otherwise create it?

,----[ (info "(gnus)Posting Styles") ]
|    Each style may contain an arbitrary amount of "attributes".  Each
| attribute consists of a `(NAME VALUE)' pair.  In addition, you can also
| use the `(NAME :file VALUE)' form or the `(NAME :value VALUE)' form.
| Where `:file' signifies VALUE represents a file name and its contents
| should be used as the attribute value, `:value' signifies VALUE does
| not represent a file name explicitly.  The attribute name can be one of:
| 
|    The attribute name can also be a string or a symbol.  In that case,
| this will be used as a header name,[...]
| 
|    The attribute value can be a string, a function with zero arguments
| (the return value will be used), a variable (its value will be used)
| or a list (it will be `eval'ed and the return value will be
| used).
`----

So it seems you can have an posting style entry like that

  (Cc (save-excursion
        (message-goto-cc)
        (concat "theboss@company.invalid"
                (buffer-substring-no-properties
                  (point) (line-end-position)))

Totally untested, of course.

Bye,
Tassilo


_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-15  9:05 ` Tassilo Horn
@ 2012-07-15 14:06   ` Adam Sjøgren
  2012-07-15 19:40     ` Tassilo Horn
  0 siblings, 1 reply; 14+ messages in thread
From: Adam Sjøgren @ 2012-07-15 14:06 UTC (permalink / raw)
  To: info-gnus-english

On Sun, 15 Jul 2012 11:05:48 +0200, Tassilo wrote:

> So it seems you can have an posting style entry like that

>   (Cc (save-excursion
>         (message-goto-cc)
>         (concat "theboss@company.invalid"
>                 (buffer-substring-no-properties
>                   (point) (line-end-position)))

> Totally untested, of course.

It fails with:

  message-position-on-field: Search failed: "^--text follows this line--$"

in an empty buffer, so I guess it runs at a different time than
expected?

I readily admit that I thought I just overlooked an option somewhere, or
something :-)


  Best regards,

    Adam

-- 
 "Godnat og sov rigtigt godt eller, subsidiært, hop op        Adam Sjøgren
  og ned og hav det rigtigt af helvede til."             asjo@koldfront.dk

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-15 14:06   ` Adam Sjøgren
@ 2012-07-15 19:40     ` Tassilo Horn
  2012-07-16  9:22       ` Adam Sjøgren
  0 siblings, 1 reply; 14+ messages in thread
From: Tassilo Horn @ 2012-07-15 19:40 UTC (permalink / raw)
  To: info-gnus-english

asjo@koldfront.dk (Adam Sjøgren) writes:


>> So it seems you can have an posting style entry like that
>
>>   (Cc (save-excursion
>>         (message-goto-cc)
>>         (concat "theboss@company.invalid"
>>                 (buffer-substring-no-properties
>>                   (point) (line-end-position)))
>
>> Totally untested, of course.
>
> It fails with:
>
>   message-position-on-field: Search failed: "^--text follows this line--$"
>
> in an empty buffer, so I guess it runs at a different time than
> expected?

Yes, seems so.  Another approach was to use gnus-parameters to add your
append-hugo-in-cc function to message-header-hook (or
message-header-setup-hook?) locally for this group.

Bye,
Tassilo


_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-15 19:40     ` Tassilo Horn
@ 2012-07-16  9:22       ` Adam Sjøgren
  2012-07-16  9:59         ` Peter Münster
  2012-07-17  6:38         ` Tassilo Horn
  0 siblings, 2 replies; 14+ messages in thread
From: Adam Sjøgren @ 2012-07-16  9:22 UTC (permalink / raw)
  To: info-gnus-english

On Sun, 15 Jul 2012 21:40:44 +0200, Tassilo wrote:

> Another approach was to use gnus-parameters to add your
> append-hugo-in-cc function to message-header-hook (or
> message-header-setup-hook?) locally for this group.

How do I add it locally? Ah, add-hook has a LOCAL parameter. Hm. Let's
see if I can figure this out...

Ok, this is what I have cobbled together in the group parameters of the
group in question:

 ((x-add-to-cc
   (lambda nil
     (add-hook 'message-setup-hook
               (lambda nil
                 (save-excursion
                   (message-goto-cc)
                   (when
                       (not
                        (string-match "gottahavethisincc@example.org"
                                      (buffer-substring-no-properties
                                       (line-beginning-position)
                                       (line-end-position))))
                     (when
                         (not
                          (=
                           (-
                            (point)
                            (line-beginning-position))
                           4))
                       (insert ", "))
                     (insert "gottahavethisincc@example.org"))))
               nil t)
     "")))))

Which kind of works; the only problem with this is, that it leaves an
empty header "X-Add-To-Cc" in the buffer, which is ugly - but I couldn't
figure out how to have my function run without adding a header...

Any ideas to clean this up will be much appreciated.


  Best regards,

    Adam

-- 
 "Godnat og sov rigtigt godt eller, subsidiært, hop op        Adam Sjøgren
  og ned og hav det rigtigt af helvede til."             asjo@koldfront.dk

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-16  9:22       ` Adam Sjøgren
@ 2012-07-16  9:59         ` Peter Münster
  2012-07-16 10:05           ` Adam Sjøgren
  2012-07-17  6:38         ` Tassilo Horn
  1 sibling, 1 reply; 14+ messages in thread
From: Peter Münster @ 2012-07-16  9:59 UTC (permalink / raw)
  To: info-gnus-english

On Mon, Jul 16 2012, Adam Sjøgren wrote:

> the only problem with this is, that it leaves an empty header
> "X-Add-To-Cc" in the buffer,

What about (message-remove-header "X-Add-To-Cc") ?

-- 
           Peter


_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-16  9:59         ` Peter Münster
@ 2012-07-16 10:05           ` Adam Sjøgren
  0 siblings, 0 replies; 14+ messages in thread
From: Adam Sjøgren @ 2012-07-16 10:05 UTC (permalink / raw)
  To: info-gnus-english

On Mon, 16 Jul 2012 11:59:37 +0200, Peter wrote:

> On Mon, Jul 16 2012, Adam Sjøgren wrote:

>> the only problem with this is, that it leaves an empty header
>> "X-Add-To-Cc" in the buffer,

> What about (message-remove-header "X-Add-To-Cc") ?

Where should I stick that? Ah. In the end of the function I add to the
hook, of course. Thanks!

It is still kind of ugly, though...


  Best regards,

    Adam

-- 
 "Godnat og sov rigtigt godt eller, subsidiært, hop op        Adam Sjøgren
  og ned og hav det rigtigt af helvede til."             asjo@koldfront.dk

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-16  9:22       ` Adam Sjøgren
  2012-07-16  9:59         ` Peter Münster
@ 2012-07-17  6:38         ` Tassilo Horn
  2012-07-17  7:25           ` Tassilo Horn
  2012-07-17 12:51           ` Adam Sjøgren
  1 sibling, 2 replies; 14+ messages in thread
From: Tassilo Horn @ 2012-07-17  6:38 UTC (permalink / raw)
  To: info-gnus-english

asjo@koldfront.dk (Adam Sjøgren) writes:

>> Another approach was to use gnus-parameters to add your
>> append-hugo-in-cc function to message-header-hook (or
>> message-header-setup-hook?) locally for this group.
>
> How do I add it locally? Ah, add-hook has a LOCAL parameter. Hm. Let's
> see if I can figure this out...

I think, there's no way to do it that way.  An existing variable in
group parameters will be automagically be made local in the
corresponding summary buffer.  So something like

 ("my\.special\.group"
   (message-setup-hook
     (append message-setup-hook
             (list (lambda () ...)))))

Probably, you can just use cons instead of append.  But I wan't sure if
your function maybe needs something that's setup by some other function
in message-setup-hook that needs to run earlier therefore.

> Which kind of works; the only problem with this is, that it leaves an
> empty header "X-Add-To-Cc" in the buffer, which is ugly - but I
> couldn't figure out how to have my function run without adding a
> header...

The above should omit this header creation.

Bye,
Tassilo


_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-17  6:38         ` Tassilo Horn
@ 2012-07-17  7:25           ` Tassilo Horn
  2012-07-17 12:51           ` Adam Sjøgren
  1 sibling, 0 replies; 14+ messages in thread
From: Tassilo Horn @ 2012-07-17  7:25 UTC (permalink / raw)
  To: info-gnus-english

Tassilo Horn <tassilo@member.fsf.org> writes:

> I think, there's no way to do it that way.
                      ^^^
Of course, that should have been "there's no *need* to do it that way".

Bye,
Tassilo

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-17  6:38         ` Tassilo Horn
  2012-07-17  7:25           ` Tassilo Horn
@ 2012-07-17 12:51           ` Adam Sjøgren
  2012-07-18 10:54             ` Tassilo Horn
  1 sibling, 1 reply; 14+ messages in thread
From: Adam Sjøgren @ 2012-07-17 12:51 UTC (permalink / raw)
  To: info-gnus-english

On Tue, 17 Jul 2012 08:38:19 +0200, Tassilo wrote:

> An existing variable in group parameters will be automagically be made
> local in the corresponding summary buffer.

Hm, I can't make it work, though; I get this error in *Messages*:

  let: Symbol's value as variable is void: bbdb-insinuate-message

The value of message-setup-hook is (asjo-add-now-playing-header
bbdb-insinuate-message), which works fine.

Maybe I messed up the group parameters somehow...

  (message-setup-hook
   (append message-setup-hook
           (list
            (lambda nil
              (save-excursion
                (message-goto-cc)
                (when
                    (not
                     (string-match "reallyreallyimportant@example.org"
                                   (buffer-substring-no-properties
                                    (line-beginning-position)
                                    (line-end-position))))
                  (when
                      (not
                       (=
                        (-
                         (point)
                         (line-beginning-position))
                        4))
                    (insert ", "))
                  (insert "reallyreallyimportant@example.org")))))))


  Best regards,

     Adam

-- 
 "Godnat og sov rigtigt godt eller, subsidiært, hop op        Adam Sjøgren
  og ned og hav det rigtigt af helvede til."             asjo@koldfront.dk

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-17 12:51           ` Adam Sjøgren
@ 2012-07-18 10:54             ` Tassilo Horn
  2012-07-18 16:04               ` Adam Sjøgren
  0 siblings, 1 reply; 14+ messages in thread
From: Tassilo Horn @ 2012-07-18 10:54 UTC (permalink / raw)
  To: info-gnus-english

asjo@koldfront.dk (Adam Sjøgren) writes:

>> An existing variable in group parameters will be automagically be
>> made local in the corresponding summary buffer.
>
> Hm, I can't make it work, though; I get this error in *Messages*:
>
>   let: Symbol's value as variable is void: bbdb-insinuate-message

Hm, do you have a backtrace?

> The value of message-setup-hook is (asjo-add-now-playing-header
> bbdb-insinuate-message), which works fine.
>
> Maybe I messed up the group parameters somehow...

Hm, basically it looks good to me.  But it might be a good idea to make
that huge lamba an own function.

--8<---------------cut here---------------start------------->8---
(defun my-gnus-add-special-cc ()
  (save-excursion
    (message-goto-cc)
    (when (not (string-match "reallyreallyimportant@example.org"
			     (buffer-substring-no-properties
			      (line-beginning-position)
			      (line-end-position))))
      (when (not (= (- (point)
		       (line-beginning-position))
		    4))
	(insert ", "))
      (insert "reallyreallyimportant@example.org"))))

(setq gnus-parameters
      '(("that\.special\.group"
         (message-setup-hook
           (append message-setup-hook
                   '(my-gnus-add-special-cc))))))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo


_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-18 10:54             ` Tassilo Horn
@ 2012-07-18 16:04               ` Adam Sjøgren
  2012-07-19  8:44                 ` Tassilo Horn
  0 siblings, 1 reply; 14+ messages in thread
From: Adam Sjøgren @ 2012-07-18 16:04 UTC (permalink / raw)
  To: info-gnus-english

On Wed, 18 Jul 2012 12:54:32 +0200, Tassilo wrote:

> asjo@koldfront.dk (Adam Sjøgren) writes:

>>> An existing variable in group parameters will be automagically be
>>> made local in the corresponding summary buffer.
 
>> Hm, I can't make it work, though; I get this error in *Messages*:
 
>> let: Symbol's value as variable is void: bbdb-insinuate-message

> Hm, do you have a backtrace?

No, I do not get a backtrace - the buffer with the email ends up without
quotation and the message above is shown in *Messages*.

[See below, though]

> Hm, basically it looks good to me.  But it might be a good idea to make
> that huge lamba an own function.

[...]

Gives me the same symptom. (I hoped it would :-))

> (setq gnus-parameters

[...]

Note that I am using Group Parameters on the group in question rather
than setting the gnus-parameters variable.

                                 o o o

After factorying out the lambda to a named function I did
toggle-debug-on-error and got this backtrace:

 Debugger entered--Lisp error: (void-variable bbdb-insinuate-message)
   (asjo-add-now-playing-header bbdb-insinuate-message asjo-handle-cc)
   (let ((value (asjo-add-now-playing-header bbdb-insinuate-message asjo-handle-cc))) (when value (message-goto-eoh) (insert "Message-Setup-Hook" ": " value) (unless (bolp) (insert "\n"))))
   (save-excursion (message-remove-header "Message-Setup-Hook") (let ((value (asjo-add-now-playing-header bbdb-insinuate-message asjo-handle-cc))) (when value (message-goto-eoh) (insert "Message-Setup-Hook" ": " value) (unless (bolp) (insert "\n")))))
   (lambda nil (save-excursion (message-remove-header "Message-Setup-Hook") (let ((value (asjo-add-now-playing-header bbdb-insinuate-message asjo-handle-cc))) (when value (message-goto-eoh) (insert "Message-Setup-Hook" ": " value) (unless (bolp) (insert "\n"))))))()
   run-hooks(message-setup-hook)
   message-setup-1([...cut...])
   message-setup([...cut...])
   message-reply(nil t)
   ad-Orig-gnus-summary-reply((398652) t (398652))
   gnus-summary-reply((398652) t (398652))
   gnus-summary-very-wide-reply-with-original(nil)
   call-interactively(gnus-summary-very-wide-reply-with-original nil nil)


  Best regards,

    Adam

-- 
 "You know, if the sun was an oboe, what would you do?"       Adam Sjøgren
                                                         asjo@koldfront.dk

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-18 16:04               ` Adam Sjøgren
@ 2012-07-19  8:44                 ` Tassilo Horn
  2012-07-19  9:54                   ` Adam Sjøgren
  0 siblings, 1 reply; 14+ messages in thread
From: Tassilo Horn @ 2012-07-19  8:44 UTC (permalink / raw)
  To: info-gnus-english

asjo@koldfront.dk (Adam Sjøgren) writes:

> Note that I am using Group Parameters on the group in question rather
> than setting the gnus-parameters variable.

Shouldn't make a difference.

> After factorying out the lambda to a named function I did
> toggle-debug-on-error and got this backtrace:

Hm, I can't reproduce the error.  But now I know that this approach
won't work anyway. :-(

The reason is that the new value of message-mode-hook is buffer-local to
the specific summary buffer of the group you've specified the parameters
for.  But ouf course, the new value has to be local in the new buffer
where you write your message just before message-mode is activated.

I don't have a clue how to do that...

Bye,
Tassilo


_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: How to create/add-to-existing headers in a posting style?
  2012-07-19  8:44                 ` Tassilo Horn
@ 2012-07-19  9:54                   ` Adam Sjøgren
  0 siblings, 0 replies; 14+ messages in thread
From: Adam Sjøgren @ 2012-07-19  9:54 UTC (permalink / raw)
  To: info-gnus-english

On Thu, 19 Jul 2012 10:44:07 +0200, Tassilo wrote:

> Hm, I can't reproduce the error.  But now I know that this approach
> won't work anyway. :-(

> The reason is that the new value of message-mode-hook is buffer-local to
> the specific summary buffer of the group you've specified the parameters
> for.  But ouf course, the new value has to be local in the new buffer
> where you write your message just before message-mode is activated.

Ah, ok.

Well, the way that inserts a dummy header and, after the tip from Peter
Münster, removes it again does work for me, so there's that.

Still, thanks for the ideas!


  Best regards,

     Adam

-- 
 "You know, if the sun was an oboe, what would you do?"       Adam Sjøgren
                                                         asjo@koldfront.dk

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

end of thread, other threads:[~2012-07-19  9:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-14 18:51 How to create/add-to-existing headers in a posting style? Adam Sjøgren
2012-07-15  9:05 ` Tassilo Horn
2012-07-15 14:06   ` Adam Sjøgren
2012-07-15 19:40     ` Tassilo Horn
2012-07-16  9:22       ` Adam Sjøgren
2012-07-16  9:59         ` Peter Münster
2012-07-16 10:05           ` Adam Sjøgren
2012-07-17  6:38         ` Tassilo Horn
2012-07-17  7:25           ` Tassilo Horn
2012-07-17 12:51           ` Adam Sjøgren
2012-07-18 10:54             ` Tassilo Horn
2012-07-18 16:04               ` Adam Sjøgren
2012-07-19  8:44                 ` Tassilo Horn
2012-07-19  9:54                   ` Adam Sjøgren

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