From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/5] emacs: Allow the indentation of content to be toggled.
Date: Tue, 31 Jan 2012 08:46:58 +0000 [thread overview]
Message-ID: <1327999620-14595-4-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1327999620-14595-1-git-send-email-dme@dme.org>
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 77ba2dd..789b6d9 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -140,6 +140,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
@@ -250,10 +254,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)
@@ -881,7 +887,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"))
@@ -889,7 +896,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))
@@ -936,6 +944,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))
@@ -1098,6 +1115,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
next prev parent reply other threads:[~2012-01-31 8:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <id:"1327486729-18052-1-git-send-email-dme@dme.org">
2012-01-31 8:46 ` [PATCH 0/5 v4] reworked crypto toggle, plus a few other toggles David Edmondson
2012-01-31 8:46 ` [PATCH 1/5] emacs: Rework crypto switch toggle David Edmondson
2012-01-31 8:46 ` [PATCH 2/5] emacs: Allow `notmuch-show-mode' to display only matching messages David Edmondson
2012-01-31 8:46 ` David Edmondson [this message]
2012-01-31 16:15 ` [PATCH 3/5] emacs: Allow the indentation of content to be toggled Mark Walters
2012-01-31 16:23 ` David Edmondson
2012-01-31 23:50 ` Mark Walters
2012-02-01 8:52 ` Tomi Ollila
2012-01-31 8:46 ` [PATCH 4/5] emacs: Add a binding (>) to toggle the truncation of long lines David Edmondson
2012-01-31 8:47 ` [PATCH 5/5] emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view' David Edmondson
2012-01-31 8:55 ` [PATCH 0/5 v4] reworked crypto toggle, plus a few other toggles David Edmondson
2012-01-25 10:18 [PATCH 0/3] reworked crypto toggle, plus a couple of " David Edmondson
2012-01-30 16:30 ` [PATCH 0/5 v3] reworked crypto toggle, plus a few " David Edmondson
2012-01-30 16:31 ` [PATCH 3/5] emacs: Allow the indentation of content to be toggled David Edmondson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327999620-14595-4-git-send-email-dme@dme.org \
--to=dme@dme.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).