From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id C540D431FC9 for ; Sat, 21 Jul 2012 10:37:21 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled 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 wq2tmDAbOKiL for ; Sat, 21 Jul 2012 10:37:20 -0700 (PDT) Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU [18.7.68.36]) by olra.theworths.org (Postfix) with ESMTP id B9960431FBF for ; Sat, 21 Jul 2012 10:37:19 -0700 (PDT) X-AuditID: 12074424-b7f2a6d0000008bf-76-500ae8ce4abd Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id 36.3D.02239.EC8EA005; Sat, 21 Jul 2012 13:37:18 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q6LHbHdr018461; Sat, 21 Jul 2012 13:37:17 -0400 Received: from drake.dyndns.org (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6LHbFs3008010 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 21 Jul 2012 13:37:16 -0400 (EDT) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1SsdcB-0001Zc-55; Sat, 21 Jul 2012 13:37:15 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v4 0/8] emacs: JSON-based search cleanups Date: Sat, 21 Jul 2012 13:37:04 -0400 Message-Id: <1342892232-5659-1-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1341354059-29396-1-git-send-email-amdragon@mit.edu> References: <1341354059-29396-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrIIsWRmVeSWpSXmKPExsUixCmqrXvuBVeAwfaJIhZ79nlZrJ7LY3H9 5kxmB2aPu6e5PHbOusvu8WzVLeYA5igum5TUnMyy1CJ9uwSujJfrWtgKWjQrzvZ+Zm5g/KLQ xcjJISFgIrHi8VF2CFtM4sK99WxdjFwcQgL7GCXu3n7CBOFsYJS4enIllPOISaK1fREjhDOX UWLG9YesIP1sAhoS2/YvZwSxRQSkJXbenQ0WZxawlPjeeg8sLgxk7944B8xmEVCVmL1/KpjN K2AvserdfDaIO+Qlnt7vA7M5BRwlVtw8ywJiCwk4SGz70ME6gZF/ASPDKkbZlNwq3dzEzJzi 1GTd4uTEvLzUIl1zvdzMEr3UlNJNjKDQYndR2cHYfEjpEKMAB6MSD6+lEleAEGtiWXFl7iFG SQ4mJVHevvtAIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8m04D5XhTEiurUovyYVLSHCxK4rzX U276CwmkJ5akZqemFqQWwWRlODiUJHjdgTEkJFiUmp5akZaZU4KQZuLgBBnOAzQ8GKSGt7gg Mbc4Mx0if4pRl+Paw1u3GIVY8vLzUqXEee1AigRAijJK8+DmwFLCK0ZxoLeEeQ1AqniA6QRu 0iugJUxAS6SzwJaUJCKkpBoYhd/+l16aK1126qZE/kG5yxz1QZr5d+UkTu8UVH/H1jz1549l L3zaHbKEWFW3qH/7GaJ/XH41x6WpP7j+nNTu+1C48/3vrZIhCTNV/DU3seU+OTyxeZuizy/f CEm9ZQeWLZCKbyqwjv4pfT1QId7pwrFHcQvsmzyPHni35pH96YvXt21S8/wVrcRSnJFoqMVc VJwIADDODqTkAgAA 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: Sat, 21 Jul 2012 17:37:22 -0000 This version fixes several bugs found in the previous version. I replaced the insert-before-markers trick in notmuch-search-update-result with direct point manipulation. This fixes the problem with authors getting unhidden when a result is updated with point after the authors on the line (since it no longer deletes the region with the invisibility overlay). I also removed the scrolling hack (which was partially necessitated by insert-before-markers), so that archiving the last visible result will properly scroll the buffer instead of jumping point to the middle of the visible window. As a result, the window may scroll when updating a multiline result, however, it will scroll to show the entire result (unlike an earlier version where it scrolled to cut off the result because of an interaction with insert-before-markers). Finally, I fixed notmuch-search-last-thread so that it behaves like it did before when there are no results, rather than failing with an obscure error. I also updated the customize documentation and NEWS to indicate that multiline search results are considered experimental. Diff from v3: diff --git a/NEWS b/NEWS index 7b33f0d..7b1f36c 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ The formatting of tags in search results can now be customized `notmuch-search-result-format` would usually break tagging from search-mode. We no longer make assumptions about the format. -Multi-line search result formats are now supported +Experimental support for multi-line search result formats It is now possible to embed newlines in `notmuch-search-result-format` to make individual search results diff --git a/emacs/notmuch.el b/emacs/notmuch.el index ec760dc..fd1836f 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -70,12 +70,12 @@ For example: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\) \(\"subject\" . \"%s\"\)\)\) -Line breaks are permitted in format strings. Note that a line -break at the end of an \"authors\" field will get elided if the -authors list is long; place it instead at the beginning of the -following field. To enter a line break when setting this -variable with setq, use \\n. To enter a line break in customize, -press \\[quoted-insert] C-j." +Line breaks are permitted in format strings (though this is +currently experimental). Note that a line break at the end of an +\"authors\" field will get elided if the authors list is long; +place it instead at the beginning of the following field. To +enter a line break when setting this variable with setq, use \\n. +To enter a line break in customize, press \\[quoted-insert] C-j." :type '(alist :key-type (string) :value-type (string)) :group 'notmuch-search) @@ -310,7 +310,8 @@ For a mouse binding, return nil." (interactive) (goto-char (point-max)) (forward-line -2) - (goto-char (notmuch-search-result-beginning))) + (let ((beg (notmuch-search-result-beginning))) + (when beg (goto-char beg)))) (defun notmuch-search-first-thread () "Select the first thread in the search results." @@ -599,30 +600,31 @@ This function advances the next thread when finished." (defun notmuch-search-update-result (result &optional pos) "Replace the result object of the thread at POS (or point) by -RESULT and redraw it." +RESULT and redraw it. + +This will keep point in a reasonable location. However, if there +are enclosing save-excursions and the saved point is in the +result being updated, the point will be restored to the beginning +of the result." (let ((start (notmuch-search-result-beginning pos)) (end (notmuch-search-result-end pos)) (init-point (point)) - (init-start (window-start)) (inhibit-read-only t)) ;; Delete the current thread (delete-region start end) ;; Insert the updated thread (notmuch-search-show-result result start) - ;; There may have been markers pointing into the text we just - ;; replaced. For the most part, there's nothing we can do about - ;; this, but we can fix markers that were at point (which includes - ;; point itself and any save-excursions for which point hasn't - ;; moved) by re-inserting the text that should come before point - ;; before markers. + ;; If point was inside the old result, make an educated guess + ;; about where to place it now. Unfortunately, this won't work + ;; with save-excursion (or any other markers that would be nice to + ;; preserve, such as the window start), but there's nothing we can + ;; do about that without a way to retrieve markers in a region. (when (and (>= init-point start) (<= init-point end)) (let* ((new-end (notmuch-search-result-end start)) (new-point (if (= init-point end) new-end (min init-point (- new-end 1))))) - (insert-before-markers (delete-and-extract-region start new-point)))) - ;; We also may have shifted the window scroll. Fix it. - (set-window-start (selected-window) init-start))) + (goto-char new-point))))) (defun notmuch-search-process-sentinel (proc msg) "Add a message to let user know when \"notmuch search\" exits"