aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-04-18 20:34:51 +0000
committerRichard M. Stallman1998-04-18 20:34:51 +0000
commit78781cbeda43c2d193a00e392e2316d0bdad0dd2 (patch)
treea89d5581dfa86942a4367911fa75374057ca8b84
parent42dfe0ad136c93ff02076ddac735fba4588c07a4 (diff)
downloademacs-78781cbeda43c2d193a00e392e2316d0bdad0dd2.tar.gz
emacs-78781cbeda43c2d193a00e392e2316d0bdad0dd2.zip
Initial revision
-rw-r--r--lisp/speedbspec.el133
1 files changed, 133 insertions, 0 deletions
diff --git a/lisp/speedbspec.el b/lisp/speedbspec.el
new file mode 100644
index 00000000000..23d63d1e777
--- /dev/null
+++ b/lisp/speedbspec.el
@@ -0,0 +1,133 @@
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