annotate lisp/mail/mh-speed.el @ 48881:23fcd656a17e

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Tue, 17 Dec 2002 11:57:18 +0000
parents 8aaba207e44b
children 30c4902b654d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1 ;;; mh-speed.el --- Speedbar interface for MH-E.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
2
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
3 ;; Copyright (C) 2002 Free Software Foundation, Inc.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
4
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
5 ;; Author: Bill Wohler <wohler@newt.com>
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
6 ;; Maintainer: Bill Wohler <wohler@newt.com>
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
7 ;; Keywords: mail
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
8 ;; See: mh-e.el
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
9
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
11
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
15 ;; any later version.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
16
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
21
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
26
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
27 ;;; Commentary:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
28 ;; Future versions should only use flists.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
29
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
30 ;; Speedbar support for MH-E package.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
31
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
32 ;;; Change Log:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
33
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
34 ;; $Id: mh-speed.el,v 1.26 2002/11/13 19:36:00 wohler Exp $
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
35
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
36 ;;; Code:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
37
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
38 ;; Requires
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
39 (require 'cl)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
40 (require 'mh-utils)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
41 (require 'mh-e)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
42 (require 'speedbar)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
43
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
44 ;; Autoloads
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
45 (autoload 'mh-index-goto-nearest-msg "mh-index")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
46 (autoload 'mh-index-parse-folder "mh-index")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
47 (autoload 'mh-visit-folder "mh-e")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
48
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
49 ;; User customizable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
50 (defcustom mh-large-folder 200
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
51 "The number of messages that indicates a large folder.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
52 If the number of messages in a folder exceeds this value, confirmation is
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
53 required when the folder is visited from the speedbar."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
54 :type 'integer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
55 :group 'mh)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
56
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
57 (defcustom mh-speed-flists-interval 60
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
58 "Time between calls to flists in seconds.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
59 If 0, flists is not called repeatedly."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
60 :type 'integer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
61 :group 'mh)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
62
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
63 (defcustom mh-speed-run-flists-flag t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
64 "Non-nil means flists is used.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
65 If non-nil, flists is executed every `mh-speed-flists-interval' seconds to
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
66 update the display of the number of unseen and total messages in each folder.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
67 If resources are limited, this can be set to nil and the speedbar display can
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
68 be updated manually with the \\[mh-speed-flists] command."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
69 :type 'boolean
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
70 :group 'mh)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
71
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
72 (defface mh-speedbar-folder-face
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
73 '((((class color) (background light))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
74 (:foreground "blue4"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
75 (((class color) (background dark))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
76 (:foreground "light blue")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
77 "Face used for folders in the speedbar buffer."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
78 :group 'mh)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
79
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
80 (defface mh-speedbar-selected-folder-face
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
81 '((((class color) (background light))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
82 (:foreground "red" :underline t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
83 (((class color) (background dark))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
84 (:foreground "red" :underline t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
85 (t (:underline t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
86 "Face used for the current folder."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
87 :group 'mh)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
88
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
89 (defface mh-speedbar-folder-with-unseen-messages-face
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
90 '((t (:inherit mh-speedbar-folder-face :bold t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
91 "Face used for folders in the speedbar buffer which have unread messages."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
92 :group 'mh)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
93
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
94 (defface mh-speedbar-selected-folder-with-unseen-messages-face
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
95 '((t (:inherit mh-speedbar-selected-folder-face :bold t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
96 "Face used for the current folder when it has unread messages."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
97 :group 'mh)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
98
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
99 ;; Global variables
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
100 (defvar mh-speed-refresh-flag nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
101 (defvar mh-speed-last-selected-folder nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
102 (defvar mh-speed-folder-map (make-hash-table :test #'equal))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
103 (defvar mh-speed-folders-cache (make-hash-table :test #'equal))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
104 (defvar mh-speed-flists-cache (make-hash-table :test #'equal))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
105 (defvar mh-speed-flists-process nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
106 (defvar mh-speed-flists-timer nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
107 (defvar mh-speed-partial-line "")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
108
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
109 ;; Add our stealth update function
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
110 (unless (member 'mh-speed-stealth-update
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
111 (cdr (assoc "files" speedbar-stealthy-function-list)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
112 ;; Is changing constant lists in elisp safe?
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
113 (setq speedbar-stealthy-function-list
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
114 (copy-tree speedbar-stealthy-function-list))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
115 (push 'mh-speed-stealth-update
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
116 (cdr (assoc "files" speedbar-stealthy-function-list))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
117
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
118 ;; Functions called by speedbar to initialize display...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
119 (defun mh-folder-speedbar-buttons (buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
120 "Interface function to create MH-E speedbar buffer.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
121 BUFFER is the MH-E buffer for which the speedbar buffer is to be created."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
122 (unless (get-text-property (point-min) 'mh-level)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
123 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
124 (clrhash mh-speed-folder-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
125 (speedbar-make-tag-line 'bracket ?+ 'mh-speed-toggle nil " " 'ignore nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
126 'mh-speedbar-folder-face 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
127 (forward-line -1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
128 (setf (gethash nil mh-speed-folder-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
129 (set-marker (make-marker) (1+ (line-beginning-position))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
130 (add-text-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
131 (line-beginning-position) (1+ (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
132 `(mh-folder nil mh-expanded nil mh-children-p t mh-level 0))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
133 (mh-speed-stealth-update t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
134 (when mh-speed-run-flists-flag
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
135 (mh-speed-flists nil))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
136
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
137 (defalias 'mh-show-speedbar-buttons 'mh-folder-speedbar-buttons)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
138 (defalias 'mh-index-folder-speedbar-buttons 'mh-folder-speedbar-buttons)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
139 (defalias 'mh-index-show-speedbar-buttons 'mh-folder-speedbar-buttons)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
140 (defalias 'mh-letter-speedbar-buttons 'mh-folder-speedbar-buttons)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
141
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
142 ;; Keymaps for speedbar...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
143 (defvar mh-folder-speedbar-key-map (speedbar-make-specialized-keymap)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
144 "Specialized speedbar keymap for MH-E buffers.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
145 (gnus-define-keys mh-folder-speedbar-key-map
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
146 "+" mh-speed-expand-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
147 "-" mh-speed-contract-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
148 "\r" mh-speed-view
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
149 "f" mh-speed-flists
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
150 "i" mh-speed-invalidate-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
151
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
152 (defvar mh-show-speedbar-key-map mh-folder-speedbar-key-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
153 (defvar mh-index-folder-speedbar-key-map mh-folder-speedbar-key-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
154 (defvar mh-index-show-speedbar-key-map mh-folder-speedbar-key-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
155 (defvar mh-letter-speedbar-key-map mh-folder-speedbar-key-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
156
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
157 ;; Menus for speedbar...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
158 (defvar mh-folder-speedbar-menu-items
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
159 '(["Visit Folder" mh-speed-view
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
160 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
161 (set-buffer speedbar-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
162 (get-text-property (line-beginning-position) 'mh-folder))]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
163 ["Expand nested folders" mh-speed-expand-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
164 (and (get-text-property (line-beginning-position) 'mh-children-p)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
165 (not (get-text-property (line-beginning-position) 'mh-expanded)))]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
166 ["Contract nested folders" mh-speed-contract-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
167 (and (get-text-property (line-beginning-position) 'mh-children-p)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
168 (get-text-property (line-beginning-position) 'mh-expanded))]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
169 ["Run Flists" mh-speed-flists t]
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
170 ["Invalidate cached folders" mh-speed-invalidate-map t])
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
171 "Extra menu items for speedbar.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
172
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
173 (defvar mh-show-speedbar-menu-items mh-folder-speedbar-menu-items)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
174 (defvar mh-index-folder-speedbar-menu-items mh-folder-speedbar-menu-items)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
175 (defvar mh-index-show-speedbar-menu-items mh-folder-speedbar-menu-items)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
176 (defvar mh-letter-speedbar-menu-items mh-folder-speedbar-menu-items)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
177
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
178 (defmacro mh-speed-select-attached-frame ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
179 "Compatibility macro to handle speedbar versions 0.11a and 0.14beta4."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
180 (cond ((fboundp 'dframe-select-attached-frame)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
181 '(dframe-select-attached-frame speedbar-frame))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
182 ((boundp 'speedbar-attached-frame)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
183 '(select-frame speedbar-attached-frame))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
184 (t (error "Installed speedbar version not supported by MH-E"))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
185
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
186 (defun mh-speed-update-current-folder (force)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
187 "Update speedbar highlighting of the current folder.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
188 The function tries to be smart so that work done is minimized. The currently
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
189 highlighted folder is cached and no highlighting happens unless it changes.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
190 Also highlighting is suspended while the speedbar frame is selected.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
191 Otherwise you get the disconcerting behavior of folders popping open on their
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
192 own when you are trying to navigate around in the speedbar buffer.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
193
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
194 The update is always carried out if FORCE is non-nil."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
195 (let* ((lastf (selected-frame))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
196 (newcf (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
197 (mh-speed-select-attached-frame)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
198 (prog1 (mh-speed-extract-folder-name (buffer-name))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
199 (select-frame lastf))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
200 (lastb (current-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
201 (case-fold-search t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
202 (when (or force
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
203 (and mh-speed-refresh-flag (not (eq lastf speedbar-frame)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
204 (and (stringp newcf)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
205 (equal (substring newcf 0 1) "+")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
206 (not (equal newcf mh-speed-last-selected-folder))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
207 (setq mh-speed-refresh-flag nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
208 (select-frame speedbar-frame)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
209 (set-buffer speedbar-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
210
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
211 ;; Remove highlight from previous match...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
212 (mh-speed-highlight mh-speed-last-selected-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
213 'mh-speedbar-folder-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
214
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
215 ;; If we found a match highlight it...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
216 (when (mh-speed-goto-folder newcf)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
217 (mh-speed-highlight newcf 'mh-speedbar-selected-folder-face))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
218
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
219 (setq mh-speed-last-selected-folder newcf)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
220 (speedbar-position-cursor-on-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
221 (set-window-point (frame-first-window speedbar-frame) (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
222 (set-buffer lastb)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
223 (select-frame lastf))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
224 (when (eq lastf speedbar-frame)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
225 (setq mh-speed-refresh-flag t))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
226
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
227 (defun mh-speed-normal-face (face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
228 "Return normal face for given FACE."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
229 (cond ((eq face 'mh-speedbar-folder-with-unseen-messages-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
230 'mh-speedbar-folder-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
231 ((eq face 'mh-speedbar-selected-folder-with-unseen-messages-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
232 'mh-speedbar-selected-folder-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
233 (t face)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
234
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
235 (defun mh-speed-bold-face (face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
236 "Return bold face for given FACE."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
237 (cond ((eq face 'mh-speedbar-folder-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
238 'mh-speedbar-folder-with-unseen-messages-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
239 ((eq face 'mh-speedbar-selected-folder-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
240 'mh-speedbar-selected-folder-with-unseen-messages-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
241 (t face)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
242
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
243 (defun mh-speed-highlight (folder face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
244 "Set FOLDER to FACE."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
245 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
246 (speedbar-with-writable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
247 (goto-char (gethash folder mh-speed-folder-map (point)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
248 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
249 (if (re-search-forward "([1-9][0-9]*/[0-9]+)" (line-end-position) t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
250 (setq face (mh-speed-bold-face face))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
251 (setq face (mh-speed-normal-face face)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
252 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
253 (when (re-search-forward "\\[.\\] " (line-end-position) t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
254 (put-text-property (point) (line-end-position) 'face face)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
255
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
256 (defun mh-speed-stealth-update (&optional force)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
257 "Do stealth update.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
258 With non-nil FORCE, the update is always carried out."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
259 (cond ((save-excursion (set-buffer speedbar-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
260 (get-text-property (point-min) 'mh-level))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
261 ;; Execute this hook and *don't* run anything else
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
262 (mh-speed-update-current-folder force)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
263 nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
264 ;; Otherwise on to your regular programming
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
265 (t t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
266
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
267 (defun mh-speed-goto-folder (folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
268 "Move point to line containing FOLDER.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
269 The function will expand out parent folders of FOLDER if needed."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
270 (let ((prefix folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
271 (suffix-list ())
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
272 (last-slash t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
273 (while (and (not (gethash prefix mh-speed-folder-map)) last-slash)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
274 (setq last-slash (search "/" prefix :from-end t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
275 (when (integerp last-slash)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
276 (push (substring prefix (1+ last-slash)) suffix-list)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
277 (setq prefix (substring prefix 0 last-slash))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
278 (let ((prefix-position (gethash prefix mh-speed-folder-map)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
279 (if prefix-position
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
280 (goto-char prefix-position)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
281 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
282 (mh-speed-toggle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
283 (unless (get-text-property (point) 'mh-expanded)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
284 (mh-speed-toggle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
285 (goto-char (gethash prefix mh-speed-folder-map))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
286 (while suffix-list
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
287 ;; We always need atleast one toggle. We need two if the directory list
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
288 ;; is stale since a folder was added.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
289 (when (equal prefix (get-text-property (line-beginning-position)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
290 'mh-folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
291 (mh-speed-toggle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
292 (unless (get-text-property (point) 'mh-expanded)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
293 (mh-speed-toggle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
294 (setq prefix (format "%s/%s" prefix (pop suffix-list)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
295 (goto-char (gethash prefix mh-speed-folder-map (point))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
296 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
297 (equal folder (get-text-property (point) 'mh-folder))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
298
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
299 (defun mh-speed-extract-folder-name (buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
300 "Given an MH-E BUFFER find the folder that should be highlighted.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
301 Do the right thing for the different kinds of buffers that MH-E uses."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
302 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
303 (set-buffer buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
304 (cond ((eq major-mode 'mh-folder-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
305 mh-current-folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
306 ((eq major-mode 'mh-show-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
307 (set-buffer mh-show-folder-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
308 mh-current-folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
309 ((eq major-mode 'mh-index-folder-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
310 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
311 (mh-index-goto-nearest-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
312 (mh-index-parse-folder)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
313 ((or (eq major-mode 'mh-index-show-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
314 (eq major-mode 'mh-letter-mode))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
315 (when (string-match mh-user-path buffer-file-name)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
316 (let* ((rel-path (substring buffer-file-name (match-end 0)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
317 (directory-end (search "/" rel-path :from-end t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
318 (when directory-end
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
319 (format "+%s" (substring rel-path 0 directory-end)))))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
320
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
321 (defun mh-speed-add-buttons (folder level)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
322 "Add speedbar button for FOLDER which is at indented by LEVEL amount."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
323 (let ((folder-list (mh-speed-folders folder)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
324 (mapc
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
325 (lambda (f)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
326 (let* ((folder-name (format "%s%s%s" (or folder "+")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
327 (if folder "/" "") (car f)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
328 (counts (gethash folder-name mh-speed-flists-cache)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
329 (speedbar-with-writable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
330 (speedbar-make-tag-line
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
331 'bracket (if (cdr f) ?+ ? )
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
332 'mh-speed-toggle nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
333 (format "%s%s"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
334 (car f)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
335 (if counts
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
336 (format " (%s/%s)" (car counts) (cdr counts))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
337 ""))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
338 'mh-speed-view nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
339 (if (and counts (> (car counts) 0))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
340 'mh-speedbar-folder-with-unseen-messages-face
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
341 'mh-speedbar-folder-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
342 level)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
343 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
344 (forward-line -1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
345 (setf (gethash folder-name mh-speed-folder-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
346 (set-marker (make-marker) (1+ (line-beginning-position))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
347 (add-text-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
348 (line-beginning-position) (1+ (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
349 `(mh-folder ,folder-name
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
350 mh-expanded nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
351 mh-children-p ,(not (not (cdr f)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
352 ,@(if counts `(mh-count (,(car counts) . ,(cdr counts))) ())
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
353 mh-level ,level))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
354 folder-list)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
355
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
356 (defun mh-speed-toggle (&rest args)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
357 "Toggle the display of child folders.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
358 The otional ARGS are ignored and there for compatibilty with speedbar."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
359 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
360 (declare (ignore args))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
361 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
362 (let ((parent (get-text-property (point) 'mh-folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
363 (kids-p (get-text-property (point) 'mh-children-p))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
364 (expanded (get-text-property (point) 'mh-expanded))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
365 (level (get-text-property (point) 'mh-level))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
366 (point (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
367 start-region)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
368 (speedbar-with-writable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
369 (cond ((not kids-p) nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
370 (expanded
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
371 (forward-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
372 (setq start-region (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
373 (while (and (get-text-property (point) 'mh-level)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
374 (> (get-text-property (point) 'mh-level) level))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
375 (remhash (get-text-property (point) 'mh-folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
376 mh-speed-folder-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
377 (forward-line))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
378 (delete-region start-region (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
379 (forward-line -1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
380 (speedbar-change-expand-button-char ?+)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
381 (add-text-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
382 (line-beginning-position) (1+ (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
383 '(mh-expanded nil)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
384 (t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
385 (forward-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
386 (mh-speed-add-buttons parent (1+ level))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
387 (goto-char point)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
388 (speedbar-change-expand-button-char ?-)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
389 (add-text-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
390 (line-beginning-position) (1+ (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
391 `(mh-expanded t)))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
392
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
393 (defalias 'mh-speed-expand-folder 'mh-speed-toggle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
394 (defalias 'mh-speed-contract-folder 'mh-speed-toggle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
395
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
396 (defun mh-speed-folder-size ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
397 "Find folder size if folder on current line."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
398 (let ((folder (get-text-property (line-beginning-position) 'mh-folder)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
399 (or (cdr (get-text-property (line-beginning-position) 'mh-count))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
400 (and (null folder) 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
401 (with-temp-buffer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
402 (call-process (expand-file-name "flist" mh-progs) nil t nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
403 "-norecurse" folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
404 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
405 (unless (re-search-forward "out of " (line-end-position) t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
406 (error "Call to flist failed on folder %s" folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
407 (car (read-from-string
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
408 (buffer-substring-no-properties (point)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
409 (line-end-position))))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
410
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
411 (defun mh-speed-view (&rest args)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
412 "View folder on current line.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
413 Optional ARGS are ignored."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
414 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
415 (declare (ignore args))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
416 (let* ((folder (get-text-property (line-beginning-position) 'mh-folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
417 (range
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
418 (cond ((save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
419 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
420 (re-search-forward "([1-9][0-9]*/[0-9]+)"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
421 (line-end-position) t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
422 mh-unseen-seq)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
423 ((> (mh-speed-folder-size) mh-large-folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
424 (let* ((size (mh-speed-folder-size))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
425 (prompt
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
426 (format "How many messages from %s (default: %s): "
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
427 folder size))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
428 (in (read-string prompt nil nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
429 (number-to-string size)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
430 (result (car (ignore-errors (read-from-string in)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
431 (cond ((null result) (format "last:%s" size))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
432 ((numberp result) (format "last:%s" result))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
433 (t (format "%s" result)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
434 (t nil))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
435 (when (stringp folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
436 (speedbar-with-attached-buffer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
437 (mh-visit-folder folder range)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
438 (delete-other-windows)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
439
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
440 (defun mh-speed-folders (folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
441 "Find the subfolders of FOLDER.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
442 The function avoids running folders unnecessarily by caching the results of
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
443 the actual folders call."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
444 (let ((match (gethash folder mh-speed-folders-cache 'no-result)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
445 (cond ((eq match 'no-result)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
446 (setf (gethash folder mh-speed-folders-cache)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
447 (mh-speed-folders-actual folder)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
448 (t match))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
449
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
450 (defun mh-speed-folders-actual (folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
451 "Execute the command folders to return the sub-folders of FOLDER.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
452 Filters out the folder names that start with \".\" so that directories that
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
453 aren't usually mail folders are hidden."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
454 (let* ((folder (cond ((and (stringp folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
455 (equal (substring folder 0 1) "+"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
456 folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
457 (t nil)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
458 (arg-list `(,(expand-file-name "folders" mh-progs)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
459 nil (t nil) nil "-noheader" "-norecurse"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
460 ,@(if (stringp folder) (list folder) ())))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
461 (results ()))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
462 (with-temp-buffer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
463 (apply #'call-process arg-list)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
464 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
465 (while (not (and (eolp) (bolp)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
466 (let ((folder-end (or (search-forward "+ " (line-end-position) t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
467 (search-forward " " (line-end-position) t))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
468 (when (integerp folder-end)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
469 (let ((name (buffer-substring (line-beginning-position)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
470 (match-beginning 0))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
471 (let ((first-char (substring name 0 1)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
472 (unless (or (string-equal first-char ".")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
473 (string-equal first-char "#")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
474 (string-equal first-char ","))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
475 (push
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
476 (cons name
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
477 (search-forward "(others)" (line-end-position) t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
478 results)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
479 (forward-line 1))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
480 (setq results (nreverse results))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
481 (when (stringp folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
482 (setq results (cdr results))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
483 (let ((folder-name-len (length (format "%s/" (substring folder 1)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
484 (setq results (mapcar (lambda (f)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
485 (cons (substring (car f) folder-name-len)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
486 (cdr f)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
487 results))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
488 results))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
489
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
490 (defun mh-speed-flists (force)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
491 "Execute flists -recurse and update message counts.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
492 If FORCE is non-nil the timer is reset."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
493 (interactive (list t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
494 (when force
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
495 (when (timerp mh-speed-flists-timer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
496 (cancel-timer mh-speed-flists-timer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
497 (setq mh-speed-flists-timer nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
498 (when (and (processp mh-speed-flists-process)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
499 (not (eq (process-status mh-speed-flists-process) 'exit)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
500 (kill-process mh-speed-flists-process)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
501 (setq mh-speed-flists-process nil)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
502 (unless mh-speed-flists-timer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
503 (setq mh-speed-flists-timer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
504 (run-at-time
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
505 nil mh-speed-flists-interval
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
506 (lambda ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
507 (unless (and (processp mh-speed-flists-process)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
508 (not (eq (process-status mh-speed-flists-process)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
509 'exit)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
510 (setq mh-speed-flists-process
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
511 (start-process (expand-file-name "flists" mh-progs) nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
512 "flists" "-recurse"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
513 (set-process-filter mh-speed-flists-process
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
514 'mh-speed-parse-flists-output)))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
515
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
516 ;; Copied from mh-make-folder-list-filter...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
517 (defun mh-speed-parse-flists-output (process output)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
518 "Parse the incremental results from flists.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
519 PROCESS is the flists process and OUTPUT is the results that must be handled
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
520 next."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
521 (let ((prevailing-match-data (match-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
522 (position 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
523 line-end line folder unseen total)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
524 (unwind-protect
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
525 (while (setq line-end (string-match "\n" output position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
526 (setq line (format "%s%s"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
527 mh-speed-partial-line
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
528 (substring output position line-end))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
529 mh-speed-partial-line "")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
530 (when (string-match "+? " line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
531 (setq folder (format "+%s" (subseq line 0 (match-beginning 0))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
532 (when (string-match " has " line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
533 (setq unseen (car (read-from-string line (match-end 0))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
534 (when (string-match "; out of " line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
535 (setq total (car (read-from-string line (match-end 0))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
536 (setf (gethash folder mh-speed-flists-cache)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
537 (cons unseen total))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
538 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
539 (when (buffer-live-p (get-buffer speedbar-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
540 (set-buffer speedbar-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
541 (speedbar-with-writable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
542 (when (get-text-property (point-min) 'mh-level)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
543 (let ((pos (gethash folder mh-speed-folder-map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
544 face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
545 (when pos
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
546 (goto-char pos)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
547 (goto-char (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
548 (cond
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
549 ((null (get-text-property (point) 'mh-count))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
550 (goto-char (line-end-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
551 (setq face (get-text-property (1- (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
552 'face))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
553 (insert (format " (%s/%s)" unseen total))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
554 (mh-speed-highlight 'unknown face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
555 (goto-char (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
556 (add-text-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
557 (point) (1+ (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
558 `(mh-count (,unseen . ,total))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
559 ((not
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
560 (equal (get-text-property (point) 'mh-count)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
561 (cons unseen total)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
562 (goto-char (line-end-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
563 (setq face (get-text-property (1- (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
564 'face))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
565 (re-search-backward
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
566 " " (line-beginning-position) t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
567 (delete-region (point) (line-end-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
568 (insert (format " (%s/%s)" unseen total))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
569 (mh-speed-highlight 'unknown face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
570 (goto-char (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
571 (add-text-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
572 (point) (1+ (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
573 `(mh-count (,unseen . ,total))))))))))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
574 (setq position (1+ line-end)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
575 (set-match-data prevailing-match-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
576 (setq mh-speed-partial-line (subseq output position))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
577
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
578 (defun mh-speed-invalidate-map (folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
579 "Remove FOLDER from various optimization caches."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
580 (interactive (list ""))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
581 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
582 (set-buffer speedbar-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
583 (let* ((speedbar-update-flag nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
584 (last-slash (search "/" folder :from-end t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
585 (parent (if last-slash (substring folder 0 last-slash) nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
586 (parent-position (gethash parent mh-speed-folder-map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
587 (parent-change nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
588 (remhash parent mh-speed-folders-cache)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
589 (remhash folder mh-speed-folders-cache)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
590 (when parent-position
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
591 (let ((parent-kids (mh-speed-folders parent)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
592 (cond ((null parent-kids)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
593 (setq parent-change ?+))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
594 ((and (null (cdr parent-kids))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
595 (equal (if last-slash
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
596 (substring folder (1+ last-slash))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
597 (substring folder 1))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
598 (caar parent-kids)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
599 (setq parent-change ? ))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
600 (goto-char parent-position)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
601 (when (equal (get-text-property (line-beginning-position) 'mh-folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
602 parent)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
603 (when (get-text-property (line-beginning-position) 'mh-expanded)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
604 (mh-speed-toggle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
605 (when parent-change
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
606 (speedbar-with-writable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
607 (mh-speedbar-change-expand-button-char parent-change)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
608 (add-text-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
609 (line-beginning-position) (1+ (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
610 `(mh-children-p ,(equal parent-change ?+)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
611 (mh-speed-highlight mh-speed-last-selected-folder
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
612 'mh-speedbar-folder-face)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
613 (setq mh-speed-last-selected-folder nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
614 (setq mh-speed-refresh-flag t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
615 (when (equal folder "")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
616 (clrhash mh-speed-folders-cache)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
617
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
618 (defun mh-speed-add-folder (folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
619 "Add FOLDER since it is being created.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
620 The function invalidates the latest ancestor that is present."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
621 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
622 (set-buffer speedbar-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
623 (let ((speedbar-update-flag nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
624 (last-slash (search "/" folder :from-end t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
625 (ancestor folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
626 (ancestor-pos nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
627 (block while-loop
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
628 (while last-slash
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
629 (setq ancestor (substring ancestor 0 last-slash))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
630 (setq ancestor-pos (gethash ancestor mh-speed-folder-map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
631 (when ancestor-pos
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
632 (return-from while-loop))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
633 (setq last-slash (search "/" ancestor :from-end t))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
634 (unless ancestor-pos (setq ancestor nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
635 (goto-char (or ancestor-pos (gethash nil mh-speed-folder-map)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
636 (speedbar-with-writable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
637 (mh-speedbar-change-expand-button-char ?+)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
638 (add-text-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
639 (line-beginning-position) (1+ (line-beginning-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
640 `(mh-children-p t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
641 (when (get-text-property (line-beginning-position) 'mh-expanded)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
642 (mh-speed-toggle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
643 (remhash ancestor mh-speed-folders-cache)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
644 (setq mh-speed-refresh-flag t))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
645
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
646 ;; Make it slightly more general to allow for [ ] buttons to be changed to
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
647 ;; [+].
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
648 (defun mh-speedbar-change-expand-button-char (char)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
649 "Change the expansion button character to CHAR for the current line."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
650 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
651 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
652 (if (re-search-forward "\\[.\\]" (line-end-position) t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
653 (speedbar-with-writable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
654 (backward-char 2)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
655 (delete-char 1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
656 (insert-char char 1 t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
657 (put-text-property (point) (1- (point)) 'invisible nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
658 ;; make sure we fix the image on the text here.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
659 (speedbar-insert-image-button-maybe (- (point) 2) 3)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
660
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
661 (provide 'mh-speed)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
662
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
663 ;;; Local Variables:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
664 ;;; sentence-end-double-space: nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
665 ;;; End:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
666
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
667 ;;; mh-speed.el ends here