summaryrefslogtreecommitdiff
path: root/lisp/cedet/srecode/table.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@gnu.org>2012-10-02 02:10:29 +0800
committerChong Yidong <cyd@gnu.org>2012-10-02 02:10:29 +0800
commit62a81506f802e4824b718cc30321ee3a0057cdf7 (patch)
treed681d7b767b1c3f7e4aee24ce39f6bef0d7f1f7e /lisp/cedet/srecode/table.el
parentb3317662acc0157406c20c8e14c43b7126eaa8a0 (diff)
downloademacs-62a81506f802e4824b718cc30321ee3a0057cdf7.tar.gz
Update CEDET from upstream.
Diffstat (limited to 'lisp/cedet/srecode/table.el')
-rw-r--r--lisp/cedet/srecode/table.el59
1 files changed, 44 insertions, 15 deletions
diff --git a/lisp/cedet/srecode/table.el b/lisp/cedet/srecode/table.el
index fb7ce6bad2f..37403c4fb9e 100644
--- a/lisp/cedet/srecode/table.el
+++ b/lisp/cedet/srecode/table.el
@@ -68,6 +68,15 @@ If this is nil, then this template table belongs to a set of generic
templates that can be used with no additional dictionary values.
When it is non-nil, it is assumed the template macros need specialized
Emacs Lisp code to fill in the dictionary.")
+ (framework :initarg :framework
+ :type symbol
+ :documentation
+ "Tracks the name of the framework these templates belong to.
+If nil, then this template table belongs to any framework, or can be
+considered generic for all files of this language.
+A framework might be a specific library or build environment for which
+special templates are desired. OpenGL might be a framework that
+exists for multiple languages.")
(priority :initarg :priority
:type number
:documentation
@@ -113,23 +122,39 @@ Tracks various lookup hash tables.")
(major-mode :initarg :major-mode
:documentation
"Table of template tables for this major-mode.")
+ (modetables :initarg :modetables
+ :documentation
+ "All that tables unique to this major mode.")
(tables :initarg :tables
:documentation
- "All the tables that have been defined for this major mode.")
+ "All the tables that can be used for this major mode.")
)
"Track template tables for a particular major mode.
Tracks all the template-tables for a specific major mode.")
(defun srecode-get-mode-table (mode)
"Get the SRecoder mode table for the major mode MODE.
-Optional argument SOFT indicates to not make a new one if a table
-was not found."
- (let ((ans nil))
- (while (and (not ans) mode)
- (setq ans (eieio-instance-tracker-find
- mode 'major-mode 'srecode-mode-table-list)
- mode (get-mode-local-parent mode)))
- ans))
+This will find the mode table specific to MODE, and then
+calculate all inherited templates from parent modes."
+ (let ((table nil)
+ (tmptable nil))
+ (while mode
+ (setq tmptable (eieio-instance-tracker-find
+ mode 'major-mode 'srecode-mode-table-list)
+ mode (get-mode-local-parent mode))
+ (when tmptable
+ (if (not table)
+ (progn
+ ;; If this is the first, update tables to have
+ ;; all the mode specific tables in it.
+ (setq table tmptable)
+ (oset table tables (oref table modetables)))
+ ;; If there already is a table, then reset the tables
+ ;; slot to include all the tables belonging to this new child node.
+ (oset table tables (append (oref table modetables)
+ (oref tmptable modetables)))))
+ )
+ table))
(defun srecode-make-mode-table (mode)
"Get the SRecoder mode table for the major mode MODE."
@@ -140,6 +165,7 @@ was not found."
(let* ((ms (if (stringp mode) mode (symbol-name mode)))
(new (srecode-mode-table ms
:major-mode mode
+ :modetables nil
:tables nil)))
;; Save this new mode table in that mode's variable.
(eval `(setq-mode-local ,mode srecode-table ,new))
@@ -149,7 +175,7 @@ was not found."
(defmethod srecode-mode-table-find ((mt srecode-mode-table) file)
"Look in the mode table MT for a template table from FILE.
Return nil if there was none."
- (object-assoc file 'file (oref mt tables)))
+ (object-assoc file 'file (oref mt modetables)))
(defun srecode-mode-table-new (mode file &rest init)
"Create a new template table for MODE in FILE.
@@ -166,16 +192,16 @@ INIT are the initialization parameters for the new template table."
init
)))
;; Whack the old table.
- (when old (object-remove-from-list mt 'tables old))
+ (when old (object-remove-from-list mt 'modetables old))
;; Add the new table
- (object-add-to-list mt 'tables new)
+ (object-add-to-list mt 'modetables new)
;; Sort the list in reverse order. When other routines
;; go front-to-back, the highest priority items are put
;; into the search table first, allowing lower priority items
;; to be the items found in the search table.
- (object-sort-list mt 'tables (lambda (a b)
- (> (oref a :priority)
- (oref b :priority))))
+ (object-sort-list mt 'modetables (lambda (a b)
+ (> (oref a :priority)
+ (oref b :priority))))
;; Return it.
new))
@@ -231,6 +257,9 @@ Use PREDICATE is the same as for the `sort' function."
(when (oref tab :application)
(princ "\nApplication: ")
(princ (oref tab :application)))
+ (when (oref tab :framework)
+ (princ "\nFramework: ")
+ (princ (oref tab :framework)))
(when (oref tab :project)
(require 'srecode/find) ; For srecode-template-table-in-project-p
(princ "\nProject Directory: ")