diff options
author | defanor <defanor@uberspace.net> | 2021-04-03 22:13:48 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2021-04-03 22:13:48 +0300 |
commit | e63817acbe4d902235613e2d9563f9e2a39ab89d (patch) | |
tree | e95c9b31c5d2c6acecabc6b853f1ecc0da5f4fe5 | |
parent | 6956f33f4b594804b48511229971fae3421c9642 (diff) |
xmpp.el: truncate XMPP buffers
-rw-r--r-- | emacs/xmpp.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/emacs/xmpp.el b/emacs/xmpp.el index 40b43af..803d64f 100644 --- a/emacs/xmpp.el +++ b/emacs/xmpp.el @@ -74,6 +74,9 @@ "A subprocess request queue.") (make-variable-buffer-local 'xmpp-request-queue) +(defvar xmpp-truncate-buffer-at 100000 + "The buffer size at which to truncate an XMPP-related buffer by + approximately halving it.") (defun xmpp-jid-to-bare (jid) (let* ((jid-list (reverse (string-to-list jid))) @@ -290,6 +293,12 @@ (defun xmpp-insert (args) (save-excursion + (when (and xmpp-truncate-buffer-at + (> xmpp-input-point xmpp-truncate-buffer-at)) + (goto-char (/ xmpp-truncate-buffer-at 2)) + (search-forward "\n") + (setq xmpp-input-point (- xmpp-input-point (1- (point)))) + (delete-region (point-min) (point))) (goto-char xmpp-input-point) (funcall 'insert args) (setq-local xmpp-input-point (point))) |