unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Pierre Neidhardt <mail@ambrevar.xyz>
To: notmuch@notmuchmail.org
Subject: Re: Reply inline in notmuch-show buffer, "mu4e-conversation style"
Date: Tue, 19 Mar 2019 15:03:21 +0100	[thread overview]
Message-ID: <877ecvm05y.fsf@bababa.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <877ecvb0q7.fsf@bababa.i-did-not-set--mail-host-address--so-tickle-me>

[-- Attachment #1: Type: text/plain, Size: 2980 bytes --]

What I did in mu4e-conversation was actually rather simple, albeit a bit
hackish:

- Copy the test from the composition buffer
- Save the window excursion
- Fire up a new message buffer as notmuch-show-reply would produce.
- Cleanup the citation.
- Insert the copied text from the composition buffer.
- Send.

Sadly, mu4e wraps too much around message-mode and this forced me to use
some ugly hacks.  I haven't looked at notmuch's code yet, but it seems
that it does not wrap quite as much, so it might be cleaner and as
simple as a writing a 10-line-longish function.

The "hardest" part is to add a composition area.

Here is the code excerpt from mu4e-conversation:

--8<---------------cut here---------------start------------->8---
(defun mu4e-conversation-send (&optional msg)
  "Send message at the end of the view buffer.
If MSG is specified, then send this message instead.

Most `mu4e-compose-…' variables are lexically bound during the
call of this function."
  (interactive)
  (unless (mu4e-conversation--buffer-p)
    (mu4e-warn "(send) Not a conversation buffer"))
  (let (draft-buf
        (buf (current-buffer))
        (mu4e-compose-signature mu4e-compose-signature)
        ;; [More local variables...]
        (mu4e-compose-crypto-reply-encrypted-policy mu4e-compose-crypto-reply-encrypted-policy))
    (run-hooks 'mu4e-conversation-before-send-hook)
    (save-window-excursion
      (mu4e-conversation--open-draft msg)
      (condition-case nil
          ;; Force-kill DRAFT-BUF on succcess since it's an implementation
          ;; detail in mu4e-conversation and the composition area is in BUF.
          (let ((message-kill-buffer-on-exit t))
            (message-send-and-exit))
        ;; Stay in draft buffer and widen in case we failed during header check.
        (error (setq draft-buf (current-buffer))
               (widen))))
    (cond
     (draft-buf
      (switch-to-buffer draft-buf))
     (mu4e-conversation-kill-buffer-on-exit
      (switch-to-buffer buf)
      (mu4e-conversation-quit 'no-confirm))
     (t
      ;; Delete message that was just sent.
      (goto-char (point-max))
      (mu4e-conversation-previous-message)
      (forward-line)
      (delete-region (line-beginning-position 1) (point-max))
      ;; Ensure it's writable.
      (insert
       (propertize "\n"
                   'face 'mu4e-conversation-header
                   'rear-nonsticky t))
      (set-buffer-modified-p nil)
      ;; -after-send-hook can be used to update the conversation buffer so that
      ;; it includes the message that was just sent.
      (run-hooks 'mu4e-conversation-after-send-hook)))))
--8<---------------cut here---------------end--------------->8---

The hackish part is in mu4e-conversation--open-draft, which I'm not
including here because it's long and boring.  Hopefully notmuch.el won't
require us to do this.

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply	other threads:[~2019-03-19 14:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 10:46 Reply inline in notmuch-show buffer, "mu4e-conversation style" Pierre Neidhardt
2019-03-19 14:03 ` Pierre Neidhardt [this message]
2019-04-03  9:12   ` Pierre Neidhardt
2019-04-03 11:08     ` David Edmondson
2019-04-10 10:53       ` Pierre Neidhardt
2019-04-10 11:19         ` David Edmondson
2019-04-10 11:52           ` Pierre Neidhardt
2019-04-10 12:04             ` David Edmondson
2019-04-10 13:27               ` Pierre Neidhardt
2019-04-10 14:19                 ` David Edmondson
2019-04-10 14:38                   ` Pierre Neidhardt

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=877ecvm05y.fsf@bababa.i-did-not-set--mail-host-address--so-tickle-me \
    --to=mail@ambrevar.xyz \
    --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).