Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 180C6431FBC for ; Tue, 19 Jan 2010 14:54:21 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.293 X-Spam-Level: X-Spam-Status: No, score=-1.293 tagged_above=-999 required=5 tests=[AWL=-1.108, BAYES_40=-0.185] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gtVRbMCtz0gG for ; Tue, 19 Jan 2010 14:54:20 -0800 (PST) Received: from tarap.cc.columbia.edu (tarap.cc.columbia.edu [128.59.29.7]) by olra.theworths.org (Postfix) with ESMTP id EA189431FAE for ; Tue, 19 Jan 2010 14:54:19 -0800 (PST) Received: from servo.finestructure.net (geco.phys.columbia.edu [128.59.170.159]) (user=jgr2110 author=jrollins@finestructure.net mech=PLAIN bits=0) by tarap.cc.columbia.edu (8.14.3/8.14.3) with ESMTP id o0JMsIbj014614 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 19 Jan 2010 17:54:19 -0500 (EST) Received: from jrollins by servo.finestructure.net with local (Exim 4.71) (envelope-from ) id 1NXMxl-0004wZ-W9 for notmuch@notmuchmail.org; Tue, 19 Jan 2010 17:54:18 -0500 From: Jameson Rollins To: Notmuch Mail list Date: Tue, 19 Jan 2010 17:54:16 -0500 Message-ID: <87ska1vh7r.fsf@servo.finestructure.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.68 on 128.59.29.7 Subject: [notmuch] [PATCH] Simplify "unread" tag handling in emacs UI. X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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: Tue, 19 Jan 2010 22:54:21 -0000 --=-=-= Content-Transfer-Encoding: quoted-printable This patch is intended to greatly simplify the handling of the "unread" tag in the emacs UI. This patch adds a new function 'notmuch-show-mark-read', that removes the "unread" tag in notmuch-show-mode. This function is then executed as a notmuch-show-hook, and by notmuch-show-next-message. All of the functions that explicitly marked messages as unread are removed or renamed. The idea here is that the user should never have to worry about manipulating the "unread" tag. The tag should persist until the user actually views a message, at which point it should be automatically removed. This patch simplifies the notmuch.el quite a bit, removing a lot of somewhat redundant functions, and reducing clutter in the name and key-mapping space. =2D-- notmuch.el | 95 +++++++++++++++++++-------------------------------------= --- 1 files changed, 31 insertions(+), 64 deletions(-) diff --git a/notmuch.el b/notmuch.el index 97914f2..2da3c06 100644 =2D-- a/notmuch.el +++ b/notmuch.el @@ -69,15 +69,12 @@ (define-key map "v" 'notmuch-show-view-all-mime-parts) (define-key map "-" 'notmuch-show-remove-tag) (define-key map "+" 'notmuch-show-add-tag) =2D (define-key map "X" 'notmuch-show-mark-read-then-archive-then-exit) (define-key map "x" 'notmuch-show-archive-thread-then-exit) =2D (define-key map "A" 'notmuch-show-mark-read-then-archive-thread) (define-key map "a" 'notmuch-show-archive-thread) (define-key map "p" 'notmuch-show-previous-message) =2D (define-key map "N" 'notmuch-show-mark-read-then-next-open-message) (define-key map "n" 'notmuch-show-next-message) (define-key map (kbd "DEL") 'notmuch-show-rewind) =2D (define-key map " " 'notmuch-show-advance-marking-read-and-archiving) + (define-key map " " 'notmuch-show-advance-and-archive) map) "Keymap for \"notmuch show\" buffers.") (fset 'notmuch-show-mode-map notmuch-show-mode-map) @@ -226,13 +223,22 @@ Unlike builtin `previous-line' this version accepts n= o arguments." (cons (notmuch-show-get-message-id) nil))) (notmuch-show-set-tags (sort (set-difference tags toremove :test 'strin= g=3D) 'string<)))))) =20 =2D(defun notmuch-show-archive-thread-maybe-mark-read (markread) +(defun notmuch-show-archive-thread () + "Archive each message in thread, then show next thread from search. + +Archive each message currently shown by removing the \"inbox\" +tag from each. Then kill this buffer and show the next thread +from the search from which this thread was originally shown. + +Note: This command is safe from any race condition of new messages +being delivered to the same thread. It does not archive the +entire thread, but only the messages shown in the current +buffer." + (interactive) (save-excursion (goto-char (point-min)) (while (not (eobp)) =2D (if markread =2D (notmuch-show-remove-tag "unread" "inbox") =2D (notmuch-show-remove-tag "inbox")) + (notmuch-show-remove-tag "inbox") (if (not (eobp)) (forward-char)) (if (not (re-search-forward notmuch-show-message-begin-regexp nil t)) @@ -245,47 +251,12 @@ Unlike builtin `previous-line' this version accepts n= o arguments." (forward-line) (notmuch-search-show-thread))))) =20 =2D(defun notmuch-show-mark-read-then-archive-thread () =2D "Remove unread tags from thread, then archive and show next thread. =2D =2DArchive each message currently shown by removing the \"unread\" =2Dand \"inbox\" tag from each. Then kill this buffer and show the =2Dnext thread from the search from which this thread was originally =2Dshown. =2D =2DNote: This command is safe from any race condition of new messages =2Dbeing delivered to the same thread. It does not archive the =2Dentire thread, but only the messages shown in the current =2Dbuffer." =2D (interactive) =2D (notmuch-show-archive-thread-maybe-mark-read t)) =2D =2D(defun notmuch-show-archive-thread () =2D "Archive each message in thread, then show next thread from search. =2D =2DArchive each message currently shown by removing the \"inbox\" =2Dtag from each. Then kill this buffer and show the next thread =2Dfrom the search from which this thread was originally shown. =2D =2DNote: This command is safe from any race condition of new messages =2Dbeing delivered to the same thread. It does not archive the =2Dentire thread, but only the messages shown in the current =2Dbuffer." =2D (interactive) =2D (notmuch-show-archive-thread-maybe-mark-read nil)) =2D (defun notmuch-show-archive-thread-then-exit () "Archive each message in thread, then exit back to search results." (interactive) (notmuch-show-archive-thread) (kill-this-buffer)) =20 =2D(defun notmuch-show-mark-read-then-archive-then-exit () =2D "Remove unread tags from thread, then archive and exit to search resul= ts." =2D (interactive) =2D (notmuch-show-mark-read-then-archive-thread) =2D (kill-this-buffer)) =2D (defun notmuch-show-view-raw-message () "View the raw email of the current message." (interactive) @@ -440,7 +411,8 @@ Returns nil if already on the last message in the buffe= r." (while (point-invisible-p) (backward-char)) (recenter 0) =2D nil)) + nil) + (notmuch-show-mark-read)) =20 (defun notmuch-show-find-next-message () "Returns the position of the next message in the buffer. @@ -503,14 +475,8 @@ it." (notmuch-show-previous-message) (point)))) =20 =2D(defun notmuch-show-mark-read-then-next-open-message () =2D "Remove unread tag from this message, then advance to next open messag= e." =2D (interactive) =2D (notmuch-show-remove-tag "unread") =2D (notmuch-show-next-open-message)) =2D (defun notmuch-show-rewind () =2D "Backup through the thread, (reverse scrolling compared to \\[notmuch-= show-advance-marking-read-and-archiving]). + "Backup through the thread, (reverse scrolling compared to \\[notmuch-sh= ow-advance-and-archive]). =20 Specifically, if the beginning of the previous email is fewer than `window-height' lines from the current point, move to it @@ -520,7 +486,7 @@ Otherwise, just scroll down a screenful of the current = message. =20 This command does not modify any message tags, (it does not undo any effects from previous calls to =2D`notmuch-show-advance-marking-read-and-archiving'." +`notmuch-show-advance-and-archive'." (interactive) (let ((previous (notmuch-show-find-previous-message))) (if (> (count-lines previous (point)) (- (window-height) next-screen-c= ontext-lines)) @@ -531,8 +497,8 @@ any effects from previous calls to (goto-char (window-start))) (notmuch-show-previous-message)))) =20 =2D(defun notmuch-show-advance-marking-read-and-archiving () =2D "Advance through thread, marking read and archiving. +(defun notmuch-show-advance-and-archive () + "Advance through thread and archive. =20 This command is intended to be one of the simplest ways to process a thread of email. It does the following: @@ -541,8 +507,7 @@ If the current message in the thread is not yet fully v= isible, scroll by a near screenful to read more of the message. =20 Otherwise, (the end of the current message is already within the =2Dcurrent window), remove the \"unread\" tag (if present) from the =2Dcurrent message and advance to the next open message. +current window), advance to the next open message. =20 Finally, if there is no further message to advance to, and this last message is already read, then archive the entire current @@ -555,7 +520,7 @@ which this thread was originally shown." (if (> next (window-end)) (scroll-up nil) (let ((last (notmuch-show-last-message-p))) =2D (notmuch-show-mark-read-then-next-open-message) + (notmuch-show-next-open-message) (if last (notmuch-show-archive-thread)))))) =20 @@ -878,17 +843,15 @@ pressing RET after positioning the cursor on a hidden= part, (for which \\[notmuch-show-next-button] and \\[notmuch-show-previous-button] ar= e helpful). =20 Reading the thread sequentially is well-supported by pressing =2D\\[notmuch-show-advance-marking-read-and-archiving]. This will scroll th= e current message (if necessary), =2Dadvance to the next message, or advance to the next thread (if =2Dalready on the last message of a thread). As each message is =2Dscrolled away its \"unread\" tag will be removed, and as each =2Dthread is scrolled away the \"inbox\" tag will be removed from =2Deach message in the thread. +\\[notmuch-show-advance-and-archive]. This will +scroll the current message (if necessary), advance to the next +message, or advance to the next thread (if already on the last +message of a thread). =20 Other commands are available to read or manipulate the thread more selectively, (such as '\\[notmuch-show-next-message]' and '\\[notmuch-show= -previous-message]' to advance to messages without removing any tags, and '\\[notmuch-show-archive-thread]' to archive an ent= ire thread without =2Dscrolling through with \\[notmuch-show-advance-marking-read-and-archivin= g]). +scrolling through with \\[notmuch-show-advance-and-archive]). =20 You can add or remove arbitary tags from the current message with '\\[notmuch-show-add-tag]' or '\\[notmuch-show-remove-tag]'. @@ -922,10 +885,14 @@ All currently available key bindings: =20 ; Make show mode a bit prettier, highlighting URLs and using word wrap =20 +(defun notmuch-show-mark-read () + (notmuch-show-remove-tag "unread")) + (defun notmuch-show-pretty-hook () (goto-address-mode 1) (visual-line-mode)) =20 +(add-hook 'notmuch-show-hook 'notmuch-show-mark-read) (add-hook 'notmuch-show-hook 'notmuch-show-pretty-hook) (add-hook 'notmuch-search-hook (lambda() =2D-=20 1.6.5 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBCAAGBQJLVjgYAAoJEO00zqvie6q8pm4P/13IpsI9vPQxOPylwgPbjNIO NdvZ9yuNWcK20SKW5+BNUQceQx1TkX2Utz7kEmbCE7rXPqnU7/rMnr9FmVqNWwiI OXhaNwDlldZ98dI7TWFk14tADiI8Htdu3Z+ZlbMo9Z3f2Tu1ikr7ohUFGERE1JLS eR87ng0tjKNlEcYy1M/vqcmof8e/bdYvEFXw2k+An2nzVsTRTth0Q/5yFe/R+qyY gSjNY4pXVPD5xtQBkjgwbVJBrleFrASf6IiuozQtxFPysxPWHfKBOSZqY0QDJiys Mn8SV30fpM2gTi306mqVrf3wuTPaQD1D27ahr14FzfuX+ikQsBDnyUCSkn1bPFoB MMgRXuOtrFkYTcLk0zLXkES6aDD7BIjOvWuvxKJ+cfGvb2+MDVNoNLNpi+ptcB/Q /0yGUl0i2mANn5703+s2XELHWqfJBX7IN6asJQ7LZqy4GBhz4cv/vx1js4tOGzfA 5fDOjBeC1ozN1QUAsQ+YQTz2Xx/rWkJvCRRLiTKbPHuEga0yEI0hHtjSLIq/Pocs w+RYIQNVkLXD0Q+qJBOIN8DGYBJcdGISzFx0yIEFufnbza81YsaRXJZd8Oz1BHuz 0WGIodwo+RLcEQn9KXMkY9NB5ugM9a8numr9K7/9M69RTntJzNwSsG2KC3pCzlqn u5HTvDXCMDxU8TU9O8iC =Z2h6 -----END PGP SIGNATURE----- --=-=-=--