[PATCH 0/3] reworked crypto toggle, plus a couple of other toggles

classic Classic list List threaded Threaded
79 messages Options
1234
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 0/3] reworked crypto toggle, plus a couple of other toggles

The crypto toggle previously worked using an argument to
`notmuch-show' and various other functions and relied on killing and
re-creating the notmuch-show-mode buffer. Various other
pseudo-buffer-local variables were present based on an ad-hoc scheme.

Replace the ad-hoc scheme with real buffer-local variables and then
update `notmuch-show-refresh-view' to erase and re-paint rather than
kill and re-create. Update the crypto switch accordingly.

Add two other toggles:
    - whether non-matching messages are available,
    - the indentation of message contents.
Both of these default to the current behaviour.

A wart in the first patch is the handling of the
`notmuch-show-process-crypto' default. It is set based on
`notmuch-crypto-process-mime', but the users choice of setting for
that variable may not have been applied at the point where
`notmuch-show-process-crypto' inherits it.

My inclination is to remove `notmuch-crypto-process-mime' altogether
(declared it an obsolete variable) and allow users to set a default
for `notmuch-show-process-crypto' directly, but that is not done in
this patchset while awaiting feedback.

`notmuch-crypto-process-mime' is used only in notmuch-show.el, so the
setting really belongs there with an appropriate name.

David Edmondson (3):
  emacs: Rework crypto switch toggle.
  emacs: Allow `notmuch-show-mode' to display only matching messages.
  emacs: Allow the indentation of content to be toggled.

 emacs/notmuch-show.el |  143 +++++++++++++++++++++++++++++--------------------
 emacs/notmuch.el      |    7 +--
 2 files changed, 87 insertions(+), 63 deletions(-)

--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 1/3] emacs: Rework crypto switch toggle.

Re-work the existing crypto switch toggle to be based on a persistant
buffer-local variable.

To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
in the current buffer rather than killing the current buffer and
creating a new one. (This will also allow more per-buffer behaviour in
future patches.)

Add a binding ('$') to toggle crypto processing of the current buffer
and remove the prefix argument approach that achieves a similar
result.
---
 emacs/notmuch-show.el |  102 ++++++++++++++++++++++--------------------------
 emacs/notmuch.el      |    7 +--
 2 files changed, 50 insertions(+), 59 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..ed77474 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -123,6 +123,17 @@ indentation."
  (const :tag "View interactively"
  notmuch-show-interactively-view-part)))
 
+(defvar notmuch-show-thread-id nil)
+(make-variable-buffer-local 'notmuch-show-thread-id)
+(defvar notmuch-show-parent-buffer nil)
+(make-variable-buffer-local 'notmuch-show-parent-buffer)
+(defvar notmuch-show-query-context nil)
+(make-variable-buffer-local 'notmuch-show-query-context)
+
+(defvar notmuch-show-process-crypto notmuch-crypto-process-mime)
+(make-variable-buffer-local 'notmuch-show-process-crypto)
+(put 'notmuch-show-process-crypto 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -379,14 +390,11 @@ message at DEPTH in the current thread."
 
 (defmacro notmuch-with-temp-part-buffer (message-id nth &rest body)
   (declare (indent 2))
-  (let ((process-crypto (make-symbol "process-crypto")))
-    `(let ((,process-crypto notmuch-show-process-crypto))
-       (with-temp-buffer
- (setq notmuch-show-process-crypto ,process-crypto)
- ;; Always acquires the part via `notmuch part', even if it is
- ;; available in the JSON output.
- (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
- ,@body))))
+  `(with-temp-buffer
+     ;; Always acquires the part via `notmuch part', even if it is
+     ;; available in the JSON output.
+     (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
+     ,@body))
 
 (defun notmuch-show-save-part (message-id nth &optional filename content-type)
   (notmuch-with-temp-part-buffer message-id nth
@@ -567,7 +575,7 @@ current buffer, if possible."
        (sigstatus (car (plist-get part :sigstatus))))
   (notmuch-crypto-insert-sigstatus-button sigstatus from))
       ;; if we're not adding sigstatus, tell the user how they can get it
-      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))
+      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))
 
   (let ((inner-parts (plist-get part :content))
  (start (point)))
@@ -593,7 +601,7 @@ current buffer, if possible."
      (sigstatus (car (plist-get part :sigstatus))))
  (notmuch-crypto-insert-sigstatus-button sigstatus from))))
       ;; if we're not adding encstatus, tell the user how they can get it
-      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))
+      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))
 
   (let ((inner-parts (plist-get part :content))
  (start (point)))
@@ -720,8 +728,6 @@ current buffer, if possible."
 
 ;; Helper for parts which are generally not included in the default
 ;; JSON output.
-;; Uses the buffer-local variable notmuch-show-process-crypto to
-;; determine if parts should be decrypted first.
 (defun notmuch-show-get-bodypart-internal (message-id part-number)
   (let ((args '("show" "--format=raw"))
  (part-arg (format "--part=%s" part-number)))
@@ -875,6 +881,15 @@ current buffer, if possible."
     ;; criteria.
     (notmuch-show-message-visible msg (plist-get msg :match))))
 
+(defun notmuch-show-toggle-process-crypto ()
+  "Toggle the processing of cryptographic MIME parts."
+  (interactive)
+  (setq notmuch-show-process-crypto (not notmuch-show-process-crypto))
+  (message (if notmuch-show-process-crypto
+       "Processing cryptographic MIME parts."
+     "Not processing cryptographic MIME parts."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -890,15 +905,6 @@ current buffer, if possible."
   "Insert the forest of threads FOREST."
   (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))
 
-(defvar notmuch-show-thread-id nil)
-(make-variable-buffer-local 'notmuch-show-thread-id)
-(defvar notmuch-show-parent-buffer nil)
-(make-variable-buffer-local 'notmuch-show-parent-buffer)
-(defvar notmuch-show-query-context nil)
-(make-variable-buffer-local 'notmuch-show-query-context)
-(defvar notmuch-show-buffer-name nil)
-(make-variable-buffer-local 'notmuch-show-buffer-name)
-
 (defun notmuch-show-buttonise-links (start end)
   "Buttonise URLs and mail addresses between START and END.
 
@@ -918,7 +924,7 @@ a corresponding notmuch search."
  'face goto-address-mail-face))))
 
 ;;;###autoload
-(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
+(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)
   "Run \"notmuch show\" with the given thread ID and display results.
 
 The optional PARENT-BUFFER is the notmuch-search buffer from
@@ -933,24 +939,17 @@ non-nil.
 The optional BUFFER-NAME provides the name of the buffer in
 which the message thread is shown. If it is nil (which occurs
 when the command is called interactively) the argument to the
-function is used.
-
-The optional CRYPTO-SWITCH toggles the value of the
-notmuch-crypto-process-mime customization variable for this show
-buffer."
+function is used."
   (interactive "sNotmuch show: ")
-  (let* ((process-crypto (if crypto-switch
-     (not notmuch-crypto-process-mime)
-   notmuch-crypto-process-mime)))
-    (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))
-
-(defun notmuch-show-worker (thread-id parent-buffer query-context buffer-name process-crypto)
-  (let* ((buffer-name (generate-new-buffer-name
-       (or buffer-name
-   (concat "*notmuch-" thread-id "*"))))
- (buffer (get-buffer-create buffer-name))
- (inhibit-read-only t))
-    (switch-to-buffer buffer)
+  (let ((buffer-name (generate-new-buffer-name
+      (or buffer-name
+  (concat "*notmuch-" thread-id "*")))))
+    (switch-to-buffer (get-buffer-create buffer-name))
+    (notmuch-show-worker thread-id parent-buffer query-context)))
+
+(defun notmuch-show-worker (thread-id parent-buffer query-context)
+  (let ((inhibit-read-only t))
+
     (notmuch-show-mode)
     ;; Don't track undo information for this buffer
     (set 'buffer-undo-list t)
@@ -958,8 +957,6 @@ buffer."
     (setq notmuch-show-thread-id thread-id)
     (setq notmuch-show-parent-buffer parent-buffer)
     (setq notmuch-show-query-context query-context)
-    (setq notmuch-show-buffer-name buffer-name)
-    (setq notmuch-show-process-crypto process-crypto)
 
     (erase-buffer)
     (goto-char (point-min))
@@ -989,21 +986,15 @@ buffer."
 
     (notmuch-show-mark-read)))
 
-(defun notmuch-show-refresh-view (&optional crypto-switch)
-  "Refresh the current view (with crypto switch if prefix given).
+(defun notmuch-show-refresh-view ()
+  "Refresh the current view.
 
-Kills the current buffer and reruns notmuch show with the same
-thread id.  If a prefix is given, crypto processing is toggled."
-  (interactive "P")
-  (let ((thread-id notmuch-show-thread-id)
- (parent-buffer notmuch-show-parent-buffer)
- (query-context notmuch-show-query-context)
- (buffer-name notmuch-show-buffer-name)
- (process-crypto (if crypto-switch
-    (not notmuch-show-process-crypto)
-  notmuch-show-process-crypto)))
-    (notmuch-kill-this-buffer)
-    (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))
+Refreshes the current view, observing changes in cryptographic preferences."
+  (interactive)
+  (let ((inhibit-read-only t))
+    (erase-buffer))
+  (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
+       notmuch-show-query-context))
 
 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
@@ -1053,6 +1044,7 @@ thread id.  If a prefix is given, crypto processing is toggled."
  (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
  (define-key map (kbd "RET") 'notmuch-show-toggle-message)
  (define-key map "#" 'notmuch-show-print-message)
+ (define-key map "$" 'notmuch-show-toggle-process-crypto)
  map)
       "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6b2c252..a427e96 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -436,9 +436,9 @@ Complete list of currently available key bindings:
   "Return a list of authors for the current region"
   (notmuch-search-properties-in-region 'notmuch-search-subject beg end))
 
-(defun notmuch-search-show-thread (&optional crypto-switch)
+(defun notmuch-search-show-thread ()
   "Display the currently selected thread."
-  (interactive "P")
+  (interactive)
   (let ((thread-id (notmuch-search-find-thread-id))
  (subject (notmuch-search-find-subject)))
     (if (> (length thread-id) 0)
@@ -452,8 +452,7 @@ Complete list of currently available key bindings:
  (concat "*"
  (truncate-string-to-width subject 32 nil nil t)
  "*")
- 32 nil nil t))
-      crypto-switch)
+ 32 nil nil t)))
       (message "End of search results."))))
 
 (defun notmuch-search-reply-to-thread (&optional prompt-for-sender)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 2/3] emacs: Allow `notmuch-show-mode' to display only matching messages.

In reply to this post by David Edmondson
The current behaviour (all messages shown, non-matching collapsed)
is retained as the default. Type '!' to switch to showing only
the matching messages - non-matching messages are not available.
'!' will switch back to showing everything.
---
 emacs/notmuch-show.el |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ed77474..916b941 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -134,6 +134,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 (put 'notmuch-show-process-crypto 'permanent-local t)
 
+(defvar notmuch-show-elide-non-matching-messages nil)
+(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -890,11 +894,22 @@ current buffer, if possible."
      "Not processing cryptographic MIME parts."))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-elide-non-matching ()
+  "Toggle the display of non-matching messages."
+  (interactive)
+  (setq notmuch-show-elide-non-matching-messages (not notmuch-show-elide-non-matching-messages))
+  (message (if notmuch-show-elide-non-matching-messages
+       "Showing matching messages only."
+     "Showing all messages."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
  (replies (cadr tree)))
-    (notmuch-show-insert-msg msg depth)
+    (if (or (not notmuch-show-elide-non-matching-messages)
+    (plist-get msg :match))
+ (notmuch-show-insert-msg msg depth))
     (notmuch-show-insert-thread replies (1+ depth))))
 
 (defun notmuch-show-insert-thread (thread depth)
@@ -1044,6 +1059,7 @@ Refreshes the current view, observing changes in cryptographic preferences."
  (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
  (define-key map (kbd "RET") 'notmuch-show-toggle-message)
  (define-key map "#" 'notmuch-show-print-message)
+ (define-key map "!" 'notmuch-show-toggle-elide-non-matching)
  (define-key map "$" 'notmuch-show-toggle-process-crypto)
  map)
       "Keymap for \"notmuch show\" buffers.")
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 3/3] emacs: Allow the indentation of content to be toggled.

In reply to this post by David Edmondson
Very deeply indented content is sometimes difficult to
read (particular for something like patches). Allow the indentation of
the content to be toggled with '<'.

Indentation of the header lines is not affected, so it remains
possible to see the structure of the thread.
---
 emacs/notmuch-show.el |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 916b941..337cd50 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -138,6 +138,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
 (put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
 
+(defvar notmuch-show-indent-content t)
+(make-variable-buffer-local 'notmuch-show-indent-content)
+(put 'notmuch-show-indent-content 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -244,10 +248,12 @@ operation on the contents of the current buffer."
  (all (buffer-substring (notmuch-show-message-top)
  (notmuch-show-message-bottom)))
 
- (props (notmuch-show-get-message-properties)))
+ (props (notmuch-show-get-message-properties))
+ (indenting notmuch-show-indent-content))
     (with-temp-buffer
       (insert all)
-      (indent-rigidly (point-min) (point-max) (- depth))
+      (if indenting
+  (indent-rigidly (point-min) (point-max) (- depth)))
       ;; Remove the original header.
       (goto-char (point-min))
       (re-search-forward "^$" (point-max) nil)
@@ -856,7 +862,8 @@ current buffer, if possible."
     (setq content-end (point-marker))
 
     ;; Indent according to the depth in the thread.
-    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
+    (if notmuch-show-indent-content
+ (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth)))
 
     (setq message-end (point-max-marker))
 
@@ -903,6 +910,15 @@ current buffer, if possible."
      "Showing all messages."))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-thread-indentation ()
+  "Toggle the indentation of threads."
+  (interactive)
+  (setq notmuch-show-indent-content (not notmuch-show-indent-content))
+  (message (if notmuch-show-indent-content
+       "Content is indented."
+     "Content is not indented."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -1061,6 +1077,7 @@ Refreshes the current view, observing changes in cryptographic preferences."
  (define-key map "#" 'notmuch-show-print-message)
  (define-key map "!" 'notmuch-show-toggle-elide-non-matching)
  (define-key map "$" 'notmuch-show-toggle-process-crypto)
+ (define-key map "<" 'notmuch-show-toggle-thread-indentation)
  map)
       "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Jameson Graef Rollins Jameson Graef Rollins
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 0/3] reworked crypto toggle, plus a couple of other toggles

In reply to this post by David Edmondson
On Wed, 25 Jan 2012 10:18:46 +0000, David Edmondson <[hidden email]> wrote:
> The crypto toggle previously worked using an argument to
> `notmuch-show' and various other functions and relied on killing and
> re-creating the notmuch-show-mode buffer. Various other
> pseudo-buffer-local variables were present based on an ad-hoc scheme.
>
> Replace the ad-hoc scheme with real buffer-local variables and then
> update `notmuch-show-refresh-view' to erase and re-paint rather than
> kill and re-create. Update the crypto switch accordingly.

Hey, David.  Thank you so much for this!  I was really hoping someone
would eventually pick this up, and your solution is great!  This new
behavior is *much* nicer.  I really like it.

I haven't done a full code review, though, just tested it out.  I may
not be able to get to it for a while, so please don't hold this patch up
on my account).

> Add two other toggles:
>     - whether non-matching messages are available,
>     - the indentation of message contents.
> Both of these default to the current behaviour.

These new features enabled by this are very cool!  I love them both.  I
bet there are other interesting toggle features that could be enabled by
this.

> My inclination is to remove `notmuch-crypto-process-mime' altogether
> (declared it an obsolete variable) and allow users to set a default
> for `notmuch-show-process-crypto' directly, but that is not done in
> this patchset while awaiting feedback.

I'm not sure I understand this.  `notmuch-show-process-crypto' *is* what
sets the default for the `notmuch-show-process-crypto' buffer-local
variable.  How would you change the current behavior or settings (beyond
just a variable rename)?

> `notmuch-crypto-process-mime' is used only in notmuch-show.el, so the
> setting really belongs there with an appropriate name.

I intentionally put this in a separate section in case there were
eventually other needs for this setting beyond just show mode.  I
personally think we should just leave it where it is, particularly since
it's been there for a while.

jamie.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (851 bytes) Download Attachment
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 3/3] emacs: Allow the indentation of content to be toggled.

In reply to this post by David Edmondson
On Wed, 25 Jan 2012 10:18:49 +0000, David Edmondson <[hidden email]> wrote:
> Very deeply indented content is sometimes difficult to
> read (particular for something like patches). Allow the indentation of
> the content to be toggled with '<'.
>
> Indentation of the header lines is not affected, so it remains
> possible to see the structure of the thread.

I really like the feature and would definitely use it. However, I have a
couple of niggles with the implementation. First, when toggled it seems
to redisplay so it jumps back to the first matching message regardless
of where you are in the thread (and closes messages you have opened).

Secondly, it doesn't seem to interact correctly with
notmuch-wash-wrap-long-lines (the lines wrap at the place they would
have wrapped had the text been indented).

[I haven't yet worked how out notmuch-wash-wrap-long-lines and visual line
mode etc are intended to interact so maybe the second point is moot.]

Best wishes

Mark

(Sorry for the resend: I sent from the wrong address again)

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 3/3] emacs: Allow the indentation of content to be toggled.

On Sun, 29 Jan 2012 22:30:42 +0000, Mark Walters <[hidden email]> wrote:
> First, when toggled it seems to redisplay so it jumps back to the
> first matching message regardless of where you are in the thread (and
> closes messages you have opened).

Yes, I agree that is annoying. Annoying enough to block the patch until
it's fixed? (I'd argue no, but I'm interested in opinions.)

> Secondly, it doesn't seem to interact correctly with
> notmuch-wash-wrap-long-lines (the lines wrap at the place they would
> have wrapped had the text been indented).

That's a bug. I'll fix it.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 0/3] reworked crypto toggle, plus a couple of other toggles

In reply to this post by Jameson Graef Rollins
On Sun, 29 Jan 2012 12:06:57 -0800, Jameson Graef Rollins <[hidden email]> wrote:
> > My inclination is to remove `notmuch-crypto-process-mime' altogether
> > (declared it an obsolete variable) and allow users to set a default
> > for `notmuch-show-process-crypto' directly, but that is not done in
> > this patchset while awaiting feedback.
>
> I'm not sure I understand this.  `notmuch-show-process-crypto' *is* what
> sets the default for the `notmuch-show-process-crypto' buffer-local
> variable.  How would you change the current behavior or settings (beyond
> just a variable rename)?

The problem with the code as I posted can be seen if you imagine the
following ~/.emacs.el sequence:



I'm sure that I can figure out either some `defcustom' goop or worse to
sort it out so that the initialisation happens correctly.

> > `notmuch-crypto-process-mime' is used only in notmuch-show.el, so the
> > setting really belongs there with an appropriate name.
>
> I intentionally put this in a separate section in case there were
> eventually other needs for this setting beyond just show mode.  I
> personally think we should just leave it where it is, particularly
> since it's been there for a while.

Okay.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (533 bytes) Download Attachment
attachment1 (203 bytes) Download Attachment
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 0/3] reworked crypto toggle, plus a couple of other toggles

On Mon, 30 Jan 2012 09:37:17 +0000, David Edmondson <[hidden email]> wrote:

> On Sun, 29 Jan 2012 12:06:57 -0800, Jameson Graef Rollins <[hidden email]> wrote:
> > > My inclination is to remove `notmuch-crypto-process-mime' altogether
> > > (declared it an obsolete variable) and allow users to set a default
> > > for `notmuch-show-process-crypto' directly, but that is not done in
> > > this patchset while awaiting feedback.
> >
> > I'm not sure I understand this.  `notmuch-show-process-crypto' *is* what
> > sets the default for the `notmuch-show-process-crypto' buffer-local
> > variable.  How would you change the current behavior or settings (beyond
> > just a variable rename)?
>
> [...]
>
> I'm sure that I can figure out either some `defcustom' goop or worse to
> sort it out so that the initialisation happens correctly.
The simplest approach is to have `notmuch-show-process-crypto' inherit
the value of `notmuch-crypto-process-mime' when any `notmuch-show-mode'
buffers are first created. Currently that happens in only one place
(`notmuch-show'), which makes things straightforward.

Updated patches soon.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 0/3 v2] reworked crypto toggle, plus a couple of other toggles

In reply to this post by David Edmondson
- Improved default for `notmuch-show-process-crypto' that is less load
  order dependant.

- Pass the _displayed_ depth of the thread to the body-insertion
  functions, allowing them to properly wrap when the content is not
  indented.

David Edmondson (3):
  emacs: Rework crypto switch toggle.
  emacs: Allow `notmuch-show-mode' to display only matching messages.
  emacs: Allow the indentation of content to be toggled.

 emacs/notmuch-show.el |  149 +++++++++++++++++++++++++++++--------------------
 emacs/notmuch.el      |    7 +-
 2 files changed, 92 insertions(+), 64 deletions(-)

--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 1/3 v2] emacs: Rework crypto switch toggle.

Re-work the existing crypto switch toggle to be based on a persistant
buffer-local variable.

To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
in the current buffer rather than killing the current buffer and
creating a new one. (This will also allow more per-buffer behaviour in
future patches.)

Add a binding ('$') to toggle crypto processing of the current buffer
and remove the prefix argument approach that achieves a similar
result.
---
 emacs/notmuch-show.el |  105 +++++++++++++++++++++++-------------------------
 emacs/notmuch.el      |    7 +--
 2 files changed, 53 insertions(+), 59 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 84ac624..53f6ae4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -124,6 +124,17 @@ indentation."
  (const :tag "View interactively"
  notmuch-show-interactively-view-part)))
 
+(defvar notmuch-show-thread-id nil)
+(make-variable-buffer-local 'notmuch-show-thread-id)
+(defvar notmuch-show-parent-buffer nil)
+(make-variable-buffer-local 'notmuch-show-parent-buffer)
+(defvar notmuch-show-query-context nil)
+(make-variable-buffer-local 'notmuch-show-query-context)
+
+(defvar notmuch-show-process-crypto nil)
+(make-variable-buffer-local 'notmuch-show-process-crypto)
+(put 'notmuch-show-process-crypto 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -410,14 +421,11 @@ message at DEPTH in the current thread."
 
 (defmacro notmuch-with-temp-part-buffer (message-id nth &rest body)
   (declare (indent 2))
-  (let ((process-crypto (make-symbol "process-crypto")))
-    `(let ((,process-crypto notmuch-show-process-crypto))
-       (with-temp-buffer
- (setq notmuch-show-process-crypto ,process-crypto)
- ;; Always acquires the part via `notmuch part', even if it is
- ;; available in the JSON output.
- (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
- ,@body))))
+  `(with-temp-buffer
+     ;; Always acquires the part via `notmuch part', even if it is
+     ;; available in the JSON output.
+     (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
+     ,@body))
 
 (defun notmuch-show-save-part (message-id nth &optional filename content-type)
   (notmuch-with-temp-part-buffer message-id nth
@@ -599,7 +607,7 @@ current buffer, if possible."
        (sigstatus (car (plist-get part :sigstatus))))
   (notmuch-crypto-insert-sigstatus-button sigstatus from))
       ;; if we're not adding sigstatus, tell the user how they can get it
-      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))
+      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))
 
   (let ((inner-parts (plist-get part :content))
  (start (point)))
@@ -625,7 +633,7 @@ current buffer, if possible."
      (sigstatus (car (plist-get part :sigstatus))))
  (notmuch-crypto-insert-sigstatus-button sigstatus from))))
       ;; if we're not adding encstatus, tell the user how they can get it
-      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))
+      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))
 
   (let ((inner-parts (plist-get part :content))
  (start (point)))
@@ -752,8 +760,6 @@ current buffer, if possible."
 
 ;; Helper for parts which are generally not included in the default
 ;; JSON output.
-;; Uses the buffer-local variable notmuch-show-process-crypto to
-;; determine if parts should be decrypted first.
 (defun notmuch-show-get-bodypart-internal (message-id part-number)
   (let ((args '("show" "--format=raw"))
  (part-arg (format "--part=%s" part-number)))
@@ -907,6 +913,15 @@ current buffer, if possible."
     ;; criteria.
     (notmuch-show-message-visible msg (plist-get msg :match))))
 
+(defun notmuch-show-toggle-process-crypto ()
+  "Toggle the processing of cryptographic MIME parts."
+  (interactive)
+  (setq notmuch-show-process-crypto (not notmuch-show-process-crypto))
+  (message (if notmuch-show-process-crypto
+       "Processing cryptographic MIME parts."
+     "Not processing cryptographic MIME parts."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -922,15 +937,6 @@ current buffer, if possible."
   "Insert the forest of threads FOREST."
   (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))
 
-(defvar notmuch-show-thread-id nil)
-(make-variable-buffer-local 'notmuch-show-thread-id)
-(defvar notmuch-show-parent-buffer nil)
-(make-variable-buffer-local 'notmuch-show-parent-buffer)
-(defvar notmuch-show-query-context nil)
-(make-variable-buffer-local 'notmuch-show-query-context)
-(defvar notmuch-show-buffer-name nil)
-(make-variable-buffer-local 'notmuch-show-buffer-name)
-
 (defun notmuch-show-buttonise-links (start end)
   "Buttonise URLs and mail addresses between START and END.
 
@@ -950,7 +956,7 @@ a corresponding notmuch search."
  'face goto-address-mail-face))))
 
 ;;;###autoload
-(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
+(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)
   "Run \"notmuch show\" with the given thread ID and display results.
 
 The optional PARENT-BUFFER is the notmuch-search buffer from
@@ -965,24 +971,20 @@ non-nil.
 The optional BUFFER-NAME provides the name of the buffer in
 which the message thread is shown. If it is nil (which occurs
 when the command is called interactively) the argument to the
-function is used.
-
-The optional CRYPTO-SWITCH toggles the value of the
-notmuch-crypto-process-mime customization variable for this show
-buffer."
+function is used."
   (interactive "sNotmuch show: ")
-  (let* ((process-crypto (if crypto-switch
-     (not notmuch-crypto-process-mime)
-   notmuch-crypto-process-mime)))
-    (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))
-
-(defun notmuch-show-worker (thread-id parent-buffer query-context buffer-name process-crypto)
-  (let* ((buffer-name (generate-new-buffer-name
-       (or buffer-name
-   (concat "*notmuch-" thread-id "*"))))
- (buffer (get-buffer-create buffer-name))
- (inhibit-read-only t))
-    (switch-to-buffer buffer)
+  (let ((buffer-name (generate-new-buffer-name
+      (or buffer-name
+  (concat "*notmuch-" thread-id "*")))))
+    (switch-to-buffer (get-buffer-create buffer-name))
+    ;; Set the default value for `notmuch-show-process-crypto' in this
+    ;; buffer.
+    (setq notmuch-show-process-crypto notmuch-crypto-process-mime)
+    (notmuch-show-worker thread-id parent-buffer query-context)))
+
+(defun notmuch-show-worker (thread-id parent-buffer query-context)
+  (let ((inhibit-read-only t))
+
     (notmuch-show-mode)
     ;; Don't track undo information for this buffer
     (set 'buffer-undo-list t)
@@ -990,8 +992,6 @@ buffer."
     (setq notmuch-show-thread-id thread-id)
     (setq notmuch-show-parent-buffer parent-buffer)
     (setq notmuch-show-query-context query-context)
-    (setq notmuch-show-buffer-name buffer-name)
-    (setq notmuch-show-process-crypto process-crypto)
 
     (erase-buffer)
     (goto-char (point-min))
@@ -1021,21 +1021,15 @@ buffer."
 
     (notmuch-show-mark-read)))
 
-(defun notmuch-show-refresh-view (&optional crypto-switch)
-  "Refresh the current view (with crypto switch if prefix given).
+(defun notmuch-show-refresh-view ()
+  "Refresh the current view.
 
-Kills the current buffer and reruns notmuch show with the same
-thread id.  If a prefix is given, crypto processing is toggled."
-  (interactive "P")
-  (let ((thread-id notmuch-show-thread-id)
- (parent-buffer notmuch-show-parent-buffer)
- (query-context notmuch-show-query-context)
- (buffer-name notmuch-show-buffer-name)
- (process-crypto (if crypto-switch
-    (not notmuch-show-process-crypto)
-  notmuch-show-process-crypto)))
-    (notmuch-kill-this-buffer)
-    (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))
+Refreshes the current view, observing changes in cryptographic preferences."
+  (interactive)
+  (let ((inhibit-read-only t))
+    (erase-buffer))
+  (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
+       notmuch-show-query-context))
 
 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
@@ -1085,6 +1079,7 @@ thread id.  If a prefix is given, crypto processing is toggled."
  (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
  (define-key map (kbd "RET") 'notmuch-show-toggle-message)
  (define-key map "#" 'notmuch-show-print-message)
+ (define-key map "$" 'notmuch-show-toggle-process-crypto)
  map)
       "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 72f78ed..9d8bebd 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -463,9 +463,9 @@ Complete list of currently available key bindings:
   "Return a list of authors for the current region"
   (notmuch-search-properties-in-region 'notmuch-search-subject beg end))
 
-(defun notmuch-search-show-thread (&optional crypto-switch)
+(defun notmuch-search-show-thread ()
   "Display the currently selected thread."
-  (interactive "P")
+  (interactive)
   (let ((thread-id (notmuch-search-find-thread-id))
  (subject (notmuch-search-find-subject)))
     (if (> (length thread-id) 0)
@@ -479,8 +479,7 @@ Complete list of currently available key bindings:
  (concat "*"
  (truncate-string-to-width subject 32 nil nil t)
  "*")
- 32 nil nil t))
-      crypto-switch)
+ 32 nil nil t)))
       (message "End of search results."))))
 
 (defun notmuch-search-reply-to-thread (&optional prompt-for-sender)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 2/3 v2] emacs: Allow `notmuch-show-mode' to display only matching messages.

In reply to this post by David Edmondson
The current behaviour (all messages shown, non-matching collapsed)
is retained as the default. Type '!' to switch to showing only
the matching messages - non-matching messages are not available.
'!' will switch back to showing everything.
---
 emacs/notmuch-show.el |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 53f6ae4..99478a4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -135,6 +135,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 (put 'notmuch-show-process-crypto 'permanent-local t)
 
+(defvar notmuch-show-elide-non-matching-messages nil)
+(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -922,11 +926,22 @@ current buffer, if possible."
      "Not processing cryptographic MIME parts."))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-elide-non-matching ()
+  "Toggle the display of non-matching messages."
+  (interactive)
+  (setq notmuch-show-elide-non-matching-messages (not notmuch-show-elide-non-matching-messages))
+  (message (if notmuch-show-elide-non-matching-messages
+       "Showing matching messages only."
+     "Showing all messages."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
  (replies (cadr tree)))
-    (notmuch-show-insert-msg msg depth)
+    (if (or (not notmuch-show-elide-non-matching-messages)
+    (plist-get msg :match))
+ (notmuch-show-insert-msg msg depth))
     (notmuch-show-insert-thread replies (1+ depth))))
 
 (defun notmuch-show-insert-thread (thread depth)
@@ -1079,6 +1094,7 @@ Refreshes the current view, observing changes in cryptographic preferences."
  (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
  (define-key map (kbd "RET") 'notmuch-show-toggle-message)
  (define-key map "#" 'notmuch-show-print-message)
+ (define-key map "!" 'notmuch-show-toggle-elide-non-matching)
  (define-key map "$" 'notmuch-show-toggle-process-crypto)
  map)
       "Keymap for \"notmuch show\" buffers.")
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 3/3 v2] emacs: Allow the indentation of content to be toggled.

In reply to this post by David Edmondson
Very deeply indented content is sometimes difficult to
read (particular for something like patches). Allow the indentation of
the content to be toggled with '<'.

Indentation of the header lines is not affected, so it remains
possible to see the structure of the thread.
---
 emacs/notmuch-show.el |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 99478a4..a2c4daf 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -139,6 +139,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
 (put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
 
+(defvar notmuch-show-indent-content t)
+(make-variable-buffer-local 'notmuch-show-indent-content)
+(put 'notmuch-show-indent-content 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -249,10 +253,12 @@ operation on the contents of the current buffer."
  (all (buffer-substring (notmuch-show-message-top)
  (notmuch-show-message-bottom)))
 
- (props (notmuch-show-get-message-properties)))
+ (props (notmuch-show-get-message-properties))
+ (indenting notmuch-show-indent-content))
     (with-temp-buffer
       (insert all)
-      (indent-rigidly (point-min) (point-max) (- depth))
+      (if indenting
+  (indent-rigidly (point-min) (point-max) (- depth)))
       ;; Remove the original header.
       (goto-char (point-min))
       (re-search-forward "^$" (point-max) nil)
@@ -880,7 +886,8 @@ current buffer, if possible."
     (setq notmuch-show-previous-subject bare-subject)
 
     (setq body-start (point-marker))
-    (notmuch-show-insert-body msg (plist-get msg :body) depth)
+    (notmuch-show-insert-body msg (plist-get msg :body)
+      (if notmuch-show-indent-content depth 0))
     ;; Ensure that the body ends with a newline.
     (unless (bolp)
       (insert "\n"))
@@ -888,7 +895,8 @@ current buffer, if possible."
     (setq content-end (point-marker))
 
     ;; Indent according to the depth in the thread.
-    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
+    (if notmuch-show-indent-content
+ (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth)))
 
     (setq message-end (point-max-marker))
 
@@ -935,6 +943,15 @@ current buffer, if possible."
      "Showing all messages."))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-thread-indentation ()
+  "Toggle the indentation of threads."
+  (interactive)
+  (setq notmuch-show-indent-content (not notmuch-show-indent-content))
+  (message (if notmuch-show-indent-content
+       "Content is indented."
+     "Content is not indented."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -1096,6 +1113,7 @@ Refreshes the current view, observing changes in cryptographic preferences."
  (define-key map "#" 'notmuch-show-print-message)
  (define-key map "!" 'notmuch-show-toggle-elide-non-matching)
  (define-key map "$" 'notmuch-show-toggle-process-crypto)
+ (define-key map "<" 'notmuch-show-toggle-thread-indentation)
  map)
       "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 0/5 v3] reworked crypto toggle, plus a few other toggles

In reply to this post by David Edmondson
v3:
 - Add a toggle for line truncation (>).
 - Retain the state of a show buffer across a call to refresh (which
   includes the various toggles here).

David Edmondson (5):
  emacs: Rework crypto switch toggle.
  emacs: Allow `notmuch-show-mode' to display only matching messages.
  emacs: Allow the indentation of content to be toggled.
  emacs: Add a binding (>) to toggle the truncation of long lines.
  emacs: Retain the state of the buffer during
    `notmuch-show-refresh-view'.

 emacs/notmuch-show.el |  183 +++++++++++++++++++++++++++++++++----------------
 emacs/notmuch.el      |    7 +-
 2 files changed, 126 insertions(+), 64 deletions(-)

--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 1/5] emacs: Rework crypto switch toggle.

Re-work the existing crypto switch toggle to be based on a persistant
buffer-local variable.

To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
in the current buffer rather than killing the current buffer and
creating a new one. (This will also allow more per-buffer behaviour in
future patches.)

Add a binding ('$') to toggle crypto processing of the current buffer
and remove the prefix argument approach that achieves a similar
result.
---
 emacs/notmuch-show.el |  105 +++++++++++++++++++++++-------------------------
 emacs/notmuch.el      |    7 +--
 2 files changed, 53 insertions(+), 59 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 84ac624..53f6ae4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -124,6 +124,17 @@ indentation."
  (const :tag "View interactively"
  notmuch-show-interactively-view-part)))
 
+(defvar notmuch-show-thread-id nil)
+(make-variable-buffer-local 'notmuch-show-thread-id)
+(defvar notmuch-show-parent-buffer nil)
+(make-variable-buffer-local 'notmuch-show-parent-buffer)
+(defvar notmuch-show-query-context nil)
+(make-variable-buffer-local 'notmuch-show-query-context)
+
+(defvar notmuch-show-process-crypto nil)
+(make-variable-buffer-local 'notmuch-show-process-crypto)
+(put 'notmuch-show-process-crypto 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -410,14 +421,11 @@ message at DEPTH in the current thread."
 
 (defmacro notmuch-with-temp-part-buffer (message-id nth &rest body)
   (declare (indent 2))
-  (let ((process-crypto (make-symbol "process-crypto")))
-    `(let ((,process-crypto notmuch-show-process-crypto))
-       (with-temp-buffer
- (setq notmuch-show-process-crypto ,process-crypto)
- ;; Always acquires the part via `notmuch part', even if it is
- ;; available in the JSON output.
- (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
- ,@body))))
+  `(with-temp-buffer
+     ;; Always acquires the part via `notmuch part', even if it is
+     ;; available in the JSON output.
+     (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
+     ,@body))
 
 (defun notmuch-show-save-part (message-id nth &optional filename content-type)
   (notmuch-with-temp-part-buffer message-id nth
@@ -599,7 +607,7 @@ current buffer, if possible."
        (sigstatus (car (plist-get part :sigstatus))))
   (notmuch-crypto-insert-sigstatus-button sigstatus from))
       ;; if we're not adding sigstatus, tell the user how they can get it
-      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))
+      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))
 
   (let ((inner-parts (plist-get part :content))
  (start (point)))
@@ -625,7 +633,7 @@ current buffer, if possible."
      (sigstatus (car (plist-get part :sigstatus))))
  (notmuch-crypto-insert-sigstatus-button sigstatus from))))
       ;; if we're not adding encstatus, tell the user how they can get it
-      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")))
+      (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))
 
   (let ((inner-parts (plist-get part :content))
  (start (point)))
@@ -752,8 +760,6 @@ current buffer, if possible."
 
 ;; Helper for parts which are generally not included in the default
 ;; JSON output.
-;; Uses the buffer-local variable notmuch-show-process-crypto to
-;; determine if parts should be decrypted first.
 (defun notmuch-show-get-bodypart-internal (message-id part-number)
   (let ((args '("show" "--format=raw"))
  (part-arg (format "--part=%s" part-number)))
@@ -907,6 +913,15 @@ current buffer, if possible."
     ;; criteria.
     (notmuch-show-message-visible msg (plist-get msg :match))))
 
+(defun notmuch-show-toggle-process-crypto ()
+  "Toggle the processing of cryptographic MIME parts."
+  (interactive)
+  (setq notmuch-show-process-crypto (not notmuch-show-process-crypto))
+  (message (if notmuch-show-process-crypto
+       "Processing cryptographic MIME parts."
+     "Not processing cryptographic MIME parts."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -922,15 +937,6 @@ current buffer, if possible."
   "Insert the forest of threads FOREST."
   (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))
 
-(defvar notmuch-show-thread-id nil)
-(make-variable-buffer-local 'notmuch-show-thread-id)
-(defvar notmuch-show-parent-buffer nil)
-(make-variable-buffer-local 'notmuch-show-parent-buffer)
-(defvar notmuch-show-query-context nil)
-(make-variable-buffer-local 'notmuch-show-query-context)
-(defvar notmuch-show-buffer-name nil)
-(make-variable-buffer-local 'notmuch-show-buffer-name)
-
 (defun notmuch-show-buttonise-links (start end)
   "Buttonise URLs and mail addresses between START and END.
 
@@ -950,7 +956,7 @@ a corresponding notmuch search."
  'face goto-address-mail-face))))
 
 ;;;###autoload
-(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
+(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)
   "Run \"notmuch show\" with the given thread ID and display results.
 
 The optional PARENT-BUFFER is the notmuch-search buffer from
@@ -965,24 +971,20 @@ non-nil.
 The optional BUFFER-NAME provides the name of the buffer in
 which the message thread is shown. If it is nil (which occurs
 when the command is called interactively) the argument to the
-function is used.
-
-The optional CRYPTO-SWITCH toggles the value of the
-notmuch-crypto-process-mime customization variable for this show
-buffer."
+function is used."
   (interactive "sNotmuch show: ")
-  (let* ((process-crypto (if crypto-switch
-     (not notmuch-crypto-process-mime)
-   notmuch-crypto-process-mime)))
-    (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))
-
-(defun notmuch-show-worker (thread-id parent-buffer query-context buffer-name process-crypto)
-  (let* ((buffer-name (generate-new-buffer-name
-       (or buffer-name
-   (concat "*notmuch-" thread-id "*"))))
- (buffer (get-buffer-create buffer-name))
- (inhibit-read-only t))
-    (switch-to-buffer buffer)
+  (let ((buffer-name (generate-new-buffer-name
+      (or buffer-name
+  (concat "*notmuch-" thread-id "*")))))
+    (switch-to-buffer (get-buffer-create buffer-name))
+    ;; Set the default value for `notmuch-show-process-crypto' in this
+    ;; buffer.
+    (setq notmuch-show-process-crypto notmuch-crypto-process-mime)
+    (notmuch-show-worker thread-id parent-buffer query-context)))
+
+(defun notmuch-show-worker (thread-id parent-buffer query-context)
+  (let ((inhibit-read-only t))
+
     (notmuch-show-mode)
     ;; Don't track undo information for this buffer
     (set 'buffer-undo-list t)
@@ -990,8 +992,6 @@ buffer."
     (setq notmuch-show-thread-id thread-id)
     (setq notmuch-show-parent-buffer parent-buffer)
     (setq notmuch-show-query-context query-context)
-    (setq notmuch-show-buffer-name buffer-name)
-    (setq notmuch-show-process-crypto process-crypto)
 
     (erase-buffer)
     (goto-char (point-min))
@@ -1021,21 +1021,15 @@ buffer."
 
     (notmuch-show-mark-read)))
 
-(defun notmuch-show-refresh-view (&optional crypto-switch)
-  "Refresh the current view (with crypto switch if prefix given).
+(defun notmuch-show-refresh-view ()
+  "Refresh the current view.
 
-Kills the current buffer and reruns notmuch show with the same
-thread id.  If a prefix is given, crypto processing is toggled."
-  (interactive "P")
-  (let ((thread-id notmuch-show-thread-id)
- (parent-buffer notmuch-show-parent-buffer)
- (query-context notmuch-show-query-context)
- (buffer-name notmuch-show-buffer-name)
- (process-crypto (if crypto-switch
-    (not notmuch-show-process-crypto)
-  notmuch-show-process-crypto)))
-    (notmuch-kill-this-buffer)
-    (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))
+Refreshes the current view, observing changes in cryptographic preferences."
+  (interactive)
+  (let ((inhibit-read-only t))
+    (erase-buffer))
+  (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
+       notmuch-show-query-context))
 
 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
@@ -1085,6 +1079,7 @@ thread id.  If a prefix is given, crypto processing is toggled."
  (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
  (define-key map (kbd "RET") 'notmuch-show-toggle-message)
  (define-key map "#" 'notmuch-show-print-message)
+ (define-key map "$" 'notmuch-show-toggle-process-crypto)
  map)
       "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 72f78ed..9d8bebd 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -463,9 +463,9 @@ Complete list of currently available key bindings:
   "Return a list of authors for the current region"
   (notmuch-search-properties-in-region 'notmuch-search-subject beg end))
 
-(defun notmuch-search-show-thread (&optional crypto-switch)
+(defun notmuch-search-show-thread ()
   "Display the currently selected thread."
-  (interactive "P")
+  (interactive)
   (let ((thread-id (notmuch-search-find-thread-id))
  (subject (notmuch-search-find-subject)))
     (if (> (length thread-id) 0)
@@ -479,8 +479,7 @@ Complete list of currently available key bindings:
  (concat "*"
  (truncate-string-to-width subject 32 nil nil t)
  "*")
- 32 nil nil t))
-      crypto-switch)
+ 32 nil nil t)))
       (message "End of search results."))))
 
 (defun notmuch-search-reply-to-thread (&optional prompt-for-sender)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 2/5] emacs: Allow `notmuch-show-mode' to display only matching messages.

In reply to this post by David Edmondson
The current behaviour (all messages shown, non-matching collapsed)
is retained as the default. Type '!' to switch to showing only
the matching messages - non-matching messages are not available.
'!' will switch back to showing everything.
---
 emacs/notmuch-show.el |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 53f6ae4..99478a4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -135,6 +135,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 (put 'notmuch-show-process-crypto 'permanent-local t)
 
+(defvar notmuch-show-elide-non-matching-messages nil)
+(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -922,11 +926,22 @@ current buffer, if possible."
      "Not processing cryptographic MIME parts."))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-elide-non-matching ()
+  "Toggle the display of non-matching messages."
+  (interactive)
+  (setq notmuch-show-elide-non-matching-messages (not notmuch-show-elide-non-matching-messages))
+  (message (if notmuch-show-elide-non-matching-messages
+       "Showing matching messages only."
+     "Showing all messages."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
  (replies (cadr tree)))
-    (notmuch-show-insert-msg msg depth)
+    (if (or (not notmuch-show-elide-non-matching-messages)
+    (plist-get msg :match))
+ (notmuch-show-insert-msg msg depth))
     (notmuch-show-insert-thread replies (1+ depth))))
 
 (defun notmuch-show-insert-thread (thread depth)
@@ -1079,6 +1094,7 @@ Refreshes the current view, observing changes in cryptographic preferences."
  (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
  (define-key map (kbd "RET") 'notmuch-show-toggle-message)
  (define-key map "#" 'notmuch-show-print-message)
+ (define-key map "!" 'notmuch-show-toggle-elide-non-matching)
  (define-key map "$" 'notmuch-show-toggle-process-crypto)
  map)
       "Keymap for \"notmuch show\" buffers.")
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 3/5] emacs: Allow the indentation of content to be toggled.

In reply to this post by David Edmondson
Very deeply indented content is sometimes difficult to
read (particular for something like patches). Allow the indentation of
the content to be toggled with '<'.

Indentation of the header lines is not affected, so it remains
possible to see the structure of the thread.
---
 emacs/notmuch-show.el |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 99478a4..a2c4daf 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -139,6 +139,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
 (put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
 
+(defvar notmuch-show-indent-content t)
+(make-variable-buffer-local 'notmuch-show-indent-content)
+(put 'notmuch-show-indent-content 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -249,10 +253,12 @@ operation on the contents of the current buffer."
  (all (buffer-substring (notmuch-show-message-top)
  (notmuch-show-message-bottom)))
 
- (props (notmuch-show-get-message-properties)))
+ (props (notmuch-show-get-message-properties))
+ (indenting notmuch-show-indent-content))
     (with-temp-buffer
       (insert all)
-      (indent-rigidly (point-min) (point-max) (- depth))
+      (if indenting
+  (indent-rigidly (point-min) (point-max) (- depth)))
       ;; Remove the original header.
       (goto-char (point-min))
       (re-search-forward "^$" (point-max) nil)
@@ -880,7 +886,8 @@ current buffer, if possible."
     (setq notmuch-show-previous-subject bare-subject)
 
     (setq body-start (point-marker))
-    (notmuch-show-insert-body msg (plist-get msg :body) depth)
+    (notmuch-show-insert-body msg (plist-get msg :body)
+      (if notmuch-show-indent-content depth 0))
     ;; Ensure that the body ends with a newline.
     (unless (bolp)
       (insert "\n"))
@@ -888,7 +895,8 @@ current buffer, if possible."
     (setq content-end (point-marker))
 
     ;; Indent according to the depth in the thread.
-    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
+    (if notmuch-show-indent-content
+ (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth)))
 
     (setq message-end (point-max-marker))
 
@@ -935,6 +943,15 @@ current buffer, if possible."
      "Showing all messages."))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-thread-indentation ()
+  "Toggle the indentation of threads."
+  (interactive)
+  (setq notmuch-show-indent-content (not notmuch-show-indent-content))
+  (message (if notmuch-show-indent-content
+       "Content is indented."
+     "Content is not indented."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -1096,6 +1113,7 @@ Refreshes the current view, observing changes in cryptographic preferences."
  (define-key map "#" 'notmuch-show-print-message)
  (define-key map "!" 'notmuch-show-toggle-elide-non-matching)
  (define-key map "$" 'notmuch-show-toggle-process-crypto)
+ (define-key map "<" 'notmuch-show-toggle-thread-indentation)
  map)
       "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 4/5] emacs: Add a binding (>) to toggle the truncation of long lines.

In reply to this post by David Edmondson
---
 emacs/notmuch-show.el |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index a2c4daf..8b07adf 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1114,6 +1114,7 @@ Refreshes the current view, observing changes in cryptographic preferences."
  (define-key map "!" 'notmuch-show-toggle-elide-non-matching)
  (define-key map "$" 'notmuch-show-toggle-process-crypto)
  (define-key map "<" 'notmuch-show-toggle-thread-indentation)
+ (define-key map ">" 'toggle-truncate-lines)
  map)
       "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 5/5] emacs: Retain the state of the buffer during `notmuch-show-refresh-view'.

In reply to this post by David Edmondson
Record the state of the buffer during `notmuch-show-refresh-view'.

In this context, "state" is defined as:
 - the open/closed state of each message,
 - the current message.
---
 emacs/notmuch-show.el |   41 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8b07adf..a77cd52 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1053,15 +1053,48 @@ function is used."
 
     (notmuch-show-mark-read)))
 
+(defun notmuch-show-capture-state ()
+  "Capture the state of the current buffer.
+
+This includes:
+ - the list of open messages,
+ - the current message."
+  (list (notmuch-show-get-message-id) (notmuch-show-get-message-ids-for-open-messages)))
+
+(defun notmuch-show-apply-state (state)
+  "Apply STATE to the current buffer.
+
+This includes:
+ - opening the messages previously opened,
+ - closing all other messages,
+ - moving to the correct current message."
+  (let ((current (car state))
+ (open (cadr state)))
+
+    ;; Open those that were open.
+    (goto-char (point-min))
+    (loop do (notmuch-show-message-visible (notmuch-show-get-message-properties)
+   (member (notmuch-show-get-message-id) open))
+  until (not (notmuch-show-goto-message-next)))
+
+    ;; Go to the previously open message.
+    (goto-char (point-min))
+    (unless (loop if (string= current (notmuch-show-get-message-id))
+  return t
+  until (not (notmuch-show-goto-message-next)))
+      (message "Previously current message not found."))))
+
 (defun notmuch-show-refresh-view ()
   "Refresh the current view.
 
 Refreshes the current view, observing changes in cryptographic preferences."
   (interactive)
-  (let ((inhibit-read-only t))
-    (erase-buffer))
-  (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
-       notmuch-show-query-context))
+  (let ((inhibit-read-only t)
+ (state (notmuch-show-capture-state)))
+    (erase-buffer)
+    (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
+ notmuch-show-query-context)
+    (notmuch-show-apply-state state)))
 
 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 3/3] emacs: Allow the indentation of content to be toggled.

In reply to this post by Mark Walters
On Sun, 29 Jan 2012 22:30:42 +0000, Mark Walters <[hidden email]> wrote:
> I really like the feature and would definitely use it. However, I have a
> couple of niggles with the implementation. First, when toggled it seems
> to redisplay so it jumps back to the first matching message regardless
> of where you are in the thread (and closes messages you have opened).

v3 is supposed to address this. Please test.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
1234
Loading...