diff options
| author | Karl Heuer | 1998-07-10 16:46:21 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-07-10 16:46:21 +0000 |
| commit | b04fa5c5a016e8aaef5ebb50b6278210785b28d1 (patch) | |
| tree | cd6495b20703d857dac5ae7c82a91891c3c4bf71 | |
| parent | f8f34fa23d98857a12027159bb5558a7e15ef14e (diff) | |
| download | emacs-b04fa5c5a016e8aaef5ebb50b6278210785b28d1.tar.gz emacs-b04fa5c5a016e8aaef5ebb50b6278210785b28d1.zip | |
No longer depends on speedbspec for byte compile.
(rmail-speedbar-match-folder-regexp) new variable.
(rmail-speedbar-menu-items) Updated speedbar menu items.
(rmail-speedbar-key-map) New keymap.
(rmail-install-speedbar-variables) New function.
Install speedbar keymap only when speedbar is loaded.
(rmail-speedbar-buttons) Use `rmail-speedbar-match-folder-regexp'.
| -rw-r--r-- | lisp/mail/rmail.el | 37 | ||||
| -rw-r--r-- | lisp/speedbspec.el | 133 |
2 files changed, 31 insertions, 139 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index d7a25ea7059..dc23ec3d2f4 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -3170,20 +3170,45 @@ This has an effect only if a summary buffer exists." | |||
| 3170 | (add-text-properties (point-min) (point-max) '(rmail-fontified t)) | 3170 | (add-text-properties (point-min) (point-max) '(rmail-fontified t)) |
| 3171 | (font-lock-fontify-region (point-min) (point-max)) | 3171 | (font-lock-fontify-region (point-min) (point-max)) |
| 3172 | (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil))))))) | 3172 | (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil))))))) |
| 3173 | 3173 | ||
| 3174 | ;;; Speedbar support for RMAIL files. | 3174 | ;;; Speedbar support for RMAIL files. |
| 3175 | (eval-when-compile (require 'speedbspec)) | 3175 | (eval-when-compile (require 'speedbar)) |
| 3176 | |||
| 3177 | (defvar rmail-speedbar-match-folder-regexp "^[A-Z0-9]+\\(\\.[A-Z0-9]+\\)?$" | ||
| 3178 | "*This regex us used to match folder names to be displayed in speedbar. | ||
| 3179 | Enabling this will permit speedbar to display your folders for easy | ||
| 3180 | browsing, and moving of messages.") | ||
| 3176 | 3181 | ||
| 3177 | (defvar rmail-speedbar-last-user nil | 3182 | (defvar rmail-speedbar-last-user nil |
| 3178 | "The last user to be displayed in the speedbar.") | 3183 | "The last user to be displayed in the speedbar.") |
| 3179 | 3184 | ||
| 3185 | (defvar rmail-speedbar-key-map nil | ||
| 3186 | "Keymap used when in rmail display mode.") | ||
| 3187 | |||
| 3188 | (defun rmail-install-speedbar-variables () | ||
| 3189 | "Install those variables used by speedbar to enhance rmail." | ||
| 3190 | (if rmail-speedbar-key-map | ||
| 3191 | nil | ||
| 3192 | (setq rmail-speedbar-key-map (speedbar-make-specialized-keymap)) | ||
| 3193 | |||
| 3194 | (define-key rmail-speedbar-key-map "e" 'speedbar-edit-line) | ||
| 3195 | (define-key rmail-speedbar-key-map "r" 'speedbar-edit-line) | ||
| 3196 | (define-key rmail-speedbar-key-map "\C-m" 'speedbar-edit-line) | ||
| 3197 | (define-key rmail-speedbar-key-map "M" | ||
| 3198 | 'rmail-speedbar-move-message-to-folder-on-line))) | ||
| 3199 | |||
| 3180 | (defvar rmail-speedbar-menu-items | 3200 | (defvar rmail-speedbar-menu-items |
| 3181 | '(["Browse Item On Line" speedbar-edit-line t] | 3201 | '(["Read Folder" speedbar-edit-line t] |
| 3182 | ["Move message to folder" rmail-move-message-to-folder-on-line | 3202 | ["Move message to folder" rmail-speedbar-move-message-to-folder-on-line |
| 3183 | (save-excursion (beginning-of-line) | 3203 | (save-excursion (beginning-of-line) |
| 3184 | (looking-at "<M> "))]) | 3204 | (looking-at "<M> "))]) |
| 3185 | "Additional menu-items to add to speedbar frame.") | 3205 | "Additional menu-items to add to speedbar frame.") |
| 3186 | 3206 | ||
| 3207 | ;; Make sure our special speedbar major mode is loaded | ||
| 3208 | (if (featurep 'speedbar) | ||
| 3209 | (rmail-install-speedbar-variables) | ||
| 3210 | (add-hook 'speedbar-load-hook 'rmail-install-speedbar-variables)) | ||
| 3211 | |||
| 3187 | (defun rmail-speedbar-buttons (buffer) | 3212 | (defun rmail-speedbar-buttons (buffer) |
| 3188 | "Create buttons for BUFFER containing rmail messages. | 3213 | "Create buttons for BUFFER containing rmail messages. |
| 3189 | Click on the address under Reply to: to reply to this person. | 3214 | Click on the address under Reply to: to reply to this person. |
| @@ -3215,7 +3240,7 @@ current message into that RMAIL folder." | |||
| 3215 | (let* ((case-fold-search nil) | 3240 | (let* ((case-fold-search nil) |
| 3216 | (df (directory-files (save-excursion (set-buffer buffer) | 3241 | (df (directory-files (save-excursion (set-buffer buffer) |
| 3217 | default-directory) | 3242 | default-directory) |
| 3218 | nil "^[A-Z0-9]+\\(\\.[A-Z0-9]+\\)?$"))) | 3243 | nil rmail-speedbar-match-folder-regexp))) |
| 3219 | (while df | 3244 | (while df |
| 3220 | (speedbar-insert-button "<M>" 'speedbar-button-face 'highlight | 3245 | (speedbar-insert-button "<M>" 'speedbar-button-face 'highlight |
| 3221 | 'rmail-speedbar-move-message (car df)) | 3246 | 'rmail-speedbar-move-message (car df)) |
| @@ -3236,7 +3261,7 @@ TOKEN and INDENT are not used." | |||
| 3236 | (message "Loading in RMAIL file %s..." text) | 3261 | (message "Loading in RMAIL file %s..." text) |
| 3237 | (find-file text))) | 3262 | (find-file text))) |
| 3238 | 3263 | ||
| 3239 | (defun rmail-move-message-to-folder-on-line () | 3264 | (defun rmail-speedbar-move-message-to-folder-on-line () |
| 3240 | "If the current line is a folder, move current message to it." | 3265 | "If the current line is a folder, move current message to it." |
| 3241 | (interactive) | 3266 | (interactive) |
| 3242 | (save-excursion | 3267 | (save-excursion |
diff --git a/lisp/speedbspec.el b/lisp/speedbspec.el deleted file mode 100644 index 23d63d1e777..00000000000 --- a/lisp/speedbspec.el +++ /dev/null | |||
| @@ -1,133 +0,0 @@ | |||
| 1 | ;;; speedbspec --- Buffer specialized configurations for speedbar | ||
| 2 | |||
| 3 | ;; Copyright (C) 1997, 1998 Free Software Foundation | ||
| 4 | ;; | ||
| 5 | ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu> | ||
| 6 | ;; Version: 0.2 | ||
| 7 | ;; Keywords: file, tags, tools | ||
| 8 | ;; | ||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation; either version 2, or (at your option) | ||
| 13 | ;; any later version. | ||
| 14 | ;; | ||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | ;; | ||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 23 | ;; Boston, MA 02111-1307, USA. | ||
| 24 | |||
| 25 | ;;; Commentary: | ||
| 26 | ;; | ||
| 27 | ;; Speedbar provides a frame in which files, and locations in | ||
| 28 | ;; files are displayed. These functions provide some mode-specific | ||
| 29 | ;; displays for some existing emacs modes. | ||
| 30 | ;; | ||
| 31 | ;; To provide special service to all the modes supported by this file, | ||
| 32 | ;; put the following in your .emacs file. | ||
| 33 | ;; | ||
| 34 | ;; (require 'speedbspec) | ||
| 35 | ;; | ||
| 36 | ;; This will load in the known functions, and the mode-enabling code | ||
| 37 | ;; into 'change-major-mode-hook. | ||
| 38 | ;; | ||
| 39 | ;; You can interactivly try to enable speedbar specialized modes by | ||
| 40 | ;; calling the function `speedbar-add-localized-speedbar-support' and | ||
| 41 | ;; disable it with `speedbar-remove-localized-speedbar-support'. | ||
| 42 | ;; | ||
| 43 | ;; This file requires speedbar. | ||
| 44 | |||
| 45 | ;;; Change log: | ||
| 46 | ;; 0.1 - Initial revision requiring speedbar 0.5 | ||
| 47 | ;; 0.1.1 - `buffer-live-p' replacement on old emacsen | ||
| 48 | ;; 0.2 - Moved actual work code into their own files. | ||
| 49 | ;; Check and load files that need loading before checking for the | ||
| 50 | ;; menu variable. | ||
| 51 | ;; Made the functions to turn on/off speedbar support interactive. | ||
| 52 | ;; It is *not* a minor-mode, it mearly enables special speedbar | ||
| 53 | ;; behaviors. | ||
| 54 | ;; 0.2.1 - Fix for emacs 20 when checking for autoload functions. | ||
| 55 | |||
| 56 | ;;; Code: | ||
| 57 | (require 'speedbar) | ||
| 58 | |||
| 59 | ;;; Compatibility: | ||
| 60 | ;; | ||
| 61 | ;; Thanks: ptype@dra.hmg.gb | ||
| 62 | (if (fboundp 'buffer-live-p) | ||
| 63 | nil | ||
| 64 | (defun buffer-live-p (buffer) | ||
| 65 | "Determine if the buffer is alive." | ||
| 66 | (memq buffer (buffer-list)))) | ||
| 67 | |||
| 68 | |||
| 69 | ;;; Generic add-new-special-mode stuff | ||
| 70 | ;; | ||
| 71 | (defvar speedbar-localized-buffer-queue nil | ||
| 72 | "List of buffers to localize for speedbar.") | ||
| 73 | |||
| 74 | (defun speedbar-add-localized-speedbar-support-to-q () | ||
| 75 | "Add speedbar support to all buffers in `speedbar-localized-buffer-queue'." | ||
| 76 | (remove-hook 'post-command-hook | ||
| 77 | 'speedbar-add-localized-speedbar-support-to-q) | ||
| 78 | (while speedbar-localized-buffer-queue | ||
| 79 | (speedbar-add-localized-speedbar-support | ||
| 80 | (car speedbar-localized-buffer-queue)) | ||
| 81 | (setq speedbar-localized-buffer-queue | ||
| 82 | (cdr speedbar-localized-buffer-queue)))) | ||
| 83 | |||
| 84 | (defun speedbar-add-localized-speedbar-support (buffer) | ||
| 85 | "Add localized speedbar support to BUFFER's mode if it is available." | ||
| 86 | (interactive "bBuffer: ") | ||
| 87 | (if (stringp buffer) (setq buffer (get-buffer buffer))) | ||
| 88 | (if (not (buffer-live-p buffer)) | ||
| 89 | nil | ||
| 90 | (save-excursion | ||
| 91 | (set-buffer buffer) | ||
| 92 | (save-match-data | ||
| 93 | (let ((ms (symbol-name major-mode)) | ||
| 94 | v tmp) | ||
| 95 | (if (not (string-match "-mode$" ms)) | ||
| 96 | nil ;; do nothing to broken mode | ||
| 97 | (setq ms (substring ms 0 (match-beginning 0))) | ||
| 98 | (setq v (intern-soft (concat ms "-speedbar-buttons"))) | ||
| 99 | (if (not v) | ||
| 100 | nil ;; do nothing if not defined | ||
| 101 | ;; If it is autoloaded, we need to load it now so that | ||
| 102 | ;; we have access to the varialbe -speedbar-menu-items. | ||
| 103 | ;; Is this XEmacs safe? | ||
| 104 | (let ((sf (symbol-function v))) | ||
| 105 | (if (and (listp sf) (eq (car sf) 'autoload)) | ||
| 106 | (load-library (car (cdr sf))))) | ||
| 107 | (set (make-local-variable 'speedbar-special-mode-expansion-list) | ||
| 108 | (list v)) | ||
| 109 | (setq v (intern-soft (concat ms "-speedbar-menu-items"))) | ||
| 110 | (if (not v) | ||
| 111 | nil ;; don't add special menus | ||
| 112 | (make-local-variable 'speedbar-easymenu-definition-special) | ||
| 113 | (setq speedbar-easymenu-definition-special | ||
| 114 | (symbol-value v)))))))))) | ||
| 115 | |||
| 116 | (defun speedbar-remove-localized-speedbar-support (buffer) | ||
| 117 | "Remove any traces that BUFFER supports speedbar in a specialized way." | ||
| 118 | (save-excursion | ||
| 119 | (set-buffer buffer) | ||
| 120 | (kill-local-variable 'speedbar-special-mode-expansion-list) | ||
| 121 | (kill-local-variable 'speedbar-easymenu-definition-special))) | ||
| 122 | |||
| 123 | (defun speedbar-change-major-mode () | ||
| 124 | "Run when the major mode is changed." | ||
| 125 | (setq speedbar-localized-buffer-queue | ||
| 126 | (add-to-list 'speedbar-localized-buffer-queue (current-buffer))) | ||
| 127 | (add-hook 'post-command-hook 'speedbar-add-localized-speedbar-support-to-q)) | ||
| 128 | |||
| 129 | (add-hook 'change-major-mode-hook 'speedbar-change-major-mode) | ||
| 130 | (add-hook 'find-file-hooks 'speedbar-change-major-mode) | ||
| 131 | |||
| 132 | (provide 'speedbspec) | ||
| 133 | ;;; speedbspec ends here | ||