]> code.delx.au - gnu-emacs/blobdiff - lisp/erc/erc-fill.el
ERC: Sync from upstream.
[gnu-emacs] / lisp / erc / erc-fill.el
index f945d838c2a6d38aa6e481b07809faae1ba33692..6ef5774fb87aef81310ac8de441581a27da68501 100644 (file)
@@ -1,6 +1,7 @@
 ;;; erc-fill.el --- Filling IRC messages in various ways
 
-;; Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2003, 2004, 2006,
+;;   2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Andreas Fuchs <asf@void.at>
 ;;         Mario Lang <mlang@delysid.org>
@@ -10,7 +11,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -122,7 +123,15 @@ characters. Set to nil to disable."
 You can put this on `erc-insert-modify-hook' and/or `erc-send-modify-hook'."
   (unless (erc-string-invisible-p (buffer-substring (point-min) (point-max)))
     (when erc-fill-function
-      (funcall erc-fill-function))))
+      ;; skip initial empty lines
+      (goto-char (point-min))
+      (save-match-data
+        (while (and (looking-at "[ \t\n]*$")
+                    (= (forward-line 1) 0))))
+      (unless (eobp)
+        (save-restriction
+          (narrow-to-region (point) (point-max))
+          (funcall erc-fill-function))))))
 
 (defun erc-fill-static ()
   "Fills a text such that messages start at column `erc-fill-static-center'."
@@ -179,14 +188,6 @@ You can put this on `erc-insert-modify-hook' and/or `erc-send-modify-hook'."
       (length (format-time-string erc-timestamp-format))
     0))
 
-(defun erc-restore-text-properties ()
-  "Restore the property 'erc-parsed for the region."
-  (let* ((parsed-posn (text-property-not-all (point-min) (point-max)
-                                             'erc-parsed nil))
-         (parsed-prop (when parsed-posn
-                        (get-text-property parsed-posn 'erc-parsed))))
-    (put-text-property (point-min) (point-max) 'erc-parsed parsed-prop)))
-
 (provide 'erc-fill)
 
 ;;; erc-fill.el ends here