erc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Erc-commit] [commit][emacs22] erc-fill: Skip initial empty lines.


From: mwolson
Subject: [Erc-commit] [commit][emacs22] erc-fill: Skip initial empty lines.
Date: Sun, 14 Oct 2007 00:48:25 -0400

commit 05e10e6d90a28fea910cfa4ad90deef1d6f5cb63
Author: Michael Olson <address@hidden>
Date:   Sat Aug 12 02:14:08 2006 +0000

    erc-fill: Skip initial empty lines.
    
    * erc-fill.el (erc-fill): Skip any initial empty lines so that we avoid
      errors when inserting disconnect messages and other messages that begin
      with newlines.
    git-archimport-id: address@hidden/erc--main--0--patch-39

diff --git a/ChangeLog b/ChangeLog
index 95b10b1..38af6c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-08-11  Michael Olson  <address@hidden>
+
+       * erc-fill.el (erc-fill): Skip any initial empty lines so that we
+       avoid errors when inserting disconnect messages and other messages
+       that begin with newlines.
+
 2006-08-07  Michael Olson  <address@hidden>
 
        * erc-backend.el (erc-process-sentinel-1): Use erc-display-message
diff --git a/erc-fill.el b/erc-fill.el
index f945d83..d318864 100644
--- a/erc-fill.el
+++ b/erc-fill.el
@@ -122,7 +122,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'."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]