unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Add configurable wrapping width for notmuch-wash-wrap-long-lines
@ 2012-02-17 18:34 Daniel Schoepe
  2012-02-17 18:46 ` David Edmondson
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Daniel Schoepe @ 2012-02-17 18:34 UTC (permalink / raw)
  To: notmuch

This introduces a variable to control after how many characters a line
is wrapped by notmuch-wash-wrap-long-lines (still wrapping at the
window width if it is lower).
---
 emacs/notmuch-wash.el |   36 ++++++++++++++++++++++++++----------
 1 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 56981d0..7d003a2 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -87,6 +87,14 @@ If there is one more line than the sum of
 `notmuch-wash-citation-lines-suffix', show that, otherwise
 collapse the remaining lines into a button.")
 
+(defvar notmuch-wash-wrap-lines-length nil
+  "Wrap line after at most this many characters.
+
+If this is nil, lines in messages will be wrapped to fit in the
+current window. If this is a number, lines will be wrapped after
+this many characters or at the window width (whichever one is
+lower).")
+
 (defun notmuch-wash-toggle-invisible-action (cite-button)
   (let ((invis-spec (button-get cite-button 'invisibility-spec)))
     (if (invisible-p invis-spec)
@@ -276,16 +284,24 @@ Perform several transformations on the message body:
 ;;
 
 (defun notmuch-wash-wrap-long-lines (msg depth)
-  "Wrap any long lines in the message to the width of the window.
-
-When doing so, maintaining citation leaders in the wrapped text."
-
-  (let ((coolj-wrap-follows-window-size nil)
-	(fill-column (- (window-width)
-			depth
-			;; 2 to avoid poor interaction with
-			;; `word-wrap'.
-			2)))
+  "Wrap long lines in the message.
+
+If `notmuch-wash-wrap-lines-length' is a number, this will wrap
+the message lines to the minimum of the width of the window or
+its value. Otherwise, this function will wrap long lines in the
+message at the window width. When doing so, citation leaders in
+the wrapped text are maintained."
+
+  (let* ((coolj-wrap-follows-window-size nil)
+	 (limit (if (numberp notmuch-wash-wrap-lines-length)
+		    (min notmuch-wash-wrap-lines-length
+			 (window-width))
+		  (window-width)))
+	 (fill-column (- limit
+			 depth
+			 ;; 2 to avoid poor interaction with
+			 ;; `word-wrap'.
+			 2)))
     (coolj-wrap-region (point-min) (point-max))))
 
 ;;
-- 
1.7.9

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-06-30  1:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-17 18:34 [PATCH] emacs: Add configurable wrapping width for notmuch-wash-wrap-long-lines Daniel Schoepe
2012-02-17 18:46 ` David Edmondson
2012-02-17 18:57   ` Daniel Schoepe
2012-04-15 17:39 ` Mark Walters
2012-04-18 15:30 ` Adam Wolfe Gordon
2012-04-18 15:46   ` Daniel Schoepe
2012-04-19 14:33     ` Adam Wolfe Gordon
2012-06-28  7:41 ` Albin Stjerna
2012-06-28  8:51   ` Daniel Schoepe
2012-06-30  1:41 ` David Bremner

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).