Re: newbie questions about notmuch.el

Subject: Re: newbie questions about notmuch.el

Date: Fri, 8 Sep 2017 14:04:02 +0200 (CEST)

To: David Bremner

Cc: Notmuch Mail, Julien Cubizolles

From: Tom Hirschowitz


> Yes, I think there has to be some mistake in what Tom quoted

Indeed :)

Regarding Julien's question:

> Tom, do you have a function defined for this ?

Yes, probably utterly naive, wrong, etc. Would be happy to be corrected, in particular about how to avoid code triplication.
There you go:

(defun notmuch-show-flag  () 
  "Switch the flagged tag for the current thread or region." 
  (interactive) 
  (let ((tag-changes (if (member "flagged" (notmuch-show-get-tags)) (list "-flagged") (list "+flagged"))))
    (notmuch-show-tag tag-changes)))

(defun notmuch-search-flag  (&optional beg end) 
  "Switch the flagged tag for the current thread or region." 
  (interactive) 
  (let ((tag-changes (if (member "flagged" (notmuch-search-get-tags)) (list "-flagged") (list "+flagged"))))
    (notmuch-search-tag tag-changes beg end)))

(defun notmuch-tree-flag ()
  "Switch the flagged tag for the current thread or region." 
  (interactive)
  (let ((tag-changes (if (member "flagged" (notmuch-tree-get-tags)) (list "-flagged") (list "+flagged"))))
    (notmuch-tree-tag tag-changes)))

(define-key notmuch-show-mode-map (kbd "SPC") 'notmuch-show-flag) 
(define-key notmuch-search-mode-map (kbd "SPC") 'notmuch-search-flag) 
(define-key notmuch-tree-mode-map (kbd "SPC") 'notmuch-tree-flag) 
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: