4 ;; SUMMARY: C++ source code browser.
5 ;; USAGE: GNU Emacs Lisp Library
6 ;; KEYWORDS: c, oop, tools
11 ;; ORIG-DATE: 12-Dec-89
12 ;; LAST-MOD: 10-May-01 at 12:49:26 by Bob Weiner
14 ;; Copyright (C) 1989-1995, 1997 BeOpen.com
15 ;; See the file BR-COPY for license information.
17 ;; This file is part of the OO-Browser.
21 ;; Use `c++-browse' to invoke the C++ OO-Browser. Prefix arg prompts for
22 ;; name of Environment file.
26 ;; ************************************************************************
27 ;; Other required Elisp libraries
28 ;; ************************************************************************
30 (mapcar 'require '(br-start br br-c++-ft))
32 ;;; ************************************************************************
34 ;;; ************************************************************************
37 (defun c++-browse (&optional env-file no-ui)
38 "Invoke the C++ OO-Browser.
39 This allows browsing through C++ library and system class hierarchies. With
40 an optional non-nil prefix argument ENV-FILE, prompt for Environment file to
41 use. Alternatively, a string value of ENV-FILE is used as the Environment
42 file name. See also the file \"br-help\"."
44 (let ((same-lang (equal br-lang-prefix c++-lang-prefix))
49 ;; Save other language Environment in memory
50 (if br-lang-prefix (br-env-copy nil))
51 (setq br-lang-prefix c++-lang-prefix
52 *br-save-wconfig* nil))
53 ;; `same-env' non-nil means the new Env is the previous Env or the most
54 ;; recent previous Env of the same language as the new Env
55 (setq same-env (or (equal c++-env-file env-file)
57 (or c++-lib-search-dirs c++-sys-search-dirs)
61 ;; If we just switched languages, restore the cached data for the new
63 (if same-lang nil (br-env-copy t))
64 ;; Environment may appear to be the same but its loading may have
65 ;; been interrupted, so ensure all variables are initialized properly.
66 (c++-browse-setup env-file)
67 (if (or (null br-paths-htable) (equal br-paths-htable br-empty-htable))
69 (br-env-try-load (or env-file br-env-file) br-env-file))))
71 ;; Create default Environment file specification if needed and none
74 (t (or env-file (file-exists-p c++-env-file)
75 (br-env-create c++-env-file c++-lang-prefix))
76 (or env-file (setq env-file c++-env-file))
78 ;; Start browsing a new Environment.
80 (c++-browse-setup env-file)
81 (setq load-succeeded (br-env-init env-file same-lang nil))
83 (setq *br-save-wconfig* nil
84 c++-env-file br-env-file
85 c++-env-name br-env-name
86 c++-sys-search-dirs br-sys-search-dirs
87 c++-lib-search-dirs br-lib-search-dirs))))
92 (or (and same-lang same-env) (br-refresh))))
94 (t (message "(c++-browse): You must build the Environment to browse it.")))))
96 ;; Don't filter Environment classes when listed.
97 (defalias 'c++-class-list-filter 'br-class-list-identity)
99 (defun c++-mode-setup ()
100 "Load best available C++ major mode and set `br-lang-mode' to the function that invokes it."
101 (defalias 'br-lang-mode
102 (cond ((or (featurep 'cc-mode) (featurep 'c++-mode))
104 ((load "cc-mode" 'missing-ok 'nomessage)
106 ((load "c++-mode" 'missing-ok 'nomessage)
108 ((featurep 'c-mode) 'c-mode)
109 ((load "c-mode" nil 'nomessage)
112 (progn (require 'cc-mode)
113 (c-initialize-cc-mode))
116 ;;; ************************************************************************
117 ;;; Internal functions
118 ;;; ************************************************************************
120 (defun c++-browse-setup (env-file)
121 "Setup language-dependent functions for OO-Browser."
124 (br-setup-constants env-file)
125 ;; Setup to add default classes to system class table after building it.
126 ;; This must come after br-setup-constants call since it clears these
128 (if (fboundp 'add-hook)
129 (add-hook 'br-after-build-sys-hook 'c++-add-default-classes)
130 (setq br-after-build-sys-hook '(c++-add-default-classes))))
132 (provide 'c++-browse)