Commits

Aidan Kehoe committed d56da29

Fix a couple of ERC bugs, thank you Johann Myrkraverk Oskarsson.

ChangeLog addition:

2013-08-03 Aidan Kehoe <kehoea@parhasard.net>

* erc-log.el (erc-log-setup-logging):
Avoid attempting to insert at a negative offset if the log file is
smaller than erc-max-buffer-size; patch from Johann 'Myrkraverk'
Oskarsson <myrkraverk@gmail.com>, thank you Johann.
* erc-goodies.el (erc-make-read-only):
Avoid making the input buffer, or its prefix, read-only on
truncating. Also from Johann, thank you Johann.

Comments (0)

Files changed (3)

+2013-08-03  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* erc-log.el (erc-log-setup-logging):
+	Avoid attempting to insert at a negative offset if the log file is
+	smaller than erc-max-buffer-size; patch from Johann 'Myrkraverk'
+	Oskarsson <myrkraverk@gmail.com>, thank you Johann.
+	* erc-goodies.el (erc-make-read-only):
+	Avoid making the input buffer, or its prefix, read-only on
+	truncating. Also from Johann, thank you Johann.
+
 2009-09-15  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 0.23 released.
 (defun erc-make-read-only ()
   "Make all the text in the current buffer read-only.
 Put this function on `erc-insert-post-hook' and/or `erc-send-post-hook'."
-  (put-text-property (point-min) (point-max) 'read-only t)
-  (put-text-property (point-min) (point-max) 'front-sticky t)
-  (put-text-property (point-min) (point-max) 'rear-nonsticky t))
+  (if (featurep 'xemacs)
+      (let ((extent (car (extent-list nil nil nil nil 'name 'erc-read-only))))
+        (cond (extent
+               ;; The buffer may be (or definitely is) narrowed to the
+               ;; recently inserted text, hence explicitly using 1 and not
+               ;; (point-min).
+               (set-extent-endpoints extent 1 erc-insert-marker))
+              (t
+               (setq extent (make-extent 1 erc-insert-marker))
+               (set-extent-property extent 'name 'erc-read-only)
+               (set-extent-property extent 'read-only t))))
+      (put-text-property (point-min) (point-max) 'read-only t)
+      (put-text-property (point-min) (point-max) 'front-sticky t)
+      (put-text-property (point-min) (point-max) 'rear-nonsticky t)))
 
 ;; Distinguish non-commands
 (defvar erc-noncommands-list '(erc-cmd-ME
              (start (if (and log-file-size
                              (memq 'erc-truncate-buffer
 				   erc-insert-post-hook))
-                        (- log-file-size erc-max-buffer-size)
+                        (max (- log-file-size erc-max-buffer-size) 0)
                       0)))
         (ignore-errors (insert-file-contents log-file nil start
                                              log-file-size))