mh-buffers.el 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ;;; mh-buffers.el --- MH-E buffer constants and utilities
  2. ;; Copyright (C) 1993, 1995, 1997, 2000-2012 Free Software Foundation, Inc.
  3. ;; Author: Bill Wohler <wohler@newt.com>
  4. ;; Maintainer: Bill Wohler <wohler@newt.com>
  5. ;; Keywords: mail
  6. ;; See: mh-e.el
  7. ;; This file is part of GNU Emacs.
  8. ;; GNU Emacs is free software: you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12. ;; GNU Emacs 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. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;;; Change Log:
  20. ;;; Code:
  21. ;; The names of ephemeral buffers have a " *mh-" prefix (so that they
  22. ;; are hidden and can be programmatically removed in mh-quit), and the
  23. ;; variable names have the form mh-temp-.*-buffer.
  24. (defconst mh-temp-buffer " *mh-temp*") ;scratch
  25. (defconst mh-temp-checksum-buffer " *mh-checksum*")
  26. (defconst mh-temp-fetch-buffer " *mh-fetch*") ;wget/curl/fetch output
  27. (defconst mh-temp-index-buffer " *mh-index*")
  28. ;; The names of MH-E buffers that are not ephemeral and can be used by
  29. ;; the user (and deleted by the user when no longer needed) have a
  30. ;; "*MH-E " prefix (so they can be programmatically removed in
  31. ;; mh-quit), and the variable names have the form mh-.*-buffer.
  32. ;; Temporary buffers for search results
  33. (defconst mh-aliases-buffer "*MH-E Aliases*") ;alias lookups
  34. (defconst mh-folders-buffer "*MH-E Folders*") ;folder list
  35. (defconst mh-help-buffer "*MH-E Help*") ;quick help
  36. (defconst mh-info-buffer "*MH-E Info*") ;version information buffer
  37. (defconst mh-log-buffer "*MH-E Log*") ;output of MH commands and so on
  38. (defconst mh-mail-delivery-buffer "*MH-E Mail Delivery*") ;mail delivery log
  39. (defconst mh-recipients-buffer "*MH-E Recipients*") ;killed when draft sent
  40. (defconst mh-sequences-buffer "*MH-E Sequences*") ;sequences list
  41. (defvar mh-log-buffer-lines 100
  42. "Number of lines to keep in `mh-log-buffer'.")
  43. (defun mh-truncate-log-buffer ()
  44. "If `mh-log-buffer' is too big then truncate it.
  45. If the number of lines in `mh-log-buffer' exceeds
  46. `mh-log-buffer-lines' then keep only the last
  47. `mh-log-buffer-lines'. As a side effect the point is set to the
  48. end of the log buffer.
  49. The function returns the size of the final size of the log buffer."
  50. (with-current-buffer (get-buffer-create mh-log-buffer)
  51. (goto-char (point-max))
  52. (save-excursion
  53. (when (equal (forward-line (- mh-log-buffer-lines)) 0)
  54. (delete-region (point-min) (point))))
  55. (unless (or (bobp)
  56. (save-excursion
  57. (and (equal (forward-line -1) 0) (equal (char-after) ? ))))
  58. (insert "\n \n"))
  59. (buffer-size)))
  60. (provide 'mh-buffers)
  61. ;; Local Variables:
  62. ;; indent-tabs-mode: nil
  63. ;; sentence-end-double-space: nil
  64. ;; End:
  65. ;;; mh-buffers.el ends here