annotate lisp/utils/speedbspec.el @ 194:2947057885e5

Added tag r20-3b23 for changeset f53b5ca2e663
author cvs
date Mon, 13 Aug 2007 09:58:32 +0200
parents 85ec50267440
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1 ;;; speedbspec --- Buffer specialized configurations for speedbar
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
2
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 Eric M. Ludlam
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
4 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
6 ;; Version: 0.1
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
7 ;; Keywords: file, tags, tools
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
8 ;; X-RCS: $Id: speedbspec.el,v 1.1 1997/06/29 23:13:34 steve Exp $
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
9 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
10 ;; This program is free software; you can redistribute it and/or modify
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
13 ;; any later version.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
14 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
15 ;; This program is distributed in the hope that it will be useful,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
18 ;; GNU General Public License for more details.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
19 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
21 ;; along with this program; if not, you can either send email to this
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
22 ;; program's author (see below) or write to:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
23 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
24 ;; The Free Software Foundation, Inc.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
25 ;; 675 Mass Ave.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
26 ;; Cambridge, MA 02139, USA.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
27 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
28 ;; Please send bug reports, etc. to zappo@gnu.ai.mit.edu.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
29 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
30
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
31 ;;; Commentary:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
32 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
33 ;; Speedbar provides a frame in which files, and locations in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
34 ;; files are displayed. These functions provide some mode-specific
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
35 ;; displays for some existing emacs modes.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
36 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
37 ;; To provide special service to all the modes supported by this file,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
38 ;; put the following in your .emacs file.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
39 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
40 ;; (require 'speedbspec)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
41 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
42 ;; This will load in the known functions, and the mode-enabling code
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
43 ;; into 'change-major-mode-hook.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
44 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
45 ;; This file requires speedbar.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
46
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
47 ;;; Change log:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
48 ;; 0.1 - Initial revision requiring speedbar 0.5
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
49
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
50 ;;; Code:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
51 (require 'speedbar)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
52
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
53 ;;; Generic add-new-special-mode stuff
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
54 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
55 (defvar speedbar-localized-buffer-queue nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
56 "List of buffers to localize for speedbar.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
57
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
58 (defun speedbar-add-localized-speedbar-support-to-q ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
59 "Add speedbar support to all buffers in `speedbar-localized-buffer-queue'."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
60 (remove-hook 'post-command-hook
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
61 'speedbar-add-localized-speedbar-support-to-q)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
62 (while speedbar-localized-buffer-queue
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
63 (speedbar-add-localized-speedbar-support
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
64 (car speedbar-localized-buffer-queue))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
65 (setq speedbar-localized-buffer-queue
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
66 (cdr speedbar-localized-buffer-queue))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
67
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
68 (defun speedbar-add-localized-speedbar-support (buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
69 "Add localized speedbar support to BUFFER's mode if it is available."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
70 (if (not (buffer-live-p buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
71 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
72 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
73 (set-buffer buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
74 (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
75 (let ((ms (symbol-name major-mode))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
76 v tmp)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
77 (if (not (string-match "-mode$" ms))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
78 nil ;; do nothing to broken mode
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
79 (setq ms (substring ms 0 (match-beginning 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
80 (setq v (intern-soft (concat ms "-speedbar-buttons")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
81 (if (not v)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
82 nil ;; do nothing if not defined
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
83 (make-local-variable 'speedbar-special-mode-expansion-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
84 (setq speedbar-special-mode-expansion-list (list v))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
85 (setq v (intern-soft (concat ms "-speedbar-menu-items")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
86 (if (not v)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
87 nil ;; don't add special menus
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
88 (make-local-variable 'speedbar-easymenu-definition-special)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
89 (setq speedbar-easymenu-definition-special
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
90 (symbol-value v))))))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
91
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
92 (defun speedbar-change-major-mode ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
93 "Run when the major mode is changed."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
94 (setq speedbar-localized-buffer-queue
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
95 (add-to-list 'speedbar-localized-buffer-queue (current-buffer)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
96 (add-hook 'post-command-hook 'speedbar-add-localized-speedbar-support-to-q))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
97
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
98 (add-hook 'change-major-mode-hook 'speedbar-change-major-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
99 (add-hook 'find-file-hooks 'speedbar-change-major-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
100
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
101 ;;; Info specific code
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
102 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
103 (defvar Info-last-speedbar-node nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
104 "Last node viewed with speedbar in the form '(NODE FILE).")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
105
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
106 (defvar Info-speedbar-menu-items
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
107 '(["Browse Item On Line" speedbar-edit-line t])
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
108 "Additional menu-items to add to speedbar frame.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
109
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
110 (defun Info-speedbar-buttons (buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
111 "Create a speedbar display to help navigation in an Info file.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
112 BUFFER is the buffer speedbar is requesting buttons for."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
113 (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
114 (if (and (looking-at "<Directory>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
115 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
116 (set-buffer buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
117 (and (equal (car Info-last-speedbar-node) Info-current-node)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
118 (equal (cdr Info-last-speedbar-node) Info-current-file))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
119 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
120 (erase-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
121 (speedbar-insert-button "<Directory>" 'info-xref 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
122 'Info-speedbar-button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
123 'Info-directory)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
124 (speedbar-insert-button "<Top>" 'info-xref 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
125 'Info-speedbar-button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
126 'Info-top-node)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
127 (speedbar-insert-button "<Last>" 'info-xref 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
128 'Info-speedbar-button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
129 'Info-last)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
130 (speedbar-insert-button "<Up>" 'info-xref 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
131 'Info-speedbar-button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
132 'Info-up)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
133 (speedbar-insert-button "<Next>" 'info-xref 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
134 'Info-speedbar-button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
135 'Info-next)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
136 (speedbar-insert-button "<Prev>" 'info-xref 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
137 'Info-speedbar-button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
138 'Info-prev)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
139 (let ((completions nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
140 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
141 (set-buffer buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
142 (setq Info-last-speedbar-node
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
143 (cons Info-current-node Info-current-file))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
144 (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
145 ;; Always skip the first one...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
146 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
147 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
148 (setq completions (cons (buffer-substring (match-beginning 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
149 (match-end 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
150 completions))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
151 (setq completions (nreverse completions))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
152 (while completions
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
153 (speedbar-make-tag-line nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
154 (car completions) 'Info-speedbar-menu
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
155 nil 'info-node 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
156 (setq completions (cdr completions))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
157
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
158 (defun Info-speedbar-button (text token indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
159 "Called when user clicks <Directory> from speedbar.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
160 TEXT, TOKEN, and INDENT are unused."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
161 (speedbar-with-attached-buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
162 (funcall token)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
163 (setq Info-last-speedbar-node nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
164 (speedbar-update-contents)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
165
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
166 (defun Info-speedbar-menu (text token indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
167 "Goto the menu node specified in TEXT.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
168 TOKEN and INDENT are not used."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
169 (speedbar-with-attached-buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
170 (Info-menu text)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
171 (setq Info-last-speedbar-node nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
172 (speedbar-update-contents)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
173
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
174 ;;; RMAIL specific code
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
175 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
176 (defvar rmail-speedbar-last-user nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
177 "The last user to be displayed in the speedbar.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
178
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
179 (defvar rmail-speedbar-menu-items
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
180 '(["Browse Item On Line" speedbar-edit-line t]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
181 ["Move message to folder" rmail-move-message-to-folder-on-line
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
182 (save-excursion (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
183 (looking-at "<M> "))])
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
184 "Additional menu-items to add to speedbar frame.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
185
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
186 (defun rmail-speedbar-buttons (buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
187 "Create buttons for BUFFER containing rmail messages.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
188 Click on the address under Reply to: to reply to this person.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
189 Under Folders: Click a name to read it, or on the <M> to move the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
190 current message into that RMAIL folder."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
191 (let ((from nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
192 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
193 (set-buffer buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
194 (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
195 (if (not (re-search-forward "^Reply-To: " nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
196 (if (not (re-search-forward "^From:? " nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
197 (setq from t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
198 (if from
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
199 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
200 (setq from (buffer-substring (point) (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
201 (end-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
202 (point))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
203 (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
204 (if (and (looking-at "Reply to:")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
205 (equal from rmail-speedbar-last-user))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
206 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
207 (setq rmail-speedbar-last-user from)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
208 (erase-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
209 (insert "Reply To:\n")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
210 (if (stringp from)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
211 (speedbar-insert-button from 'speedbar-directory-face 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
212 'rmail-speedbar-button 'rmail-reply))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
213 (insert "Folders:\n")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
214 (let* ((case-fold-search nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
215 (df (directory-files (save-excursion (set-buffer buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
216 default-directory)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
217 nil "^[A-Z0-9]+\\(\\.[A-Z0-9]+\\)?$")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
218 (while df
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
219 (speedbar-insert-button "<M>" 'speedbar-button-face 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
220 'rmail-speedbar-move-message (car df))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
221 (speedbar-insert-button (car df) 'speedbar-file-face 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
222 'rmail-speedbar-find-file nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
223 (setq df (cdr df)))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
224
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
225 (defun rmail-speedbar-button (text token indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
226 "Execute an rmail command specified by TEXT.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
227 The command used is TOKEN. INDENT is not used."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
228 (speedbar-with-attached-buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
229 (funcall token t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
230
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
231 (defun rmail-speedbar-find-file (text token indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
232 "Load in the rmail file TEXT.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
233 TOKEN and INDENT are not used."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
234 (speedbar-with-attached-buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
235 (message "Loading in RMAIL file %s..." text)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
236 (find-file text)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
237
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
238 (defun rmail-move-message-to-folder-on-line ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
239 "If the current line is a folder, move current message to it."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
240 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
241 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
242 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
243 (if (re-search-forward "<M> " (save-excursion (end-of-line) (point)) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
244 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
245 (forward-char -2)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
246 (speedbar-do-function-pointer)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
247
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
248 (defun rmail-speedbar-move-message (text token indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
249 "From button TEXT, copy current message to the rmail file specified by TOKEN.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
250 TEXT and INDENT are not used."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
251 (speedbar-with-attached-buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
252 (message "Moving message to %s" token)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
253 (rmail-output-to-rmail-file token)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
254
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
255 ;;; W3 speedbar help
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
256 (defvar w3-speedbar-last-buffer nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
257 "The last buffer shown by w3-speedbar.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
258
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
259 (defun w3-speedbar-buttons (buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
260 "Create speedbar buttons for the current web BUFFER displayed in w3 mode."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
261 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
262 (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
263 (if (and (looking-at "History:") (equal w3-speedbar-last-buffer buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
264 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
265 (setq w3-speedbar-last-buffer buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
266 (erase-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
267 (let ((links (save-excursion (set-buffer buffer) (w3-only-links)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
268 (part nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
269 (insert "History:\n")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
270 ;; This taken out of w3 which was used to create the history list,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
271 ;; and is here modified to create the speedbar buttons
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
272 (cl-maphash
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
273 (function
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
274 (lambda (url desc)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
275 (speedbar-insert-button (w3-speedbar-shorten-button url)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
276 'speedbar-directory-face 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
277 'w3-speedbar-link url)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
278 url-history-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
279 (insert "Links:\n")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
280 (while links
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
281 (setq part (car (cdr (member 'href (car links))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
282 links (cdr links))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
283 (speedbar-insert-button (w3-speedbar-shorten-button part)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
284 'speedbar-file-face 'highlight
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
285 'w3-speedbar-link part))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
286
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
287 (defun w3-speedbar-shorten-button (button)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
288 "Takes text BUTTON and shortens it as much as possible."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
289 ;; I should make this more complex, but I'm not sure how...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
290 (let ((fnnd (file-name-nondirectory button)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
291 (if (< 0 (length fnnd))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
292 fnnd
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
293 (if (string-match "\\(ht\\|f\\)tp://" button)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
294 (setq button (substring button (match-end 0))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
295 (if (string-match "/$" button)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
296 (setq button (substring button 0 (match-beginning 0))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
297 button)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
298
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
299 (defun w3-speedbar-link (text token indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
300 "Follow link described by TEXT which has the URL TOKEN.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
301 INDENT is not used."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
302 (speedbar-with-attached-buffer (w3-fetch token)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
303
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
304 (provide 'speedbspec)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
305 ;;; speedbspec ends here