]> crepu.dev Git - config.git/blob - djavu-asus/elpa/jabber-20230715.456/jabber-truncate.el
Archivo de configuraciĆ³n de la terminal
[config.git] / djavu-asus / elpa / jabber-20230715.456 / jabber-truncate.el
1 ;; jabber-truncate.el - cleanup top lines in chatbuffers -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2007 - Kirill A. Korinskiy - catap@catap.ru
4
5 ;; This file is a part of jabber.el.
6
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.
11
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.
16
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
20
21 (require 'jabber-chat)
22 (require 'jabber-alert)
23
24 (require 'cl-lib)
25
26 (defvar jabber-log-lines-to-keep 1000
27 "Maximum number of lines in chat buffer.")
28
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.
34
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."
38 (interactive)
39 (let* ((inhibit-read-only t)
40 (work-ewoc (if ewoc ewoc jabber-chat-ewoc))
41 (delete-before
42 ;; go back one node, to make this function "idempotent"
43 (ewoc-prev
44 work-ewoc
45 (ewoc-locate work-ewoc
46 (save-excursion
47 (set-buffer buffer)
48 (goto-char (point-max))
49 (forward-line (- jabber-log-lines-to-keep))
50 (point))))))
51 (while delete-before
52 (setq delete-before
53 (prog1
54 (ewoc-prev work-ewoc delete-before)
55 (ewoc-delete work-ewoc delete-before))))))
56
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
60 keep."
61 (jabber-truncate-top buffer))
62
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
66 keep.
67
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))
72
73 (provide 'jabber-truncate)
74
75 ;; arch-tag: 3d1e3428-f598-11db-a314-000a95c2fcd0