an emacs macro

Tom Hirschowitz tom.hirschowitz at univ-savoie.fr
Fri Jun 6 05:20:53 PDT 2014


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 at gmail.com> writes:

> On Thu, 05 Jun 2014, Tom Hirschowitz <tom.hirschowitz at 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


More information about the notmuch mailing list