discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: sourcehut@relevant-information.com
Cc: piem@inbox.kyleam.com
Subject: Re: [PATCH] Add ability to edit patches before applying them
Date: Fri, 17 Dec 2021 00:58:49 -0500	[thread overview]
Message-ID: <878rwjwz52.fsf@kyleam.com> (raw)
In-Reply-To: <20211216200504.31619-1-sourcehut@relevant-information.com>

sourcehut@relevant-information.com writes:

> From: Leo <sourcehut@relevant-information.com>
>
> Sometimes it is necessary to edit patches before applying them.  These changes
> allows you to do that by providing a new command `piem-edit` that
> shows the buffer that is prepared by `piem-am-ready-mbox` to the user.
> ---
> Alright, here is the patch!

Thanks, I don't have time tonight to play around with this, but this is
looking good.  Here are some comments from a quick read.

>  piem.el | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
>
> diff --git a/piem.el b/piem.el
> index afe6b7a..668f282 100644
> --- a/piem.el
> +++ b/piem.el
> @@ -900,6 +900,40 @@ (defun piem-am-read-worktree (coderepo branch)
>            (concat (file-name-nondirectory fname) "-"
>                    (replace-regexp-in-string "/" "-" branch))))))
>  
> +(defvar-local piem-edit-patch--coderepo nil)
> +
> +(defun piem-edit ()
> +  "Edit an am-ready mbox before feeding it to `git am'."
> +  (interactive)
> +  (pcase-let ((`(,mbox . ,_)

The ignored return value above should be passed as the format argument
to piem-am.

> +               (or (piem-am-ready-mbox)

I like the idea of using piem-am-ready-mbox, but it generates a hidden
buffer name (due to the leading space), which is inconvenient/confusing
for a user-facing buffer.  Perhaps piem-am-ready-mbox should gain an
optional argument to allow the buffer name to be specified and a
dedicated name should be used for this buffer ("*piem-edit-patch*"?).

> +                   (user-error
> +                    "Could not find am-ready mbox for current buffer")))
> +              (coderepo (piem-inbox-coderepo)))
> +    (progn

superfluous progn

> +      (switch-to-buffer mbox)

I'd prefer pop-to-buffer unless there's a specific reason to go with
switch-to-buffer.

> +      (piem-edit-patch-mode)
> +      (setq piem-edit-patch--coderepo coderepo))))
> +
> +(defun piem-edit-patch-am ()
> +  "Apply the patch that is currently edited."
> +  (interactive)
> +  (piem-am (current-buffer)
> +       "mbox"
> +       (piem-extract-mbox-info (current-buffer))
> +       piem-edit-patch--coderepo))

piem-edit-patch-am should probably take care of killing the buffer
(piem-am only does that for interactive calls).

> +(defvar piem-edit-patch-mode-map
> +  (let ((map (make-sparse-keymap)))
> +    (define-key map (kbd "C-c C-c") #'piem-edit-patch-am)
> +    map)
> +  "Keymap for editing patches with piem.")
> +
> +(define-derived-mode piem-edit-patch-mode text-mode  "piem-edit-patch"

extra space after text-mode

> +  "Major mode for editing patches with piem."
> +  :group 'piem
> +  :after-hook (buffer-enable-undo))

Hmm, I don't see a reason for after-hook here versus the more standard
call in BODY.

And very much a nitpick, but I'd like if this code came after piem-am.

  reply	other threads:[~2021-12-17  5:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 16:01 Adding support for editing patches before applying them sourcehut
2021-12-08 16:01 ` [PATCH 1/1] piem-notmuch-am-ready-mbox: Add option to edit " sourcehut
2021-12-09  3:43   ` Kyle Meyer
2021-12-09  5:20     ` Kyle Meyer
2021-12-09 10:10     ` Leo
2021-12-09 13:00       ` Leo
2021-12-10  5:08         ` Kyle Meyer
2021-12-10  9:31           ` Leo
2021-12-11 21:44             ` Kyle Meyer
2021-12-16 20:05               ` [PATCH] Add ability " sourcehut
2021-12-17  5:58                 ` Kyle Meyer [this message]
2021-12-21 14:02                   ` [PATCH v2] " sourcehut
2021-12-24 18:32                     ` Kyle Meyer
2021-12-27 16:07                       ` Leo
2021-12-27 21:07                         ` distributing piem via *ELPA Kyle Meyer
2021-12-27 21:30                           ` Kyle Meyer
2021-12-09  3:38 ` Adding support for editing patches before applying them 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=878rwjwz52.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \
    --cc=sourcehut@relevant-information.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).