--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 327DA431FAF\r
+ for <notmuch@notmuchmail.org>; Tue, 7 Feb 2012 21:11:36 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id UXG2gd6eqeGq for <notmuch@notmuchmail.org>;\r
+ Tue, 7 Feb 2012 21:11:35 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU\r
+ [18.9.25.12])\r
+ by olra.theworths.org (Postfix) with ESMTP id DA816431FAE\r
+ for <notmuch@notmuchmail.org>; Tue, 7 Feb 2012 21:11:34 -0800 (PST)\r
+X-AuditID: 1209190c-b7fad6d000000920-ff-4f320406ca0c\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 43.56.02336.604023F4; Wed, 8 Feb 2012 00:11:34 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q185BXKA025143; \r
+ Wed, 8 Feb 2012 00:11:34 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q185BWS8025291\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Wed, 8 Feb 2012 00:11:33 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1RuznM-0001BY-8V; Wed, 08 Feb 2012 00:10:16 -0500\r
+Date: Wed, 8 Feb 2012 00:10:16 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: David Edmondson <dme@dme.org>\r
+Subject: Re: [PATCH v7 1/8] emacs: Rework crypto switch toggle.\r
+Message-ID: <20120208051016.GB27039@mit.edu>\r
+References: <1327486729-18052-1-git-send-email-dme@dme.org>\r
+ <1328520082-26659-1-git-send-email-dme@dme.org>\r
+ <1328520082-26659-2-git-send-email-dme@dme.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1328520082-26659-2-git-send-email-dme@dme.org>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFupnleLIzCtJLcpLzFFi42IRYrdT12VjMfI3WLxJ0GLfnS1MFtdvzmR2\r
+ YPLY9fwvk8ezVbeYA5iiuGxSUnMyy1KL9O0SuDJ2ft7BUjA9oaJ13y7mBsZ/vl2MHBwSAiYS\r
+ N7YVdDFyApliEhfurWcDsYUE9jFKfJxp1sXIBWSvZ5To2/ODFcI5wSRxYukeNghnCaPEpmkN\r
+ YC0sAioSa3Z3MYLYbAIaEtv2LwezRQQUJf5/W8EOYjMLSEt8+93MBGILC9hLPDi5gBnE5hXQ\r
+ kXgwYycTxND5jBL39iyESghKnJz5hAWiWUvixr+XTCBngwxa/o8DJMwpYCOxqPMh2C5RoBum\r
+ nNzGNoFRaBaS7llIumchdC9gZF7FKJuSW6Wbm5iZU5yarFucnJiXl1qka6iXm1mil5pSuokR\r
+ FNackjw7GN8cVDrEKMDBqMTDy3HI0F+INbGsuDL3EKMkB5OSKO86JiN/Ib6k/JTKjMTijPii\r
+ 0pzU4kOMEhzMSiK8S4OAynlTEiurUovyYVLSHCxK4rwqWu/8hATSE0tSs1NTC1KLYLIyHBxK\r
+ Erx5zEBDBYtS01Mr0jJzShDSTBycIMN5gIY3gtTwFhck5hZnpkPkTzHqcnw+9fk8oxBLXn5e\r
+ qpQ47ySQIgGQoozSPLg5sHT0ilEc6C1h3pkgVTzAVAY36RXQEiagJSlMIB8UlyQipKQaGOdv\r
+ 8BZpPfk2uyGE/+bXqjl1h4PinlhPLz7mcOFD9RmxN+19DudfvM3fNn3rPfUdxxw9mlYs5LSu\r
+ n70483dYX9envxpt7779jJyyjHftsyntPDpJU8trj1xSvqH16lnMbNmspS9fRpz79/ra3q87\r
+ AxvlDH/n5dS+4I6U+q6k5Msa7zGPcbEVr4gSS3FGoqEWc1FxIgDBEkkZIgMAAA==\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 08 Feb 2012 05:11:36 -0000\r
+\r
+Seems reasonable. I'm definitely in favor of erasing buffers instead\r
+of killing and recreating them. Two questions below.\r
+\r
+Quoth David Edmondson on Feb 06 at 9:21 am:\r
+> Re-work the existing crypto switch toggle to be based on a persistant\r
+> buffer-local variable.\r
+> \r
+> To allow this, modify `notmuch-show-refresh-view' to erase and re-draw\r
+> in the current buffer rather than killing the current buffer and\r
+> creating a new one. (This will also allow more per-buffer behaviour in\r
+> future patches.)\r
+> \r
+> Add a binding ('$') to toggle crypto processing of the current buffer\r
+> and remove the prefix argument approach that achieves a similar\r
+> result.\r
+> ---\r
+> emacs/notmuch-show.el | 126 ++++++++++++++++++++++++------------------------\r
+> emacs/notmuch.el | 7 +--\r
+> 2 files changed, 66 insertions(+), 67 deletions(-)\r
+> \r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index 7469e2e..4b29dbd 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -125,6 +125,22 @@ indentation."\r
+> (const :tag "View interactively"\r
+> notmuch-show-interactively-view-part)))\r
+> \r
+> +(defvar notmuch-show-thread-id nil)\r
+> +(make-variable-buffer-local 'notmuch-show-thread-id)\r
+> +(put 'notmuch-show-thread-id 'permanent-local t)\r
+> +\r
+> +(defvar notmuch-show-parent-buffer nil)\r
+> +(make-variable-buffer-local 'notmuch-show-parent-buffer)\r
+> +(put 'notmuch-show-parent-buffer 'permanent-local t)\r
+> +\r
+> +(defvar notmuch-show-query-context nil)\r
+> +(make-variable-buffer-local 'notmuch-show-query-context)\r
+> +(put 'notmuch-show-query-context 'permanent-local t)\r
+> +\r
+> +(defvar notmuch-show-process-crypto nil)\r
+> +(make-variable-buffer-local 'notmuch-show-process-crypto)\r
+> +(put 'notmuch-show-process-crypto 'permanent-local t)\r
+> +\r
+\r
+Do these need to be permanent-local given that refreshing is now done\r
+by erasing the buffer instead of killing it?\r
+\r
+> (defmacro with-current-notmuch-show-message (&rest body)\r
+> "Evaluate body with current buffer set to the text of current message"\r
+> `(save-excursion\r
+> @@ -421,14 +437,11 @@ message at DEPTH in the current thread."\r
+> \r
+> (defmacro notmuch-with-temp-part-buffer (message-id nth &rest body)\r
+> (declare (indent 2))\r
+> - (let ((process-crypto (make-symbol "process-crypto")))\r
+> - `(let ((,process-crypto notmuch-show-process-crypto))\r
+> - (with-temp-buffer\r
+> - (setq notmuch-show-process-crypto ,process-crypto)\r
+> - ;; Always acquires the part via `notmuch part', even if it is\r
+> - ;; available in the JSON output.\r
+> - (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))\r
+> - ,@body))))\r
+> + `(with-temp-buffer\r
+> + ;; Always acquires the part via `notmuch part', even if it is\r
+> + ;; available in the JSON output.\r
+> + (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))\r
+> + ,@body))\r
+\r
+Why is the piping of notmuch-show-process-crypto no longer necessary?\r
+It's still buffer-local, and hence will be nil in the temp buffer.\r
+\r
+> \r
+> (defun notmuch-show-save-part (message-id nth &optional filename content-type)\r
+> (notmuch-with-temp-part-buffer message-id nth\r
+> @@ -610,7 +623,7 @@ current buffer, if possible."\r
+> (sigstatus (car (plist-get part :sigstatus))))\r
+> (notmuch-crypto-insert-sigstatus-button sigstatus from))\r
+> ;; if we're not adding sigstatus, tell the user how they can get it\r
+> - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))\r
+> + (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))\r
+> \r
+> (let ((inner-parts (plist-get part :content))\r
+> (start (point)))\r
+> @@ -636,7 +649,7 @@ current buffer, if possible."\r
+> (sigstatus (car (plist-get part :sigstatus))))\r
+> (notmuch-crypto-insert-sigstatus-button sigstatus from))))\r
+> ;; if we're not adding encstatus, tell the user how they can get it\r
+> - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))\r
+> + (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))\r
+> \r
+> (let ((inner-parts (plist-get part :content))\r
+> (start (point)))\r
+> @@ -763,8 +776,6 @@ current buffer, if possible."\r
+> \r
+> ;; Helper for parts which are generally not included in the default\r
+> ;; JSON output.\r
+> -;; Uses the buffer-local variable notmuch-show-process-crypto to\r
+> -;; determine if parts should be decrypted first.\r
+> (defun notmuch-show-get-bodypart-internal (message-id part-number)\r
+> (let ((args '("show" "--format=raw"))\r
+> (part-arg (format "--part=%s" part-number)))\r
+> @@ -918,6 +929,15 @@ current buffer, if possible."\r
+> ;; criteria.\r
+> (notmuch-show-message-visible msg (plist-get msg :match))))\r
+> \r
+> +(defun notmuch-show-toggle-process-crypto ()\r
+> + "Toggle the processing of cryptographic MIME parts."\r
+> + (interactive)\r
+> + (setq notmuch-show-process-crypto (not notmuch-show-process-crypto))\r
+> + (message (if notmuch-show-process-crypto\r
+> + "Processing cryptographic MIME parts."\r
+> + "Not processing cryptographic MIME parts."))\r
+> + (notmuch-show-refresh-view))\r
+> +\r
+> (defun notmuch-show-insert-tree (tree depth)\r
+> "Insert the message tree TREE at depth DEPTH in the current thread."\r
+> (let ((msg (car tree))\r
+> @@ -933,15 +953,6 @@ current buffer, if possible."\r
+> "Insert the forest of threads FOREST."\r
+> (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))\r
+> \r
+> -(defvar notmuch-show-thread-id nil)\r
+> -(make-variable-buffer-local 'notmuch-show-thread-id)\r
+> -(defvar notmuch-show-parent-buffer nil)\r
+> -(make-variable-buffer-local 'notmuch-show-parent-buffer)\r
+> -(defvar notmuch-show-query-context nil)\r
+> -(make-variable-buffer-local 'notmuch-show-query-context)\r
+> -(defvar notmuch-show-buffer-name nil)\r
+> -(make-variable-buffer-local 'notmuch-show-buffer-name)\r
+> -\r
+> (defun notmuch-show-buttonise-links (start end)\r
+> "Buttonise URLs and mail addresses between START and END.\r
+> \r
+> @@ -961,7 +972,7 @@ a corresponding notmuch search."\r
+> 'face goto-address-mail-face))))\r
+> \r
+> ;;;###autoload\r
+> -(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)\r
+> +(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)\r
+> "Run \"notmuch show\" with the given thread ID and display results.\r
+> \r
+> The optional PARENT-BUFFER is the notmuch-search buffer from\r
+> @@ -976,46 +987,41 @@ non-nil.\r
+> The optional BUFFER-NAME provides the name of the buffer in\r
+> which the message thread is shown. If it is nil (which occurs\r
+> when the command is called interactively) the argument to the\r
+> -function is used.\r
+> -\r
+> -The optional CRYPTO-SWITCH toggles the value of the\r
+> -notmuch-crypto-process-mime customization variable for this show\r
+> -buffer."\r
+> +function is used."\r
+> (interactive "sNotmuch show: ")\r
+> - (let* ((process-crypto (if crypto-switch\r
+> - (not notmuch-crypto-process-mime)\r
+> - notmuch-crypto-process-mime)))\r
+> - (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))\r
+> -\r
+> -(defun notmuch-show-worker (thread-id parent-buffer query-context buffer-name process-crypto)\r
+> - (let* ((buffer-name (generate-new-buffer-name\r
+> - (or buffer-name\r
+> - (concat "*notmuch-" thread-id "*"))))\r
+> - (buffer (get-buffer-create buffer-name))\r
+> - (inhibit-read-only t))\r
+> - (switch-to-buffer buffer)\r
+> + (let ((buffer-name (generate-new-buffer-name\r
+> + (or buffer-name\r
+> + (concat "*notmuch-" thread-id "*")))))\r
+> + (switch-to-buffer (get-buffer-create buffer-name))\r
+> + ;; Set the default value for `notmuch-show-process-crypto' in this\r
+> + ;; buffer.\r
+> + (setq notmuch-show-process-crypto notmuch-crypto-process-mime)\r
+> +\r
+> + (setq notmuch-show-thread-id thread-id\r
+> + notmuch-show-parent-buffer parent-buffer\r
+> + notmuch-show-query-context query-context)\r
+> + (notmuch-show-worker)))\r
+> +\r
+> +(defun notmuch-show-worker ()\r
+> + (let ((inhibit-read-only t))\r
+> +\r
+> (notmuch-show-mode)\r
+> ;; Don't track undo information for this buffer\r
+> (set 'buffer-undo-list t)\r
+> \r
+> - (setq notmuch-show-thread-id thread-id)\r
+> - (setq notmuch-show-parent-buffer parent-buffer)\r
+> - (setq notmuch-show-query-context query-context)\r
+> - (setq notmuch-show-buffer-name buffer-name)\r
+> - (setq notmuch-show-process-crypto process-crypto)\r
+> -\r
+> (erase-buffer)\r
+> (goto-char (point-min))\r
+> (save-excursion\r
+> - (let* ((basic-args (list thread-id))\r
+> - (args (if query-context\r
+> - (append (list "\'") basic-args (list "and (" query-context ")\'"))\r
+> + (let* ((basic-args (list notmuch-show-thread-id))\r
+> + (args (if notmuch-show-query-context\r
+> + (append (list "\'") basic-args\r
+> + (list "and (" notmuch-show-query-context ")\'"))\r
+> (append (list "\'") basic-args (list "\'")))))\r
+> (notmuch-show-insert-forest (notmuch-query-get-threads args))\r
+> ;; If the query context reduced the results to nothing, run\r
+> ;; the basic query.\r
+> (when (and (eq (buffer-size) 0)\r
+> - query-context)\r
+> + notmuch-show-query-context)\r
+> (notmuch-show-insert-forest\r
+> (notmuch-query-get-threads basic-args))))\r
+> \r
+> @@ -1032,21 +1038,14 @@ buffer."\r
+> \r
+> (notmuch-show-mark-read)))\r
+> \r
+> -(defun notmuch-show-refresh-view (&optional crypto-switch)\r
+> - "Refresh the current view (with crypto switch if prefix given).\r
+> +(defun notmuch-show-refresh-view ()\r
+> + "Refresh the current view.\r
+> \r
+> -Kills the current buffer and reruns notmuch show with the same\r
+> -thread id. If a prefix is given, crypto processing is toggled."\r
+> - (interactive "P")\r
+> - (let ((thread-id notmuch-show-thread-id)\r
+> - (parent-buffer notmuch-show-parent-buffer)\r
+> - (query-context notmuch-show-query-context)\r
+> - (buffer-name notmuch-show-buffer-name)\r
+> - (process-crypto (if crypto-switch\r
+> - (not notmuch-show-process-crypto)\r
+> - notmuch-show-process-crypto)))\r
+> - (notmuch-kill-this-buffer)\r
+> - (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))\r
+> +Refreshes the current view, observing changes in cryptographic preferences."\r
+> + (interactive)\r
+> + (let ((inhibit-read-only t))\r
+> + (erase-buffer))\r
+> + (notmuch-show-worker))\r
+> \r
+> (defvar notmuch-show-stash-map\r
+> (let ((map (make-sparse-keymap)))\r
+> @@ -1097,6 +1096,7 @@ thread id. If a prefix is given, crypto processing is toggled."\r
+> (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)\r
+> (define-key map (kbd "RET") 'notmuch-show-toggle-message)\r
+> (define-key map "#" 'notmuch-show-print-message)\r
+> + (define-key map "$" 'notmuch-show-toggle-process-crypto)\r
+> map)\r
+> "Keymap for \"notmuch show\" buffers.")\r
+> (fset 'notmuch-show-mode-map notmuch-show-mode-map)\r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index cd04ffd..ff0db99 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -463,9 +463,9 @@ Complete list of currently available key bindings:\r
+> "Return a list of authors for the current region"\r
+> (notmuch-search-properties-in-region 'notmuch-search-subject beg end))\r
+> \r
+> -(defun notmuch-search-show-thread (&optional crypto-switch)\r
+> +(defun notmuch-search-show-thread ()\r
+> "Display the currently selected thread."\r
+> - (interactive "P")\r
+> + (interactive)\r
+> (let ((thread-id (notmuch-search-find-thread-id))\r
+> (subject (notmuch-prettify-subject (notmuch-search-find-subject))))\r
+> (if (> (length thread-id) 0)\r
+> @@ -473,8 +473,7 @@ Complete list of currently available key bindings:\r
+> (current-buffer)\r
+> notmuch-search-query-string\r
+> ;; Name the buffer based on the subject.\r
+> - (concat "*" (truncate-string-to-width subject 30 nil nil t) "*")\r
+> - crypto-switch)\r
+> + (concat "*" (truncate-string-to-width subject 30 nil nil t) "*"))\r
+> (message "End of search results."))))\r
+> \r
+> (defun notmuch-search-reply-to-thread (&optional prompt-for-sender)\r