unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: functions for parsing mail addresses
Date: Wed, 25 Oct 2023 04:42:30 +0200	[thread overview]
Message-ID: <87pm13jucp.fsf@dataswamp.org> (raw)
In-Reply-To: 87sf5z1lfq.fsf@gnu.org

Roland Winkler wrote:

> I am looking at functions in the Emacs code base for parsing
> mail addresses, trying to figure out their differences.
> But this appears to be somewhat messy.
>
> The docstring of the user variable
> `gnus-extract-address-components' says that two pre-defined
> function exist: ‘gnus-extract-address-components’, which is
> the default, quite fast, and too simplistic solution, and
> ‘mail-extract-address-components’, which works much better,
> but is slower. But it seems to me that calls of the function
> `gnus-extract-address-components' are as often hard-coded as
> the user variable `gnus-extract-address-components' is used.

I have something like that:

(defun citation-style-f ()
  (let*((from (mail-header-from message-reply-headers))
        (from-data (gnus-extract-address-components from))
        (name (or (car from-data)
                  ;; if the user hasn't set his name, use the
                  ;; mail username e.g. joe for joe@hacker.com
                  (car (split-string (cadr from-data) "@"))))
        (citation-string (format "%s wrote:\n\n" name)) )
    (insert citation-string) ))

Whole file:
  https://dataswamp.org/~incal/emacs-init/gnus/gnus-cite-incal.el

-- 
underground experts united
https://dataswamp.org/~incal




      reply	other threads:[~2023-10-25  2:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25  2:32 functions for parsing mail addresses Roland Winkler
2023-10-25  2:42 ` Emanuel Berg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pm13jucp.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).