Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Automatically filling to-address (tip and question)
@ 2010-05-04 11:01 Cecil Westerhof
  2010-05-04 15:02 ` Adam Sjøgren
  2010-05-04 17:56 ` Cecil Westerhof
  0 siblings, 2 replies; 4+ messages in thread
From: Cecil Westerhof @ 2010-05-04 11:01 UTC (permalink / raw)
  To: info-gnus-english

When I post to a mailing list, I always have to use the same e-mail
address. As a real programmer I am lazy and do not like to do what can
be done by the computer. For this I made the code below.

There is one problem. The sequence of the fields is changed. Normally it
is:
    To:
    Subject:
    From:
    Gcc:
With my code it becomes:
    Subject:
    From:
    Gcc:
    To:

Can I do something about this?

Let me know if the code could be optimised.

    (defvar gnus-to-addresses nil
    "A list of group names and to-addesses to use;")
    (setq   gnus-to-addresses  '(
        ("INBOX\\.Info\\.bbdb"         . "bbdb-info@lists.sourceforge.net")
        ("INBOX\\.Info\\.clisp"        . "clisp-list@lists.sourceforge.net")
        ("INBOX\\.Info\\.ffmpeg"       . "ffmpeg-user@mplayerhq.hu")
        ("INBOX\\.Info.\\Floss"        . "floss@vrijschrift.nl")
        ("INBOX\\.Info\\.OpenOffice"   . "gebruikers@nl.openoffice.org")
        ("INBOX\\.Info\\.openSUSE"     . "opensuse-factory@opensuse.org")
        ("INBOX\\.Info\\.org-mode"     . "emacs-orgmode@gnu.org")
        ("INBOX\\.Info\\.slime"        . "slime-devel@common-lisp.net")
        ("INBOX\\.Info\\.spamassassin" . "users@spamassassin.apache.org")
        ("INBOX\\.KDE"                 . "kde-i18n-nl@kde.org")
        ("INBOX\\.NLLGG\\.Leden"       . "stamtafel@lists.nllgg.nl")
        ("INBOX\\.NLLGG\\.Linux"       . "linux@lists.nllgg.nl")
        ("INBOX\\.NLLGG\\.Starter"     . "linux-starter@lists.nllgg.nl")
        ))

    (defun gnus-set-to-address ()
      "Determine what to-address to use on the current message;"
      (let ((to-address ""))
        (if (message-news-p)
            (setq to-address nil)
          (when gnus-newsgroup-name
            (dolist (item gnus-to-addresses)
              (when (string-match (car item) gnus-newsgroup-name)
                (setq to-address (cdr item))))))
        to-address))

    ;; Posting Styles To Various Groups
    (setq gnus-posting-styles
          '((".*"
             (to (gnus-set-to-address))

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

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

* Re: Automatically filling to-address (tip and question)
  2010-05-04 11:01 Automatically filling to-address (tip and question) Cecil Westerhof
@ 2010-05-04 15:02 ` Adam Sjøgren
  2010-05-04 18:00   ` Cecil Westerhof
  2010-05-04 17:56 ` Cecil Westerhof
  1 sibling, 1 reply; 4+ messages in thread
From: Adam Sjøgren @ 2010-05-04 15:02 UTC (permalink / raw)
  To: info-gnus-english

On Tue, 04 May 2010 13:01:02 +0200, Cecil wrote:

> When I post to a mailing list, I always have to use the same e-mail
> address. As a real programmer I am lazy and do not like to do what can
> be done by the computer. For this I made the code below.

Even lazier, in terms of lines of code written, but, alas, not in lines
of manual to read:

 * http://gnus.org/manual/gnus_28.html#SEC28 - Group Parameters


  :-),

   Adam

-- 
 "How did someone as misanthropic as me end up in this        Adam Sjøgren
  business anyway? What the hell am I doing here?"       asjo@koldfront.dk

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

* Re: Automatically filling to-address (tip and question)
  2010-05-04 11:01 Automatically filling to-address (tip and question) Cecil Westerhof
  2010-05-04 15:02 ` Adam Sjøgren
@ 2010-05-04 17:56 ` Cecil Westerhof
  1 sibling, 0 replies; 4+ messages in thread
From: Cecil Westerhof @ 2010-05-04 17:56 UTC (permalink / raw)
  To: info-gnus-english

I did find a much better way to fill the To address. The sequence of the
fields is also not changed. It is possible to later still fill the To
field with the correct value, after having emptied it. (For example when
the reply the field is filled with the address of the sender instead of
with the address of the mailing list.) Is there a function to empty the
To field?

The only problem is that I know how to check for message-mode, but I do
not know how to differentiate between an article and an e-mail message.
With an article for a newsgroup there is no To field. Properly not a
very important problem. What is the chance that the name of a e-mail
folder will look like the name of a newsgroup? Still, if someone knows
how to differentiate ...

    (defvar dcbl-gnus-to-addresses nil
      "A list of group names and to-addesses to use;")
    (setq   dcbl-gnus-to-addresses  '(
        ("INBOX\\.Info\\.bbdb"         . "bbdb-info@lists.sourceforge.net")
        ("INBOX\\.Info\\.clisp"        . "clisp-list@lists.sourceforge.net")
        ("INBOX\\.Info\\.ffmpeg"       . "ffmpeg-user@mplayerhq.hu")
        ("INBOX\\.Info.\\Floss"        . "floss@vrijschrift.nl")
        ("INBOX\\.Info\\.OpenOffice"   . "gebruikers@nl.openoffice.org")
        ("INBOX\\.Info\\.openSUSE"     . "opensuse-factory@opensuse.org")
        ("INBOX\\.Info\\.org-mode"     . "emacs-orgmode@gnu.org")
        ("INBOX\\.Info\\.slime"        . "slime-devel@common-lisp.net")
        ("INBOX\\.Info\\.spamassassin" . "users@spamassassin.apache.org")
        ("INBOX\\.KDE"                 . "kde-i18n-nl@kde.org")
        ("INBOX\\.NLLGG\\.Leden"       . "stamtafel@lists.nllgg.nl")
        ("INBOX\\.NLLGG\\.Linux"       . "linux@lists.nllgg.nl")
        ("INBOX\\.NLLGG\\.Starter"     . "linux-starter@lists.nllgg.nl")
        ))

    ;; Fill To-address
    (defadvice gnus-summary-mail-other-window (after formalities () activate)
      (dcbl-fill-to-address))

    (defun dcbl-fill-to-address ()
      "Determine what to-address to use on the current message;"
      (let ((to-address nil))
        (when (and (string= major-mode "message-mode")
                   gnus-newsgroup-name
                   (not (message-fetch-field "To")))
          (dolist (item dcbl-gnus-to-addresses)
            (when (string-match (car item) gnus-newsgroup-name)
              (setq to-address (cdr item))))
          (when to-address
            (message-goto-to)
            (insert to-address)
            (message-goto-subject)))))

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

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

* Re: Automatically filling to-address (tip and question)
  2010-05-04 15:02 ` Adam Sjøgren
@ 2010-05-04 18:00   ` Cecil Westerhof
  0 siblings, 0 replies; 4+ messages in thread
From: Cecil Westerhof @ 2010-05-04 18:00 UTC (permalink / raw)
  To: info-gnus-english

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

>> When I post to a mailing list, I always have to use the same e-mail
>> address. As a real programmer I am lazy and do not like to do what can
>> be done by the computer. For this I made the code below.
>
> Even lazier, in terms of lines of code written, but, alas, not in lines
> of manual to read:
>
>  * http://gnus.org/manual/gnus_28.html#SEC28 - Group Parameters

I already made a much better version. I posted it in this thread. With
this version you can also fill the To address later on.

Another plus is that the groups and addresses are close together. But it
is still a good idea to read info about Group Parameters. Thanks.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

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

end of thread, other threads:[~2010-05-04 18:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-04 11:01 Automatically filling to-address (tip and question) Cecil Westerhof
2010-05-04 15:02 ` Adam Sjøgren
2010-05-04 18:00   ` Cecil Westerhof
2010-05-04 17:56 ` Cecil Westerhof

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