unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* an emacs macro
@ 2014-06-05  9:52 Tom Hirschowitz
  2014-06-06 12:02 ` Mark Walters
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Hirschowitz @ 2014-06-05  9:52 UTC (permalink / raw)
  To: notmuch


Hi all, 

I'm trying to define a macro for notmuch/emacs which in show-mode would

 - prompt the user for tags (possibly starting with "+"),

 - tag the shown message with these tags plus an additional fixed tag,
   say "+local".

I know next to nothing about emacs/lisp, so I tried to mimick notmuch*.el.

Here's my most plausible attempt:

(defun notmuch-show-move (tag-changes)
  "Add the local tag, plus possibly others, given as interactive arguments."
  (interactive (list (notmuch-read-tag-changes (notmuch-show-get-tags)
					       "Tag message" "+")))
  (let* ((tag-changes-with-local (cons "+local" tag-changes))
	 (rien (notmuch-tag (notmuch-show-get-message-id) tag-changes-with-local))
	 (current-tags (notmuch-show-get-tags))
	 (new-tags (notmuch-update-tags current-tags tag-changes-with-local)))
    (unless (equal current-tags new-tags)
      (notmuch-show-set-tags new-tags))))

(define-key notmuch-show-mode-map (kbd "M") 'notmuch-show-move)
(define-key notmuch-search-mode-map (kbd "M") 'notmuch-show-move)

This seems to work in show-mode, but not in search-mode.
I'd be grateful for any hint on doing this in tree- and search-modes
(and possibly explanations on why the current version does not work).

Thanks,
Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: an emacs macro
  2014-06-05  9:52 an emacs macro Tom Hirschowitz
@ 2014-06-06 12:02 ` Mark Walters
  2014-06-06 12:20   ` Tom Hirschowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Walters @ 2014-06-06 12:02 UTC (permalink / raw)
  To: Tom Hirschowitz, notmuch


On Thu, 05 Jun 2014, Tom Hirschowitz <tom.hirschowitz@univ-savoie.fr> wrote:
> Hi all, 
>
> I'm trying to define a macro for notmuch/emacs which in show-mode would
>
>  - prompt the user for tags (possibly starting with "+"),
>
>  - tag the shown message with these tags plus an additional fixed tag,
>    say "+local".
>
> I know next to nothing about emacs/lisp, so I tried to mimick notmuch*.el.
>
> Here's my most plausible attempt:
>
> (defun notmuch-show-move (tag-changes)
>   "Add the local tag, plus possibly others, given as interactive arguments."
>   (interactive (list (notmuch-read-tag-changes (notmuch-show-get-tags)
> 					       "Tag message" "+")))
>   (let* ((tag-changes-with-local (cons "+local" tag-changes))
> 	 (rien (notmuch-tag (notmuch-show-get-message-id) tag-changes-with-local))
> 	 (current-tags (notmuch-show-get-tags))
> 	 (new-tags (notmuch-update-tags current-tags tag-changes-with-local)))
>     (unless (equal current-tags new-tags)
>       (notmuch-show-set-tags new-tags))))

Yes this looks fine for notmuch-show. It won't work for search mode as
notmuch-show- commands basically only work in notmuch-show. I would
suggest copying notmuch-search-tag and tweaking it to use
tag-changes-with-local (as you have done for the show version
above). Something similar should work for tree-mode (ie copy
notmuch-tree-tag)

I think you will need separate functions for the three modes.

Best wishes

Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: an emacs macro
  2014-06-06 12:02 ` Mark Walters
@ 2014-06-06 12:20   ` Tom Hirschowitz
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Hirschowitz @ 2014-06-06 12:20 UTC (permalink / raw)
  To: notmuch


Thanks, you were right, although that's what i had tried. No idea what i
did wrong the first time.

Here's the code in case anyone is interested (i actually tweaked *-add-tag):

(defun notmuch-search-move  (tag-changes &optional beg end) 
  "Add the local tag, plus possibly others, given as interactive arguments,  
for the current thread or region (defaulting to add)." 
  (interactive (notmuch-search-interactive-tag-changes "+")) 
  (notmuch-search-tag (cons "+local" tag-changes) beg end)) 

(defun notmuch-tree-move (tag-changes)
  "Add the local tag, plus possibly others, given as interactive arguments,  
for the current thread or region (defaulting to add)." 
  (interactive
   (list (notmuch-read-tag-changes (notmuch-tree-get-tags) "Tag message" "+")))
  (notmuch-tree-tag (cons "+local" tag-changes)))

Cheers,
Tom

Mark Walters <markwalters1009@gmail.com> writes:

> On Thu, 05 Jun 2014, Tom Hirschowitz <tom.hirschowitz@univ-savoie.fr> wrote:
>> Hi all, 
>>
>> I'm trying to define a macro for notmuch/emacs which in show-mode would
>>
>>  - prompt the user for tags (possibly starting with "+"),
>>
>>  - tag the shown message with these tags plus an additional fixed tag,
>>    say "+local".
>>
>> I know next to nothing about emacs/lisp, so I tried to mimick notmuch*.el.
>>
>> Here's my most plausible attempt:
>>
>> (defun notmuch-show-move (tag-changes)
>>   "Add the local tag, plus possibly others, given as interactive arguments."
>>   (interactive (list (notmuch-read-tag-changes (notmuch-show-get-tags)
>> 					       "Tag message" "+")))
>>   (let* ((tag-changes-with-local (cons "+local" tag-changes))
>> 	 (rien (notmuch-tag (notmuch-show-get-message-id) tag-changes-with-local))
>> 	 (current-tags (notmuch-show-get-tags))
>> 	 (new-tags (notmuch-update-tags current-tags tag-changes-with-local)))
>>     (unless (equal current-tags new-tags)
>>       (notmuch-show-set-tags new-tags))))
>
> Yes this looks fine for notmuch-show. It won't work for search mode as
> notmuch-show- commands basically only work in notmuch-show. I would
> suggest copying notmuch-search-tag and tweaking it to use
> tag-changes-with-local (as you have done for the show version
> above). Something similar should work for tree-mode (ie copy
> notmuch-tree-tag)
>
> I think you will need separate functions for the three modes.
>
> Best wishes
>
> Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-06 12:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-05  9:52 an emacs macro Tom Hirschowitz
2014-06-06 12:02 ` Mark Walters
2014-06-06 12:20   ` Tom Hirschowitz

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