git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH (resend)] send-email: address expansion for common mailers

From
RARyan Anderson <ryan@michonline.com>
Date
May 15, 2006, 04:12 UTC
Message-ID
<20060515041227.GP32076@h4x0r5.com>
In-Reply-To
<11476592243181-git-send-email-normalperson@yhbt.net>
On Sun, May 14, 2006 at 07:13:44PM -0700, Eric Wong wrote:
Show 18 quoted lines
> mutt, gnus, pine, mailrc formats should be supported.
> 
> Testing and feedback for correctness and completeness of all formats
> and support for additional formats would be good.
> 
> Nested expansions are also supported.
> 
> More than one alias file to be used.
> 
> All alias file formats must still of be the same type, though.
> 
> Two git repo-config keys are required for this
> (as suggested by Ryan Anderson):
> 
>     sendemail.aliasesfile = <filename of aliases file>
>     sendemail.aliasfiletype = (mutt|gnus|pine|mailrc)
> 
> Signed-off-by: Eric Wong <normalperson@yhbt.net>
Acked-by: Ryan Anderson <ryan@michonline.com>
Show 80 quoted lines
> ---
> 
> Looks like this patch got forgotten a while ago, and I never noticed
> because I forgot to set WITH_SEND_EMAIL when doing make install.
> Of course, WITH_SEND_EMAIL should no longer be needed...
> 
>  git-send-email.perl |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 48 insertions(+), 0 deletions(-)
> 
> ff6593287dc500853c1cf05bdb0f32f970f10c9d
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 703dd1f..d8c4b1f 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -89,6 +89,41 @@ sub gitvar_ident {
>  my ($author) = gitvar_ident('GIT_AUTHOR_IDENT');
>  my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');
>  
> +my %aliases;
> +chomp(my @alias_files = `git-repo-config --get-all sendemail.aliasesfile`);
> +chomp(my $aliasfiletype = `git-repo-config sendemail.aliasfiletype`);
> +my %parse_alias = (
> +	# multiline formats can be supported in the future
> +	mutt => sub { my $fh = shift; while (<$fh>) {
> +		if (/^alias\s+(\S+)\s+(.*)$/) {
> +			my ($alias, $addr) = ($1, $2);
> +			$addr =~ s/#.*$//; # mutt allows # comments
> +			 # commas delimit multiple addresses
> +			$aliases{$alias} = [ split(/\s*,\s*/, $addr) ];
> +		}}},
> +	mailrc => sub { my $fh = shift; while (<$fh>) {
> +		if (/^alias\s+(\S+)\s+(.*)$/) {
> +			# spaces delimit multiple addresses
> +			$aliases{$1} = [ split(/\s+/, $2) ];
> +		}}},
> +	pine => sub { my $fh = shift; while (<$fh>) {
> +		if (/^(\S+)\s+(.*)$/) {
> +			$aliases{$1} = [ split(/\s*,\s*/, $2) ];
> +		}}},
> +	gnus => sub { my $fh = shift; while (<$fh>) {
> +		if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
> +			$aliases{$1} = [ $2 ];
> +		}}}
> +);
> +
> +if (@alias_files && defined $parse_alias{$aliasfiletype}) {
> +	foreach my $file (@alias_files) {
> +		open my $fh, '<', $file or die "opening $file: $!\n";
> +		$parse_alias{$aliasfiletype}->($fh);
> +		close $fh;
> +	}
> +}
> +
>  my $prompting = 0;
>  if (!defined $from) {
>  	$from = $author || $committer;
> @@ -112,6 +147,19 @@ if (!@to) {
>  	$prompting++;
>  }
>  
> +sub expand_aliases {
> +	my @cur = @_;
> +	my @last;
> +	do {
> +		@last = @cur;
> +		@cur = map { $aliases{$_} ? @{$aliases{$_}} : $_ } @last;
> +	} while (join(',',@cur) ne join(',',@last));
> +	return @cur;
> +}
> +
> +@to = expand_aliases(@to);
> +@initial_cc = expand_aliases(@initial_cc);
> +
>  if (!defined $initial_subject && $compose) {
>  	do {
>  		$_ = $term->readline("What subject should the emails start with? ",
> -- 
> 1.3.2.g1c9b
> 
> 
Previous: Eric WongNext: Eric Wong
Message 19 of 24 in “send-email: dependency removal, cleanup, + small feature”
  1. Eric WongMar 25, 2006
  2. 1/4 send-email: Change from Mail::Sendmail to Net::SMTPEric Wong, Mar 25, 2006
  3. Ryan AndersonMar 25, 2006
  4. Eric WongMar 26, 2006
  5. Junio C HamanoMar 26, 2006
  6. send-email: Change from Mail::Sendmail to Net::SMTPEric Wong, Mar 26, 2006
  7. Martin LanghoffApr 26, 2006
  8. Junio C HamanoApr 26, 2006
  9. Martin LanghoffApr 26, 2006
  10. Eric WongApr 28, 2006
  11. Martin LanghoffApr 28, 2006
  12. 4/4 send-email: add support for mutt aliases filesEric Wong, Mar 25, 2006
  13. Junio C HamanoMar 25, 2006
  14. Ryan AndersonMar 25, 2006
  15. send-email: address expansion for common mailersEric Wong, Mar 26, 2006
  16. Junio C HamanoMar 26, 2006
  17. Eric WongMar 26, 2006
  18. send-email: address expansion for common mailersEric Wong, May 15, 2006
  19. Ryan AndersonMay 15, 2006
  20. 3/4 send-email: lazy-load Email::Valid and make it optionalEric Wong, Mar 25, 2006
  21. Randal L. SchwartzMar 25, 2006
  22. Junio C HamanoMar 25, 2006
  23. send-email: lazy-load Email::Valid and make it optionalEric Wong, Mar 26, 2006
  24. 2/4 send-email: use built-in time() instead of /bin/date '+%s'Eric Wong, Mar 25, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.