Mercurial > emacs
annotate lisp/emacs-lisp/eieio-speedbar.el @ 111502:df6573cbdd34
* lisp/emacs-lisp/pcase.el (pcase-let*, pcase-let): Add debug and
indentation specs.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 11 Nov 2010 20:35:06 -0500 |
parents | 280c8ae2476d |
children | 417b1e4d63cd |
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 |
106815 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2009, 2010 |
105282 | 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 | 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 |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106895
diff
changeset
|
9 ;; Package: eieio |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; 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
|
12 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 ;; 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
|
14 ;; 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
|
15 ;; 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
|
16 ;; (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
|
17 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 ;; 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
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 ;; 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
|
24 ;; 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
|
25 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;;; Commentary: |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 ;; 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
|
29 ;; 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
|
30 ;; of that type. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; 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
|
33 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 ;;; 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
|
35 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ;; 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
|
37 ;; 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
|
38 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 ;; 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
|
40 ;; 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
|
41 ;; * `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
|
42 ;; * `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
|
43 ;; * `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
|
44 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 ;; 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
|
46 ;; `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
|
47 ;; 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
|
48 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 ;; 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
|
50 ;; methods: |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 ;; * `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
|
52 ;; * `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
|
53 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 ;; 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
|
55 ;; `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
|
56 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 ;; 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
|
58 ;; 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
|
59 ;; path. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 ;; 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
|
62 ;; 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
|
63 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 ;; 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
|
65 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 ;; 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
|
67 ;; 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
|
68 ;; 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
|
69 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 ;; 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
|
71 ;; 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
|
72 ;; `eieio-speedbar-menu'. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 ;; 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
|
75 ;; 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
|
76 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 ;; 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
|
78 ;; 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
|
79 ;; 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
|
80 ;; |
105327 | 81 ;; 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
|
82 ;; |
105327 | 83 ;; (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
|
84 ;; "documentation" |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 ;; (interactive) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 ;; (speedbar-frame-mode 1) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 ;; (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
|
88 ;; (speedbar-get-focus)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 ;; 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
|
91 ;; as the MODENAME parameter. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 ;; @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
|
94 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 ;;; Code: |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 (require 'eieio) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 (require 'eieio-custom) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 (require 'speedbar) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 ;;; 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
|
101 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 (defun eieio-speedbar-make-map () |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 "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
|
104 (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
|
105 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 ;; General viewing things |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 (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
|
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-expand-line) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 (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
|
111 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 ;; Some object based things |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 (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
|
114 map)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 (defvar eieio-speedbar-key-map (eieio-speedbar-make-map) |
105474 | 117 "A generic object based speedbar display keymap.") |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 (defvar eieio-speedbar-menu |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 '([ "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
|
121 [ "Expand Object" speedbar-expand-line |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 (save-excursion (beginning-of-line) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 (looking-at "[0-9]+: *.\\+. "))] |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 [ "Contract Object" speedbar-contract-line |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 (save-excursion (beginning-of-line) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 (looking-at "[0-9]+: *.-. "))] |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 "---" |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 [ "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
|
129 (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
|
130 ) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 "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
|
132 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 ;; 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
|
134 (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
|
135 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 (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
|
137 "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
|
138 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
|
139 MAP-VAR is the keymap variable used. |
105327 | 140 MENU-VAR is the symbol containing an easymenu compatible menu part to use. |
141 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
|
142 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
|
143 creating the speedbar display." |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 (if (not (featurep 'speedbar)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 (add-hook 'speedbar-load-hook |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (list 'lambda nil |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 (list 'eieio-speedbar-create-engine |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 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 (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
|
150 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 (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
|
152 "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
|
153 Called from `eieio-speedbar-create', or the speedbar load-hook. |
105474 | 154 MAP-FN, MAP-VAR, MENU-VAR, MODENAME, and FETCHER are the same as in |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 `eieio-speedbar-create'." |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 ;; make sure the keymap exists |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 (funcall map-fn) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 ;; Add to the expansion list. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 (speedbar-add-expansion-list |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 (list modename |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 menu-var |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 map-var |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 (list 'lambda '(dir depth) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 (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
|
165 (list 'quote fetcher))))) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 ;; Set the special functions. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 (speedbar-add-mode-functions-list |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 (list modename |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 '(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
|
170 '(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
|
171 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 (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
|
173 "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
|
174 Start in directory DIR-OR-OBJECT. If it is an object, just display that |
105474 | 175 object's subelements. |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 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
|
177 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
|
178 that path." |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 (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
|
180 (list dir-or-object)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 ((stringp dir-or-object) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 (funcall fetcher dir-or-object)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 (t dir-or-object)))) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 (if (not objlst) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 (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
|
186 depth) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 ;; Dump all objects into speedbar |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 (while objlst |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 (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
|
190 (setq objlst (cdr objlst)))))) |
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 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 ;;; DEFAULT SUPERCLASS baseline methods |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 ;; 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
|
196 ;; will have some minor support. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 (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
|
199 "Return a string describing OBJECT." |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 (object-name-string object)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 (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
|
203 "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
|
204 nil) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 (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
|
207 "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
|
208 (object-name-string object)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 (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
|
211 depth) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 "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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 (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
|
218 (eieio-speedbar-object-buttonname object) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 'eieio-speedbar-object-click |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 object |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 'speedbar-tag-face |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 depth)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 (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
|
225 "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
|
226 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
|
227 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
|
228 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
|
229 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 If your object represents some other item, override this method |
106895
181539c8b6a4
Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
231 and take the appropriate action." |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 (require 'eieio-custom) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 (speedbar-with-attached-buffer |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 (eieio-customize-object object)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 (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
|
236 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 ;;; Class definitions |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 ;; 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
|
241 ;; 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
|
242 ;; object hierarchies. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 ;; 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
|
245 ;; lists of children buttons. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 (defclass eieio-speedbar nil |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 ((buttontype :initform nil |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 :type symbol |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 :documentation |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 "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
|
252 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
|
253 to `speedbar-make-tag-line'." |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 :allocation :class) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 (buttonface :initform speedbar-tag-face |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 :type (or symbol face) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 :documentation |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 "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
|
259 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
|
260 :allocation :class) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (expanded :initform nil |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 :type boolean |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 :documentation |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 "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
|
265 ) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 "Class which provides basic speedbar support for child classes. |
105474 | 267 Add one of the child classes to this class to the parent list of a class." |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 :method-invocation-order :depth-first |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 :abstract t) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 (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
|
272 ((buttontype :initform angle) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 (buttonface :initform speedbar-directory-face)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 "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
|
275 :method-invocation-order :depth-first |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 :abstract t) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 (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
|
279 ((buttontype :initform bracket) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 (buttonface :initform speedbar-file-face)) |
105474 | 281 "Class providing support for objects which behave like a file." |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 :method-invocation-order :depth-first |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 :abstract t) |
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 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 ;;; 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
|
287 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 (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
|
289 depth) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 "Insert a tag line into speedbar at point for OBJECT. |
105474 | 291 All objects a child of symbol `eieio-speedbar' can be created from |
292 this method. Override this if you need non-traditional tag lines. | |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 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
|
294 (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
|
295 (exp (oref object expanded))) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 (if (not children) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 (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
|
298 (speedbar-make-tag-line 'statictag |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 ? nil nil |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 (eieio-speedbar-object-buttonname object) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 'eieio-speedbar-object-click |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 object |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 (oref object buttonface) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 depth) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 (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
|
306 ? nil nil |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 (eieio-speedbar-object-buttonname object) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 'eieio-speedbar-object-click |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 object |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (oref object buttonface) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 depth)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 (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
|
313 (if exp ?- ?+) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 'eieio-speedbar-object-expand |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 object |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 (eieio-speedbar-object-buttonname object) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 'eieio-speedbar-object-click |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 object |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 (oref object buttonface) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 depth) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 (if exp |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 (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
|
323 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 (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
|
325 "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
|
326 (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
|
327 (object-name object))) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 (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
|
330 "Expand OBJECT at indentation DEPTH. |
106895
181539c8b6a4
Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
331 Inserts a list of new tag lines representing expanded elements within |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 OBJECT." |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 (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
|
334 (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
|
335 (mapcar (lambda (car) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 (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
|
337 children)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 (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
|
339 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 ;;; Speedbar specific function callbacks. |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 (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
|
344 "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
|
345 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
|
346 (eieio-speedbar-handle-click token)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 (defun eieio-speedbar-object-expand (text token indent) |
105474 | 349 "Expand object represented by TEXT. |
350 TOKEN is the object. INDENT is the current indentation level." | |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 (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
|
352 (speedbar-change-expand-button-char ?-) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (oset token expanded t) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 (speedbar-with-writable |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 (save-excursion |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 (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
|
357 (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
|
358 ((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
|
359 (speedbar-change-expand-button-char ?+) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 (oset token expanded nil) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 (speedbar-delete-subblock indent)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (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
|
363 (speedbar-center-buffer-smartly)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 (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
|
366 "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
|
367 (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
|
368 (object-name obj))) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 (defun eieio-speedbar-item-info () |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 "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
|
372 ;; 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
|
373 (let ((tok (speedbar-line-token))) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 (cond ((eieio-object-p tok) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 (message (eieio-speedbar-description tok))) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 (t |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 (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
|
378 (if no |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 (eieio-speedbar-child-description no))))))) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 (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
|
382 "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
|
383 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
|
384 (save-excursion |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 (if (not depth) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 (progn |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 (beginning-of-line) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 (when (looking-at "^\\([0-9]+\\):") |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 (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
|
390 (when depth |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (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
|
392 (> depth 0)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 (setq depth (1- depth)) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 (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
|
395 (speedbar-line-token)))) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 (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
|
398 "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
|
399 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
|
400 (save-match-data |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 (if (not depth) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 (progn |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 (beginning-of-line) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 (looking-at "^\\([0-9]+\\):") |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 (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
|
406 ;; 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
|
407 (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
|
408 (if (eieio-object-p tok) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 (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
|
410 default-directory)))) |
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 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 ;;; 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
|
414 ;; |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 (defmethod eieio-speedbar-object-children ((object eieio-speedbar)) |
105474 | 416 "Return a list of children to be displayed in speedbar. |
104431
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 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
|
418 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
|
419 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
|
420 to create a speedbar button." |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 nil) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 (provide 'eieio-speedbar) |
a64f3429f0ac
emacs-lisp/eieio-base.el, emacs-lisp/eieio-comp.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
424 |
105377 | 425 ;; 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
|
426 ;;; eieio-speedbar.el ends here |