/usr/share/emacs/site-lisp/riece/riece-shrink-buffer.el is in riece 9.0.0-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | ;;; riece-shrink-buffer.el --- free old IRC messages to save memory usage -*- lexical-binding: t -*-
;; Copyright (C) 1998-2005 Daiki Ueno
;; Author: Daiki Ueno <ueno@unixuser.org>
;; Created: 1998-09-28
;; Keywords: IRC, riece
;; This file is part of Riece.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; NOTE: This is an add-on module for Riece.
;;; Code:
(require 'riece-globals)
(require 'derived)
(defgroup riece-shrink-buffer nil
"Free old IRC messages to save memory usage."
:prefix "riece-"
:group 'riece)
(defcustom riece-shrink-buffer-idle-time-delay 5
"Number of idle seconds to wait before shrinking channel buffers."
:type 'integer
:group 'riece-shrink-buffer)
(defcustom riece-max-buffer-size 65536
"Maximum size of channel buffers."
:type '(integer :tag "Number of characters")
:group 'riece-shrink-buffer)
(defcustom riece-shrink-buffer-remove-chars (/ riece-max-buffer-size 2)
"Number of chars removed when shrinking channel buffers."
:type 'integer
:group 'riece-shrink-buffer)
(defvar riece-shrink-buffer-idle-timer nil
"Timer object to periodically shrink channel buffers.")
(defconst riece-shrink-buffer-description
"Free old IRC messages to save memory usage.")
(defun riece-shrink-buffer-idle-timer ()
(let ((buffers riece-buffer-list))
(while buffers
(if (and (get 'riece-shrink-buffer 'riece-addon-enabled)
(buffer-live-p (car buffers))
(with-current-buffer (car buffers)
(riece-derived-mode-p 'riece-dialogue-mode)))
(riece-shrink-buffer (car buffers)))
(setq buffers (cdr buffers)))))
(defun riece-shrink-buffer (buffer)
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(while (> (buffer-size) riece-max-buffer-size)
(let* ((inhibit-read-only t)
buffer-read-only
(end (progn
(goto-char riece-shrink-buffer-remove-chars)
(beginning-of-line 2)
(point)))
(overlays (riece-overlays-in (point-min) end)))
(while overlays
(riece-delete-overlay (car overlays))
(setq overlays (cdr overlays)))
(delete-region (point-min) end)))))
(defun riece-shrink-buffer-startup-hook ()
(setq riece-shrink-buffer-idle-timer
(riece-run-with-idle-timer
riece-shrink-buffer-idle-time-delay t
'riece-shrink-buffer-idle-timer)))
(defun riece-shrink-buffer-exit-hook ()
(if riece-shrink-buffer-idle-timer
(riece-cancel-timer riece-shrink-buffer-idle-timer)))
(defun riece-shrink-buffer-insinuate ()
(add-hook 'riece-startup-hook
'riece-shrink-buffer-startup-hook)
;; Reset the timer since riece-shrink-buffer-insinuate will be
;; called before running riece-startup-hook.
(unless riece-shrink-buffer-idle-timer
(riece-shrink-buffer-startup-hook))
(add-hook 'riece-exit-hook
'riece-shrink-buffer-exit-hook))
(defun riece-shrink-buffer-uninstall ()
(riece-shrink-buffer-exit-hook)
(remove-hook 'riece-startup-hook
'riece-shrink-buffer-startup-hook)
(remove-hook 'riece-exit-hook
'riece-shrink-buffer-exit-hook))
(provide 'riece-shrink-buffer)
;;; riece-shrink-buffer.el ends here
|