Skip to content
Browse files

Some code clearings and small fixes

  • Loading branch information...
1 parent d6b17a1 commit e57071a1e5147258a8e282cd5b47ee903ecf74e0 berndl committed Jun 23, 2009
Showing with 407 additions and 226 deletions.
  1. +1 −1 ecb-cedet-wrapper.el
  2. +2 −3 ecb-common-browser.el
  3. +4 −4 ecb-compatibility.el
  4. +1 −1 ecb-create-layout.el
  5. +4 −4 ecb-file-browser.el
  6. +2 −2 ecb-help.el
  7. +31 −42 ecb-layout.el
  8. +1 −1 ecb-makedef.mk
  9. +32 −122 ecb-method-browser.el
  10. +1 −1 ecb-mode-line.el
  11. +1 −1 ecb-navigate.el
  12. +142 −0 ecb-semantic.el
  13. +2 −2 ecb-speedbar.el
  14. +21 −21 ecb-symboldef.el
  15. +17 −10 ecb-util.el
  16. +145 −11 ecb.texi
View
2 ecb-cedet-wrapper.el
@@ -1,4 +1,4 @@
-;;; ecb-cedet-wrapper.el -- define wrappers for all semantic funcs/vars
+;;; ecb-cedet-wrapper.el -- define wrappers for all cedet funcs/vars
;; Copyright (C) 2000 - 2009 Klaus Berndl,
;; Free Software Foundation, Inc.
View
5 ecb-common-browser.el
@@ -985,8 +985,7 @@ existing ans readable file this means the file is loaded into a buffer.
Note: The buffer is just returned but not displayed."
(let* ((my-source (if (consp source) source (cons source nil)))
(filename (car my-source))
- (buffer (and (cdr my-source)
- (get-buffer (cdr my-source)))))
+ (buffer (ecb-buffer-obj (cdr my-source))))
(or buffer
(find-file-noselect filename))))
@@ -1149,7 +1148,7 @@ See `defecb-window-dedicator-to-ecb-buffer' for more details and an example.")
(delq nil (mapcar (function (lambda (e)
(and (or (not only-tree-buffers)
(nth 2 e))
- (get-buffer (nth 0 e)))))
+ (ecb-buffer-obj (nth 0 e)))))
ecb-ecb-buffer-registry)))
(defsubst ecb-ecb-buffer-registry-get-symbol (name)
View
8 ecb-compatibility.el
@@ -123,8 +123,8 @@ BUFFER is displayed in an edit-window!"
"Ensures that the electric-* commands work well with ECB."
(when (and ecb-minor-mode
(equal (selected-frame) ecb-frame))
- (if (get-buffer "*Buffer List*")
- (bury-buffer (get-buffer "*Buffer List*")))))
+ (if (ecb-buffer-obj "*Buffer List*")
+ (bury-buffer (ecb-buffer-obj "*Buffer List*")))))
;; package master.el (only Emacs >= 22.X) ------------------------------------
@@ -139,12 +139,12 @@ BUFFER is displayed in an edit-window!"
(if (or (not ecb-minor-mode)
(not (equal (selected-frame) ecb-frame)))
(ecb-with-original-basic-functions ad-do-it)
- (if (null (buffer-live-p (get-buffer master-of)))
+ (if (null (buffer-live-p (ecb-buffer-obj master-of)))
(error "Slave buffer has disappeared")
(let ((window (selected-window))
(point-loc (ecb-where-is-point))
(p (point)))
- (if (not (eq (window-buffer window) (get-buffer master-of)))
+ (if (not (eq (window-buffer window) (ecb-buffer-obj master-of)))
(switch-to-buffer-other-window master-of))
(if (ad-get-arg 0)
(condition-case nil
View
2 ecb-create-layout.el
@@ -344,7 +344,7 @@ DELETE-FRAME is not nil then the new created frame will be deleted and the
(defun ecb-create-layout-insert-file-header ()
(insert (format ";;; %s --- user defined ECB-layouts" ;;
- (file-name-nondirectory ecb-create-layout-file)))
+ (ecb-file-name-nondirectory ecb-create-layout-file)))
(insert ecb-create-layout-file-header))
(defun ecb-create-layout-save-layout ()
View
8 ecb-file-browser.el
@@ -2520,13 +2520,13 @@ Returns t if the current history filter has been applied otherwise nil."
((directory directory-with-source-path)
(ecb-substring-no-properties
(ecb-fix-filename
- (file-name-directory
+ (ecb-file-name-directory
(cdr elem)))
(if ecb-running-xemacs 0)))
(mode (symbol-name
- (if (get-buffer (car elem))
+ (if (ecb-buffer-obj (car elem))
(save-excursion
- (set-buffer (get-buffer (car elem)))
+ (set-buffer (ecb-buffer-obj (car elem)))
major-mode)
;; for dead buffers of the
;; history we use auto-mode-alist
@@ -2646,7 +2646,7 @@ Returns t if the current history filter has been applied otherwise nil."
;; `ecb-history-stick-indirect-buffers-to-basebuffer' is not
;; nil --> see above the mechanism how indirect-buffer-base
;; is build
- (indirect-buffer-p (buffer-base-buffer (get-buffer buf-name)))
+ (indirect-buffer-p (buffer-base-buffer (ecb-buffer-obj buf-name)))
;; Note: indirect-buffer elems can not be dead-buffer
;; elems, because indirect-buffer-items are *always*
;; removed immediately from the history-buffer when such a
View
4 ecb-help.el
@@ -311,8 +311,8 @@ a backtrace-buffer and inserts the contents of that."
(let* ((messages-buffer
(get-buffer
(if ecb-running-xemacs " *Message-Log*" "*Messages*")))
- (backtrace-buffer (get-buffer "*Backtrace*"))
- (tag-dump-buffer (get-buffer "*ecb-tag-dump*")))
+ (backtrace-buffer (ecb-buffer-obj "*Backtrace*"))
+ (tag-dump-buffer (ecb-buffer-obj "*ecb-tag-dump*")))
;;insert the contents of the tag-dump buffer if it is there.
(insert "\n\n-----------------------------------------------------\n")
View
73 ecb-layout.el
@@ -1896,6 +1896,7 @@ for current layout."
;; properly within `ecb-display-buffer-xemacs' and
;; `show-temp-buffer-in-current-frame'; see the comments in both of these
;; functions.
+;; !!! This function is not used anymore - but we leave it here !!!!!!!!
(defun ecb-display-buffer-xemacs (buffer &optional not-this-window-p
override-frame
shrink-to-fit)
@@ -1949,7 +1950,7 @@ Returns the window displaying BUFFER."
(catch 'done
(let (window old-frame target-frame explicit-frame shrink-it)
(setq old-frame (or (last-nonminibuf-frame) (selected-frame)))
- (setq buffer (get-buffer buffer))
+ (setq buffer (ecb-buffer-obj buffer))
(check-argument-type 'bufferp buffer)
;; KB: For pre-display-buffer-function and
@@ -2742,7 +2743,7 @@ it will be computed."
(let ((visible-ecb-buffers (ecb-get-current-visible-ecb-buffers ecb-window-list)))
(dolist (elem ecb-autocontrol/sync-fcn-register)
(when (or (null (cdr elem))
- (member (get-buffer (symbol-value (cdr elem)))
+ (member (ecb-buffer-obj (symbol-value (cdr elem)))
visible-ecb-buffers))
(funcall (car elem) t))))))
@@ -2986,21 +2987,6 @@ So never a dedicated window is returned during activated ECB."
)
-(defun ecb-compile-bug-test ()
- (interactive)
- (let ((buffer-save (current-buffer))
- (tempbuf (get-buffer-create "klausimausi"))
- (win-list nil))
- (unwind-protect
- (progn
- (set-buffer tempbuf)
- (message "Klausi-1: curr-buf:%s" (current-buffer))
- (setq win-list (ecb-canonical-windows-list))
- ;; (setq win-list (ecb-window-list))
- (message "Klausi-1: curr-buf:%s" (current-buffer))
- )
- (set-buffer buffer-save))))
-
;; This advice is the heart of the mechanism which displays all buffer in the
;; compile-window if they are are "compilation-buffers" in the sense of
;; `ecb-compilation-buffer-p'!
@@ -3656,13 +3642,10 @@ with the following ECB-adjustment: The behavior depends on
"The ECB-version of `delete-windows-on'. Works exactly like the original
function with the following ECB-adjustment:
-An error is reported if BUFFER is an ECB-tree-buffer. These windows are not
+An error is reported if BUFFER is a special ECB-buffer. These windows are not
allowed to be deleted."
(let ((curr-frame (selected-frame))
- (buf-name (or (and (stringp (ad-get-arg 0))
- (ad-get-arg 0))
- (and (bufferp (ad-get-arg 0))
- (buffer-name (ad-get-arg 0)))))
+ (buf-name (ecb-buffer-name (ad-get-arg 0)))
(frames (case (ad-get-arg 1)
(0 ;; visible or iconified frames
(delete nil (mapcar (lambda (f)
@@ -3680,26 +3663,32 @@ allowed to be deleted."
(otherwise ;; a certain frame
(if (frame-live-p (ad-get-arg 1))
(list (ad-get-arg 1)))))))
- (if (member (get-buffer buf-name) (ecb-get-current-visible-ecb-buffers))
+ (if (member (ecb-buffer-obj buf-name) (ecb-dedicated-special-buffers))
(if ecb-advice-window-functions-signal-error
(ecb-error "delete-windows-on is not allowed for the special ECB-buffers!"))
(dolist (f frames)
(if (not (equal f ecb-frame))
(progn
(ad-set-arg 1 f)
ad-do-it)
- (when (get-buffer-window buf-name ecb-frame)
- (select-frame ecb-frame)
- ;; first we must delete the window
- (delete-window (get-buffer-window buf-name ecb-frame))
- ;; to get exactly the same behavior like the original version
- ;; we must check if the current-buffer in the edit-window is
- ;; the same as the buffer argument for the current call and if
- ;; yes we must switch to the buffer returned by `other-buffer'.
- (if (ecb-string= buf-name
- (buffer-name (window-buffer (car (ecb-canonical-edit-windows-list)))))
- (switch-to-buffer (other-buffer buf-name
- nil ecb-frame)))
+ (unwind-protect
+ (progn
+ (select-frame ecb-frame)
+ (let ((windows-to-delete (delq nil (mapcar (function
+ (lambda (w)
+ (when (string= buf-name
+ (ecb-buffer-name w))
+ w)))
+ (ecb-canonical-edit-windows-list))))
+;; (buffer-to-switch (when (string= buf-name
+;; (ecb-buffer-name (selected-window)))
+;; (other-buffer buf-name t ecb-frame)))
+ )
+ (dolist (w windows-to-delete)
+ (delete-window w))
+;; (when buffer-to-switch
+;; (switch-to-buffer buffer-to-switch))
+ ))
(select-frame curr-frame)))))))
(defvar ecb-edit-area-creators nil)
@@ -4249,7 +4238,7 @@ If the currently visible ECB-buffers are needed then use the
function `ecb-get-current-visible-ecb-buffers'. "
(delq nil (mapcar (function (lambda (e)
(and (nth 3 e)
- (get-buffer (nth 0 e)))))
+ (ecb-buffer-obj (nth 0 e)))))
ecb-ecb-buffer-registry)))
(defun ecb-get-current-visible-ecb-buffers (&optional ecb-window-list)
@@ -5637,26 +5626,26 @@ contain the buffer before the emergency-redraw."
;; fill-up the history new with all buffers if the history buffer was
;; not shown before the redisplay but now (means if the layout has
;; changed)
- (when (and (not (member (get-buffer ecb-history-buffer-name)
+ (when (and (not (member (ecb-buffer-obj ecb-history-buffer-name)
ecb-buffers-before-redraw))
- (member (get-buffer ecb-history-buffer-name)
+ (member (ecb-buffer-obj ecb-history-buffer-name)
current-ecb-buffers))
(ecb-add-buffers-to-history-new))
;; update the directories buffer if the directories buffer was not
;; shown before the redisplay but now (means if the layout has
;; changed or - in case of left-right layout - another side is
;; visible than before)
- (when (and (not (member (get-buffer ecb-directories-buffer-name)
+ (when (and (not (member (ecb-buffer-obj ecb-directories-buffer-name)
ecb-buffers-before-redraw))
- (member (get-buffer ecb-directories-buffer-name)
+ (member (ecb-buffer-obj ecb-directories-buffer-name)
current-ecb-buffers))
(ecb-update-directories-buffer))
;; deactivate the speedbar stuff if the speedbar-integration-buffer
;; was shown before but not now - but only if the layout has been
;; changed
- (when (and (member (get-buffer ecb-speedbar-buffer-name)
+ (when (and (member (ecb-buffer-obj ecb-speedbar-buffer-name)
ecb-buffers-before-redraw)
- (not (member (get-buffer ecb-speedbar-buffer-name)
+ (not (member (ecb-buffer-obj ecb-speedbar-buffer-name)
current-ecb-buffers))
;; The following conditions are necessary to ensure the
;; layout has been changed
View
2 ecb-makedef.mk
@@ -38,7 +38,7 @@ ecb_LISP_EL=tree-buffer.el ecb-util.el ecb-mode-line.el ecb-help.el \
ecb-jde.el ecb-file-browser.el ecb-method-browser.el \
ecb-winman-support.el ecb-cedet-wrapper.el \
ecb-compatibility.el ecb-common-browser.el ecb-analyse.el \
- ecb-symboldef.el ecb-advice-test.el
+ ecb-symboldef.el ecb-semantic.el ecb-advice-test.el
ecb_LISP_ELC=$(ecb_LISP_EL:.el=.elc)
View
154 ecb-method-browser.el
@@ -41,6 +41,7 @@
(require 'ecb-speedbar)
(require 'ecb-cedet-wrapper)
+(require 'ecb-semantic)
;; This loads the semantic-setups for the major-modes.
(require 'semantic-load)
@@ -561,8 +562,8 @@ as specified in `ecb-type-tag-expansion'"
(defcustom ecb-find-external-tag-functions
(list (cons 'default
(list (if (fboundp 'semantic-calculate-scope)
- 'ecb-search-tag-by-semantic-analyzer
- 'ecb-search-tag-by-semanticdb)))
+ 'ecb-search-type-tag-by-semantic-analyzer
+ 'ecb-search-type-tag-by-semanticdb)))
(cons 'jde-mode (list 'ecb-jde-show-class-source)))
"*Functions used for searching external tags clicked in the methods buffer.
The methods buffer displays for oo-languages the parents of a
@@ -596,8 +597,8 @@ ECB first performs all find-functions defined for current
the special symbol 'default \(if any).
ECB offers some predefined senseful finding-functions. Currently there are:
-- `ecb-search-tag-by-semantic-analyzer' (most powerful)
-- `ecb-search-tag-by-semanticdb'
+- `ecb-search-type-tag-by-semantic-analyzer' (most powerful)
+- `ecb-search-type-tag-by-semanticdb'
- `ecb-jde-show-class-source' (for major-mode `jde-mode' when coding in java)
This function does not only the searching but displays the founded tag.
See the documentation of these function for details how they work.
@@ -635,10 +636,10 @@ Current point depends on the clicked tag:
:group 'ecb-methods
:type '(repeat (cons (symbol :tag "Major-mode or default")
(repeat (choice :tag "Find external tag function" :menu-tag "Function list"
- (const :tag "ecb-search-tag-by-semantic-analyzer"
- :value ecb-search-tag-by-semantic-analyzer)
- (const :tag "ecb-search-tag-by-semanticdb"
- :value ecb-search-tag-by-semanticdb)
+ (const :tag "ecb-search-type-tag-by-semantic-analyzer"
+ :value ecb-search-type-tag-by-semantic-analyzer)
+ (const :tag "ecb-search-type-tag-by-semanticdb"
+ :value ecb-search-type-tag-by-semanticdb)
(const :tag "ecb-jde-show-class-source"
:value ecb-jde-show-class-source)
(function :tag "Function"))))))
@@ -2261,7 +2262,7 @@ argument INVERSE is ignored here."
(set-buffer source-buffer)
(ecb-get-type-tag-of-tag (ecb-get-real-curr-tag)))))
((equal (current-buffer)
- (get-buffer ecb-methods-buffer-name))
+ (ecb-buffer-obj ecb-methods-buffer-name))
(let ((node (tree-buffer-get-node-at-point)))
(and node
(tree-node->data (ecb-get-type-node-of-node node)))))
@@ -2293,7 +2294,7 @@ argument INVERSE is ignored here."
(cond ((ecb-point-in-edit-window-number)
(current-buffer))
((equal (current-buffer)
- (get-buffer ecb-methods-buffer-name))
+ (ecb-buffer-obj ecb-methods-buffer-name))
(ecb-methods-get-data-store 'source-buffer))
(t (or (and ecb-last-source-buffer
(buffer-live-p ecb-last-source-buffer)
@@ -2528,7 +2529,7 @@ otherwise nil."
applied to the displayed tags is displayed. This function is only for using by
the option `ecb-mode-line-prefixes'."
(let* ((filters (and sel-source
- (cdr (assoc (get-buffer (cdr sel-source))
+ (cdr (assoc (ecb-buffer-obj (cdr sel-source))
ecb-methods-user-filter-alist))))
(top-filter-spec (ecb-last filters))
(filter-type-str (nth 3 top-filter-spec))
@@ -3863,112 +3864,23 @@ types which are parsed by imenu or etags \(see
(symbol-name elem))))))
spec)))
-;; TODO: Klaus Berndl <klaus.berndl@sdm.de>: modify this so it can be used by
-;; ecb-find-external-tag-functions - currently not used
-;; (defun ecb-semantic-tag-external-class-default (tag)
-;; "Return a list of real tags that faux TAG might represent.
-;; See `semantic-tag-external-class' for details."
-;; (if (and (fboundp 'semanticdb-minor-mode-p)
-;; (semanticdb-minor-mode-p))
-;; (let* ((semanticdb-search-system-databases nil)
-;; (m (semanticdb-find-tags-by-class
-;; (semantic-tag-class tag)
-;; (semanticdb-find-tags-by-name (semantic-tag-name tag)))))
-;; (semanticdb-strip-find-results m))
-;; ;; Presumably, if the tag is faux, it is not local.
-;; nil
-;; ))
-
-
-;; ;; semantic 1.X does not have this
-(silentcomp-defvar semanticdb-search-system-databases)
-
-(defun ecb-semanticdb-find-result-nth-with-file (result n)
- "In RESULT, return the Nth search result.
-This is a 0 based search result, with the first match being element 0. Returns
-a cons cell with car is the searched and found tag and the cdr is the
-associated full filename of this tag. If the search result is not associated
-with a file, then the cdr of the result-cons is nil."
- (let ((result-nth (ecb--semanticdb-find-result-nth result n)))
- (if (and (car result-nth)
- (ecb--semantic-tag-with-position-p (car result-nth))
- (cdr result-nth))
- (cons (car result-nth)
- (ecb--semanticdb-full-filename (cdr result-nth)))
- (cons (car result-nth) nil))))
-
-(defun ecb-semanticdb-get-type-definition-list (external-tag)
- "Search for the definition of the type with name of EXTERNAL-TAG.
-The search is performed viy semanticdb.
-`semanticdb-search-system-databases' is taken into account.
-Return-value is either nil \(if no positioned tag can be found
-for external-tag or a positioned semantic-tag for the
-type-definition of EXTERNAL-TAG."
- (when (and (featurep 'semanticdb) (ecb--semanticdb-minor-mode-p))
- ;; With semantic 2.X we do a full featured database-search.
- (let* ((search-result (ecb--semanticdb-find-tags-by-name
- (ecb--semantic-tag-name external-tag)))
- (result-tags (and search-result
- (ecb--semanticdb-strip-find-results search-result)))
- (type-tag-numbers nil))
- (when (and result-tags
- ;; some paranoia
- (= (length result-tags)
- (ecb--semanticdb-find-result-length search-result)))
- ;; First we check which tags in the stripped search-result
- ;; (result-tags) are types with positions (means associated with a
- ;; file) and collect their sequence-positions in type-tag-numbers.
- (dotimes (i (length result-tags))
- (if (and (equal (ecb--semantic-tag-class (nth i result-tags))
- 'type)
- (ecb--semantic-tag-with-position-p (nth i result-tags)))
- (setq type-tag-numbers
- (cons i type-tag-numbers))))
- (setq type-tag-numbers (nreverse type-tag-numbers))
- ;; Now we get for each element in type-tag-numbers the related
- ;; filename (where the tag is defined) and collect them in an alist
- ;; where each element is a cons-cell where car is the filename and
- ;; cdr is the tag in this file. Especially with scoped languages
- ;; like C++ or Java a type with the same name can be defined in more
- ;; than one file - each of these files belonging to another
- ;; package/library.
- (delq nil
- (mapcar (function (lambda (n)
- (let ((r (ecb-semanticdb-find-result-nth-with-file
- search-result n)))
- (if (and (cdr r)
- (stringp (cdr r))
- (ecb-file-readable-p (cdr r)))
- (cons (cdr r) (car r))))))
- type-tag-numbers))))))
-
-(defun ecb-search-tag-by-semanticdb (external-tag)
- "Uses semanticdb to search for the type-definition of EXTERNAL-TAG.
-Return exactly one semantic tag for the type-definition of
-EXTERNAL-TAG. If more than one definition have been found then
-the user has to make a choice on file-basis.
-
-This function is for usage with `ecb-find-external-tag-functions.'"
- (let ((type-definition-alist (ecb-semanticdb-get-type-definition-list
- external-tag))
- (result-elem))
- (when type-definition-alist
- ;; if we got more than one file for EXTERNAL-TAG then the user has to
- ;; choose one.
- (setq result-elem
- (if (> (length type-definition-alist) 1)
- (assoc (ecb-offer-choices "Select a definition-file: "
- (mapcar #'car type-definition-alist))
- type-definition-alist)
- (car type-definition-alist)))
- ;; we add the filename to the tag, then all needed informations are
- ;; within the tag and afterwards `semantic-tag-buffer can do its work
- (ecb--semantic--tag-put-property (cdr result-elem)
- :filename
- (car result-elem)))))
-
-(defun ecb-search-tag-by-semantic-analyzer (tag)
- "Calculate the scope at current point and search for a type with name of TAG.
+
+(defun ecb-search-type-tag-by-semantic-analyzer (tag)
+ "Calculate scope at point and search for a type with name of TAG.
+
+Return either a positioned semantic-tag for the found
+type-definition or nil if nothing is found. This mechanism uses
+the semantic-analyzer. Therefore it will work at its best if all
+needed customizations for the semantic analyzer have been done.
+\(See the manual of the semantic analyzer for how to customizing
+it).
+
+This function is fully fitting the needs of the option
+`ecb-find-external-tag-functions'."
+ (ecb-search-tag-by-semantic-analyzer (ecb--semantic-tag-name tag) 'type))
+
+(defun ecb-search-type-tag-by-semanticdb (tag)
+ "Uses semanticdb for searching a type with name of TAG.
Return either a positioned semantic-tag for the found
type-definition or nil if nothing is found. This mechanism uses
@@ -3977,11 +3889,9 @@ needed customizations for the semantic analyzer have been done.
\(See the manual of the semantic analyzer for how to customizing
it).
-This function is for usage with `ecb-find-external-tag-functions'."
- (let* ((scope (ecb--semantic-calculate-scope)))
- (when scope
- (ecb--semantic-analyze-find-tag (ecb--semantic-tag-name tag)
- 'type scope))))
+This function is fully fitting the needs of the option
+`ecb-find-external-tag-functions'."
+ (ecb-search-tag-by-semanticdb (ecb--semantic-tag-name tag) 'type))
(defun ecb-next-tag-parent-node (node)
"Go upward in the parent-hierarchy of NODE and return next node holding a tag."
View
2 ecb-mode-line.el
@@ -325,7 +325,7 @@ as \"W-<number>\"."
(defun ecb-mode-line-update-buffer (buffer-name new-mode-line-format)
"Update the given buffer...."
- (if (get-buffer buffer-name)
+ (if (ecb-buffer-obj buffer-name)
(save-excursion
(set-buffer buffer-name)
(setq mode-line-format new-mode-line-format)
View
2 ecb-navigate.el
@@ -281,7 +281,7 @@ case no position saving is done."
;; long)?
(and (ecb-nav-get-file item)
(or (null (ecb-nav-get-indirect-buffer-name item))
- (get-buffer (ecb-nav-get-indirect-buffer-name item)))))
+ (ecb-buffer-obj (ecb-nav-get-indirect-buffer-name item)))))
;;====================================================
;;
View
142 ecb-semantic.el
@@ -0,0 +1,142 @@
+;;; ecb-semantic.el -- define tag-utilities based on semantic
+
+;; Copyright (C) 2000 - 2009 Klaus Berndl,
+;; Free Software Foundation, Inc.
+
+;; Author: Klaus Berndl <klaus.berndl@sdm.de>
+;; Maintainer: Klaus Berndl <klaus.berndl@sdm.de>
+;; Keywords: browser, code, programming, tools
+;; Created: 2009
+
+;; This program is free software; you can redistribute it and/or modify it under
+;; the terms of the GNU General Public License as published by the Free Software
+;; Foundation; either version 2, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but WITHOUT
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+;; details.
+
+;; You should have received a copy of the GNU General Public License along with
+;; GNU Emacs; see the file COPYING. If not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+;; $Id$
+
+;;; Commentary:
+
+;; This file contains some tag-utility functions based on semantic (part of
+;; CEDET-suite) which are needed by ECB
+
+
+(require 'ecb-cedet-wrapper)
+(require 'ecb-util)
+
+(eval-when-compile
+ (require 'silentcomp))
+
+(defun ecb-semanticdb-find-result-nth-with-file (result n)
+ "In RESULT, return the Nth search result.
+This is a 0 based search result, with the first match being element 0. Returns
+a cons cell with car is the searched and found tag and the cdr is the
+associated full filename of this tag. If the search result is not associated
+with a file, then the cdr of the result-cons is nil."
+ (let ((result-nth (ecb--semanticdb-find-result-nth result n)))
+ (if (and (car result-nth)
+ (ecb--semantic-tag-with-position-p (car result-nth))
+ (cdr result-nth))
+ (cons (car result-nth)
+ (ecb--semanticdb-full-filename (cdr result-nth)))
+ (cons (car result-nth) nil))))
+
+(defun ecb-get-definition-list-by-semanticdb (tag-name &optional tag-class)
+ "Search for the definitions of the tag with TAG-NAME and TAG-CLASS.
+The search is performed via semanticdb.
+`semanticdb-search-system-databases' is taken into account.
+Return-value is either nil \(if no positioned tag can be found
+for TAG-NAME and TAG-CLASS) or a positioned semantic-tag for the
+type-definition of TAG-NAME.
+
+If TAG-CLASS is nil then tags regardless of their class are returned as long
+as they match with TAG-NAME."
+ (when (and (featurep 'semanticdb) (ecb--semanticdb-minor-mode-p))
+ ;; With semantic 2.X we do a full featured database-search.
+ (let* ((search-result (ecb--semanticdb-find-tags-by-name tag-name))
+ (result-tags (and search-result
+ (ecb--semanticdb-strip-find-results search-result)))
+ (tag-numbers nil))
+ (when (and result-tags
+ ;; some paranoia
+ (= (length result-tags)
+ (ecb--semanticdb-find-result-length search-result)))
+ ;; First we check which tags in the stripped search-result
+ ;; (result-tags) are of the right tag-class and with positions (means
+ ;; associated with a file) and collect their sequence-positions in
+ ;; tag-numbers.
+ (dotimes (i (length result-tags))
+ (if (and (or (null tag-class) ;; we are interested in any tags regardless of class
+ (equal (ecb--semantic-tag-class (nth i result-tags)) tag-class))
+ (ecb--semantic-tag-with-position-p (nth i result-tags)))
+ (setq tag-numbers (cons i tag-numbers))))
+ (setq tag-numbers (nreverse tag-numbers))
+ ;; Now we get for each element in tag-numbers the related
+ ;; filename (where the tag is defined) and collect them in an alist
+ ;; where each element is a cons-cell where car is the filename and
+ ;; cdr is the tag in this file. Especially with scoped languages
+ ;; like C++ or Java a type with the same name can be defined in more
+ ;; than one file - each of these files belonging to another
+ ;; package/library.
+ (delq nil
+ (mapcar (function (lambda (n)
+ (let ((r (ecb-semanticdb-find-result-nth-with-file
+ search-result n)))
+ (if (and (cdr r)
+ (stringp (cdr r))
+ (file-readable-p (cdr r)))
+ (cons (cdr r) (car r))))))
+ tag-numbers))))))
+
+(defun ecb-search-tag-by-semanticdb (tag-name &optional tag-class)
+ "Uses semanticdb to search for the definition of tag with TAG-NAME and TAG-CLASS.
+Return exactly one semantic tag for the definition of TAG-NAME.
+If more than one definition have been found then the user has to
+make a choice on file-basis.
+If TAG-CLASS is nil then a tag regardless of its class is returned as long
+as it matches with TAG-NAME.
+
+The returned tag will contain the filename as its :file-attribute."
+ (let ((definition-alist (ecb-get-definition-list-by-semanticdb tag-name tag-class))
+ (result-elem))
+ (when definition-alist
+ ;; if we got more than one file for tag-name then the user has to
+ ;; choose one.
+ (setq result-elem
+ (if (> (length definition-alist) 1)
+ (assoc (ecb-offer-choices "Select a definition-file: "
+ (mapcar #'car definition-alist))
+ definition-alist)
+ (car definition-alist)))
+ ;; we add the filename to the tag, then all needed informations are
+ ;; within the tag
+ (ecb--semantic--tag-put-property (cdr result-elem)
+ :filename
+ (car result-elem)))))
+
+(defun ecb-search-tag-by-semantic-analyzer (tag-name &optional tag-class)
+ "Calculate scope at point and search for a tag-definition with TAG-NAME.
+
+If TAG-CLASS is not nil then only tags with this tag-class are searched.
+
+Return either a positioned semantic-tag for the found
+tag-definition or nil if nothing is found. This mechanism uses
+the semantic-analyzer. Therefore it will work at its best if all
+needed customizations for the semantic analyzer have been done.
+\(See the manual of the semantic analyzer for how to customizing
+it)."
+ (let* ((scope (ecb--semantic-calculate-scope)))
+ (when scope
+ (ecb--semantic-analyze-find-tag tag-name tag-class scope))))
+
+(silentcomp-provide 'ecb-semantic)
+
+;;; ecb-semantic.el end here
View
4 ecb-speedbar.el
@@ -175,7 +175,7 @@ could slow down dramatically!"
"Name of the ECB speedbar buffer.")
(defun ecb-speedbar-buffer-selected ()
- (equal (current-buffer) (get-buffer ecb-speedbar-buffer-name)))
+ (equal (current-buffer) (ecb-buffer-obj ecb-speedbar-buffer-name)))
(defecb-advice speedbar-click around ecb-speedbar-adviced-functions
"Makes the function compatible with ECB. If ECB is active and the window of
@@ -397,7 +397,7 @@ future this could break."
(defun ecb-speedbar-active-p ()
"Return not nil if speedbar is active and integrated in the `ecb-frame'."
- (and (get-buffer ecb-speedbar-buffer-name)
+ (and (ecb-buffer-obj ecb-speedbar-buffer-name)
(get-buffer-window (get-buffer ecb-speedbar-buffer-name) ecb-frame)))
(defun ecb-speedbar-update-contents ()
View
42 ecb-symboldef.el
@@ -112,13 +112,18 @@ cons-cells:
The function can either return nil or a string which will be integrated in
the modeline-display of this ecb-window.
-There are two prefined functions `ecb-symboldef-find-lisp-doc' and
-`ecb-symboldef-find-definition' whereas the latter on is used a default
+There are two predefined functions `ecb-symboldef-find-lisp-doc' and
+`ecb-symboldef-find-definition' whereas the latter one is used as a default
find-function."
:group 'ecb-symboldef
:type '(repeat (cons (symbol :tag "Major-mode")
(function :tag "Find function"))))
+(defcustom ecb-symboldef-minimum-symbol-length 3
+ "*Minimum length a symbol must have so its definition or doc is displayed."
+ :group 'ecb-symboldef
+ :type 'integer)
+
;; TODO: Klaus Berndl <klaus.berndl@sdm.de>: This option is an example how the
;; user could determine which backends should be used for finding a definition
;; and also in which order the backends should be tried...
@@ -225,11 +230,6 @@ Only prints mode and info but does not find any symbol-definition."
(insert "* No symbol definition function for current mode *\n"
"* See variable `ecb-symboldef-find-functions' *")))
-;; TODO: Klaus Berndl <klaus.berndl@sdm.de>: check if the folliwng can be
-;; replaced by using semantic-documentation-for-tag (and the elisp overide
-;; semantic-documentation-for-tag-emacs-lisp-mode or semantic-ia-show-doc or a
-;; combination !!
-
;; currently not used
(defun ecb-symboldef-get-doc-for-fsymbol (fsymbol)
"Use `describe-function-1' to get the doc-string for FSYMBOL."
@@ -249,11 +249,12 @@ Only prints mode and info but does not find any symbol-definition."
"Insert the lisp-documentation of symbol with name SYMBOL-NAME."
(setq truncate-lines nil)
(let ((symbol (intern symbol-name))
+ (fsymbol-p nil)
+ (begin-vdoc (point-min))
(retval nil)
(args nil))
- ;; TODO: Klaus Berndl <klaus.berndl@sdm.de>: handle the case if a symbol
- ;; is a var AND a function!
(when (fboundp symbol)
+ (setq fsymbol-p t)
(unless ecb-running-xemacs
;; With XEmacs the symbol itself is already contained in the
;; docstring describe-function-1 returns - with Emacs we must add it
@@ -289,12 +290,17 @@ Only prints mode and info but does not find any symbol-definition."
'font-lock-function-name-face
ecb-symboldef-symbol-face)
(1+ beg)
- (match-end 0))))
+ (match-end 0))))
+ (goto-char (point-max))
+ ;; we needs this later if the symbol is not only a function but a
+ ;; variable too!
+ (setq begin-vdoc (point))
(setq retval (format "Lisp %s"
(if (commandp symbol)
"Command"
"Function"))))
(when (boundp symbol)
+ (when fsymbol-p (insert "\n\n___________\n\n"))
(insert (format "%s is a %s\n\n%s\n\nValue: %s\n\n" symbol
(if (user-variable-p symbol)
"Option " "Variable")
@@ -304,7 +310,7 @@ Only prints mode and info but does not find any symbol-definition."
(symbol-value symbol)))
(let ((beg nil)
(end nil))
- (goto-char (point-min))
+ (goto-char begin-vdoc)
(when (and ecb-symboldef-symbol-face
(re-search-forward (regexp-quote symbol-name) nil t))
(setq beg (match-beginning 0))
@@ -316,6 +322,7 @@ Only prints mode and info but does not find any symbol-definition."
beg end)
(goto-char end)))
(setq retval "Lisp Variable"))
+ (goto-char (point-min))
(fill-region (point-min) (point-max) 'left)
retval))
@@ -406,19 +413,12 @@ symbol. Displays the found text in the buffer of
(save-excursion
(let ((modeline-display nil)
(edit-buffer (current-buffer))
- (current-symbol
- ;; check if point is not at start, since
- ;; buggy thingatpt yields error then:
- ;; TODO: Klaus Berndl <klaus.berndl@sdm.de>: i can not believe this
- (if (> (point) (point-min))
- (ecb-thing-at-point 'symbol)
- nil))
+ (current-symbol (ignore-errors (ecb-thing-at-point 'symbol)))
;; find tag search function according to mode:
(find-func (ecb-symboldef-get-find-function)))
- ;; TODO: Klaus Berndl <klaus.berndl@sdm.de>: make an option for this
- ;; min-length
;; only use tags with a minimal length:
- (setq current-symbol (if (> (length current-symbol) 3)
+ (setq current-symbol (if (>= (length current-symbol)
+ ecb-symboldef-minimum-symbol-length)
current-symbol))
;; buggy thingatpt returns whole buffer if on empty line:
(setq current-symbol (if (< (length current-symbol) 80)
View
27 ecb-util.el
@@ -1704,18 +1704,25 @@ or a buffer-object."
(if (file-exists-p exp-file)
(delete-file exp-file))))
-(defun ecb-buffer-name (buffer-or-name)
- "Return the buffer-name of BUFFER-OR-NAME."
- (typecase buffer-or-name
- (string buffer-or-name)
- (buffer (buffer-name buffer-or-name))
+(defun ecb-buffer-name (buffer-or-window)
+ "Return the buffer-name of BUFFER-OR-WINDOW.
+BUFFER-OR-WINDOW can be a buffer-name, a buffer or a window. If a
+window then the name of the buffer curently displayed in this
+window is returned."
+ (typecase buffer-or-window
+ (string buffer-or-window)
+ (buffer (buffer-name buffer-or-window))
+ (window (buffer-name (window-buffer buffer-or-window)))
(otherwise nil)))
-(defun ecb-buffer-obj (buffer-or-name)
- "Return the buffer-object of BUFFER-OR-NAME."
- (typecase buffer-or-name
- (string (get-buffer buffer-or-name))
- (buffer buffer-or-name)
+(defun ecb-buffer-obj (buffer-or-window)
+ "Return the buffer-object of BUFFER-OR-WINDOW.
+BUFFER-OR-WINDOW can be a buffer-name, a buffer or a window.
+If a window then the buffer curently displayed in this window is returned."
+ (typecase buffer-or-window
+ (string (get-buffer buffer-or-window))
+ (buffer buffer-or-window)
+ (window (window-buffer buffer-or-window))
(otherwise nil)))
(defun ecb-buffer-local-value (sym buffer)
View
156 ecb.texi
@@ -255,7 +255,7 @@ Working with the keyboard in the ECB-windows
* Personal tree-keybindings:: Adding personal keybindings to a tree-buffer
* Using popup-menus:: Using the popup-menus from keyboard.
-Using and customizing the ECB-Methods buffer
+Using and customizing the ECB-Methods window
* Visiting tags:: Possible actions after visiting a tag
* Expanding:: Explicit and automatic expanding
@@ -305,6 +305,7 @@ All customizable options of ECB
* ecb-methods:: Customizing the ECB-methods-window
* ecb-history:: Customizing the ECB-history-window
* ecb-analyse:: Customizing the ECB-analyse-window
+* ecb-symboldef:: Customizing the ECB-symboldef-window
* ecb-layout:: Customizing the ECB-layout
* ecb-compilation:: Customizing the compile-window
* ecb-create-layout:: Customizing options for creating layouts
@@ -3632,9 +3633,9 @@ special symbol 'default (if any).
ECB offers some predefined senseful finding-functions. Currently there are:
@itemize @minus
-@item @code{ecb-search-tag-by-semantic-analyzer}: The most powerfil one, based
+@item @code{ecb-search-type-tag-by-semantic-analyzer}: The most powerfil one, based
on the semantic-analyzer
-@item @code{ecb-search-tag-by-semanticdb}: A backup for the first one
+@item @code{ecb-search-type-tag-by-semanticdb}: A backup for the first one
@item @code{ecb-jde-show-class-source}: For major-mode @code{jde-mode} when
coding in java, uses java-mechanisms - maybe for java the best choice.
@end itemize
@@ -6302,6 +6303,7 @@ been done for a better readable option index. @xref{Option Index}.
* ecb-methods:: Customizing the ECB-methods-window
* ecb-history:: Customizing the ECB-history-window
* ecb-analyse:: Customizing the ECB-analyse-window
+* ecb-symboldef:: Customizing the ECB-symboldef-window
* ecb-layout:: Customizing the ECB-layout
* ecb-compilation:: Customizing the compile-window
* ecb-create-layout:: Customizing options for creating layouts
@@ -7966,8 +7968,8 @@ ECB first performs all find-functions defined for current @code{major-mode}
ECB offers some predefined senseful finding-functions. Currently there are:
@itemize
-@item @code{ecb-search-tag-by-semantic-analyzer} (most powerful)
-@item @code{ecb-search-tag-by-semanticdb}
+@item @code{ecb-search-type-tag-by-semantic-analyzer} (most powerful)
+@item @code{ecb-search-type-tag-by-semanticdb}
@item @code{ecb-jde-show-class-source} (for major-mode @code{jde-mode} when
coding in java)
@end itemize
@@ -8779,7 +8781,7 @@ Asks, if the history-entry should be removed after the kill.
@end itemize
@end defopt
-@node ecb-analyse, ecb-layout, ecb-history, Customizable options
+@node ecb-analyse, ecb-symboldef, ecb-history, Customizable options
@subsection Group ecb-analyse
@defopt analyse-bucket-element-face
@@ -9010,7 +9012,116 @@ is echo-area-display.
See also @code{ecb-analyse-gen-tag-info-fn}.
@end defopt
-@node ecb-layout, ecb-compilation, ecb-analyse, Customizable options
+@node ecb-symboldef, ecb-layout, ecb-analyse, Customizable options
+@subsection Group ecb-analyse
+
+@defopt symboldef-buffer-name
+Name of the ECB-symbol-definition buffer.
+Because it is not a normal buffer for editing you should enclose the name with
+stars, e.g. ``*ECB Symboldefinition*''.
+
+If it is necessary for you you can get emacs-lisp access to the buffer-object
+of the ECB-symbol-definition-buffer by this name, e.g. by a call of
+@code{set-buffer}.
+
+Changes for this option at runtime will take affect only after deactivating and
+then activating ECB again!
+@end defopt
+
+@defopt symboldef-buffer-sync
+Synchronize the symboldef buffer automatically with current edit buffer.
+
+If @code{always} then the synchronization takes place always a buffer changes in the
+edit window, if nil then never. If a list of major-modes then only if the
+@code{major-mode} of the new buffer belongs NOT to this list.
+
+If the special value @code{basic} is set then ECB uses the setting of the option
+@code{ecb-basic-buffer-sync}.
+
+IMPORTANT NOTE: Every time the synchronization is done the hook
+@code{ecb-symboldef-buffer-sync-hook} is evaluated.
+@end defopt
+
+@defopt symboldef-buffer-sync-delay
+Time Emacs must be idle before the symboldef-buffer is synchronized.
+Synchronizing is done with the current source displayed in the edit window. If
+nil then there is no delay, means synchronization takes place immediately. A
+small value of about 0.25 seconds saves CPU resources and you get even though
+almost the same effect as if you set no delay.
+
+If the special value 'basic is set then ECB uses the setting of the option
+@code{ecb-basic-buffer-sync-delay}.
+@end defopt
+
+@defopt symboldef-buffer-sync-hook
+ook run at the end of the function @code{ecb-symboldef-buffer-sync}.
+See documentation of @code{ecb-symboldef-buffer-sync} for conditions when
+synchronization takes place and so in turn these hooks are evaluated.
+
+Preconditions for such a hook:
+
+@itemize
+@item Current buffer is the buffer of the currently selected edit-window.
+@item The symboldef-buffer is displayed in a visible window of the
+ecb-frame (so no check for visibilty of the symboldef-buffer in
+the ecb-frame is necessary in a hook function)
+@end itemize
+
+Postcondition for such a hook:
+Point must stay in the same edit-window as before evaluating the hook.
+
+Important note: If the option @code{ecb-symboldef-buffer-sync} is not
+nil the function @code{ecb-symboldef-buffer-sync} is running either
+every time Emacs is idle or even after every command (see
+@code{ecb-symboldef-buffer-sync-delay}). So if the symboldef-buffer is
+displayed in a window of the ecb-frame (see preconditions above)
+these hooks can be really called very often! Therefore each
+function of this hook should/must check in an efficient way at
+beginning if its task have to be really performed and then do
+them only if really necessary! Otherwise performance of Emacs
+could slow down dramatically!
+@end defopt
+
+@defopt symboldef-find-functions
+Funtions to find the definition for current symbol under point.
+This functionality is set on a major-mode base, i.e. for every major-mode a
+different setting can be used. The value of this option is a list of
+cons-cells:
+
+@itemize
+
+@item
+The car is either a major-mode symbol or the special symbol 'default which
+means if no setting for a certain major-mode is defined then the cdr of
+the 'default cons-cell is used.
+
+@item
+The car is a function intended to find the definition of a certain symbol for
+files of this major-mode. Such a function will be called with two arguments,
+the first is the symbol-name as string for which the definition should be
+displayed and the second the current edit-buffer as buffer-object,
+i.e. the current buffer of the current edit-window. The function will be
+called with the special ecb-symbol-definition-buffer as current buffer
+whereas this buffer is empty. The function has to insert everything
+necessary to display the symbol-definition and is also responsible to format
+the displayed text. The buffer-local variable @code{fill-column is already preset
+to the window-width of the special ecb-window minus 1. The function is
+responsible to set the buffer-local variable `truncate-lines} appropriate.
+The function can either return nil or a string which will be integrated in
+the modeline-display of this ecb-window.
+@end itemize
+
+There are two prefined functions @code{ecb-symboldef-find-lisp-doc} and
+@code{ecb-symboldef-find-definition} whereas the latter on is used a default
+find-function.
+@end defopt
+
+@defopt symboldef-minimum-symbol-length
+Minimum length a symbol must have so its definition or doc is displayed.
+@end defopt
+
+
+@node ecb-layout, ecb-compilation, ecb-symboldef, Customizable options
@subsection Group ecb-layout
@noindent
@@ -9995,6 +10106,23 @@ Changes take first effect after finishing and reactivating ECB!
Face for read-only sources.
@end defopt
+@defopt symboldef-prototype-face
+Which face should be used for the symbol prototype in the symboldef-buffer.
+
+The prototype can be the function prototype in case of a function or method or
+- in case of a variable - the type of the variable (in case of a typed
+language).
+@end defopt
+
+@defopt symboldef-symbol-face
+Which face should be used for the symbol itself in the symboldef-buffer.
+
+There are two choices: Either a face or the special symbol 'use-font-lock-face
+whereas the latter one means that ECB uses that face font-lock uses for
+fontifying the symbol (e.g. font-lock-function-name-face for a function
+symbol or font-lock-variable-name-face for a variable symbol).
+@end defopt
+
@defopt tag-header-face
Face used for highlighting the tag header after jumping to it by
clicking onto a node in the methods buffer.
@@ -10128,6 +10256,10 @@ Define face for the data in the mode-line. See
Define face for the prefix in the mode-line. See
@code{ecb-mode-line-prefixes}.
+@item ecb-mode-line-win-nr-face
+Define face for the window-number in the mode-line. See
+@code{ecb-mode-line-display-window-number}.
+
@item ecb-source-face:
Define face used for highlighting current source in the sources
buffer.
@@ -10142,6 +10274,12 @@ the font-family, the font-size, the basic color etc.
@item ecb-source-read-only-face
Define a face for read-only sources
+@item ecb-symboldef-prototype-face
+Define face used for the prototype of symbol in the symboldef-buffer.
+
+@item ecb-symboldef-symbol-face
+Define a face used for the symbol itself in the symboldef-buffer
+
@item ecb-tag-header-face:
Define face used for highlighting the tag header after jumping to it
by clicking onto a node in the methods buffer.
@@ -10171,10 +10309,6 @@ Define face used with option @code{ecb-type-tag-display}.
@item ecb-type-tag-union-face:
Define face used with option @code{ecb-type-tag-display}.
-@item ecb-mode-line-win-nr-face
-Define face for the window-number in the mode-line. See
-@code{ecb-mode-line-display-window-number}.
-
@end table
Just call @code{customize-face <face-name>} to customize these faces

0 comments on commit e57071a

Please sign in to comment.
Something went wrong with that request. Please try again.