From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id D21356DE0C67 for ; Tue, 10 Oct 2017 20:51:53 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.623 X-Spam-Level: X-Spam-Status: No, score=-0.623 tagged_above=-999 required=5 tests=[AWL=0.078, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7xVar7Y-0-dQ for ; Tue, 10 Oct 2017 20:51:52 -0700 (PDT) Received: from sasl.smtp.pobox.com (pb-smtp1.pobox.com [64.147.108.70]) by arlo.cworth.org (Postfix) with ESMTPS id 1867C6DE0B78 for ; Tue, 10 Oct 2017 20:51:51 -0700 (PDT) Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 178159FB29; Tue, 10 Oct 2017 23:51:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=Odc6FKKU0kiUGsIKogW/bTSLePw=; b=LPWkjK bWfAbtRBzsiDpTbJj+kWWJrTGFaMv9H0H1405GpVD0p1AqwBi/V7sxZ6uv1oiOjr 4EKcRuJMZKWqMH1jt3f//fKUfHSIVTrv32NCvoRn+m39j3p7LZY39TyNaRglX+7i 8XOa0TVee9yFNdjA1yKSqsiyYEBM2NpvefYIA= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 0BD179FB27; Tue, 10 Oct 2017 23:51:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=WTeAfpZqjv0k8ljXwTHwz9LFVTZsePpWdcot0IhbUHU=; b=py0/IFiN1HoR6iwA7I47AuiKt/lx1kurP+0TsRMcp+Gvu2VvxydCUqICeW09KXQOXer2jOko/ZyqsU5R2I4BiBf9SVCiCiZZi/nDvN2diaoCQAf71KzD275ch87X8rYHE/XQzlQBZBNeJXIzaKyaQwFqGNKuAELYJBJGBV/Bb0A= Received: from localhost (unknown [24.60.167.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id EFBCF9FB22; Tue, 10 Oct 2017 23:51:42 -0400 (EDT) From: Kyle Meyer To: William Casarin Cc: notmuch@notmuchmail.org Subject: Re: Washing GitHub emails to include inline patch? In-Reply-To: <87h8v6foet.fsf@jb55.com> References: <87d16jtsdj.fsf@kyleam.com> <878tgi7vo3.fsf@jb55.com> <87o9pebwyb.fsf@kyleam.com> <87h8v6foet.fsf@jb55.com> Date: Tue, 10 Oct 2017 23:51:42 -0400 Message-ID: <871smae3zl.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 7EB00250-AE37-11E7-BA3D-8EF31968708C-24757444!pb-smtp1.pobox.com X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 03:51:54 -0000 William Casarin writes: > I now mainly review GitHub PRs via the patch fetching snippet you sent, > but there's a tedious disconnect between notmuch and magit. In the above > scenario, I would have to: > > 1. cd to the project > 2. open magit > 2. fetch > 3. checkout the branch > 4. start reviewing > > If I want to start a review on GitHub: > > 5. go back to the mail buffer > 6. open the GitHub link > 7. try to find lines where I had a comment > 8. make comment, start review > > Steps 1-4 are way too long for the number of code reviews I do at work > and on public projects. Fair enough. 5-8 are my pain points. > Perhaps I could write a script that quickly jump from steps 1 to 4. I > think this would still be too slow compared to simply fetching the patch > and having a nicer view, at least until we have full magit code reviews. > I guess I could just wait until that's finished. I think you could get 1-4 nearly as quick as calling the patch fetching command. How about something like this? --8<---------------cut here---------------start------------->8--- (defun km/notmuch-github-pr-number () "Return the PR number for this message." (let (pr) (with-current-notmuch-show-message (goto-char (point-min)) (if (re-search-forward "https://github\\.com/.*/pull/\\([0-9]+\\)" nil t) (setq pr (match-string-no-properties 1)) (user-error "Could not find PR number"))) pr)) ;; This function could be anything that figures out the project based ;; on the current notmuch message. Or, if you use projectile and ;; don't mind getting queried each time, it could just read a project ;; from `projectile-relevant-known-projects'. (defun km/notmuch-repo-from-message () "Return the repository that this message is associated with." (let ((fname (notmuch-show-get-filename))) (or (and fname (string-match-p "magit-list" fname) "~/src/emacs/magit") (user-error "Could not determine repo")))) (defun km/notmuch-visit-pr-in-magit (&optional dont-fetch) "Show the Magit log for this message's PR. If DONT-FETCH is non-nil, do not fetch first." (interactive "P") (let* ((pr (km/notmuch-github-pr-number)) (repo (km/notmuch-repo-from-message)) (default-directory repo)) ;; "origin" is hard-coded below, but it could of course be ;; anything. You could also have an alist that maps repo -> ;; remote. ;; ;; This assumes that you've added ;; ;; fetch = +refs/pull/*/head:refs/pull/origin/* ;; ;; to origin's in ".git/config". You could drop that assumption ;; passing a more explicit refspec to the fetch call. (unless dont-fetch (magit-call-git "fetch" "origin")) (magit-log (list (concat "master..refs/pull/origin/" pr))))) --8<---------------cut here---------------end--------------->8--- Call M-x km/notmuch-visit-pr-in-magit in a notmuch-show buffer for a GitHub PR, modifying km/notmuch-repo-from-message so that it returns the full path to the local repository. -- Kyle