[mew-int 2908] Re: Wish for mew-use-format-flowed

Christophe TROESTLER <[email protected]> Tue, 24 Aug 2010 10:19:24 +0200 (CEST)
Newsgroups gmane.mail.mew.general
Organization Universite de Mons (http://math.umons.ac.be/an/)
Message-ID <20100824.101924.1044883581491875730.Christophe.Troestler@umons.ac.be>
On Tue, 24 Aug 2010 10:04:49 +0900, Kazu Yamamoto wrote:
> 
> > Thanks!  Your code was a good basis to push me to investigate further
> > but it does not work.  To make it work, I had to use
> > mew-tinfo-set-use-flowed.  Also running mew-draft-mode-name toggle the
> > "F" in the mode line which is a nice visual feedback.  Since I will
> > seldom use it, I also wanted an entry menu (there is a high risk I
> > forget the shortcut).  So, eventually, here is the code I ended up
> > with:
> 
> Christophe, would you like merge this to the main stream?

Here is a tentative patch.  Tell me what you think.

Best,
Christophe
mew.patch (text/x-patch, 1.6 KB)
=== modified file 'mew-draft.el'
--- old/mew-draft.el	2010-01-05 06:35:39 +0000
+++ new/mew-draft.el	2010-08-24 08:14:23 +0000
@@ -604,6 +604,30 @@
       (mew-draft-rehighlight)
       (setq buffer-undo-list nil))))
 
+(defun mew-draft-use-format-flowed (&optional arg)
+  "Toggle the use of format=flowed for the current draft.
+If called with '\\[universal-argument]', enable format=flowed iff the argument
+is positive.  You can use `mew-draft-use-format-flowed-hooks' to 
+enable interesting minor modes according to whether the message is
+flowed or not.  Here is an example:
+
+\(add-hook 'mew-draft-use-format-flowed-hooks
+     '(lambda()
+	(if mew-use-format-flowed
+	    (progn
+	      (auto-fill-mode 0)
+	      (setq word-wrap t))
+	  (auto-fill-mode 1))
+	))"
+  (interactive "P")
+  (set (make-local-variable 'mew-use-format-flowed)
+       (if (null arg)
+	   (not (mew-use-format-flowed))
+	 (> (prefix-numeric-value arg) 0)))
+  (mew-tinfo-set-use-flowed mew-use-format-flowed)
+  (mew-draft-mode-name); Display "F" iff Flowed
+  (run-hooks 'mew-draft-use-format-flowed-hooks))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; Misc

=== modified file 'mew-key.el'
--- old/mew-key.el	2010-05-20 14:17:28 +0000
+++ new/mew-key.el	2010-08-24 07:16:15 +0000
@@ -429,6 +429,8 @@
    "Mew"
    ["Cite"                mew-draft-cite t]
    ["Cite without Label"  mew-draft-yank t]
+   ["Flowed"              mew-draft-use-format-flowed :style toggle
+    :selected mew-use-format-flowed]
    mew-draft-mode-toolbar-menu
    ["Queue Message"       mew-draft-make-message        t]
    ["Send Message"        mew-draft-send-message        t]
mew1.patch (text/x-patch, 3.9 KB)
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: [email protected]\
#   1vwuwfy15vcp1i7j
# target_branch: file:///home/trch/software/mew/trunk/
# testament_sha1: 26ae25b213ec3764bf834d07c1109bbf0b7dad2a
# timestamp: 2010-08-24 10:18:13 +0200
# base_revision_id: git-v1:51a9b9bdaf1c22a12672fa02853daa7ae30f1ce1
# 
# Begin patch
=== modified file 'mew-draft.el'
--- mew-draft.el	2010-01-05 06:35:39 +0000
+++ mew-draft.el	2010-08-24 08:16:54 +0000
@@ -604,6 +604,30 @@
       (mew-draft-rehighlight)
       (setq buffer-undo-list nil))))
 
+(defun mew-draft-use-format-flowed (&optional arg)
+  "Toggle the use of format=flowed for the current draft.
+If called with '\\[universal-argument]', enable format=flowed iff the argument
+is positive.  You can use `mew-draft-use-format-flowed-hooks' to 
+enable interesting minor modes according to whether the message is
+flowed or not.  Here is an example:
+
+\(add-hook 'mew-draft-use-format-flowed-hooks
+     '(lambda()
+	(if mew-use-format-flowed
+	    (progn
+	      (auto-fill-mode 0)
+	      (setq word-wrap t))
+	  (auto-fill-mode 1))
+	))"
+  (interactive "P")
+  (set (make-local-variable 'mew-use-format-flowed)
+       (if (null arg)
+	   (not (mew-use-format-flowed))
+	 (> (prefix-numeric-value arg) 0)))
+  (mew-tinfo-set-use-flowed mew-use-format-flowed)
+  (mew-draft-mode-name); Display "F" iff Flowed
+  (run-hooks 'mew-draft-use-format-flowed-hooks))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; Misc

=== modified file 'mew-key.el'
--- mew-key.el	2010-05-20 14:17:28 +0000
+++ mew-key.el	2010-08-24 08:16:54 +0000
@@ -429,6 +429,8 @@
    "Mew"
    ["Cite"                mew-draft-cite t]
    ["Cite without Label"  mew-draft-yank t]
+   ["Flowed"              mew-draft-use-format-flowed :style toggle
+    :selected mew-use-format-flowed]
    mew-draft-mode-toolbar-menu
    ["Queue Message"       mew-draft-make-message        t]
    ["Send Message"        mew-draft-send-message        t]

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWTWYbuQAAmffgHgwUef//19g
1C7////wUAWt1a8HQW3FFbJ2AQyQmgmTE1TzU2NAp6o8o9J+qab1T1ANpGgGhzAEYJiAYBME0ZDQ
wCYIxMNNJpolNlHtQ1GjIAAAAAAAAkSJpJ6Kfqnoh+kekymaIaGIyaZBjU9RtBMJJCZMTQmII0g9
QmgPU8kYTI0APSaNBaAPd0kJsrsvPbB4dO8I+/8vxqtTaglS+4wYMvumIKbYiuVb1awf4adpCYCi
JkYEGiqCUgRYF/cC+frRrqqGO2BvTfBaaS4abbsyZtSspho1BfUfGUmTZuY/ngpbeIN2EaQgI/S2
70L7CvFnzYZ0QqeplFh70kC7LAta1sK5lOPBGw96w792L9H5uDSbvEfCO3pU8+pyG0Gm/tzeIsTx
7lZ6ZrDkJ0QNntqEqCpaKwqYvg9y8zNcV8toEAZvFBvmJTaTEYjQxyqU6Eo+Xlg4q6NjTTMjvvo+
5p2wdmgvQRiMNADiYwedC+5LuYNuDl63gfQgaGH2HRQ7yh4aOQXjgMbEESWpheU+GMR1HTWSZijM
53juA92PExmevUfD3GxXNUrpq5t24+IX5zBxp+GLypyAkBn+Tj8bH/I4FjTZPNhMR1XBtC2gH5ga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