]> code.delx.au - gnu-emacs/blob - lisp/mh-e/mh-buffers.el
ca06cc9f51074ba95fbc0f268fd11bd3cb506b43
[gnu-emacs] / lisp / mh-e / mh-buffers.el
1 ;;; mh-buffers.el --- MH-E buffer constants and utilities
2
3 ;; Copyright (C) 1993, 1995, 1997,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 ;; Free Software Foundation, Inc.
6
7 ;; Author: Bill Wohler <wohler@newt.com>
8 ;; Maintainer: Bill Wohler <wohler@newt.com>
9 ;; Keywords: mail
10 ;; See: mh-e.el
11
12 ;; This file is part of GNU Emacs.
13
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation, either version 3 of the License, or
17 ;; (at your option) any later version.
18
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26
27 ;;; Commentary:
28
29 ;;; Change Log:
30
31 ;;; Code:
32
33 ;; The names of ephemeral buffers have a " *mh-" prefix (so that they
34 ;; are hidden and can be programmatically removed in mh-quit), and the
35 ;; variable names have the form mh-temp-.*-buffer.
36 (defconst mh-temp-buffer " *mh-temp*") ;scratch
37 (defconst mh-temp-checksum-buffer " *mh-checksum*")
38 (defconst mh-temp-fetch-buffer " *mh-fetch*") ;wget/curl/fetch output
39 (defconst mh-temp-index-buffer " *mh-index*")
40
41 ;; The names of MH-E buffers that are not ephemeral and can be used by
42 ;; the user (and deleted by the user when no longer needed) have a
43 ;; "*MH-E " prefix (so they can be programmatically removed in
44 ;; mh-quit), and the variable names have the form mh-.*-buffer.
45 ;; Temporary buffers for search results
46 (defconst mh-aliases-buffer "*MH-E Aliases*") ;alias lookups
47 (defconst mh-folders-buffer "*MH-E Folders*") ;folder list
48 (defconst mh-help-buffer "*MH-E Help*") ;quick help
49 (defconst mh-info-buffer "*MH-E Info*") ;version information buffer
50 (defconst mh-log-buffer "*MH-E Log*") ;output of MH commands and so on
51 (defconst mh-mail-delivery-buffer "*MH-E Mail Delivery*") ;mail delivery log
52 (defconst mh-recipients-buffer "*MH-E Recipients*") ;killed when draft sent
53 (defconst mh-sequences-buffer "*MH-E Sequences*") ;sequences list
54
55 (defvar mh-log-buffer-lines 100
56 "Number of lines to keep in `mh-log-buffer'.")
57
58 \f
59
60 (defun mh-truncate-log-buffer ()
61 "If `mh-log-buffer' is too big then truncate it.
62 If the number of lines in `mh-log-buffer' exceeds
63 `mh-log-buffer-lines' then keep only the last
64 `mh-log-buffer-lines'. As a side effect the point is set to the
65 end of the log buffer.
66
67 The function returns the size of the final size of the log buffer."
68 (with-current-buffer (get-buffer-create mh-log-buffer)
69 (goto-char (point-max))
70 (save-excursion
71 (when (equal (forward-line (- mh-log-buffer-lines)) 0)
72 (delete-region (point-min) (point))))
73 (unless (or (bobp)
74 (save-excursion
75 (and (equal (forward-line -1) 0) (equal (char-after) ?\f))))
76 (insert "\n\f\n"))
77 (buffer-size)))
78
79 (provide 'mh-buffers)
80
81 ;; Local Variables:
82 ;; indent-tabs-mode: nil
83 ;; sentence-end-double-space: nil
84 ;; End:
85
86 ;;; mh-buffers.el ends here