changeset 66995:e10f2e7919f0

Add hacks for citation in mail-mode and message-mode.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 18 Nov 2005 19:40:35 +0000
parents f7e79cfcfc4f
children cf7bf8dadf78
files lisp/ChangeLog lisp/longlines.el
diffstat 2 files changed, 25 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Nov 18 19:11:19 2005 +0000
+++ b/lisp/ChangeLog	Fri Nov 18 19:40:35 2005 +0000
@@ -1,3 +1,8 @@
+2005-11-18  Chong Yidong  <cyd@stupidchicken.com>
+
+	* longlines.el (longlines-mode): Add hacks for mail-mode and
+	message-mode.
+
 2005-11-18  Carsten Dominik  <dominik@science.uva.nl>
 
 	* textmodes/org.el: (org-table-sort-lines): New command.
--- a/lisp/longlines.el	Fri Nov 18 19:11:19 2005 +0000
+++ b/lisp/longlines.el	Fri Nov 18 19:40:35 2005 +0000
@@ -137,7 +137,21 @@
           (add-hook 'after-change-functions
                     'longlines-after-change-function nil t)
           (add-hook 'post-command-hook
-                    'longlines-post-command-function nil t)))
+                    'longlines-post-command-function nil t))
+
+	;; Hacks to make longlines play nice with various modes.
+	(cond ((eq major-mode 'mail-mode)
+	       (or mail-citation-hook
+		   (add-hook 'mail-citation-hook 'mail-indent-citation nil t))
+	       (add-hook 'mail-citation-hook 'longlines-decode-region nil t))
+	      ((eq major-mode 'message-mode)
+	       (make-local-variable 'message-indent-citation-function)
+	       (if (not (listp message-indent-citation-function))
+		   (setq message-indent-citation-function
+			 (list message-indent-citation-function)))
+	       (add-to-list 'message-indent-citation-function
+			    'longlines-decode-region t)))
+	)
     ;; Turn off longlines mode
     (setq buffer-file-format (delete 'longlines buffer-file-format))
     (if longlines-showing
@@ -298,8 +312,11 @@
                    (1+ (current-column)))
                  space))))))
 
-(defun longlines-decode-region (beg end)
-  "Turn all newlines between BEG and END into hard newlines."
+(defun longlines-decode-region (&optional beg end)
+  "Turn all newlines between BEG and END into hard newlines.
+If BEG and END are nil, the point and mark are used."
+  (if (null beg) (setq beg (point)))
+  (if (null end) (setq end (mark t)))
   (save-excursion
     (goto-char (min beg end))
     (while (search-forward "\n" (max beg end) t)