* [PATCH] emacs: add stash support for git send-email command line @ 2014-10-28 19:38 Jani Nikula 2014-10-29 8:41 ` David Edmondson 2015-01-01 17:45 ` [PATCH v2] " Jani Nikula 0 siblings, 2 replies; 12+ messages in thread From: Jani Nikula @ 2014-10-28 19:38 UTC (permalink / raw) To: notmuch Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as --in-reply-to, suitable for pasting to git send-email command line. --- emacs/notmuch-show.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index a9974826e824..328c93ba0584 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1274,6 +1274,7 @@ reset based on the original query." (define-key map "t" 'notmuch-show-stash-to) (define-key map "l" 'notmuch-show-stash-mlarchive-link) (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) + (define-key map "G" 'notmuch-show-stash-git-send-email) (define-key map "?" 'notmuch-subkeymap-help) map) "Submap for stash commands") @@ -2125,6 +2126,30 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." (notmuch-show-stash-mlarchive-link mla) (browse-url (current-kill 0 t))) +(defun notmuch-show-stash-git-helper (addresses prefix) + "Escape, trim, and add PREFIX to each address in list of ADDRESSES." + (when addresses + (mapconcat (lambda (x) + (concat prefix "\"" + ;; escape double-quotes + (replace-regexp-in-string + "\"" "\\\\\"" + ;; trim leading and trailing spaces + (replace-regexp-in-string + "\\(^ *\\| *$\\)" "" + x)) "\" ")) + addresses ""))) + +(defun notmuch-show-stash-git-send-email () + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line." + (interactive) + (notmuch-common-do-stash + (concat + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=") + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=") + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=") + (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\"")))) + ;; Interactive part functions and their helpers (defun notmuch-show-generate-part-buffer (message-id nth) -- 2.1.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: add stash support for git send-email command line 2014-10-28 19:38 [PATCH] emacs: add stash support for git send-email command line Jani Nikula @ 2014-10-29 8:41 ` David Edmondson 2014-10-29 8:50 ` Tomi Ollila 2014-10-29 20:45 ` Jani Nikula 2015-01-01 17:45 ` [PATCH v2] " Jani Nikula 1 sibling, 2 replies; 12+ messages in thread From: David Edmondson @ 2014-10-29 8:41 UTC (permalink / raw) To: Jani Nikula, notmuch On Tue, Oct 28 2014, Jani Nikula wrote: > Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as > --in-reply-to, suitable for pasting to git send-email command line. > --- > emacs/notmuch-show.el | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index a9974826e824..328c93ba0584 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -1274,6 +1274,7 @@ reset based on the original query." > (define-key map "t" 'notmuch-show-stash-to) > (define-key map "l" 'notmuch-show-stash-mlarchive-link) > (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) > + (define-key map "G" 'notmuch-show-stash-git-send-email) > (define-key map "?" 'notmuch-subkeymap-help) > map) > "Submap for stash commands") > @@ -2125,6 +2126,30 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." > (notmuch-show-stash-mlarchive-link mla) > (browse-url (current-kill 0 t))) > > +(defun notmuch-show-stash-git-helper (addresses prefix) > + "Escape, trim, and add PREFIX to each address in list of ADDRESSES." > + (when addresses > + (mapconcat (lambda (x) > + (concat prefix "\"" > + ;; escape double-quotes > + (replace-regexp-in-string > + "\"" "\\\\\"" > + ;; trim leading and trailing spaces > + (replace-regexp-in-string > + "\\(^ *\\| *$\\)" "" > + x)) "\" ")) > + addresses ""))) This doesn't seem quite right. You leave a spurious trailing space. Maybe that's because you need it in the following function to separate the from/to/cc elements? That kind of interaction between the two functions is icky. There's no need to test `addresses' at the head of the list - mapconcat is fine with nil. How about: (defun notmuch-show-stash-git-helper (addresses prefix) "Escape, trim, and add PREFIX to each address in list of ADDRESSES." (mapconcat (lambda (x) (concat prefix "\"" ;; escape double-quotes (replace-regexp-in-string "\"" "\\\\\"" ;; trim leading and trailing spaces (replace-regexp-in-string "\\(^ *\\| *$\\)" "" x)) "\"")) addresses " ")) This would remove the trailing space, so... > + > +(defun notmuch-show-stash-git-send-email () > + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line." > + (interactive) > + (notmuch-common-do-stash > + (concat > + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=") > + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=") > + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=") > + (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\"")))) ...this would have to use something like: (mapconcat 'identity (list (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=") (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=") (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=") (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\"")) "") to separate the chunks (untested). Could you avoid the double-quote quoting by using single quotes inside the strings? Do the leading and trailing spaces really matter? (Domo: Look, I managed to write 'separate', twice!) > + > ;; Interactive part functions and their helpers > > (defun notmuch-show-generate-part-buffer (message-id nth) > -- > 2.1.1 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: add stash support for git send-email command line 2014-10-29 8:41 ` David Edmondson @ 2014-10-29 8:50 ` Tomi Ollila 2014-10-29 20:45 ` Jani Nikula 1 sibling, 0 replies; 12+ messages in thread From: Tomi Ollila @ 2014-10-29 8:50 UTC (permalink / raw) To: David Edmondson, notmuch On Wed, Oct 29 2014, David Edmondson <dme@dme.org> wrote: > [lines dropped -- no way to open ;)] > space. Maybe that's because you need it in the following function to > separate the from/to/cc elements? That kind of interaction between the > two functions is icky. > [lines dropped -- no way to open ;)] > to separate the chunks (untested). > [lines dropped -- no way to open ;)] > > (Domo: Look, I managed to write 'separate', twice!) :D Tomi > >> + >> ;; Interactive part functions and their helpers >> >> (defun notmuch-show-generate-part-buffer (message-id nth) >> -- >> 2.1.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: add stash support for git send-email command line 2014-10-29 8:41 ` David Edmondson 2014-10-29 8:50 ` Tomi Ollila @ 2014-10-29 20:45 ` Jani Nikula 2014-10-30 8:23 ` David Edmondson 1 sibling, 1 reply; 12+ messages in thread From: Jani Nikula @ 2014-10-29 20:45 UTC (permalink / raw) To: David Edmondson, notmuch On Wed, 29 Oct 2014, David Edmondson <dme@dme.org> wrote: > On Tue, Oct 28 2014, Jani Nikula wrote: >> Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as >> --in-reply-to, suitable for pasting to git send-email command line. >> --- >> emacs/notmuch-show.el | 25 +++++++++++++++++++++++++ >> 1 file changed, 25 insertions(+) >> >> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el >> index a9974826e824..328c93ba0584 100644 >> --- a/emacs/notmuch-show.el >> +++ b/emacs/notmuch-show.el >> @@ -1274,6 +1274,7 @@ reset based on the original query." >> (define-key map "t" 'notmuch-show-stash-to) >> (define-key map "l" 'notmuch-show-stash-mlarchive-link) >> (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) >> + (define-key map "G" 'notmuch-show-stash-git-send-email) >> (define-key map "?" 'notmuch-subkeymap-help) >> map) >> "Submap for stash commands") >> @@ -2125,6 +2126,30 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." >> (notmuch-show-stash-mlarchive-link mla) >> (browse-url (current-kill 0 t))) >> >> +(defun notmuch-show-stash-git-helper (addresses prefix) >> + "Escape, trim, and add PREFIX to each address in list of ADDRESSES." >> + (when addresses >> + (mapconcat (lambda (x) >> + (concat prefix "\"" >> + ;; escape double-quotes >> + (replace-regexp-in-string >> + "\"" "\\\\\"" >> + ;; trim leading and trailing spaces >> + (replace-regexp-in-string >> + "\\(^ *\\| *$\\)" "" >> + x)) "\" ")) >> + addresses ""))) > > This doesn't seem quite right. You leave a spurious trailing > space. Maybe that's because you need it in the following function to > separate the from/to/cc elements? That kind of interaction between the > two functions is icky. Agreed, thanks for pointing it out. > There's no need to test `addresses' at the head of the list - mapconcat > is fine with nil. > > How about: > > (defun notmuch-show-stash-git-helper (addresses prefix) > "Escape, trim, and add PREFIX to each address in list of ADDRESSES." > (mapconcat (lambda (x) > (concat prefix "\"" > ;; escape double-quotes > (replace-regexp-in-string > "\"" "\\\\\"" > ;; trim leading and trailing spaces > (replace-regexp-in-string > "\\(^ *\\| *$\\)" "" > x)) "\"")) > addresses " ")) > > This would remove the trailing space, so... > >> + >> +(defun notmuch-show-stash-git-send-email () >> + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line." >> + (interactive) >> + (notmuch-common-do-stash >> + (concat >> + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=") >> + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=") >> + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=") >> + (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\"")))) > > ...this would have to use something like: > > (mapconcat 'identity (list > (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=") > (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=") > (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=") > (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\"")) > "") > > to separate the chunks (untested). The last "" has to be " " to separate the elements, but this brings another small wrinkle: if one of the headers is missing, typically Cc:, it will be nil in the list, and mapconcat adds spaces both sides of that, i.e. double space. Any ideas how to fix that? > Could you avoid the double-quote quoting by using single quotes inside > the strings? The addresses may contain both single quotes and double quotes, so escaping either of them seems like the only option. > Do the leading and trailing spaces really matter? Does aesthetically displeasing count? Because message-tokenize-header splits using "," but headers typically have ", " between addresses, the end result will practically always have --to=" user@example.com" without the trimming. Thanks for the helpful review; I'm not much of a lisp coder... BR, Jani. > > (Domo: Look, I managed to write 'separate', twice!) > >> + >> ;; Interactive part functions and their helpers >> >> (defun notmuch-show-generate-part-buffer (message-id nth) >> -- >> 2.1.1 >> >> _______________________________________________ >> notmuch mailing list >> notmuch@notmuchmail.org >> http://notmuchmail.org/mailman/listinfo/notmuch ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: add stash support for git send-email command line 2014-10-29 20:45 ` Jani Nikula @ 2014-10-30 8:23 ` David Edmondson 0 siblings, 0 replies; 12+ messages in thread From: David Edmondson @ 2014-10-30 8:23 UTC (permalink / raw) To: Jani Nikula, notmuch On Wed, Oct 29 2014, Jani Nikula wrote: >>> +(defun notmuch-show-stash-git-send-email () >>> + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line." >>> + (interactive) >>> + (notmuch-common-do-stash >>> + (concat >>> + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=") >>> + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=") >>> + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=") >>> + (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\"")))) >> >> ...this would have to use something like: >> >> (mapconcat 'identity (list >> (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=") >> (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=") >> (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=") >> (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\"")) >> "") >> >> to separate the chunks (untested). > > The last "" has to be " " to separate the elements, Of course. > but this brings another small wrinkle: if one of the headers is > missing, typically Cc:, it will be nil in the list, and mapconcat adds > spaces both sides of that, i.e. double space. Any ideas how to fix > that? I suppose a collecting loop would do it. >> Do the leading and trailing spaces really matter? > > Does aesthetically displeasing count? Because message-tokenize-header > splits using "," but headers typically have ", " between addresses, the > end result will practically always have --to=" user@example.com" without > the trimming. The trimming is fine, really. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2] emacs: add stash support for git send-email command line 2014-10-28 19:38 [PATCH] emacs: add stash support for git send-email command line Jani Nikula 2014-10-29 8:41 ` David Edmondson @ 2015-01-01 17:45 ` Jani Nikula 2015-01-02 6:48 ` David Edmondson 1 sibling, 1 reply; 12+ messages in thread From: Jani Nikula @ 2015-01-01 17:45 UTC (permalink / raw) To: notmuch Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as --in-reply-to, suitable for pasting to git send-email command line. --- emacs/notmuch-show.el | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index b8cfbb8a3286..887d877672fc 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1280,6 +1280,7 @@ reset based on the original query." (define-key map "t" 'notmuch-show-stash-to) (define-key map "l" 'notmuch-show-stash-mlarchive-link) (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) + (define-key map "G" 'notmuch-show-stash-git-send-email) (define-key map "?" 'notmuch-subkeymap-help) map) "Submap for stash commands") @@ -2131,6 +2132,43 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." (notmuch-show-stash-mlarchive-link mla) (browse-url (current-kill 0 t))) +(defun notmuch-show-stash-git-helper (addresses prefix) + "Escape, trim, quote, and add PREFIX to each address in list of ADDRESSES." + (mapconcat (lambda (x) + (concat prefix "\"" + ;; escape double-quotes + (replace-regexp-in-string + "\"" "\\\\\"" + ;; trim leading and trailing spaces + (replace-regexp-in-string + "\\(^ *\\| *$\\)" "" + x)) "\"")) + addresses " ")) + +(put 'notmuch-show-stash-git-send-email 'notmuch-prefix-doc + "Copy From/To/Cc of current message to kill-ring in a form suitable for pasting to git send-email command line.") + +(defun notmuch-show-stash-git-send-email (&optional no-in-reply-to) + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line. + +If invoked with a prefix argument (or NO-IN-REPLY-TO is non-nil, +omit --in-reply-to=<Message-Id>." + (interactive "P") + (notmuch-common-do-stash + (mapconcat 'identity + (remove "" + (list + (notmuch-show-stash-git-helper + (message-tokenize-header (notmuch-show-get-from)) "--to=") + (notmuch-show-stash-git-helper + (message-tokenize-header (notmuch-show-get-to)) "--to=") + (notmuch-show-stash-git-helper + (message-tokenize-header (notmuch-show-get-cc)) "--cc=") + (unless no-in-reply-to + (notmuch-show-stash-git-helper + (list (notmuch-show-get-message-id t)) "--in-reply-to=")))) + " "))) + ;; Interactive part functions and their helpers (defun notmuch-show-generate-part-buffer (message-id nth) -- 2.1.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2] emacs: add stash support for git send-email command line 2015-01-01 17:45 ` [PATCH v2] " Jani Nikula @ 2015-01-02 6:48 ` David Edmondson 2015-01-02 17:48 ` [PATCH v3] " Jani Nikula 2015-01-02 17:49 ` [PATCH v2] " Jani Nikula 0 siblings, 2 replies; 12+ messages in thread From: David Edmondson @ 2015-01-02 6:48 UTC (permalink / raw) To: Jani Nikula, notmuch On Thu, Jan 01 2015, Jani Nikula wrote: > Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as > --in-reply-to, suitable for pasting to git send-email command line. > --- > emacs/notmuch-show.el | 38 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index b8cfbb8a3286..887d877672fc 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -1280,6 +1280,7 @@ reset based on the original query." > (define-key map "t" 'notmuch-show-stash-to) > (define-key map "l" 'notmuch-show-stash-mlarchive-link) > (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) > + (define-key map "G" 'notmuch-show-stash-git-send-email) > (define-key map "?" 'notmuch-subkeymap-help) > map) > "Submap for stash commands") > @@ -2131,6 +2132,43 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." > (notmuch-show-stash-mlarchive-link mla) > (browse-url (current-kill 0 t))) > > +(defun notmuch-show-stash-git-helper (addresses prefix) > + "Escape, trim, quote, and add PREFIX to each address in list of > ADDRESSES." "...and return the result as a single string." > + (mapconcat (lambda (x) > + (concat prefix "\"" > + ;; escape double-quotes > + (replace-regexp-in-string > + "\"" "\\\\\"" > + ;; trim leading and trailing spaces > + (replace-regexp-in-string > + "\\(^ *\\| *$\\)" "" > + x)) "\"")) > + addresses " ")) > + > +(put 'notmuch-show-stash-git-send-email 'notmuch-prefix-doc > + "Copy From/To/Cc of current message to kill-ring in a form suitable for pasting to git send-email command line.") > + > +(defun notmuch-show-stash-git-send-email (&optional no-in-reply-to) > + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line. > + > +If invoked with a prefix argument (or NO-IN-REPLY-TO is non-nil, > +omit --in-reply-to=<Message-Id>." Missing ")" after "non-nil". > + (interactive "P") > + (notmuch-common-do-stash > + (mapconcat 'identity > + (remove "" > + (list > + (notmuch-show-stash-git-helper > + (message-tokenize-header (notmuch-show-get-from)) "--to=") > + (notmuch-show-stash-git-helper > + (message-tokenize-header (notmuch-show-get-to)) "--to=") > + (notmuch-show-stash-git-helper > + (message-tokenize-header (notmuch-show-get-cc)) "--cc=") > + (unless no-in-reply-to > + (notmuch-show-stash-git-helper > + (list (notmuch-show-get-message-id t)) > "--in-reply-to=")))) This will still generate a trailing space if `no-in-reply-to' is set, but I think that we can live with it. > + " "))) > + > ;; Interactive part functions and their helpers > > (defun notmuch-show-generate-part-buffer (message-id nth) > -- > 2.1.4 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3] emacs: add stash support for git send-email command line 2015-01-02 6:48 ` David Edmondson @ 2015-01-02 17:48 ` Jani Nikula 2015-01-02 18:12 ` David Edmondson 2015-01-17 10:55 ` David Bremner 2015-01-02 17:49 ` [PATCH v2] " Jani Nikula 1 sibling, 2 replies; 12+ messages in thread From: Jani Nikula @ 2015-01-02 17:48 UTC (permalink / raw) To: David Edmondson, notmuch Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as --in-reply-to, suitable for pasting to git send-email command line. --- emacs/notmuch-show.el | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index b8cfbb8a3286..9f6fe077df0c 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1280,6 +1280,7 @@ reset based on the original query." (define-key map "t" 'notmuch-show-stash-to) (define-key map "l" 'notmuch-show-stash-mlarchive-link) (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) + (define-key map "G" 'notmuch-show-stash-git-send-email) (define-key map "?" 'notmuch-subkeymap-help) map) "Submap for stash commands") @@ -2131,6 +2132,43 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." (notmuch-show-stash-mlarchive-link mla) (browse-url (current-kill 0 t))) +(defun notmuch-show-stash-git-helper (addresses prefix) + "Escape, trim, quote, and add PREFIX to each address in list of ADDRESSES, and return the result as a single string." + (mapconcat (lambda (x) + (concat prefix "\"" + ;; escape double-quotes + (replace-regexp-in-string + "\"" "\\\\\"" + ;; trim leading and trailing spaces + (replace-regexp-in-string + "\\(^ *\\| *$\\)" "" + x)) "\"")) + addresses " ")) + +(put 'notmuch-show-stash-git-send-email 'notmuch-prefix-doc + "Copy From/To/Cc of current message to kill-ring in a form suitable for pasting to git send-email command line.") + +(defun notmuch-show-stash-git-send-email (&optional no-in-reply-to) + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line. + +If invoked with a prefix argument (or NO-IN-REPLY-TO is non-nil), +omit --in-reply-to=<Message-Id>." + (interactive "P") + (notmuch-common-do-stash + (mapconcat 'identity + (remove "" + (list + (notmuch-show-stash-git-helper + (message-tokenize-header (notmuch-show-get-from)) "--to=") + (notmuch-show-stash-git-helper + (message-tokenize-header (notmuch-show-get-to)) "--to=") + (notmuch-show-stash-git-helper + (message-tokenize-header (notmuch-show-get-cc)) "--cc=") + (unless no-in-reply-to + (notmuch-show-stash-git-helper + (list (notmuch-show-get-message-id t)) "--in-reply-to=")))) + " "))) + ;; Interactive part functions and their helpers (defun notmuch-show-generate-part-buffer (message-id nth) -- 2.1.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3] emacs: add stash support for git send-email command line 2015-01-02 17:48 ` [PATCH v3] " Jani Nikula @ 2015-01-02 18:12 ` David Edmondson 2015-01-02 19:54 ` Tomi Ollila 2015-01-17 10:55 ` David Bremner 1 sibling, 1 reply; 12+ messages in thread From: David Edmondson @ 2015-01-02 18:12 UTC (permalink / raw) To: Jani Nikula, notmuch Looks good to me. On Fri, Jan 02 2015, Jani Nikula wrote: > Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as > --in-reply-to, suitable for pasting to git send-email command line. > --- > emacs/notmuch-show.el | 38 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index b8cfbb8a3286..9f6fe077df0c 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -1280,6 +1280,7 @@ reset based on the original query." > (define-key map "t" 'notmuch-show-stash-to) > (define-key map "l" 'notmuch-show-stash-mlarchive-link) > (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) > + (define-key map "G" 'notmuch-show-stash-git-send-email) > (define-key map "?" 'notmuch-subkeymap-help) > map) > "Submap for stash commands") > @@ -2131,6 +2132,43 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." > (notmuch-show-stash-mlarchive-link mla) > (browse-url (current-kill 0 t))) > > +(defun notmuch-show-stash-git-helper (addresses prefix) > + "Escape, trim, quote, and add PREFIX to each address in list of ADDRESSES, and return the result as a single string." > + (mapconcat (lambda (x) > + (concat prefix "\"" > + ;; escape double-quotes > + (replace-regexp-in-string > + "\"" "\\\\\"" > + ;; trim leading and trailing spaces > + (replace-regexp-in-string > + "\\(^ *\\| *$\\)" "" > + x)) "\"")) > + addresses " ")) > + > +(put 'notmuch-show-stash-git-send-email 'notmuch-prefix-doc > + "Copy From/To/Cc of current message to kill-ring in a form suitable for pasting to git send-email command line.") > + > +(defun notmuch-show-stash-git-send-email (&optional no-in-reply-to) > + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line. > + > +If invoked with a prefix argument (or NO-IN-REPLY-TO is non-nil), > +omit --in-reply-to=<Message-Id>." > + (interactive "P") > + (notmuch-common-do-stash > + (mapconcat 'identity > + (remove "" > + (list > + (notmuch-show-stash-git-helper > + (message-tokenize-header (notmuch-show-get-from)) "--to=") > + (notmuch-show-stash-git-helper > + (message-tokenize-header (notmuch-show-get-to)) "--to=") > + (notmuch-show-stash-git-helper > + (message-tokenize-header (notmuch-show-get-cc)) "--cc=") > + (unless no-in-reply-to > + (notmuch-show-stash-git-helper > + (list (notmuch-show-get-message-id t)) "--in-reply-to=")))) > + " "))) > + > ;; Interactive part functions and their helpers > > (defun notmuch-show-generate-part-buffer (message-id nth) > -- > 2.1.4 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] emacs: add stash support for git send-email command line 2015-01-02 18:12 ` David Edmondson @ 2015-01-02 19:54 ` Tomi Ollila 0 siblings, 0 replies; 12+ messages in thread From: Tomi Ollila @ 2015-01-02 19:54 UTC (permalink / raw) To: David Edmondson, Jani Nikula, notmuch On Fri, Jan 02 2015, David Edmondson <dme@dme.org> wrote: > Looks good to me. LGTM, too, and seems to work -- and docstrings actually adhere the conventions... from http://web.mit.edu/Emacs/source/emacs/lisp/emacs-lisp/checkdoc.el ;; * Format the documentation string so that it fits in an ;; Emacs window on an 80-column screen. It is a good idea ;; for most lines to be no wider than 60 characters. The ;; first line can be wider if necessary to fit the ;; information that ought to be there. Tomi > On Fri, Jan 02 2015, Jani Nikula wrote: >> Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as >> --in-reply-to, suitable for pasting to git send-email command line. >> --- >> emacs/notmuch-show.el | 38 ++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 38 insertions(+) >> >> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el >> index b8cfbb8a3286..9f6fe077df0c 100644 >> --- a/emacs/notmuch-show.el >> +++ b/emacs/notmuch-show.el >> @@ -1280,6 +1280,7 @@ reset based on the original query." >> (define-key map "t" 'notmuch-show-stash-to) >> (define-key map "l" 'notmuch-show-stash-mlarchive-link) >> (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) >> + (define-key map "G" 'notmuch-show-stash-git-send-email) >> (define-key map "?" 'notmuch-subkeymap-help) >> map) >> "Submap for stash commands") >> @@ -2131,6 +2132,43 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." >> (notmuch-show-stash-mlarchive-link mla) >> (browse-url (current-kill 0 t))) >> >> +(defun notmuch-show-stash-git-helper (addresses prefix) >> + "Escape, trim, quote, and add PREFIX to each address in list of ADDRESSES, and return the result as a single string." >> + (mapconcat (lambda (x) >> + (concat prefix "\"" >> + ;; escape double-quotes >> + (replace-regexp-in-string >> + "\"" "\\\\\"" >> + ;; trim leading and trailing spaces >> + (replace-regexp-in-string >> + "\\(^ *\\| *$\\)" "" >> + x)) "\"")) >> + addresses " ")) >> + >> +(put 'notmuch-show-stash-git-send-email 'notmuch-prefix-doc >> + "Copy From/To/Cc of current message to kill-ring in a form suitable for pasting to git send-email command line.") >> + >> +(defun notmuch-show-stash-git-send-email (&optional no-in-reply-to) >> + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line. >> + >> +If invoked with a prefix argument (or NO-IN-REPLY-TO is non-nil), >> +omit --in-reply-to=<Message-Id>." >> + (interactive "P") >> + (notmuch-common-do-stash >> + (mapconcat 'identity >> + (remove "" >> + (list >> + (notmuch-show-stash-git-helper >> + (message-tokenize-header (notmuch-show-get-from)) "--to=") >> + (notmuch-show-stash-git-helper >> + (message-tokenize-header (notmuch-show-get-to)) "--to=") >> + (notmuch-show-stash-git-helper >> + (message-tokenize-header (notmuch-show-get-cc)) "--cc=") >> + (unless no-in-reply-to >> + (notmuch-show-stash-git-helper >> + (list (notmuch-show-get-message-id t)) "--in-reply-to=")))) >> + " "))) >> + >> ;; Interactive part functions and their helpers >> >> (defun notmuch-show-generate-part-buffer (message-id nth) >> -- >> 2.1.4 > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] emacs: add stash support for git send-email command line 2015-01-02 17:48 ` [PATCH v3] " Jani Nikula 2015-01-02 18:12 ` David Edmondson @ 2015-01-17 10:55 ` David Bremner 1 sibling, 0 replies; 12+ messages in thread From: David Bremner @ 2015-01-17 10:55 UTC (permalink / raw) To: Jani Nikula, David Edmondson, notmuch Jani Nikula <jani@nikula.org> writes: > Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as > --in-reply-to, suitable for pasting to git send-email command line. > --- > emacs/notmuch-show.el | 38 ++++++++++++++++++++++++++++++++++++ pushed. and used already ;). d ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] emacs: add stash support for git send-email command line 2015-01-02 6:48 ` David Edmondson 2015-01-02 17:48 ` [PATCH v3] " Jani Nikula @ 2015-01-02 17:49 ` Jani Nikula 1 sibling, 0 replies; 12+ messages in thread From: Jani Nikula @ 2015-01-02 17:49 UTC (permalink / raw) To: David Edmondson, notmuch On Fri, 02 Jan 2015, David Edmondson <dme@dme.org> wrote: > On Thu, Jan 01 2015, Jani Nikula wrote: >> Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as >> --in-reply-to, suitable for pasting to git send-email command line. >> --- >> emacs/notmuch-show.el | 38 ++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 38 insertions(+) >> >> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el >> index b8cfbb8a3286..887d877672fc 100644 >> --- a/emacs/notmuch-show.el >> +++ b/emacs/notmuch-show.el >> @@ -1280,6 +1280,7 @@ reset based on the original query." >> (define-key map "t" 'notmuch-show-stash-to) >> (define-key map "l" 'notmuch-show-stash-mlarchive-link) >> (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) >> + (define-key map "G" 'notmuch-show-stash-git-send-email) >> (define-key map "?" 'notmuch-subkeymap-help) >> map) >> "Submap for stash commands") >> @@ -2131,6 +2132,43 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." >> (notmuch-show-stash-mlarchive-link mla) >> (browse-url (current-kill 0 t))) >> >> +(defun notmuch-show-stash-git-helper (addresses prefix) >> + "Escape, trim, quote, and add PREFIX to each address in list of >> ADDRESSES." > > "...and return the result as a single string." > >> + (mapconcat (lambda (x) >> + (concat prefix "\"" >> + ;; escape double-quotes >> + (replace-regexp-in-string >> + "\"" "\\\\\"" >> + ;; trim leading and trailing spaces >> + (replace-regexp-in-string >> + "\\(^ *\\| *$\\)" "" >> + x)) "\"")) >> + addresses " ")) >> + >> +(put 'notmuch-show-stash-git-send-email 'notmuch-prefix-doc >> + "Copy From/To/Cc of current message to kill-ring in a form suitable for pasting to git send-email command line.") >> + >> +(defun notmuch-show-stash-git-send-email (&optional no-in-reply-to) >> + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line. >> + >> +If invoked with a prefix argument (or NO-IN-REPLY-TO is non-nil, >> +omit --in-reply-to=<Message-Id>." > > Missing ")" after "non-nil". > >> + (interactive "P") >> + (notmuch-common-do-stash >> + (mapconcat 'identity >> + (remove "" >> + (list >> + (notmuch-show-stash-git-helper >> + (message-tokenize-header (notmuch-show-get-from)) "--to=") >> + (notmuch-show-stash-git-helper >> + (message-tokenize-header (notmuch-show-get-to)) "--to=") >> + (notmuch-show-stash-git-helper >> + (message-tokenize-header (notmuch-show-get-cc)) "--cc=") >> + (unless no-in-reply-to >> + (notmuch-show-stash-git-helper >> + (list (notmuch-show-get-message-id t)) >> "--in-reply-to=")))) > > This will still generate a trailing space if `no-in-reply-to' is set, > but I think that we can live with it. I know I can! ;) Thanks for the review, v3 in reply. BR, Jani. > >> + " "))) >> + >> ;; Interactive part functions and their helpers >> >> (defun notmuch-show-generate-part-buffer (message-id nth) >> -- >> 2.1.4 ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-01-17 10:55 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-10-28 19:38 [PATCH] emacs: add stash support for git send-email command line Jani Nikula 2014-10-29 8:41 ` David Edmondson 2014-10-29 8:50 ` Tomi Ollila 2014-10-29 20:45 ` Jani Nikula 2014-10-30 8:23 ` David Edmondson 2015-01-01 17:45 ` [PATCH v2] " Jani Nikula 2015-01-02 6:48 ` David Edmondson 2015-01-02 17:48 ` [PATCH v3] " Jani Nikula 2015-01-02 18:12 ` David Edmondson 2015-01-02 19:54 ` Tomi Ollila 2015-01-17 10:55 ` David Bremner 2015-01-02 17:49 ` [PATCH v2] " Jani Nikula
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).