annotate lisp/emacs-lisp/eieio-speedbar.el @ 105458:4d2aa5860e37

(Ffile_attributes): Doc fix. (Bug#4638)
author Eli Zaretskii <eliz@gnu.org>
date Mon, 05 Oct 2009 08:35:12 +0000
parents 7f4c7f5c0eba
children 0a64442c10e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104431
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; eieio-speedbar.el -- Classes for managing speedbar displays.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
105282
bdd443ec02cf Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 104431
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2009
bdd443ec02cf Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 104431
diff changeset
4 ;; Free Software Foundation, Inc.
104431
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5
105327
dcbb3800a4e1 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105282
diff changeset
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
104431
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Version: 0.2
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8 ;; Keywords: OO, tools
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; (at your option) any later version.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;; Commentary:
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; This provides some classes that can be used as a parent which
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;; will automatically provide SPEEDBAR support for any list of objects
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; of that type.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; This file requires speedbar version 0.10 or later.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;;; Creating a new speedbar mode based on a pre-existing object hierarchy
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;; To create a new speedbar mode based on lists of objects is easier
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;; than creating a whole new speedbar mode from scratch.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;; 1) Objects that will have lists of items that can be expanded
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;; should also inherit from the classes:
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ;; * `eieio-speedbar' - specify your own button behavior
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 ;; * `eieio-speedbar-directory-button' - objects that behave like directories
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 ;; * `eieio-speedbar-file-button' - objects that behave like files
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;; 2) Objects that have lists of children should implement the method
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ;; `eieio-speedbar-object-children' which returns a list of more
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;; objects, or a list of strings.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 ;; 3) Objects that return a list of strings should also implement these
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;; methods:
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ;; * `eieio-speedbar-child-make-tag-lines' - make tag lines for a child.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 ;; * `eieio-speedbar-child-description' - describe non-object children
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 ;; 4) Objects which have expanded information should implement the method
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 ;; `eieio-speedbar-description' to produce more information.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ;; 5) Objects that are associated with a directory should implement
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 ;; the method `eieio-speedbar-derive-line-path' which returns a
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 ;; path.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 ;; 6) Objects that have a specialized behavior when clicked should
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 ;; define the method `eieio-speedbar-handle-click'.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;; To initialize a new eieio based speedbar display, do the following.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 ;; 1) Create a keymap variable `foo-speedbar-key-map'.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 ;; This keymap variable should be initialized in a function.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 ;; If you have no special needs, use `eieio-speedbar-key-map'
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 ;; 2) Create a variable containing an easymenu definition compatible
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;; with speedbar. if you have no special needs, use
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 ;; `eieio-speedbar-menu'.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 ;; 3) Create a function which returns the top-level list of children
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 ;; objects to be displayed in speedbar.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 ;; 4) Call `eieio-speedbar-create' as specified in it's documentation
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 ;; string. This will automatically handle cases when speedbar is
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 ;; not already loaded, and specifying all overload functions.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 ;;
105327
dcbb3800a4e1 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105282
diff changeset
80 ;; 5) Create an initializer function which looks like this:
104431
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 ;;
105327
dcbb3800a4e1 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105282
diff changeset
82 ;; (defun my-speedbar-mode-initialize ()
104431
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 ;; "documentation"
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 ;; (interactive)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 ;; (speedbar-frame-mode 1)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 ;; (speedbar-change-initial-expansion-list mymodename)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 ;; (speedbar-get-focus))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 ;; where `mymodename' is the same value as passed to `eieio-speedbar-create'
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 ;; as the MODENAME parameter.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 ;; @todo - Can we make this ECB friendly?
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 ;;; Code:
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 (require 'eieio)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 (require 'eieio-custom)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 (require 'speedbar)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 ;;; Support a way of adding generic object based modes into speedbar.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (defun eieio-speedbar-make-map ()
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 "Make the generic object based speedbar keymap."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (let ((map (speedbar-make-specialized-keymap)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 ;; General viewing things
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (define-key map "\C-m" 'speedbar-edit-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 (define-key map "+" 'speedbar-expand-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (define-key map "=" 'speedbar-expand-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (define-key map "-" 'speedbar-contract-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 ;; Some object based things
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (define-key map "C" 'eieio-speedbar-customize-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 map))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (defvar eieio-speedbar-key-map (eieio-speedbar-make-map)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 "A Generic object based speedbar display keymap.")
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 (defvar eieio-speedbar-menu
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 '([ "Edit Object/Field" speedbar-edit-line t]
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 [ "Expand Object" speedbar-expand-line
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 (save-excursion (beginning-of-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (looking-at "[0-9]+: *.\\+. "))]
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 [ "Contract Object" speedbar-contract-line
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (save-excursion (beginning-of-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 (looking-at "[0-9]+: *.-. "))]
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 "---"
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 [ "Customize Object" eieio-speedbar-customize-line
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 (eieio-object-p (speedbar-line-token)) ]
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 )
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 "Menu part in easymenu format used in speedbar while browsing objects.")
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 ;; Note to self: Fix this silly thing!
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 (defalias 'eieio-speedbar-customize-line 'speedbar-edit-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 (defun eieio-speedbar-create (map-fn map-var menu-var modename fetcher)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 "Create a speedbar mode for displaying an object hierarchy.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 MAP-FN is the keymap generator function used for extra keys.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 MAP-VAR is the keymap variable used.
105327
dcbb3800a4e1 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105282
diff changeset
139 MENU-VAR is the symbol containing an easymenu compatible menu part to use.
dcbb3800a4e1 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105282
diff changeset
140 MODENAME is a string used to identify this browser mode.
104431
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 FETCHER is a generic function used to fetch the base object list used when
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 creating the speedbar display."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (if (not (featurep 'speedbar))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (add-hook 'speedbar-load-hook
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 (list 'lambda nil
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 (list 'eieio-speedbar-create-engine
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 map-fn map-var menu-var modename fetcher)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (eieio-speedbar-create-engine map-fn map-var menu-var modename fetcher)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 (defun eieio-speedbar-create-engine (map-fn map-var menu-var modename fetcher)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 "Create a speedbar mode for displaying an object hierarchy.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 Called from `eieio-speedbar-create', or the speedbar load-hook.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 MAP-FN, MAP-VAR, MENU-VAR, MODENAME, and FETCHER are the same as
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 `eieio-speedbar-create'."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 ;; make sure the keymap exists
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (funcall map-fn)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 ;; Add to the expansion list.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 (speedbar-add-expansion-list
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 (list modename
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 menu-var
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 map-var
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 (list 'lambda '(dir depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (list 'eieio-speedbar-buttons 'dir 'depth
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (list 'quote fetcher)))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 ;; Set the special functions.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (speedbar-add-mode-functions-list
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 (list modename
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 '(speedbar-item-info . eieio-speedbar-item-info)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 '(speedbar-line-directory . eieio-speedbar-line-path))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 (defun eieio-speedbar-buttons (dir-or-object depth fetcher)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 "Create buttons for the speedbar display.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 Start in directory DIR-OR-OBJECT. If it is an object, just display that
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 objects subelements.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 Argument DEPTH specifies how far down we have already been displayed.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 If it is a directory, use FETCHER to fetch all objects associated with
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 that path."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (let ((objlst (cond ((eieio-object-p dir-or-object)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (list dir-or-object))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 ((stringp dir-or-object)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (funcall fetcher dir-or-object))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (t dir-or-object))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (if (not objlst)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (speedbar-make-tag-line nil nil nil nil "Empty display" nil nil nil
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 ;; Dump all objects into speedbar
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 (while objlst
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (eieio-speedbar-make-tag-line (car objlst) depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (setq objlst (cdr objlst))))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 ;;; DEFAULT SUPERCLASS baseline methods
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 ;; First, define methods onto the superclass so all classes
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 ;; will have some minor support.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (defmethod eieio-speedbar-description ((object eieio-default-superclass))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 "Return a string describing OBJECT."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (object-name-string object))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (defmethod eieio-speedbar-derive-line-path ((object eieio-default-superclass))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 "Return the path which OBJECT has something to do with."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 nil)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (defmethod eieio-speedbar-object-buttonname ((object eieio-default-superclass))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 "Return a string to use as a speedbar button for OBJECT."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (object-name-string object))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (defmethod eieio-speedbar-make-tag-line ((object eieio-default-superclass)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 "Insert a tag line into speedbar at point for OBJECT.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 By default, all objects appear as simple TAGS with no need to inherit from
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 the special `eieio-speedbar' classes. Child classes should redefine this
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 method to create more accurate tag lines.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 Argument DEPTH is the depth at which the tag line is inserted."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (speedbar-make-tag-line nil nil nil nil
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (eieio-speedbar-object-buttonname object)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 'eieio-speedbar-object-click
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 object
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 'speedbar-tag-face
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 depth))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (defmethod eieio-speedbar-handle-click ((object eieio-default-superclass))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 "Handle a click action on OBJECT in speedbar.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 Any object can be represented as a tag in SPEEDBAR without special
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 attributes. These default objects will be pulled up in a custom
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 object edit buffer doing an in-place edit.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 If your object represents some other item, override this method
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 and take the apropriate action."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (require 'eieio-custom)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 (speedbar-with-attached-buffer
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (eieio-customize-object object))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 (speedbar-maybee-jump-to-attached-frame))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 ;;; Class definitions
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 ;; Now define a special speedbar class with some
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 ;; variables with :allocation class which can be attached into
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 ;; object hierarchies.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 ;; These more complex types are for objects which wish to display
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 ;; lists of children buttons.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (defclass eieio-speedbar nil
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 ((buttontype :initform nil
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 :type symbol
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 :documentation
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 "The type of expansion button used for objects of this class.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 Possible values are those symbols supported by the `exp-button-type' argument
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 to `speedbar-make-tag-line'."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 :allocation :class)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (buttonface :initform speedbar-tag-face
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 :type (or symbol face)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 :documentation
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 "The face used on the textual part of the button for this class.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 See `speedbar-make-tag-line' for details."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 :allocation :class)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (expanded :initform nil
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 :type boolean
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 :documentation
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 "State of an object being expanded in speedbar.")
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 )
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 "Class which provides basic speedbar support for child classes.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 Add one of thie child classes to this class to the parent list of a class."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 :method-invocation-order :depth-first
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 :abstract t)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 (defclass eieio-speedbar-directory-button (eieio-speedbar)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 ((buttontype :initform angle)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (buttonface :initform speedbar-directory-face))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 "Class providing support for objects which behave like a directory."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 :method-invocation-order :depth-first
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 :abstract t)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (defclass eieio-speedbar-file-button (eieio-speedbar)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 ((buttontype :initform bracket)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 (buttonface :initform speedbar-file-face))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 "Class providing support for objects which behave like a directory."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 :method-invocation-order :depth-first
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 :abstract t)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 ;;; Methods to eieio-speedbar-* which do not need to be overriden
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (defmethod eieio-speedbar-make-tag-line ((object eieio-speedbar)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 "Insert a tag line into speedbar at point for OBJECT.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 All objects a child of symbol `eieio-speedbar' can be created from this
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 method. Override this if you need non-traditional tag lines.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 Argument DEPTH is the depth at which the tag line is inserted."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 (let ((children (eieio-speedbar-object-children object))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (exp (oref object expanded)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (if (not children)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (if (eq (oref object buttontype) 'expandtag)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (speedbar-make-tag-line 'statictag
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 ? nil nil
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (eieio-speedbar-object-buttonname object)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 'eieio-speedbar-object-click
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 object
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 (oref object buttonface)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (speedbar-make-tag-line (oref object buttontype)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 ? nil nil
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (eieio-speedbar-object-buttonname object)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 'eieio-speedbar-object-click
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 object
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (oref object buttonface)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 depth))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (speedbar-make-tag-line (oref object buttontype)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 (if exp ?- ?+)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 'eieio-speedbar-object-expand
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 object
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 (eieio-speedbar-object-buttonname object)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 'eieio-speedbar-object-click
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 object
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 (oref object buttonface)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 (if exp
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (eieio-speedbar-expand object (1+ depth))))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (defmethod eieio-speedbar-child-make-tag-lines ((object eieio-speedbar) depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 "Base method for creating tag lines for non-object children."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (error "You must implement `eieio-speedbar-child-make-tag-lines' for %s"
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (object-name object)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (defmethod eieio-speedbar-expand ((object eieio-speedbar) depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 "Expand OBJECT at indentation DEPTH.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 Inserts a list of new tag lines representing expanded elements withing
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 OBJECT."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 (let ((children (eieio-speedbar-object-children object)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 (cond ((eieio-object-p (car children))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (mapcar (lambda (car)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (eieio-speedbar-make-tag-line car depth))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 children))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (children (eieio-speedbar-child-make-tag-lines object depth)))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 ;;; Speedbar specific function callbacks.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 (defun eieio-speedbar-object-click (text token indent)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 "Handle a user click on TEXT representing object TOKEN.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 The object is at indentation level INDENT."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 (eieio-speedbar-handle-click token))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (defun eieio-speedbar-object-expand (text token indent)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 "Expand object represented by TEXT. TOKEN is the object.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 INDENT is the current indentation level."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (cond ((string-match "+" text) ;we have to expand this file
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (speedbar-change-expand-button-char ?-)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (oset token expanded t)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (speedbar-with-writable
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 (save-excursion
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 (end-of-line) (forward-char 1)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (eieio-speedbar-expand token (1+ indent)))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 ((string-match "-" text) ;we have to contract this node
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 (speedbar-change-expand-button-char ?+)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (oset token expanded nil)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 (speedbar-delete-subblock indent))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (t (error "Ooops... not sure what to do")))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 (speedbar-center-buffer-smartly))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (defmethod eieio-speedbar-child-description ((obj eieio-speedbar))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 "Return a description for a child of OBJ which is not an object."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (error "You must implement `eieio-speedbar-child-description' for %s"
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 (object-name obj)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 (defun eieio-speedbar-item-info ()
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 "Display info for the current line when in EDE display mode."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 ;; Switch across the types of the tokens.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 (let ((tok (speedbar-line-token)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 (cond ((eieio-object-p tok)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (message (eieio-speedbar-description tok)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 (t
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (let ((no (eieio-speedbar-find-nearest-object)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (if no
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 (eieio-speedbar-child-description no)))))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (defun eieio-speedbar-find-nearest-object (&optional depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 "Search backwards to the first line associated with an object.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 Optional argument DEPTH is the current depth of the search."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (save-excursion
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 (if (not depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (progn
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (beginning-of-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (when (looking-at "^\\([0-9]+\\):")
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (setq depth (string-to-number (match-string 1))))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (when depth
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (while (and (not (eieio-object-p (speedbar-line-token)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (> depth 0))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 (setq depth (1- depth))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (re-search-backward (format "^%d:" depth) nil t))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (speedbar-line-token))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 (defun eieio-speedbar-line-path (&optional depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 "If applicable, return the path to the file the cursor is on.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 Optional DEPTH is the depth we start at."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (save-match-data
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (if (not depth)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (progn
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (beginning-of-line)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (looking-at "^\\([0-9]+\\):")
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (setq depth (string-to-number (match-string 1)))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 ;; This whole function is presently bogus. Make it better later.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (let ((tok (eieio-speedbar-find-nearest-object depth)))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 (if (eieio-object-p tok)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (eieio-speedbar-derive-line-path tok)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 default-directory))))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 ;;; Methods to the eieio-speedbar-* classes which need to be overriden.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 ;;
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (defmethod eieio-speedbar-object-children ((object eieio-speedbar))
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 "Return a list of children to be displayed in SPEEDBAR.
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 If the return value is a list of OBJECTs, then those objects are
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 queried for details. If the return list is made of strings,
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 then this object will be queried for the details needed
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 to create a speedbar button."
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 nil)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (provide 'eieio-speedbar)
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105327
diff changeset
424 ;; arch-tag: eaac1283-10b0-4419-a929-982b87e83234
104431
a64f3429f0ac emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 ;;; eieio-speedbar.el ends here