1 ;; jabber-truncate.el - cleanup top lines in chatbuffers -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2007 - Kirill A. Korinskiy - catap@catap.ru
5 ;; This file is a part of jabber.el.
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2 of the License, or
10 ;; (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; if not, write to the Free Software
19 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 (require 'jabber-chat)
22 (require 'jabber-alert)
26 (defvar jabber-log-lines-to-keep 1000
27 "Maximum number of lines in chat buffer.")
29 (defun jabber-truncate-top (buffer &optional ewoc)
30 "Clean old history from a chat BUFFER.
31 Optional EWOC is ewoc-widget to work. Default is
32 `jabber-chat-ewoc'. `jabber-log-lines-to-keep' specifies the
33 number of lines to keep.
35 Note that this might interfere with
36 `jabber-chat-display-more-backlog': you ask for more history, you
37 get it, and then it just gets deleted."
39 (let* ((inhibit-read-only t)
40 (work-ewoc (if ewoc ewoc jabber-chat-ewoc))
42 ;; go back one node, to make this function "idempotent"
45 (ewoc-locate work-ewoc
48 (goto-char (point-max))
49 (forward-line (- jabber-log-lines-to-keep))
54 (ewoc-prev work-ewoc delete-before)
55 (ewoc-delete work-ewoc delete-before))))))
57 (defun jabber-truncate-muc (nick group buffer text proposed-alert)
58 "Clean old history from MUC buffers.
59 `jabber-log-lines-to-keep' specifies the number of lines to
61 (jabber-truncate-top buffer))
63 (defun jabber-truncate-chat (from buffer text proposed-alert)
64 "Clean old history from chat buffers.
65 `jabber-log-lines-to-keep' specifies the number of lines to
68 Note that this might interfer with
69 `jabber-chat-display-more-backlog': you ask for more history, you
70 get it, and then it just gets deleted."
71 (jabber-truncate-top buffer))
73 (provide 'jabber-truncate)
75 ;; arch-tag: 3d1e3428-f598-11db-a314-000a95c2fcd0