annotate lisp/=speedbspec.el @ 31960:eb2d3d3a8eb5

(xreload): Note its need on GNU/Linux.
author Dave Love <fx@gnu.org>
date Thu, 28 Sep 2000 19:16:27 +0000
parents 434894b93608
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21652
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; speedbspec --- Buffer specialized configurations for speedbar
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1997, 1998 Free Software Foundation
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Version: 0.2
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: file, tags, tools
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; Speedbar provides a frame in which files, and locations in
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; files are displayed. These functions provide some mode-specific
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; displays for some existing emacs modes.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; To provide special service to all the modes supported by this file,
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; put the following in your .emacs file.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; (require 'speedbspec)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; This will load in the known functions, and the mode-enabling code
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; into 'change-major-mode-hook.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; You can interactivly try to enable speedbar specialized modes by
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; calling the function `speedbar-add-localized-speedbar-support' and
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; disable it with `speedbar-remove-localized-speedbar-support'.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; This file requires speedbar.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;;; Change log:
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; 0.1 - Initial revision requiring speedbar 0.5
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; 0.1.1 - `buffer-live-p' replacement on old emacsen
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; 0.2 - Moved actual work code into their own files.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; Check and load files that need loading before checking for the
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; menu variable.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; Made the functions to turn on/off speedbar support interactive.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; It is *not* a minor-mode, it mearly enables special speedbar
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; behaviors.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; 0.2.1 - Fix for emacs 20 when checking for autoload functions.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;;; Code:
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (require 'speedbar)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;;; Compatibility:
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; Thanks: ptype@dra.hmg.gb
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (if (fboundp 'buffer-live-p)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 nil
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (defun buffer-live-p (buffer)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 "Determine if the buffer is alive."
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (memq buffer (buffer-list))))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;;; Generic add-new-special-mode stuff
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;;
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (defvar speedbar-localized-buffer-queue nil
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 "List of buffers to localize for speedbar.")
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (defun speedbar-add-localized-speedbar-support-to-q ()
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 "Add speedbar support to all buffers in `speedbar-localized-buffer-queue'."
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (remove-hook 'post-command-hook
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 'speedbar-add-localized-speedbar-support-to-q)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (while speedbar-localized-buffer-queue
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (speedbar-add-localized-speedbar-support
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (car speedbar-localized-buffer-queue))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (setq speedbar-localized-buffer-queue
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (cdr speedbar-localized-buffer-queue))))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (defun speedbar-add-localized-speedbar-support (buffer)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 "Add localized speedbar support to BUFFER's mode if it is available."
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (interactive "bBuffer: ")
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (if (stringp buffer) (setq buffer (get-buffer buffer)))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (if (not (buffer-live-p buffer))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 nil
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (save-excursion
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (set-buffer buffer)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (save-match-data
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (let ((ms (symbol-name major-mode))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 v tmp)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (if (not (string-match "-mode$" ms))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 nil ;; do nothing to broken mode
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (setq ms (substring ms 0 (match-beginning 0)))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (setq v (intern-soft (concat ms "-speedbar-buttons")))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (if (not v)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 nil ;; do nothing if not defined
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;; If it is autoloaded, we need to load it now so that
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; we have access to the varialbe -speedbar-menu-items.
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; Is this XEmacs safe?
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (let ((sf (symbol-function v)))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (if (and (listp sf) (eq (car sf) 'autoload))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (load-library (car (cdr sf)))))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (set (make-local-variable 'speedbar-special-mode-expansion-list)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (list v))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (setq v (intern-soft (concat ms "-speedbar-menu-items")))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (if (not v)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 nil ;; don't add special menus
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (make-local-variable 'speedbar-easymenu-definition-special)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (setq speedbar-easymenu-definition-special
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (symbol-value v))))))))))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (defun speedbar-remove-localized-speedbar-support (buffer)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 "Remove any traces that BUFFER supports speedbar in a specialized way."
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (save-excursion
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (set-buffer buffer)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (kill-local-variable 'speedbar-special-mode-expansion-list)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (kill-local-variable 'speedbar-easymenu-definition-special)))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (defun speedbar-change-major-mode ()
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 "Run when the major mode is changed."
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (setq speedbar-localized-buffer-queue
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (add-to-list 'speedbar-localized-buffer-queue (current-buffer)))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (add-hook 'post-command-hook 'speedbar-add-localized-speedbar-support-to-q))
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (add-hook 'change-major-mode-hook 'speedbar-change-major-mode)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (add-hook 'find-file-hooks 'speedbar-change-major-mode)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (provide 'speedbspec)
434894b93608 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;;; speedbspec ends here