1 ;; jabber-truncate.el - cleanup top lines in chatbuffers
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 (eval-when-compile (require 'cl
))
24 (defvar jabber-log-lines-to-keep
1000
25 "Maximum number of lines in chat buffer")
27 (defun jabber-truncate-top ()
28 "Clean old history from a chat buffer.
29 `jabber-log-lines-to-keep' specifies the number of lines to
32 (let ((inhibit-read-only t
)
34 ;; go back one node, to make this function "idempotent"
37 (ewoc-locate jabber-chat-ewoc
39 (goto-char (point-max))
40 (forward-line (- jabber-log-lines-to-keep
))
45 (ewoc-prev jabber-chat-ewoc delete-before
)
46 (ewoc-delete jabber-chat-ewoc delete-before
))))))
48 (defun jabber-truncate-muc (nick group buffer text proposed-alert
)
49 "Clean old history from MUC buffers.
50 `jabber-log-lines-to-keep' specifies the number of lines to
52 (jabber-truncate-top))
54 (defun jabber-truncate-chat (from buffer text proposed-alert
)
55 "Clean old history from chat buffers.
56 `jabber-log-lines-to-keep' specifies the number of lines to
59 Note that this might interfer with
60 `jabber-chat-display-more-backlog': you ask for more history, you
61 get it, and then it just gets deleted."
62 (jabber-truncate-top))
64 (pushnew 'jabber-truncate-muc
(get 'jabber-alert-muc-hooks
'custom-options
))
65 (pushnew 'jabber-truncate-chat
(get 'jabber-alert-message-hooks
'custom-options
))
67 (provide 'jabber-truncate
)
69 ;; arch-tag: 3d1e3428-f598-11db-a314-000a95c2fcd0