unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: Austin Clements <amdragon@MIT.EDU>, David Edmondson <dme@dme.org>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH] emacs: create patch filename from subject for inline patch fake parts
Date: Wed, 21 Dec 2011 22:21:27 +0200	[thread overview]
Message-ID: <877h1py8u0.fsf@nikula.org> (raw)
In-Reply-To: <20111221144008.GG10376@mit.edu>

On Wed, 21 Dec 2011 09:40:08 -0500, Austin Clements <amdragon@MIT.EDU> wrote:
> I would definitely go with the latter.
> 
> It might feel less unwieldy with a shorter variable name than
> "filename", since that has to be repeated so many times.  (It's also
> not really a filename in the middle of the replace process.)
> 
> This is splitting hairs, but in my original suggestion, I was thinking
> something like
> 
>   (let* ((s subject)
>          (s (replace-regexp-in-string "^ *\\(\\[[^]]*\\]\\)? *" "" s))
>          (s (replace-regexp-in-string "[. ]*$" "" s))
>          (s (replace-regexp-in-string "[^A-Za-z0-9._-]+" "-" s))
>          (s (replace-regexp-in-string "\\.+" "." s))
>          (s (substring s 0 (min (length s) 50))))
>      (concat s ".patch"))
> 
> Out of curiosity, where'd the regexps come from?  They all seem
> reasonable, but some of them seem somewhat arbitrary.

The regexps should definitely have some explanation. I tried to mimic
the 'git format-patch' behaviour [1] using as simple and straightforward
regexps as possible. For simplicity, there's no creation of patch
sequence numbers. The max length is the same as in git, excluding the
sequence number.

If the patch was sent using git format-patch/send-email, this should
result in re-creation of the same filename as the sender had (apart from
the sequence number, obviously).

I seem to be missing the trimming of any trailing '.' and '-' after
truncating the string to max length, though.


BR,
Jani.

[1] https://github.com/gitster/git/blob/master/pretty.c#L712

  reply	other threads:[~2011-12-21 20:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18 23:02 [PATCH] emacs: create patch filename from subject for inline patch fake parts Jani Nikula
2011-12-20 20:05 ` Jani Nikula
2011-12-20 20:11   ` Dmitry Kurochkin
2011-12-20 21:52   ` Austin Clements
2011-12-21  9:21     ` David Edmondson
2011-12-21 14:40       ` Austin Clements
2011-12-21 20:21         ` Jani Nikula [this message]
2011-12-25 22:00 ` [PATCH v2 0/2] emacs: patch filename from subject Jani Nikula
2011-12-25 22:00   ` [PATCH v2 1/2] emacs: create patch filename from subject for inline patch fake parts Jani Nikula
2011-12-26 12:06     ` David Edmondson
2011-12-26 12:24       ` Jani Nikula
2011-12-26 20:38         ` Jameson Graef Rollins
2011-12-26 21:52           ` Jani Nikula
2011-12-26 22:05             ` David Edmondson
2011-12-25 22:00   ` [PATCH v2 2/2] test: emacs: test notmuch-wash-subject-to-* functions Jani Nikula
2011-12-27 16:04 ` [PATCH v3 0/3] emacs: patch filename from subject Jani Nikula
2011-12-27 16:04   ` [PATCH v3 1/3] emacs: add inline patch fake parts through a special handler Jani Nikula
2011-12-27 16:04   ` [PATCH v3 2/3] emacs: create patch filename from subject for inline patch fake parts Jani Nikula
2011-12-27 16:04   ` [PATCH v3 3/3] test: emacs: test notmuch-wash-subject-to-* functions Jani Nikula
2011-12-28 12:22   ` [PATCH v3 0/3] emacs: patch filename from subject David Bremner

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://notmuchmail.org/

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

  git send-email \
    --in-reply-to=877h1py8u0.fsf@nikula.org \
    --to=jani@nikula.org \
    --cc=amdragon@MIT.EDU \
    --cc=dme@dme.org \
    --cc=notmuch@notmuchmail.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.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

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