diff options
Diffstat (limited to 'lisp/cedet/srecode')
| -rw-r--r-- | lisp/cedet/srecode/args.el | 25 | ||||
| -rw-r--r-- | lisp/cedet/srecode/compile.el | 38 | ||||
| -rw-r--r-- | lisp/cedet/srecode/cpp.el | 3 | ||||
| -rw-r--r-- | lisp/cedet/srecode/dictionary.el | 8 | ||||
| -rw-r--r-- | lisp/cedet/srecode/fields.el | 4 | ||||
| -rw-r--r-- | lisp/cedet/srecode/insert.el | 4 | ||||
| -rw-r--r-- | lisp/cedet/srecode/java.el | 22 | ||||
| -rw-r--r-- | lisp/cedet/srecode/map.el | 3 | ||||
| -rw-r--r-- | lisp/cedet/srecode/mode.el | 2 | ||||
| -rw-r--r-- | lisp/cedet/srecode/srt-mode.el | 6 | ||||
| -rw-r--r-- | lisp/cedet/srecode/srt-wy.el | 6 | ||||
| -rw-r--r-- | lisp/cedet/srecode/srt.el | 6 | ||||
| -rw-r--r-- | lisp/cedet/srecode/table.el | 2 |
13 files changed, 95 insertions, 34 deletions
diff --git a/lisp/cedet/srecode/args.el b/lisp/cedet/srecode/args.el index b91f96f611d..6bc78295fa7 100644 --- a/lisp/cedet/srecode/args.el +++ b/lisp/cedet/srecode/args.el @@ -26,6 +26,7 @@ ;; a set of simple arguments for srecode templates. (require 'srecode/dictionary) +(require 'ede) ;;; Code: @@ -157,6 +158,30 @@ do not contain any text from preceding or following text." (srecode-dictionary-show-section dict "RCS") ))) +;;; :project ARGUMENT HANDLING +;; +;; When the :project argument is required, fill the dictionary with +;; information that the current project (from EDE) might know +(defun srecode-semantic-handle-:project (dict) + "Add macros into the dictionary DICT based on the current ede project." + (let* ((bfn (buffer-file-name)) + (dir (file-name-directory bfn))) + (if (ede-toplevel) + (let* ((projecttop (ede-toplevel-project default-directory)) + (relfname (file-relative-name bfn projecttop)) + (reldir (file-relative-name dir projecttop)) + ) + (srecode-dictionary-set-value dict "PROJECT_FILENAME" relfname) + (srecode-dictionary-set-value dict "PROJECT_DIRECTORY" reldir) + (srecode-dictionary-set-value dict "PROJECT_NAME" (ede-name (ede-toplevel))) + (srecode-dictionary-set-value dict "PROJECT_VERSION" (oref (ede-toplevel) :version)) + ) + ;; If there is no EDE project, then put in some base values. + (srecode-dictionary-set-value dict "PROJECT_FILENAME" bfn) + (srecode-dictionary-set-value dict "PROJECT_DIRECTORY" dir) + (srecode-dictionary-set-value dict "PROJECT_NAME" "N/A") + (srecode-dictionary-set-value dict "PROJECT_VERSION" "1.0")))) + ;;; :system ARGUMENT HANDLING ;; ;; When a :system argument is required, fill the dictionary with diff --git a/lisp/cedet/srecode/compile.el b/lisp/cedet/srecode/compile.el index 170b99c1fd2..542fd49f8e5 100644 --- a/lisp/cedet/srecode/compile.el +++ b/lisp/cedet/srecode/compile.el @@ -200,10 +200,11 @@ Arguments ESCAPE-START and ESCAPE-END are the current escape sequences in use." "Compile a semantic recode template file into a mode-local variable." (interactive) (unless (semantic-active-p) - (error "You have to activate semantic-mode to compile SRecode templates.")) + (error "You have to activate semantic-mode to compile SRecode templates")) (require 'srecode/insert) - (message "Compiling template %s..." - (file-name-nondirectory (buffer-file-name))) + (when (called-interactively-p 'interactive) + (message "Compiling template %s..." + (file-name-nondirectory (buffer-file-name)))) (let ((tags (semantic-fetch-tags)) (tag nil) (class nil) @@ -288,10 +289,11 @@ Arguments ESCAPE-START and ESCAPE-END are the current escape sequences in use." ) ;; Continue (setq tags (cdr tags))) - + ;; MSG - Before install since nreverse whacks our list. - (message "%d templates compiled for %s" - (length table) mode) + (when (called-interactively-p 'interactive) + (message "%d templates compiled for %s" + (length table) mode)) ;; ;; APPLY TO MODE @@ -316,12 +318,14 @@ Arguments ESCAPE-START and ESCAPE-END are the current escape sequences in use." (if (stringp project) (setq priority (+ 50 defaultdelta)) (setq priority (+ 80 defaultdelta)))) - (message "Templates %s has estimated priority of %d" - (file-name-nondirectory (buffer-file-name)) - priority)) - (message "Compiling templates %s priority %d... done!" - (file-name-nondirectory (buffer-file-name)) - priority)) + (when (called-interactively-p 'interactive) + (message "Templates %s has estimated priority of %d" + (file-name-nondirectory (buffer-file-name)) + priority))) + (when (called-interactively-p 'interactive) + (message "Compiling templates %s priority %d... done!" + (file-name-nondirectory (buffer-file-name)) + priority))) ;; Save it up! (srecode-compile-template-table table mode priority application framework project vars) @@ -510,12 +514,12 @@ to the inserter constructor." ;;(message "Compile: %s %S" name props) (if (not key) (apply 'srecode-template-inserter-variable name props) - (let ((classes (class-children srecode-template-inserter)) + (let ((classes (eieio-class-children srecode-template-inserter)) (new nil)) ;; Loop over the various subclasses and ;; create the correct inserter. (while (and (not new) classes) - (setq classes (append classes (class-children (car classes)))) + (setq classes (append classes (eieio-class-children (car classes)))) ;; Do we have a match? (when (and (not (class-abstract-p (car classes))) (equal (oref (car classes) key) key)) @@ -594,7 +598,7 @@ A list of defined variables VARS provides a variable table." (defmethod srecode-dump ((tmp srecode-template)) "Dump the contents of the SRecode template tmp." (princ "== Template \"") - (princ (object-name-string tmp)) + (princ (eieio-object-name-string tmp)) (princ "\" in context ") (princ (oref tmp context)) (princ "\n") @@ -640,12 +644,12 @@ Argument INDENT specifies the indentation level for the list." (defmethod srecode-dump ((ins srecode-template-inserter) indent) "Dump the state of the SRecode template inserter INS." (princ "INS: \"") - (princ (object-name-string ins)) + (princ (eieio-object-name-string ins)) (when (oref ins :secondname) (princ "\" : \"") (princ (oref ins :secondname))) (princ "\" type \"") - (let* ((oc (symbol-name (object-class ins))) + (let* ((oc (symbol-name (eieio-object-class ins))) (junk (string-match "srecode-template-inserter-" oc)) (on (if junk (substring oc (match-end 0)) diff --git a/lisp/cedet/srecode/cpp.el b/lisp/cedet/srecode/cpp.el index 94b394a1631..fd500b6d9a3 100644 --- a/lisp/cedet/srecode/cpp.el +++ b/lisp/cedet/srecode/cpp.el @@ -70,8 +70,7 @@ HEADER - Shown section if in a header file." (srecode-dictionary-show-section dict "NOTHEADER")) ;; Strip out bad characters - (while (string-match "\\.\\| " fsym) - (setq fsym (replace-match "_" t t fsym))) + (setq fsym (replace-regexp-in-string "[^a-zA-Z0-9_]" "_" fsym)) (srecode-dictionary-set-value dict "FILENAME_SYMBOL" fsym) ) ) diff --git a/lisp/cedet/srecode/dictionary.el b/lisp/cedet/srecode/dictionary.el index bac05666726..bbc791f09d8 100644 --- a/lisp/cedet/srecode/dictionary.el +++ b/lisp/cedet/srecode/dictionary.el @@ -175,7 +175,7 @@ associated with a buffer or parent." ((srecode-dictionary-child-p buffer-or-parent) (setq parent buffer-or-parent buffer (oref buffer-or-parent buffer) - origin (concat (object-name buffer-or-parent) " in " + origin (concat (eieio-object-name buffer-or-parent) " in " (if buffer (buffer-name buffer) "no buffer"))) (when buffer @@ -454,12 +454,12 @@ If you subclass `srecode-dictionary-compound-value' then this method could return nil, but if it does that, it must insert the value itself using `princ', or by detecting if the current standard out is a buffer, and using `insert'." - (object-name cp)) + (eieio-object-name cp)) (defmethod srecode-dump ((cp srecode-dictionary-compound-value) &optional indent) "Display information about this compound value." - (princ (object-name cp)) + (princ (eieio-object-name cp)) ) (defmethod srecode-compound-toString ((cp srecode-dictionary-compound-variable) @@ -654,7 +654,7 @@ STATE is the current compiler state." 4))) (while entry (princ " --> SUBDICTIONARY ") - (princ (object-name dict)) + (princ (eieio-object-name dict)) (princ "\n") (srecode-dump (car entry) newindent) (setq entry (cdr entry)) diff --git a/lisp/cedet/srecode/fields.el b/lisp/cedet/srecode/fields.el index 652702ea8f2..ea856f3a394 100644 --- a/lisp/cedet/srecode/fields.el +++ b/lisp/cedet/srecode/fields.el @@ -447,4 +447,8 @@ PRE-LEN is used in the after mode for the length of the changed text." (provide 'srecode/fields) +;; Local variables: +;; generated-autoload-load-name: "srecode/fields" +;; End: + ;;; srecode/fields.el ends here diff --git a/lisp/cedet/srecode/insert.el b/lisp/cedet/srecode/insert.el index 466efae3b9c..0d647bb56c5 100644 --- a/lisp/cedet/srecode/insert.el +++ b/lisp/cedet/srecode/insert.el @@ -809,7 +809,7 @@ Arguments ESCAPE-START and ESCAPE-END are the current escape sequences in use." (srecode-insert-report-error dict "Only section dictionaries allowed for `%s'" - (object-name-string sti))) + (eieio-object-name-string sti))) ;; Output the code from the sub-template. (srecode-insert-method (slot-value sti slot) dict)) @@ -866,7 +866,7 @@ Return the remains of INPUT." (let* ((out (srecode-compile-split-code tag input STATE (oref ins :object-name)))) (oset ins template (srecode-template - (object-name-string ins) + (eieio-object-name-string ins) :context nil :args nil :code (cdr out))) diff --git a/lisp/cedet/srecode/java.el b/lisp/cedet/srecode/java.el index db4d2deee28..1b8922c2746 100644 --- a/lisp/cedet/srecode/java.el +++ b/lisp/cedet/srecode/java.el @@ -27,6 +27,7 @@ (require 'srecode/dictionary) (require 'semantic/find) +(require 'ede) ;;;###autoload (defun srecode-semantic-handle-:java (dict) @@ -42,9 +43,24 @@ FILENAME_AS_CLASS - file converted to a Java class name." ) (while (string-match "\\.\\| " fpak) (setq fpak (replace-match "_" t t fpak))) - (if (string-match "src/" dir) - (setq dir (substring dir (match-end 0))) - (setq dir (file-name-nondirectory (directory-file-name dir)))) + ;; We can extract package from: + ;; 1) a java EDE project source paths, + (cond ((ede-current-project) + (let* ((proj (ede-current-project)) + (pths (ede-source-paths proj 'java-mode)) + (pth) + (res)) + (while (and (not res) + (setq pth (expand-file-name (car pths)))) + (when (string-match pth dir) + (setq res (substring dir (match-end 0)))) + (setq pths (cdr pths))) + (setq dir res))) + ;; 2) a simple heuristic + ((string-match "src/" dir) + (setq dir (substring dir (match-end 0)))) + ;; 3) outer directory as a fallback + (t (setq dir (file-name-nondirectory (directory-file-name dir))))) (setq dir (directory-file-name dir)) (while (string-match "/" dir) (setq dir (replace-match "." t t dir))) diff --git a/lisp/cedet/srecode/map.el b/lisp/cedet/srecode/map.el index cbe602f3299..1dd9ba4cf47 100644 --- a/lisp/cedet/srecode/map.el +++ b/lisp/cedet/srecode/map.el @@ -363,6 +363,9 @@ Return non-nil if the map changed." (let ((semantic-init-hook nil)) (semantic-new-buffer-fcn)) ) + ;; Force semantic to be enabled in this buffer. + (unless (semantic-active-p) + (semantic-new-buffer-fcn)) (semantic-fetch-tags) (let* ((mode-tag diff --git a/lisp/cedet/srecode/mode.el b/lisp/cedet/srecode/mode.el index 8c4a53ec891..e8e1c78198e 100644 --- a/lisp/cedet/srecode/mode.el +++ b/lisp/cedet/srecode/mode.el @@ -225,7 +225,7 @@ MENU-DEF is the menu to bind this into." (ctxtcons (assoc ctxt alltabs)) (bind (if (slot-boundp temp 'binding) (oref temp binding))) - (name (object-name-string temp))) + (name (eieio-object-name-string temp))) (when (not ctxtcons) (if (string= context ctxt) diff --git a/lisp/cedet/srecode/srt-mode.el b/lisp/cedet/srecode/srt-mode.el index 455895c003d..2f43dc3872b 100644 --- a/lisp/cedet/srecode/srt-mode.el +++ b/lisp/cedet/srecode/srt-mode.el @@ -187,7 +187,7 @@ we can tell font lock about them.") "Keymap used in srecode mode.") ;;;###autoload -(define-derived-mode srecode-template-mode fundamental-mode "SRecorder" +(define-derived-mode srecode-template-mode fundamental-mode "SRecode" "Major-mode for writing SRecode macros." (set (make-local-variable 'comment-start) ";;") (set (make-local-variable 'comment-end) "") @@ -232,7 +232,7 @@ we can tell font lock about them.") "Provide help for working with macros in a template." (interactive) (let* ((root 'srecode-template-inserter) - (chl (aref (class-v root) class-children)) + (chl (eieio--class-children (class-v root))) (ess (srecode-template-get-escape-start)) (ees (srecode-template-get-escape-end)) ) @@ -248,7 +248,7 @@ we can tell font lock about them.") (showexample t) ) (setq chl (cdr chl)) - (setq chl (append (aref (class-v C) class-children) chl)) + (setq chl (append (eieio--class-children (class-v C)) chl)) (catch 'skip (when (eq C 'srecode-template-inserter-section-end) diff --git a/lisp/cedet/srecode/srt-wy.el b/lisp/cedet/srecode/srt-wy.el index 5560d35a70c..450f57d943c 100644 --- a/lisp/cedet/srecode/srt-wy.el +++ b/lisp/cedet/srecode/srt-wy.el @@ -131,6 +131,10 @@ ((SET symbol insertable-string-list newline) (wisent-raw-tag (semantic-tag-new-variable $2 nil $3))) + ((SET symbol number newline) + (wisent-raw-tag + (semantic-tag-new-variable $2 nil + (list $3)))) ((SHOW symbol newline) (wisent-raw-tag (semantic-tag-new-variable $2 nil t)))) @@ -290,8 +294,8 @@ It ignores whitespace, newlines and comments." srecode-template-separator-block srecode-template-wy--<keyword>-keyword-analyzer srecode-template-property-analyzer - srecode-template-wy--<symbol>-regexp-analyzer srecode-template-wy--<number>-regexp-analyzer + srecode-template-wy--<symbol>-regexp-analyzer srecode-template-wy--<string>-sexp-analyzer srecode-template-wy--<punctuation>-string-analyzer semantic-lex-default-action diff --git a/lisp/cedet/srecode/srt.el b/lisp/cedet/srecode/srt.el index 3875246cb37..1fad31dafd6 100644 --- a/lisp/cedet/srecode/srt.el +++ b/lisp/cedet/srecode/srt.el @@ -69,6 +69,7 @@ DEFAULT is the default if RET is hit." nil initial (or hist 'srecode-read-major-mode-history)) ) +;;;###autoload (defun srecode-semantic-handle-:srt (dict) "Add macros into the dictionary DICT based on the current SRT file. Adds the following: @@ -104,4 +105,9 @@ MODE - The mode of this buffer. If not declared yet, guess." (provide 'srecode/srt) +;; Local variables: +;; generated-autoload-file: "loaddefs.el" +;; generated-autoload-load-name: "srecode/srt" +;; End: + ;;; srecode/srt.el ends here diff --git a/lisp/cedet/srecode/table.el b/lisp/cedet/srecode/table.el index 802740ba063..26163bd1e51 100644 --- a/lisp/cedet/srecode/table.el +++ b/lisp/cedet/srecode/table.el @@ -251,7 +251,7 @@ Use PREDICATE is the same as for the `sort' function." (defmethod srecode-dump ((tab srecode-template-table)) "Dump the contents of the SRecode template table TAB." (princ "Template Table for ") - (princ (object-name-string tab)) + (princ (eieio-object-name-string tab)) (princ "\nPriority: ") (prin1 (oref tab :priority)) (when (oref tab :application) |
