viper -- Update and prettify package-info.in provides.
[packages] / xemacs-packages / ecb / ecb-method-browser.el
1 ;;; ecb-method-browser.el --- the method-browser of Emacs
2
3 ;; Copyright (C) 2000 - 2003 Jesper Nordenberg,
4 ;;                           Klaus Berndl,
5 ;;                           Free Software Foundation, Inc.
6
7 ;; Author: Jesper Nordenberg <mayhem@home.se>
8 ;;         Klaus Berndl <klaus.berndl@sdm.de>
9 ;; Maintainer: Klaus Berndl <klaus.berndl@sdm.de>
10 ;;             Kevin A. Burton <burton@openprivacy.org>
11 ;; Keywords: browser, code, programming, tools
12 ;; Created: 2000
13
14 ;; This program is free software; you can redistribute it and/or modify it under
15 ;; the terms of the GNU General Public License as published by the Free Software
16 ;; Foundation; either version 2, or (at your option) any later version.
17
18 ;; This program is distributed in the hope that it will be useful, but WITHOUT
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 ;; FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
21 ;; details.
22
23 ;; You should have received a copy of the GNU General Public License along with
24 ;; GNU Emacs; see the file COPYING.  If not, write to the Free Software
25 ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;; $Id: ecb-method-browser.el,v 1.8 2004-12-10 16:34:17 berndl Exp $
28
29 ;;; Commentary:
30
31 ;; This file contains the code for the method-browser of ECB
32
33
34 (require 'tree-buffer)
35 (require 'ecb-util)
36 (require 'ecb-layout)
37 (require 'ecb-mode-line)
38 (require 'ecb-navigate)
39 (require 'ecb-face)
40 (require 'ecb-speedbar)
41 (require 'ecb-common-browser)
42
43 (require 'ecb-semantic-wrapper)
44 ;; This loads the semantic-setups for the major-modes.
45 (require 'semantic-load)
46
47 ;; various loads
48 (require 'assoc)
49
50 (eval-when-compile
51   ;; to avoid compiler grips
52   (require 'cl))
53
54 (eval-when-compile
55   (require 'silentcomp))
56
57 (silentcomp-defun hs-minor-mode)
58 (silentcomp-defun hs-show-block)
59 (silentcomp-defun hs-hide-block)
60 (silentcomp-defvar hs-minor-mode)
61 (silentcomp-defvar hs-block-start-regexp)
62 (silentcomp-defvar imenu--index-alist)
63
64 (silentcomp-defun ecb-get-tags-for-non-semantic-files)
65 (silentcomp-defun ecb-create-non-semantic-tree)
66
67 (defvar ecb-selected-tag nil
68   "The currently selected Semantic tag.")
69 (make-variable-buffer-local 'ecb-selected-tag)
70
71 (defvar ecb-methods-root-node nil
72   "Path to currently selected source.")
73
74 (defconst ecb-methods-nodetype-tag 0)
75 (defconst ecb-methods-nodetype-bucket 1)
76 (defconst ecb-methods-nodetype-externtag 2)
77
78 (defun ecb-method-browser-initialize-caches ()
79   "Initialize the caches of the method-browser of ECB."
80   (ecb-clear-tag-tree-cache))
81
82 (defun ecb-method-browser-initialize (&optional no-caches)
83   "Initialize the method-browser of ECB. If optional arg NO-CACHES is not nil
84 then the caches used by the method-browser will not be initialized."
85   (setq ecb-selected-tag nil)
86   (setq ecb-methods-root-node nil)
87   (setq ecb-methods-user-filter-alist nil)
88   (setq ecb-current-post-processed-tag-table nil)
89   (unless no-caches
90     (ecb-method-browser-initialize-caches)))
91
92 ;;====================================================
93 ;; Customization
94 ;;====================================================
95
96 (defgroup ecb-methods nil
97   "Settings for the methods-buffer in the Emacs code browser."
98   :group 'ecb
99   :prefix "ecb-")
100
101
102 (defgroup ecb-non-semantic nil
103   "Settings for parsing and displaying non-semantic files."
104   :group 'ecb
105   :prefix "ecb-")
106
107
108 (defcustom ecb-methods-buffer-name " *ECB Methods*"
109   "*Name of the ECB methods buffer.
110 Because it is not a normal buffer for editing you should enclose the name with
111 stars, e.g. \"*ECB Methods*\".
112
113 If it is necessary for you you can get emacs-lisp access to the buffer-object of
114 the ECB-methods-buffer by this name, e.g. by a call of `set-buffer'.
115
116 Changes for this option at runtime will take affect only after deactivating and
117 then activating ECB again!"
118   :group 'ecb-methods
119   :type 'string)
120
121
122 (defcustom ecb-auto-expand-tag-tree 'expand-spec
123   "*Expand the methods-tag-tree automatically if node invisible.
124 This option has only an effect if option `ecb-highlight-tag-with-point' is
125 switched on too. There are three possible choices:
126 - nil: No auto. expanding of the method buffer.
127 - expand-spec: Auto expand the method-buffer nodes if the node belonging to
128   current tag under point is invisible because its parent-node is collapsed.
129   But expanding is only done if the type of the tag under point in the
130   edit-buffer is contained in `ecb-methods-nodes-expand-spec'.
131 - all: Like expand-spec but expands all tags regardless of the setting in
132   `ecb-methods-nodes-expand-spec'.
133
134 This options takes only effect for semantic-sources - means sources supported
135 by semantic!"
136   :group 'ecb-methods
137   :type '(radio (const :tag "No auto. expand" :value nil)
138                 (const :tag "Expand as specified" :value expand-spec)
139                 (const :tag "Expand all" :value all)))
140
141
142 (defcustom ecb-auto-expand-tag-tree-collapse-other nil
143   "*Auto. expanding the tag-tree collapses all not related nodes.
144 There are several choices:
145 - Only if on tag: This means collapsing all nodes which have no relevance for
146   the currently highlighted node will be collapsed, because they are not
147   necessary to make the highlighted node visible. But do this only if point
148   stays onto a tag in the selected edit-window.
149 - Always: Same as before but collapse also when point doesn't stays on a tag
150   \(e.g. between two defuns in elisp) in the selected edit-window. This means
151   in such a situation a full collapsing of the methods-buffer.
152 - Never: Do not automatically collapse the methods-buffer."
153   :group 'ecb-methods
154   :type '(radio (const :tag "Collapse only when point stays on a tag"
155                        :value only-if-on-tag)
156                 (const :tag "Collapse always" :value always)
157                 (const :tag "Never" :value nil)))
158
159 (defcustom ecb-expand-methods-switch-off-auto-expand t
160   "*Switch off auto expanding in the ECB-method buffer.
161 If on then auto expanding is switched off after explicit expanding or
162 collapsing by `ecb-expand-methods-nodes'.
163
164 This is done with `ecb-toggle-auto-expand-tag-tree' so after the switch off
165 the auto expanding feature can again switched on quickly.
166
167 But after explicitly expanding/collapsing the methods-buffer to a certain
168 level the auto. expanding could undo this when the node belonging to current
169 tag under point in the edit-window is invisible after
170 `ecb-expand-methods-nodes' - then the auto. expand feature would make this
171 node immediately visible and destroys the explicitly set expand-level."
172   :group 'ecb-methods
173   :type 'boolean)
174
175
176 (defcustom ecb-auto-update-methods-after-save t
177   "*Automatically updating the ECB method buffer after saving a source."
178   :group 'ecb-methods
179   :type 'boolean)
180
181
182 (defcustom ecb-font-lock-tags t
183   "*Adds font-locking \(means highlighting) to the ECB-method buffer.
184 This options takes only effect for semantic-sources - means sources supported
185 by semantic!"
186   :group 'ecb-methods
187   :set (function (lambda (symbol value)
188                    (set symbol value)
189                    (ecb-clear-tag-tree-cache)))
190   :type 'boolean
191   :initialize 'custom-initialize-default)
192
193
194 (defcustom ecb-tag-jump-sets-mark t
195   "*Set the mark after jumping to a tag from the ECB-method buffer.
196 If set the user can easily jump back."
197   :group 'ecb-methods
198   :type 'boolean)
199
200 (defconst ecb-tag->text-functions
201   (mapcar (lambda (fkt-elem)
202             (cons (intern
203                    (concat "ecb-"
204                            (mapconcat 'identity
205                                       (cdr (split-string (symbol-name
206                                                           (cdr fkt-elem)) "-"))
207                                       "-")))
208                   (intern
209                    (concat "ecb--" (symbol-name (cdr fkt-elem))))))
210           ecb--semantic-format-function-alist)
211   "Alist containing one element for every member of 
212 `ecb--semantic-format-function-alist'")
213
214 (defcustom ecb-tag-display-function '((default . ecb-format-tag-uml-prototype))
215   "*Function to use for displaying tags in the methods buffer.
216 This functionality is set on major-mode base, i.e. for every major-mode a
217 different function can be used. The value of this option is a list of
218 cons-cells:
219 - The car is either a major-mode symbol or the special symbol 'default which
220   means if no function for a certain major-mode is defined then the cdr of
221   the 'default cons-cell is used.
222 - The cdr is the function used for displaying a tag in the related
223   major-mode.
224 Every function is called with 3 arguments:
225 1. The tag
226 2. The parent-tag of tag \(can be nil)
227 3. The value of `ecb-font-lock-tags'.
228 Every function must return the display of the tag as string, colorized if
229 the third argument is not nil.
230
231 The following functions are predefined:
232 - For each element E of `ecb--semantic-format-function-alist' exists a
233   function with name \"ecb--<\(cdr E)>\". These functions are just aliase to
234   the builtin format-functions of semantic. See the docstring of these
235   functions to see what they do.
236   Example: \(semantic-name-nonterminal . semantic-format-tag-name) is an
237   element of `ecb--semantic-format-function-alist'. Therefore the
238   alias-function for this element is named `ecb--semantic-format-tag-name'.
239 - For every cdr in `ecb--semantic-format-function-alist' with name
240   \"semantic-XYZ\" a function with name \"ecb-XYC\" is predefined. The
241   differences between the semantic- and the ECB-version are:
242   + The ECB-version displays for type tags only the type-name and nothing
243     else \(exception: In c++-mode a template specifier is appended to the
244     type-name if a template instead a normal class).
245   + The ECB-version displays type-tags according to the setting in
246     `ecb-type-tag-display'. This is useful for better recognizing
247     different classes, structs etc. in the ECB-method window.
248   For all tags which are not types the display of the ECB-version is
249   identical to the semantic version. Example: For
250   `ecb--semantic-format-tag-name' \(the builtin semantic formatter) the
251   pendant is `ecb-format-tag-name'.
252
253 This functionality also allows the user to display tags as UML. To enable
254 this functionality set the function for a major-mode \(e.g. `jde-mode') to
255 `ecb--semantic-format-tag-uml-concise-prototype',
256 `ecb--semantic-format-tag-uml-prototype', or
257 `ecb--semantic-format-tag-uml-abbreviate' the ECB-versions of these functions.
258
259 If the value is nil, i.e. neither a function for a major-mode is defined nor
260 the special 'default, then `ecb--semantic-format-tag-prototype' is used for
261 displaying the tags.
262
263 This options takes only effect for semantic-sources - means sources supported
264 by semantic!"
265   :group 'ecb-methods
266   :group 'ecb-most-important
267   :set (function (lambda (symbol value)
268                    (set symbol value)
269                    (ecb-clear-tag-tree-cache)))
270   :type (list 'repeat ':tag "Display functions per mode"
271               (list 'cons ':tag "Mode tag display"
272                     '(symbol :tag "Major mode")
273                     (nconc (list 'choice ':tag "Display function"
274                                  ':menu-tag '"Display function")
275                            (append
276                             (mapcar (lambda (f)
277                                       (list 'const ':tag
278                                             (symbol-name (car f)) (car f)))
279                                     ecb-tag->text-functions)
280                             (mapcar (lambda (f)
281                                       (list 'const ':tag
282                                             (symbol-name (cdr f)) (cdr f)))
283                                     ecb-tag->text-functions)
284                             (list '(function :tag "Function"))))))
285   :initialize 'custom-initialize-default)
286
287 (defun ecb-get-tag-display-function ()
288   (let ((mode-display-fkt (cdr (assoc major-mode ecb-tag-display-function)))
289         (default-fkt (cdr (assoc 'default ecb-tag-display-function))))
290     (or (and (fboundp mode-display-fkt) mode-display-fkt)
291         (and (fboundp default-fkt) default-fkt)
292         'ecb--semantic-format-tag-prototype)))
293   
294
295 (defcustom ecb-type-tag-display nil
296   "*How to display semantic type-tags in the methods buffer.
297 Normally all tag displaying, colorizing and facing is done by semantic
298 according to the value of `ecb--semantic-format-face-alist' and the semantic
299 display-function \(e.g. one from `ecb--semantic-format-function-alist'). But
300 sometimes a finer distinction in displaying the different type specifiers of
301 type-tags can be useful. For a description when this option is evaluated look
302 at `ecb-tag-display-function'!
303
304 This functionality is set on a major-mode base, i.e. for every major-mode a
305 different setting can be used. The value of this option is a list of
306 cons-cells:
307 - The car is either a major-mode symbol or the special symbol 'default which
308   means if no setting for a certain major-mode is defined then the cdr of
309   the 'default cons-cell is used.
310 - The cdr is a list of 3-element-lists:
311   1. First entry is a semantic type specifier in string-form. Current
312      available type specifiers are for example \"class\", \"interface\",
313      \"struct\", \"typedef\", \"union\" and \"enum\". In addition to these
314      ones there is also a special ECB type specifier \"group\" which is
315      related to grouping tags \(see `ecb-post-process-semantic-taglist' and
316      `ecb-group-function-tags-with-parents'). Any arbitrary specifier can be
317      set here but if it is not \"group\" or not known by semantic it will be
318      useless.
319   2. Second entry is a flag which indicates if the type-specifier string from
320      \(1.) itself should be removed \(if there is any) from the display.
321   3. Third entry is the face which is used in the ECB-method window to display
322      type-tags with this specifier. ECB has some predefined faces for this
323      \(`ecb-type-tag-class-face', `ecb-type-tag-interface-face',
324      `ecb-type-tag-struct-face', `ecb-type-tag-typedef-face',
325      `ecb-type-tag-union-face', `ecb-type-tag-enum-face' and
326      `ecb-type-tag-group-face') but any arbitrary face can be set here. This
327      face is merged with the faces semantic already uses to display a tag,
328      i.e. the result is a display where all face-attributes of the ECB-face
329      take effect plus all face-attributes of the semantic-faces which are not
330      set in the ECB-face \(with XEmacs this merge doesn't work so here the
331      ECB-face replaces the semantic-faces; this may be fixed in future
332      versions).
333
334 The default value is nil means there is no special ECB-displaying of
335 type-tags in addition to the displaying and colorizing semantic does. But a
336 value like the following could be a useful setting:
337
338   \(\(default
339      \(\"class\" t ecb-type-tag-class-face)
340      \(\"group\" nil ecb-type-tag-group-face))
341     \(c-mode
342      \(\"struct\" nil ecb-type-tag-struct-face)
343      \(\"typedef\" nil ecb-type-tag-typedef-face)))
344
345 This means that in `c-mode' only \"struct\"s and \"typedef\"s are displayed
346 with special faces \(the specifiers itself are not removed) and in all other
347 modes \"class\"es and grouping-tags \(see `ecb-tag-display-function',
348 `ecb-group-function-tags-with-parents') have special faces and the \"class\"
349 specifier-string is removed from the display.
350
351 This options takes only effect for semantic-sources - means sources supported
352 by semantic!"
353   :group 'ecb-methods
354   :group 'ecb-most-important
355   :set (function (lambda (symbol value)
356                    (set symbol value)
357                    (ecb-clear-tag-tree-cache)))
358   :type '(repeat (cons (symbol :tag "Major-mode")
359                        (repeat :tag "Display of type specifiers"
360                                (list (choice :tag "Specifier list"
361                                              :menu-tag "Specifier list"
362                                              (const :tag "class"
363                                                     :value "class")
364                                              (const :tag "interface"
365                                                     :value "interface")
366                                              (const :tag "struct"
367                                                     :value "struct")
368                                              (const :tag "typedef"
369                                                     :value "typedef")
370                                              (const :tag "union"
371                                                     :value "union")
372                                              (const :tag "enum"
373                                                     :value "enum")
374                                              (const :tag "group"
375                                                     :value "group")
376                                              (string :tag "Any specifier"))
377                                      (boolean :tag "Remove the type-specifier" t)
378                                      (face :tag "Any face"
379                                            :value ecb-type-tag-class-face)))))
380   :initialize 'custom-initialize-default)
381
382 (defun ecb-get-face-for-type-tag (type-specifier)
383   "Return the face set in `ecb-type-tag-display' for current major-mode and
384 TYPE-SPECIFIER or nil."
385   (let ((mode-display (cdr (assoc major-mode ecb-type-tag-display)))
386         (default-display (cdr (assoc 'default ecb-type-tag-display))))
387     (or (nth 2 (assoc type-specifier mode-display))
388         (and (null mode-display)
389              (nth 2 (assoc type-specifier default-display))))))
390
391
392 (defun ecb-get-remove-specifier-flag-for-type-tag (type-specifier)
393   "Return the remove-specifier-flag set in `ecb-type-tag-display' for
394 current major-mode and TYPE-SPECIFIER or nil."
395   (let ((mode-display (cdr (assoc major-mode ecb-type-tag-display)))
396         (default-display (cdr (assoc 'default ecb-type-tag-display))))
397     (or (nth 1 (assoc type-specifier mode-display))
398         (and (null mode-display)
399              (nth 1 (assoc type-specifier default-display))))))
400
401 (defcustom ecb-type-tag-expansion
402   '((default . ("class" "interface" "group" "namespace"))
403     (c-mode .  ("struct")))
404   "*Default expansion of semantic type-tags.
405 Semantic groups type-tags into different type-specifiers. Current available
406 type specifiers are for example \"class\", \"interface\", \"struct\",
407 \"typedef\", \"union\" and \"enum\". In addition to these ones there is also a
408 special ECB type specifier \"group\" which is related to grouping tags \(see
409 `ecb-post-process-semantic-taglist').
410
411 This option defines which type-specifiers should be expanded at
412 file-open-time. Any arbitrary specifier can be set here but if it is not
413 \"group\" or not known by semantic it will be useless.
414
415 This functionality is set on a major-mode base, i.e. for every major-mode a
416 different setting can be used. The value of this option is a list of
417 cons-cells:
418 - The car is either a major-mode symbol or the special symbol 'default which
419   means if no setting for a certain major-mode is defined then the cdr of
420   the 'default cons-cell is used.
421 - The cdr is either a list of type-specifiers which should be expanded at
422   file-open-time or the symbol 'all-specifiers \(then a type-tag is always
423   expanded regardless of its type-specifier).
424
425 This options takes only effect for semantic-sources - means sources supported
426 by semantic!"
427   :group 'ecb-methods
428   :group 'ecb-most-important
429   :type '(repeat (cons (symbol :tag "Major-mode")
430                        (radio (const :tag "Expand all type-specifiers"
431                                      :value all-specifiers)
432                               (repeat :tag "Expand type specifiers"
433                                       (choice :tag "Specifier"
434                                               :menu-tag "Specifier"
435                                               (const :tag "class"
436                                                      :value "class")
437                                               (const :tag "interface"
438                                                      :value "interface")
439                                               (const :tag "struct"
440                                                      :value "struct")
441                                               (const :tag "typedef"
442                                                      :value "typedef")
443                                               (const :tag "union"
444                                                      :value "union")
445                                               (const :tag "enum"
446                                                      :value "enum")
447                                               (const :tag "group"
448                                                      :value "group")
449                                               (string :tag "Any specifier"))))))
450   :set (function (lambda (symbol value)
451                    (set symbol value)
452                    (ecb-clear-tag-tree-cache)))
453   :initialize 'custom-initialize-default)
454   
455 (defun ecb-type-tag-expansion (type-specifier)
456   "Return the default expansion-state of TYPE-SPECIFIER for current major-mode
457 as specified in `ecb-type-tag-expansion'"
458   (let ((mode-expansion (cdr (assoc major-mode ecb-type-tag-expansion)))
459         (default-expansion (cdr (assoc 'default ecb-type-tag-expansion))))
460     (or (equal mode-expansion 'all-specifiers)
461         (member type-specifier mode-expansion)
462         (and (null mode-expansion)
463              (or (equal default-expansion 'all-specifiers)
464                  (member type-specifier default-expansion))))))
465
466 (defsubst ecb-faux-group-tag-p (tag)
467   "Returns not nil if TAG is a \"virtual\" faux-group token which has no
468 position but groups some external members having the same parent-tag."
469   (or (ecb--semantic--tag-get-property tag 'ecb-group-tag)
470       (ecb--semantic--tag-get-property tag 'faux)))
471
472 (defun ecb-get-type-specifier (tag)
473   (if (ecb-faux-group-tag-p tag)
474       "group"
475     (ecb--semantic-tag-type tag)))
476   
477
478 (dolist (elem ecb-tag->text-functions)
479   (fset (car elem)
480         `(lambda (tag &optional parent-tag colorize)
481            (if (eq 'type (ecb--semantic-tag-class tag))
482                (let* (;; we must here distinguish between UML- and
483                       ;; not-UML-semantic functions because for UML we must
484                       ;; preserve some semantic facing added by semantic (e.g.
485                       ;; italic for abstract classes)!
486                       (text (funcall (if (string-match "-uml-" (symbol-name (quote ,(car elem))))
487                                          'ecb--semantic-format-tag-uml-abbreviate
488                                        'ecb--semantic-format-tag-name)
489                                      tag parent-tag colorize))
490                       (type-specifier (ecb-get-type-specifier tag))
491                       (face (ecb-get-face-for-type-tag type-specifier))
492                       (remove-flag (ecb-get-remove-specifier-flag-for-type-tag
493                                     type-specifier)))
494                  (save-match-data
495                    ;; the following is done to replace the "struct" from
496                    ;; grouping tags (see
497                    ;; ecb-group-function-tags-with-parents) with "group".
498                    ;; This code can be removed (or changed) if semantic allows
499                    ;; correct protection display for function-tags with
500                    ;; parent-tag.
501                    (when (ecb-faux-group-tag-p tag)
502                      (if (string-match (concat "^\\(.+"
503                                                (ecb--semantic-uml-colon-string)
504                                                "\\)\\("
505                                                (if (ecb--semantic--tag-get-property tag 'faux)
506                                                    (ecb--semantic-orphaned-member-metaparent-type)
507                                                  "struct")
508                                                "\\)") text)
509                          (let ((type-spec-text "group"))
510                            (put-text-property 0 (length type-spec-text)
511                                               'face
512                                               (get-text-property
513                                                0 'face
514                                                (match-string 2 text))
515                                               type-spec-text)
516                            (setq text (concat (match-string 1 text)
517                                               type-spec-text)))))
518                    ;; Now we must maybe add a template-spec in c++-mode and
519                    ;; maybe remove the type-specifier string.
520                    (let (col-type-name col-type-spec template-text)
521                      (if (string-match (concat "^\\(.+\\)\\("
522                                                (ecb--semantic-uml-colon-string)
523                                                type-specifier "\\)")
524                                        text)
525                          (setq col-type-name (match-string 1 text)
526                                col-type-spec (if (not remove-flag)
527                                                  (match-string 2 text)))
528                        (setq col-type-name text))
529                      (when (and (equal major-mode 'c++-mode)
530                                 (fboundp 'semantic-c-template-string))
531                        (setq template-text (semantic-c-template-string
532                                             tag parent-tag colorize))
533                        ;; Removing {...} from within the template-text.
534                        ;; Normally the semantic-formatters should not add this
535                        ;; ugly stuff.
536                        (if (string-match "^\\(.+\\){.*}\\(.+\\)$" template-text)
537                            (setq template-text
538                                  (concat (match-string 1 template-text)
539                                          (match-string 2 template-text))))
540                        (put-text-property 0 (length template-text)
541                                           'face
542                                           (get-text-property
543                                            (1- (length col-type-name)) 'face
544                                            col-type-name)
545                                           template-text))
546                      (setq text (concat col-type-name template-text
547                                         col-type-spec))))
548                  ;; now we add some own colorizing if necessary
549                  (if face
550                      (ecb-merge-face-into-text text face))
551                  text)
552              (funcall (quote ,(cdr elem)) tag parent-tag colorize)))))
553
554 (defcustom ecb-display-image-icons-for-semantic-tags ecb-images-can-be-used
555   "*Display nice and pretty icons for semantic-tags in the Methods-buffer.
556 This option takes only effect if Emacs can display images and if
557 `ecb-tree-buffer-style' is set to 'image."
558   :group 'ecb-methods
559   :type 'boolean)
560
561 (defsubst ecb-use-images-for-semantic-tags ()
562   (and ecb-display-image-icons-for-semantic-tags
563        ecb-images-can-be-used
564        (equal ecb-tree-buffer-style 'image)))
565
566 (defcustom ecb-post-process-semantic-taglist
567   '((c++-mode . (ecb-group-function-tags-with-parents))
568     (emacs-lisp-mode . (ecb-group-function-tags-with-parents))
569     (c-mode . (ecb-filter-c-prototype-tags)))
570   "*Define mode-dependent post-processing for the semantic-taglist.
571 This is an alist where the car is a major-mode symbol and the cdr is a list of
572 function-symbols of functions which should be used for post-processing the
573 taglist \(returned by `ecb--semantic-fetch-tags') for a buffer in this
574 major-mode. The first function in the list is called with current semantic
575 taglist of current buffer and must return a valid taglist again. All other
576 functions are called with the result-taglist of its preceding function and
577 have to return a new taglist again.
578
579 For oo-programming languages where the methods of a class can be defined
580 outside the class-definition \(e.g. C++, Eieio) the function
581 `ecb-group-function-tags-with-parents' can be used to get a much better
582 method-display in the methods-window of ECB, because all method
583 implementations of a class are grouped together.
584
585 Another senseful usage is to filter out certain tags, e.g. prototype tags in
586 `c-mode'. For this you can set `ecb-filter-c-prototype-tags'.
587
588 This options takes only effect for semantic-sources - means sources supported
589 by semantic!"
590   :group 'ecb-methods
591   :type '(repeat (cons (symbol :tag "Major-mode")
592                        (repeat (function :tag "Post-process function")))))
593
594 (defcustom ecb-default-tag-filter nil
595   "*Default tag-filters for certain files.
596 This option allow to define default tag-filters for certain files which are
597 applied automatically after loading such a file into a buffer. The possible
598 filters are the same as offered by the command `ecb-methods-filter' and they
599 are applied in the same manner - the only difference is they are applied
600 automatically. Please be aware that symbol-filters \(e.g. protection-symbols
601 like public or private) must not be inserted with quotes whereas a
602 filter-regexp has to be inserted with surrounding double-quotes! In addition
603 backslashes in a regexp have to be doubled!
604
605 For each file-spec \(a major-mode plus a file-regexp which both specify a
606 file for which filters should be applied) there can be as much filters as
607 needed - they are layered like with `ecb-methods-filter' too.
608
609 Tag-classes which are completely hidden or excluded by the option
610 `ecb-show-tags' will never being displayed in the Methods-buffer regardless of
611 the filters of this option!"
612   :group 'ecb-methods
613   :type '(repeat (cons :tag "Default tag filter"
614                        (cons :tag "Filespec"
615                              (symbol :tag "Major-mode")
616                              (regexp :tag "Filename-regexp"))
617                        (repeat :tag "Default filters"
618                                (list :tag "Filterspec"
619                                      (choice :tag "Filter-type"
620                                              :menu-tag "Filtertype"
621                                              (const :tag "Regexp" :value regexp)
622                                              (const :tag "Protection" :value protection)
623                                              (const :tag "Tag-class" :value tag-class)
624                                              (const :tag "Funtion" :value function))
625                                      (sexp :tag "Filter-value")
626                                      (boolean :tag "inverse"))))))
627
628   
629 (defcustom ecb-show-only-positioned-tags t
630   "*Show only nodes in the method-buffer which are \"jump-able\".
631 If not nil then ECB displays in the method-buffer only nodes which are
632 \"jump-able\", i.e. after selecting it by clicking or with RET then ECB jumps
633 to the corresponding location in the edit-window.
634 Example: With CLOS or Eieio source-code there can exist some position-less
635 nodes like variable-attributes in a `defclass' form which are only displayed
636 if this option is nil. Displaying such nodes can be senseful even if they can
637 not be jumped.
638
639 This options takes only effect for semantic-sources - means sources supported
640 by semantic!"
641   :group 'ecb-methods
642   :type 'boolean)
643
644
645 (defcustom ecb-show-tags
646   '((default . ((include collapsed nil)
647                 (parent collapsed nil)
648                 (type flattened nil)
649                 (variable collapsed access)
650                 (function flattened access)
651                 (label hidden nil)
652                 (t collapsed nil)))
653     (c++-mode . ((include collapsed nil)
654                  (parent collapsed nil)
655                  (type flattened nil)
656                  (variable collapsed access)
657                  (function flattened access) ;; for Methods
658                  (function collapsed access) ;; for Method-prototypes
659                  (label hidden nil)
660                  (t collapsed nil)))
661     (c-mode . ((include collapsed nil)
662                (parent collapsed nil)
663                (type flattened nil)
664                (variable collapsed access)
665                (function flattened access) ;; for Functions
666                (function collapsed access) ;; for Function-prototypes
667                (label hidden nil)
668                (t collapsed nil)))
669     (bovine-grammar-mode . ((keyword collapsed name)
670                             (token collapsed name)
671                             (nonterminal flattened name)
672                             (rule flattened name)
673                             (t collapsed nil)))
674     (wisent-grammar-mode . ((keyword collapsed name)
675                             (token collapsed name)
676                             (nonterminal flattened name)
677                             (rule flattened name)
678                             (t collapsed nil)))
679     (texinfo-mode . ((section flattened nil)
680                      (def collapsed name)
681                      (t collapsed nil))))
682   "*How to show tags in the methods buffer first time after find-file.
683 This functionality is set on a major-mode base, i.e. for every major-mode a
684 different setting can be used. The value of this option is a list of
685 cons-cells:
686
687 The car is either a major-mode symbol or the special symbol 'default which
688 means if no setting for a certain major-mode is defined then the cdr of
689 the 'default cons-cell is used. This option should always contain a
690 default-setting!
691
692 The cdr is a list where each element represents a type of tags:
693
694 \(<tag type> <display type> <sort method>)
695
696 There can be more than 1 element for a certain <tag type>. This is for example
697 useful for C++ and C because these languages distinct between a
698 method-prototype \(rsp. function-prototype for C) and the method \(rsp.
699 function for C) itself. The default value of these option contains two entries
700 for <tag type> is 'function whereas the first one is responsible for the
701 \"real\" methods \(rsp. functions) and the second one for the prototypes. So
702 if the methods should be flattened and the prototypes collapsed the
703 show-tags-list for C++ and C must contain two entries for <tag type>
704 'function, the first one defined as 'flattened and the second one defined as
705 'collapsed. See also `ecb-methods-separate-prototypes'.
706
707 The tags in the methods buffer are displayed in the order as they appear in
708 this list.
709
710 Tag Type
711 ----------
712
713 A Semantic tag type symbol \(for all possible type symbols see documentation
714 of semantic):