discussion and development of piem
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Kyle Meyer <kyle@kyleam.com>
Cc: piem@inbox.kyleam.com
Subject: Re: [PATCH] piem-am: Order attached patches by file name prefix
Date: Sat, 09 Jul 2022 15:38:50 +0800	[thread overview]
Message-ID: <87fsjaspkl.fsf@localhost> (raw)
In-Reply-To: <878rp2pyx1.fsf@kyleam.com>

Kyle Meyer <kyle@kyleam.com> writes:

> Regardless of what you call it, I don't mind piem trying to be more
> clever/helpful in these scenarios.  How about something like this?
> (Tested on <87v8s8n1bm.fsf@heagren.com> from Notmuch and Gnus.)

LGTM!
I only have some minor comments on the code.

>  (defun piem-gnus-am-ready-mbox ()
>    "Return a function that inserts an am-ready mbox.
> +
>  If the buffer has any MIME parts that look like a patch, use
> -those parts' contents (in order) as the mbox.  Otherwise, use the
> -message itself if it looks like a patch."
> +those parts' contents as the mbox, ordering the patches based on
> +the number at the start of the file name.  If none of the file
> +names start with a number, retain the original order of the
> +attachments.
> ...
>  (defun piem-notmuch-am-ready-mbox ()
>    "Return a function that inserts an am-ready mbox.
> +
>  If the buffer has any MIME parts that look like a patch, use
> -those parts' contents (in order) as the mbox.  Otherwise, use the
> -message itself if it looks like a patch."
> +those parts' contents as the mbox, ordering the patches based on
> +the number at the start of the file name.  If none of the file
> +names start with a number, retain the original order of the
> +attachments.

There is certainly some code duplication going on here (;

> +  (when (listp handle)
> +    (let ((type (mm-handle-media-type handle))
> +          (filename (mm-handle-filename handle)))
> +      (and (or (member type '("text/x-diff" "text/x-patch"))
> +               (and filename
> +                    (equal type "text/plain")
> +                    (string-suffix-p ".patch" filename t)))
> +           (with-temp-buffer
> +             (mm-display-inline handle)
> +             (cons
> +              (string-to-number filename)
> +              (buffer-substring-no-properties (point-min) (point-max))))))))

Why using (and ...)? It feels like (when ...) is more appropriate in
this context.

Best,
Ihor

  reply	other threads:[~2022-07-09  7:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-09  3:11 [BUG] Patch order is not respected for sequence of patches like [PATCH X/Y] Ihor Radchenko
2022-07-09  6:45 ` [PATCH] piem-am: Order attached patches by file name prefix Kyle Meyer
2022-07-09  7:38   ` Ihor Radchenko [this message]
2022-07-09 16:56     ` Kyle Meyer
2022-07-10  9:59       ` Ihor Radchenko
2022-07-10 14:25         ` Kyle Meyer

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://git.kyleam.com/

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

  git send-email \
    --in-reply-to=87fsjaspkl.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \
    /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://git.kyleam.com/piem/

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