2021-03-05 21:00:00 -05:00
|
|
|
|
;;; srecode/srt-mode.el --- Major mode for writing screcode macros -*- lexical-binding: t; -*-
|
2009-09-20 21:06:41 +00:00
|
|
|
|
|
2022-01-01 02:45:51 -05:00
|
|
|
|
;; Copyright (C) 2005, 2007-2022 Free Software Foundation, Inc.
|
2009-09-20 21:06:41 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs 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 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs 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
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2009-09-20 21:06:41 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; Originally named srecode-template-mode.el in the CEDET repository.
|
|
|
|
|
|
|
|
|
|
(require 'srecode/compile)
|
|
|
|
|
(require 'srecode/ctxt)
|
|
|
|
|
(require 'srecode/template)
|
|
|
|
|
|
|
|
|
|
(require 'semantic)
|
|
|
|
|
(require 'semantic/analyze)
|
|
|
|
|
(require 'semantic/wisent)
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(require 'semantic/find))
|
|
|
|
|
|
|
|
|
|
(declare-function srecode-create-dictionary "srecode/dictionary")
|
2019-06-14 17:03:59 +02:00
|
|
|
|
(declare-function srecode-resolve-argument-list "srecode/insert")
|
2019-06-15 17:34:48 +02:00
|
|
|
|
(declare-function srecode-inserter-prin-example "srecode/insert")
|
2009-09-20 21:06:41 +00:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
(defvar srecode-template-mode-syntax-table
|
|
|
|
|
(let ((table (make-syntax-table (standard-syntax-table))))
|
|
|
|
|
(modify-syntax-entry ?\; ". 12" table) ;; SEMI, Comment start ;;
|
|
|
|
|
(modify-syntax-entry ?\n ">" table) ;; Comment end
|
|
|
|
|
(modify-syntax-entry ?$ "." table) ;; Punctuation
|
|
|
|
|
(modify-syntax-entry ?: "." table) ;; Punctuation
|
|
|
|
|
(modify-syntax-entry ?< "." table) ;; Punctuation
|
|
|
|
|
(modify-syntax-entry ?> "." table) ;; Punctuation
|
|
|
|
|
(modify-syntax-entry ?# "." table) ;; Punctuation
|
|
|
|
|
(modify-syntax-entry ?! "." table) ;; Punctuation
|
|
|
|
|
(modify-syntax-entry ?? "." table) ;; Punctuation
|
|
|
|
|
(modify-syntax-entry ?\" "\"" table) ;; String
|
|
|
|
|
(modify-syntax-entry ?\- "_" table) ;; Symbol
|
|
|
|
|
(modify-syntax-entry ?\\ "\\" table) ;; Quote
|
|
|
|
|
(modify-syntax-entry ?\` "'" table) ;; Prefix ` (backquote)
|
|
|
|
|
(modify-syntax-entry ?\' "'" table) ;; Prefix ' (quote)
|
|
|
|
|
(modify-syntax-entry ?\, "'" table) ;; Prefix , (comma)
|
|
|
|
|
|
|
|
|
|
table)
|
|
|
|
|
"Syntax table used in semantic recoder macro buffers.")
|
|
|
|
|
|
|
|
|
|
(defface srecode-separator-face
|
|
|
|
|
'((t (:weight bold :strike-through t)))
|
|
|
|
|
"Face used for decorating separators in srecode template mode."
|
|
|
|
|
:group 'srecode)
|
|
|
|
|
|
|
|
|
|
(defvar srecode-font-lock-keywords
|
|
|
|
|
'(
|
|
|
|
|
;; Template
|
2019-04-12 19:43:16 -07:00
|
|
|
|
("^\\(template\\)\\s-+\\(\\w*\\)\\(\\( \\(:\\w+\\)\\)*\\)$"
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(1 font-lock-keyword-face)
|
|
|
|
|
(2 font-lock-function-name-face)
|
|
|
|
|
(3 font-lock-builtin-face ))
|
|
|
|
|
("^\\(sectiondictionary\\)\\s-+\""
|
|
|
|
|
(1 font-lock-keyword-face))
|
2012-10-02 02:10:29 +08:00
|
|
|
|
("^\\s\s*\\(section\\)\\s-+\""
|
|
|
|
|
(1 font-lock-keyword-face))
|
|
|
|
|
("^\\s\s*\\(end\\)"
|
|
|
|
|
(1 font-lock-keyword-face))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
("^\\(bind\\)\\s-+\""
|
|
|
|
|
(1 font-lock-keyword-face))
|
|
|
|
|
;; Variable type setting
|
2012-10-02 02:10:29 +08:00
|
|
|
|
("^\\s\s*\\(set\\)\\s-+\\(\\w+\\)\\s-+"
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(1 font-lock-keyword-face)
|
|
|
|
|
(2 font-lock-variable-name-face))
|
2012-10-02 02:10:29 +08:00
|
|
|
|
("^\\s\s*\\(show\\)\\s-+\\(\\w+\\)\\s-*$"
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(1 font-lock-keyword-face)
|
|
|
|
|
(2 font-lock-variable-name-face))
|
|
|
|
|
("\\<\\(macro\\)\\s-+\""
|
|
|
|
|
(1 font-lock-keyword-face))
|
|
|
|
|
;; Context type setting
|
|
|
|
|
("^\\(context\\)\\s-+\\(\\w+\\)"
|
|
|
|
|
(1 font-lock-keyword-face)
|
|
|
|
|
(2 font-lock-builtin-face))
|
|
|
|
|
;; Prompting setting
|
|
|
|
|
("^\\(prompt\\)\\s-+\\(\\w+\\)"
|
|
|
|
|
(1 font-lock-keyword-face)
|
|
|
|
|
(2 font-lock-variable-name-face))
|
|
|
|
|
("\\(default\\(macro\\)?\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
|
|
|
|
|
(1 font-lock-keyword-face)
|
|
|
|
|
(3 font-lock-type-face))
|
|
|
|
|
("\\<\\(default\\(macro\\)?\\)\\>" (1 font-lock-keyword-face))
|
|
|
|
|
("\\<\\(read\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
|
|
|
|
|
(1 font-lock-keyword-face)
|
|
|
|
|
(2 font-lock-type-face))
|
|
|
|
|
|
|
|
|
|
;; Macro separators
|
|
|
|
|
("^----\n" 0 'srecode-separator-face)
|
|
|
|
|
|
|
|
|
|
;; Macro Matching
|
|
|
|
|
(srecode-template-mode-macro-escape-match 1 font-lock-string-face)
|
|
|
|
|
((lambda (limit)
|
|
|
|
|
(srecode-template-mode-font-lock-macro-helper
|
|
|
|
|
limit "\\(\\??\\w+\\)[^ \t\n{}$#@&*()]*"))
|
|
|
|
|
1 font-lock-variable-name-face)
|
|
|
|
|
((lambda (limit)
|
|
|
|
|
(srecode-template-mode-font-lock-macro-helper
|
|
|
|
|
limit "\\([#/]\\w+\\)[^ \t\n{}$#@&*()]*"))
|
|
|
|
|
1 font-lock-keyword-face)
|
|
|
|
|
((lambda (limit)
|
|
|
|
|
(srecode-template-mode-font-lock-macro-helper
|
|
|
|
|
limit "\\([<>]\\w*\\):\\(\\w+\\):\\(\\w+\\)"))
|
|
|
|
|
(1 font-lock-keyword-face)
|
|
|
|
|
(2 font-lock-builtin-face)
|
|
|
|
|
(3 font-lock-type-face))
|
|
|
|
|
((lambda (limit)
|
|
|
|
|
(srecode-template-mode-font-lock-macro-helper
|
|
|
|
|
limit "\\([<>?]?\\w*\\):\\(\\w+\\)"))
|
|
|
|
|
(1 font-lock-keyword-face)
|
|
|
|
|
(2 font-lock-type-face))
|
|
|
|
|
((lambda (limit)
|
|
|
|
|
(srecode-template-mode-font-lock-macro-helper
|
|
|
|
|
limit "!\\([^{}$]*\\)"))
|
|
|
|
|
1 font-lock-comment-face)
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
"Keywords for use with srecode macros and font-lock.")
|
|
|
|
|
|
|
|
|
|
(defun srecode-template-mode-font-lock-macro-helper (limit expression)
|
|
|
|
|
"Match against escape characters.
|
|
|
|
|
Don't scan past LIMIT. Match with EXPRESSION."
|
|
|
|
|
(let* ((done nil)
|
|
|
|
|
(md nil)
|
|
|
|
|
(es (regexp-quote (srecode-template-get-escape-start)))
|
|
|
|
|
(ee (regexp-quote (srecode-template-get-escape-end)))
|
|
|
|
|
(regex (concat es expression ee))
|
|
|
|
|
)
|
|
|
|
|
(while (not done)
|
|
|
|
|
(save-match-data
|
|
|
|
|
(if (re-search-forward regex limit t)
|
|
|
|
|
(when (equal (car (srecode-calculate-context)) "code")
|
|
|
|
|
(setq md (match-data)
|
|
|
|
|
done t))
|
|
|
|
|
(setq done t))))
|
|
|
|
|
(set-match-data md)
|
|
|
|
|
;; (when md (message "Found a match!"))
|
|
|
|
|
(when md t)))
|
|
|
|
|
|
|
|
|
|
(defun srecode-template-mode-macro-escape-match (limit)
|
|
|
|
|
"Match against escape characters.
|
|
|
|
|
Don't scan past LIMIT."
|
|
|
|
|
(let* ((done nil)
|
|
|
|
|
(md nil)
|
|
|
|
|
(es (regexp-quote (srecode-template-get-escape-start)))
|
|
|
|
|
(ee (regexp-quote (srecode-template-get-escape-end)))
|
|
|
|
|
(regex (concat "\\(" es "\\|" ee "\\)"))
|
|
|
|
|
)
|
|
|
|
|
(while (not done)
|
|
|
|
|
(save-match-data
|
|
|
|
|
(if (re-search-forward regex limit t)
|
|
|
|
|
(when (equal (car (srecode-calculate-context)) "code")
|
|
|
|
|
(setq md (match-data)
|
|
|
|
|
done t))
|
|
|
|
|
(setq done t))))
|
|
|
|
|
(set-match-data md)
|
|
|
|
|
;;(when md (message "Found a match!"))
|
|
|
|
|
(when md t)))
|
|
|
|
|
|
|
|
|
|
(defvar srecode-font-lock-macro-keywords nil
|
|
|
|
|
"Dynamically generated `font-lock' keywords for srecode templates.
|
|
|
|
|
Once the escape_start, and escape_end sequences are known, then
|
|
|
|
|
we can tell font lock about them.")
|
|
|
|
|
|
2022-09-13 15:05:28 +02:00
|
|
|
|
(defvar-keymap srecode-template-mode-map
|
|
|
|
|
:doc "Keymap used in srecode mode."
|
|
|
|
|
"C-c C-c" #'srecode-compile-templates
|
|
|
|
|
"C-c C-m" #'srecode-macro-help
|
|
|
|
|
"/" #'srecode-self-insert-complete-end-macro)
|
2009-09-20 21:06:41 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
Merge with CEDET upstream (rev. 8499).
lisp/
* eieio/eieio-datadebug.el (data-debug/eieio-insert-slots):
Inhibit read only while inserting objects.
lisp/cedet/
* semantic.el (navigate-menu): Yank Tag :enable. Make sure
`senator-tag-ring' is bound.
(semantic-parse-region-default): Stop reversing the output of
parse-whole-stream.
(semantic-repeat-parse-whole-stream): Append returned tags
differently, so they come out in the right order.
* semantic/sb.el (semantic-sb-filter-tags-of-class): New option.
(semantic-sb-fetch-tag-table): Filter tags being bucketed to exclude
tags belonging to above filtered classes.
* semantic/find.el (semantic-filter-tags-by-class): New function.
* semantic/tag-ls.el (semantic-tag-similar-p-default): Add
short-circuit in case tag1 and 2 are identical.
* semantic/analyze/fcn.el
(semantic-analyze-dereference-metatype-stack): Use
`semantic-tag-similar-p' instead of 'eq' when comparing two tags
during metatype evaluation in case they are the same, but not the same
node. (Tweaked patch from Tomasz Gajewski) (Tiny change)
* semantic/db-find.el (semanticdb-partial-synchronize): Fix require to
semantic/db-typecache to be correct.
(semanticdb-find-tags-external-children-of-type): Make this a brutish
search by default.
* semantic/sort.el (semantic-tag-external-member-children-default):
When calling `semanticdb-find-tags-external-children-of-type', pass in
the input tag as the place to start searching for externally defined
methods.
* semantic/db-file.el (semanticdb-default-save-directory): Doc
fix: Add ref to default value.
* semantic/complete.el (semantic-complete-post-command-hook): When
detecting if cursor is outside completion area, do so if cursor moves
before start of overlay, or the original starting location of the
overlay (i.e., if user deletes past beginning of the overlay region).
(semantic-complete-inline-tag-engine): Initialize original start of
`semantic-complete-inline-overlay'.
* semantic/bovine/c.el (semantic-c-describe-environment): Update some
section titles. Test semanticdb table before printing it.
(semantic-c-reset-preprocessor-symbol-map): Update
`semantic-lex-spp-macro-symbol-obarray' outside the loop over all the
files contributing to its value.
(semantic-c-describe-environment): If there is an EDE project but no
spp symbols from it, say so.
* srecode/args.el (srecode-semantic-handle-:project): New argument
handler. Provide variable values if not in an EDE project.
* srecode/srt-mode.el (srecode-template-mode): Fix typo on srecode
name.
* srecode/cpp.el (srecode-semantic-handle-:c): Replace all characters
in FILENAME_SYMBOL that aren't valid CPP symbol chars.
* srecode/map.el (srecode-map-validate-file-for-mode): Force semantic
to load if it is not active in the template being added to the map.
* srecode/srt.el: Add local variables for setting the autoload file
name.
(srecode-semantic-handle-:srt): New autoload cookie
* ede.el (ede-apply-preprocessor-map): Apply map to
`semantic-lex-spp-project-macro-symbol-obarray' instead of the system
one. Add require for semantic.
* ede/proj-elisp.el (ede-update-version-in-source): In case a file has
both a version variable and a Version: comment, always use
`call-next-method'.
* ede/cpp-root.el (ede-set-project-variables): Deleted.
`ede-preprocessor-map' does the job this function was attempting to do
with :spp-table.
(ede-preprocessor-map): Update file tests to provide better messages.
Do not try to get symbols from a file that is the file in the current
buffer.
* ede/base.el (ede-project-placeholder): Add more documentation to
:file slot.
(ede-load-cache): Use `insert-file-contents' instead of
`find-file-noselect' in order to avoid activating other tools.
* semantic/bovine/c.el (semantic-get-local-variables): Also add a new
variable 'this' if we are in an inline member function. For detecting
this, we check overlays at point if there is a class spanning the
current function. Also, the variable 'this' has to be a pointer.
* semantic/bovine/gcc.el (semantic-gcc-setup): Fail gracefully when
querying g++ for defines returns an error.
* srecode/srt-mode.el:
* srecode/compile.el:
* semantic/elp.el:
* semantic/db-el.el:
* semantic/complete.el:
* ede.el:
* cogre.el:
* srecode/table.el:
* srecode/mode.el:
* srecode/insert.el:
* srecode/compile.el:
* semantic/decorate/include.el:
* semantic/db.el:
* semantic/adebug.el:
* ede/auto.el:
* srecode/dictionary.el:
* semantic/ede-grammar.el:
* semantic/db.el:
* semantic/db-find.el:
* semantic/db-file.el:
* semantic/complete.el:
* semantic/bovine/c.el:
* semantic/analyze.el:
* ede/util.el:
* ede/proj.el:
* ede/proj-elisp.el:
* ede/pconf.el:
* ede/locate.el:
* ede.el: Adapt to EIEIO namespace cleanup: Rename `object-name' to
`eieio-object-name', `object-set-name-string' to
`eieio-object-set-name-string', `object-class' to
`eieio-object-class', `class-parent' to `eieio-class-parent',
`class-parents' to `eieio-class-parents', `class-children' to
`eieio-class-children', `object-name-string' to
`eieio-object-name-string', `object-class-fast' to
`eieio--object-class'. Also replace direct access with new accessor
functions.
* ede/cpp-root.el (ede-project-autoload, initialize-instance): Fix EDE
file symbol to match rename. Fix ede-cpp-root symbol to include
-project in name.
* cedet-files.el (cedet-files-list-recursively): New function.
Recursively find files whose names are matching to given regex
* ede.el (ede-current-project): Rewrite to avoid imperative style.
* ede/files.el (ede-find-file): Simplify code.
* ede/base.el (ede-normalize-file/directory): Add function to
normalize :file or :directory slots if they are missing.
* ede/cpp-root.el (ede-cpp-root-project): Add compile-command slot.
(project-compile-project): Compiles project using value specified in
:compule-command slot or in compile-command local variable. Value of
slot or local variable could be string or function that receives
project and should return string that will be invoked as command.
(project-compile-target): Invokes compilation of whole project
* ede/files.el (ede-find-project-root): New function to find root of
project that contains specific file.
(ede-files-find-existing): New function which checks presence of given
directory in the list of registered projects.
etc/
* srecode/ede-autoconf.srt: Change Copyright to FSF.
(ede-empty): Change AC_INIT to use PROJECT_NAME, and PROJECT_VERSION.
* srecode/ede-make.srt (ede-empty): Add a dependency on :project. Add
header comment specifying the project's relative path.
* srecode/c.srt (header_guard): Upcase the filename symbol.
* srecode/java.srt (empty-main): New.
(class-tag): Decapitalize class.
2013-03-21 23:11:03 +01:00
|
|
|
|
(define-derived-mode srecode-template-mode fundamental-mode "SRecode"
|
2013-09-17 11:50:33 -04:00
|
|
|
|
;; FIXME: Shouldn't it derive from prog-mode?
|
2009-10-03 19:28:05 +00:00
|
|
|
|
"Major-mode for writing SRecode macros."
|
2020-12-04 17:55:46 +01:00
|
|
|
|
(setq-local comment-start ";;")
|
|
|
|
|
(setq-local comment-end "")
|
|
|
|
|
(setq-local parse-sexp-ignore-comments t)
|
|
|
|
|
(setq-local comment-start-skip
|
|
|
|
|
"\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
|
|
|
|
|
(setq-local font-lock-defaults
|
|
|
|
|
'(srecode-font-lock-keywords
|
|
|
|
|
nil ;; perform string/comment fontification
|
|
|
|
|
nil ;; keywords are case sensitive.
|
|
|
|
|
;; This puts _ & - as a word constituent,
|
|
|
|
|
;; simplifying our keywords significantly
|
|
|
|
|
((?_ . "w") (?- . "w")))))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2021-03-05 21:00:00 -05:00
|
|
|
|
(defalias 'srt-mode #'srecode-template-mode)
|
2009-09-20 21:06:41 +00:00
|
|
|
|
|
|
|
|
|
;;; Template Commands
|
|
|
|
|
;;
|
|
|
|
|
(defun srecode-self-insert-complete-end-macro ()
|
|
|
|
|
"Self insert the current key, then autocomplete the end macro."
|
|
|
|
|
(interactive)
|
|
|
|
|
(call-interactively 'self-insert-command)
|
|
|
|
|
(when (and (semantic-current-tag)
|
|
|
|
|
(semantic-tag-of-class-p (semantic-current-tag) 'function)
|
|
|
|
|
)
|
|
|
|
|
(let* ((es (srecode-template-get-escape-start))
|
|
|
|
|
(ee (srecode-template-get-escape-end))
|
|
|
|
|
(name (save-excursion
|
|
|
|
|
(forward-char (- (length es)))
|
|
|
|
|
(forward-char -1)
|
|
|
|
|
(if (looking-at (regexp-quote es))
|
|
|
|
|
(srecode-up-context-get-name (point) t))))
|
|
|
|
|
)
|
|
|
|
|
(when name
|
|
|
|
|
(insert name)
|
|
|
|
|
(insert ee))))
|
|
|
|
|
)
|
|
|
|
|
|
2019-06-17 15:51:43 +02:00
|
|
|
|
(eieio-declare-slots key)
|
2009-09-20 21:06:41 +00:00
|
|
|
|
|
|
|
|
|
(defun srecode-macro-help ()
|
2009-10-01 03:08:03 +00:00
|
|
|
|
"Provide help for working with macros in a template."
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(interactive)
|
2019-06-15 17:34:48 +02:00
|
|
|
|
(require 'srecode/insert)
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(let* ((root 'srecode-template-inserter)
|
2014-12-22 12:43:23 -05:00
|
|
|
|
(chl (eieio-class-children root))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(ess (srecode-template-get-escape-start))
|
|
|
|
|
(ees (srecode-template-get-escape-end))
|
|
|
|
|
)
|
|
|
|
|
(with-output-to-temp-buffer "*SRecode Macros*"
|
|
|
|
|
(princ "Description of known SRecode Template Macros.")
|
|
|
|
|
(terpri)
|
|
|
|
|
(terpri)
|
|
|
|
|
(while chl
|
|
|
|
|
(let* ((C (car chl))
|
|
|
|
|
(name (symbol-name C))
|
|
|
|
|
(key (when (slot-exists-p C 'key)
|
2019-06-17 15:51:43 +02:00
|
|
|
|
(oref C key)))
|
2019-06-16 15:42:30 +02:00
|
|
|
|
(showexample t))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(setq chl (cdr chl))
|
2014-12-22 12:43:23 -05:00
|
|
|
|
(setq chl (append (eieio-class-children C) chl))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
|
|
|
|
|
(catch 'skip
|
|
|
|
|
(when (eq C 'srecode-template-inserter-section-end)
|
|
|
|
|
(throw 'skip nil))
|
|
|
|
|
|
|
|
|
|
(when (class-abstract-p C)
|
|
|
|
|
(throw 'skip nil))
|
|
|
|
|
|
2022-09-10 07:37:36 +02:00
|
|
|
|
(princ (substitute-quotes "`"))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(princ name)
|
2022-09-10 07:37:36 +02:00
|
|
|
|
(princ (substitute-quotes "'"))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(when (slot-exists-p C 'key)
|
|
|
|
|
(when key
|
|
|
|
|
(princ " - Character Key: ")
|
|
|
|
|
(if (stringp key)
|
|
|
|
|
(progn
|
|
|
|
|
(setq showexample nil)
|
|
|
|
|
(cond ((string= key "\n")
|
|
|
|
|
(princ "\"\\n\"")
|
|
|
|
|
)
|
|
|
|
|
(t
|
|
|
|
|
(prin1 key)
|
|
|
|
|
)))
|
|
|
|
|
(prin1 (format "%c" key))
|
|
|
|
|
)))
|
|
|
|
|
(terpri)
|
|
|
|
|
(princ (documentation-property C 'variable-documentation))
|
|
|
|
|
(terpri)
|
|
|
|
|
(when showexample
|
|
|
|
|
(princ "Example:")
|
|
|
|
|
(terpri)
|
|
|
|
|
(srecode-inserter-prin-example C ess ees)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(terpri)
|
|
|
|
|
|
|
|
|
|
) ;; catch
|
|
|
|
|
);; let*
|
|
|
|
|
))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Misc Language Overrides
|
|
|
|
|
;;
|
|
|
|
|
(define-mode-local-override semantic-ia-insert-tag
|
|
|
|
|
srecode-template-mode (tag)
|
|
|
|
|
"Insert the SRecode TAG into the current buffer."
|
|
|
|
|
(insert (semantic-tag-name tag)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Local Context Parsing.
|
|
|
|
|
|
|
|
|
|
(defun srecode-in-macro-p (&optional point)
|
|
|
|
|
"Non-nil if POINT is inside a macro bounds.
|
|
|
|
|
If the ESCAPE_START and END are different sequences,
|
|
|
|
|
a simple search is used. If ESCAPE_START and END are the same
|
2009-10-01 03:08:03 +00:00
|
|
|
|
characters, start at the beginning of the line, and find out
|
2009-09-20 21:06:41 +00:00
|
|
|
|
how many occur."
|
|
|
|
|
(let ((tag (semantic-current-tag))
|
|
|
|
|
(es (regexp-quote (srecode-template-get-escape-start)))
|
|
|
|
|
(ee (regexp-quote (srecode-template-get-escape-end)))
|
|
|
|
|
(start (or point (point)))
|
|
|
|
|
)
|
|
|
|
|
(when (and tag (semantic-tag-of-class-p tag 'function))
|
|
|
|
|
(if (string= es ee)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(while (re-search-forward es start t 2))
|
|
|
|
|
(if (re-search-forward es start t)
|
2009-10-04 01:44:39 +00:00
|
|
|
|
;; If there is a single, the answer is yes.
|
2009-09-20 21:06:41 +00:00
|
|
|
|
t
|
|
|
|
|
;; If there wasn't another, then the answer is no.
|
|
|
|
|
nil)
|
|
|
|
|
)
|
|
|
|
|
;; ES And EE are not the same.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(and (re-search-backward es (semantic-tag-start tag) t)
|
|
|
|
|
(>= (or (re-search-forward ee (semantic-tag-end tag) t)
|
|
|
|
|
;; No end match means an incomplete macro.
|
|
|
|
|
start)
|
|
|
|
|
start)))
|
|
|
|
|
))))
|
|
|
|
|
|
|
|
|
|
(defun srecode-up-context-get-name (&optional point find-unmatched)
|
|
|
|
|
"Move up one context as for `semantic-up-context', and return the name.
|
|
|
|
|
Moves point to the opening characters of the section macro text.
|
|
|
|
|
If there is no upper context, return nil.
|
|
|
|
|
Starts at POINT if provided.
|
|
|
|
|
If FIND-UNMATCHED is specified as non-nil, then we are looking for an unmatched
|
|
|
|
|
section."
|
|
|
|
|
(when point (goto-char (point)))
|
|
|
|
|
(let* ((tag (semantic-current-tag))
|
|
|
|
|
(es (regexp-quote (srecode-template-get-escape-start)))
|
|
|
|
|
(start (concat es "[#<]\\(\\w+\\)"))
|
|
|
|
|
(orig (point))
|
|
|
|
|
(name nil)
|
|
|
|
|
(res nil))
|
|
|
|
|
(when (semantic-tag-of-class-p tag 'function)
|
|
|
|
|
(while (and (not res)
|
|
|
|
|
(re-search-backward start (semantic-tag-start tag) t))
|
|
|
|
|
(when (save-excursion
|
|
|
|
|
(setq name (match-string 1))
|
|
|
|
|
(let ((endr (concat es "/" name)))
|
|
|
|
|
(if (re-search-forward endr (semantic-tag-end tag) t)
|
|
|
|
|
(< orig (point))
|
|
|
|
|
(if (not find-unmatched)
|
|
|
|
|
(error "Unmatched Section Template")
|
|
|
|
|
;; We found what we want.
|
|
|
|
|
t))))
|
|
|
|
|
(setq res (point)))
|
|
|
|
|
)
|
|
|
|
|
;; Restore in no result found.
|
|
|
|
|
(goto-char (or res orig))
|
|
|
|
|
name)))
|
|
|
|
|
|
|
|
|
|
(define-mode-local-override semantic-up-context
|
|
|
|
|
srecode-template-mode (&optional point)
|
|
|
|
|
"Move up one context in the current code.
|
|
|
|
|
Moves out one named section."
|
|
|
|
|
(not (srecode-up-context-get-name point)))
|
|
|
|
|
|
|
|
|
|
(define-mode-local-override semantic-beginning-of-context
|
|
|
|
|
srecode-template-mode (&optional point)
|
|
|
|
|
"Move to the beginning of the current context.
|
2009-10-04 02:25:42 +00:00
|
|
|
|
Moves to the beginning of one named section."
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(if (semantic-up-context point)
|
|
|
|
|
t
|
|
|
|
|
(let ((es (regexp-quote (srecode-template-get-escape-start)))
|
|
|
|
|
(ee (regexp-quote (srecode-template-get-escape-end))))
|
|
|
|
|
(re-search-forward es) ;; move over the start chars.
|
|
|
|
|
(re-search-forward ee) ;; Move after the end chars.
|
|
|
|
|
nil)))
|
|
|
|
|
|
|
|
|
|
(define-mode-local-override semantic-end-of-context
|
|
|
|
|
srecode-template-mode (&optional point)
|
2009-10-04 02:25:42 +00:00
|
|
|
|
"Move to the end of the current context.
|
|
|
|
|
Moves to the end of one named section."
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(let ((name (srecode-up-context-get-name point))
|
|
|
|
|
(tag (semantic-current-tag))
|
|
|
|
|
(es (regexp-quote (srecode-template-get-escape-start))))
|
|
|
|
|
(if (not name)
|
|
|
|
|
t
|
|
|
|
|
(unless (re-search-forward (concat es "/" name) (semantic-tag-end tag) t)
|
|
|
|
|
(error "Section %s has no end" name))
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
nil)))
|
|
|
|
|
|
|
|
|
|
(define-mode-local-override semantic-get-local-variables
|
|
|
|
|
srecode-template-mode (&optional point)
|
|
|
|
|
"Get local variables from an SRecode template."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(when point (goto-char (point)))
|
|
|
|
|
(let* ((tag (semantic-current-tag))
|
|
|
|
|
(name (save-excursion
|
|
|
|
|
(srecode-up-context-get-name (point))))
|
|
|
|
|
(subdicts (semantic-tag-get-attribute tag :dictionaries))
|
|
|
|
|
(global nil)
|
|
|
|
|
)
|
|
|
|
|
(dolist (D subdicts)
|
|
|
|
|
(setq global (cons (semantic-tag-new-variable (car D) nil)
|
|
|
|
|
global)))
|
|
|
|
|
(if name
|
|
|
|
|
;; Lookup any subdictionaries in TAG.
|
|
|
|
|
(let ((res nil))
|
|
|
|
|
|
|
|
|
|
(while (and (not res) subdicts)
|
|
|
|
|
;; Find the subdictionary with the same name. Those variables
|
|
|
|
|
;; are now local to this section.
|
|
|
|
|
(when (string= (car (car subdicts)) name)
|
|
|
|
|
(setq res (cdr (car subdicts))))
|
|
|
|
|
(setq subdicts (cdr subdicts)))
|
|
|
|
|
;; Pre-pend our global vars.
|
|
|
|
|
(append global res))
|
|
|
|
|
;; If we aren't in a subsection, just do the global variables
|
|
|
|
|
global
|
|
|
|
|
))))
|
|
|
|
|
|
|
|
|
|
(define-mode-local-override semantic-get-local-arguments
|
|
|
|
|
srecode-template-mode (&optional point)
|
|
|
|
|
"Get local arguments from an SRecode template."
|
2019-06-14 17:03:59 +02:00
|
|
|
|
(require 'srecode/insert)
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(when point (goto-char (point)))
|
|
|
|
|
(let* ((tag (semantic-current-tag))
|
|
|
|
|
(args (semantic-tag-function-arguments tag))
|
2021-03-05 21:00:00 -05:00
|
|
|
|
(argsym (mapcar #'intern args))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(argvars nil)
|
|
|
|
|
;; Create a temporary dictionary in which the
|
|
|
|
|
;; arguments can be resolved so we can extract
|
|
|
|
|
;; the results.
|
|
|
|
|
(dict (srecode-create-dictionary t))
|
|
|
|
|
)
|
|
|
|
|
;; Resolve args into our temp dictionary
|
|
|
|
|
(srecode-resolve-argument-list argsym dict)
|
|
|
|
|
|
|
|
|
|
(maphash
|
|
|
|
|
(lambda (key entry)
|
|
|
|
|
(setq argvars
|
|
|
|
|
(cons (semantic-tag-new-variable key nil entry)
|
|
|
|
|
argvars)))
|
|
|
|
|
(oref dict namehash))
|
|
|
|
|
|
|
|
|
|
argvars)))
|
|
|
|
|
|
|
|
|
|
(define-mode-local-override semantic-ctxt-current-symbol
|
|
|
|
|
srecode-template-mode (&optional point)
|
|
|
|
|
"Return the current symbol under POINT.
|
|
|
|
|
Return nil if point is not on/in a template macro."
|
|
|
|
|
(let ((macro (srecode-parse-this-macro point)))
|
|
|
|
|
(cdr macro))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defun srecode-parse-this-macro (&optional point)
|
|
|
|
|
"Return the current symbol under POINT.
|
|
|
|
|
Return nil if point is not on/in a template macro.
|
|
|
|
|
The first element is the key for the current macro, such as # for a
|
|
|
|
|
section or ? for an ask variable."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if point (goto-char point))
|
|
|
|
|
(let ((tag (semantic-current-tag))
|
|
|
|
|
(es (regexp-quote (srecode-template-get-escape-start)))
|
|
|
|
|
(ee (regexp-quote (srecode-template-get-escape-end)))
|
|
|
|
|
(start (point))
|
|
|
|
|
(macrostart nil)
|
2021-03-05 21:00:00 -05:00
|
|
|
|
;; (raw nil)
|
2009-09-20 21:06:41 +00:00
|
|
|
|
)
|
|
|
|
|
(when (and tag (semantic-tag-of-class-p tag 'function)
|
|
|
|
|
(srecode-in-macro-p point)
|
|
|
|
|
(re-search-backward es (semantic-tag-start tag) t))
|
|
|
|
|
(setq macrostart (match-end 0))
|
|
|
|
|
(goto-char macrostart)
|
|
|
|
|
;; We have a match
|
|
|
|
|
(when (not (re-search-forward ee (semantic-tag-end tag) t))
|
|
|
|
|
(goto-char start) ;; Pretend we are ok for completion
|
|
|
|
|
(set-match-data (list start start))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(if (> start (point))
|
|
|
|
|
;; If our starting point is after the found point, that
|
2011-11-13 22:27:12 -08:00
|
|
|
|
;; means we are not inside the macro. Return nil.
|
2009-09-20 21:06:41 +00:00
|
|
|
|
nil
|
|
|
|
|
;; We are inside the macro, extract the text so far.
|
|
|
|
|
(let* ((macroend (match-beginning 0))
|
|
|
|
|
(raw (buffer-substring-no-properties
|
|
|
|
|
macrostart macroend))
|
cedet: remove obsolete name args to constructors
* lisp/cedet/ede/proj-archive.el, lisp/cedet/ede/proj-aux.el:
* lisp/cedet/ede/proj-elisp.el, lisp/cedet/ede/proj-info.el:
* lisp/cedet/ede/proj-misc.el, lisp/cedet/ede/proj-obj.el:
* lisp/cedet/ede/proj-shared.el, lisp/cedet/ede/simple.el:
* lisp/cedet/ede/source.el, lisp/cedet/semantic/:
* lisp/cedet/semantic/analyze.el, lisp/cedet/semantic/complete.el:
* lisp/cedet/semantic/db-javascript.el:
* lisp/cedet/semantic/db-ref.el, lisp/cedet/semantic/debug.el:
* lisp/cedet/semantic/ede-grammar.el:
* lisp/cedet/semantic/mru-bookmark.el, lisp/cedet/semantic/scope.el:
* lisp/cedet/semantic/texi.el, lisp/cedet/semantic/bovine/:
* lisp/cedet/semantic/bovine/c.el:
* lisp/cedet/semantic/bovine/debug.el, lisp/cedet/srecode/:
* lisp/cedet/srecode/extract.el, lisp/cedet/srecode/map.el:
* lisp/cedet/srecode/srt-mode.el:
Remove obsolete name args to constructors.
2018-03-16 20:34:27 -04:00
|
|
|
|
(STATE (srecode-compile-state))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(inserter (condition-case nil
|
|
|
|
|
(srecode-compile-parse-inserter
|
|
|
|
|
raw STATE)
|
|
|
|
|
(error nil)))
|
|
|
|
|
)
|
|
|
|
|
(when inserter
|
|
|
|
|
(let ((base
|
2019-06-13 18:01:42 +02:00
|
|
|
|
(cons (oref inserter object-name)
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(if (and (slot-boundp inserter :secondname)
|
2019-06-13 18:01:42 +02:00
|
|
|
|
(oref inserter secondname))
|
|
|
|
|
(split-string (oref inserter secondname)
|
2009-09-20 21:06:41 +00:00
|
|
|
|
":")
|
|
|
|
|
nil)))
|
2019-06-17 12:22:15 +02:00
|
|
|
|
(key (when (slot-exists-p inserter 'key)
|
2019-06-17 15:51:43 +02:00
|
|
|
|
(oref inserter key))))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(cond ((null key)
|
|
|
|
|
;; A plain variable
|
|
|
|
|
(cons nil base))
|
|
|
|
|
(t
|
|
|
|
|
;; A complex variable thingy.
|
|
|
|
|
(cons (format "%c" key)
|
|
|
|
|
base)))))
|
|
|
|
|
)
|
|
|
|
|
)))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(define-mode-local-override semantic-analyze-current-context
|
|
|
|
|
srecode-template-mode (point)
|
|
|
|
|
"Provide a Semantic analysis in SRecode template mode."
|
|
|
|
|
(let* ((context-return nil)
|
|
|
|
|
(prefixandbounds (semantic-ctxt-current-symbol-and-bounds))
|
|
|
|
|
(prefix (car prefixandbounds))
|
|
|
|
|
(bounds (nth 2 prefixandbounds))
|
|
|
|
|
(key (car (srecode-parse-this-macro (point))))
|
|
|
|
|
(prefixsym nil)
|
|
|
|
|
(prefix-var nil)
|
|
|
|
|
(prefix-context nil)
|
|
|
|
|
(prefix-function nil)
|
|
|
|
|
(prefixclass (semantic-ctxt-current-class-list))
|
|
|
|
|
(globalvar (semantic-find-tags-by-class 'variable (current-buffer)))
|
|
|
|
|
(argtype 'macro)
|
|
|
|
|
(scope (semantic-calculate-scope point))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(oset scope fullscope (append (oref scope localvar) globalvar))
|
|
|
|
|
|
|
|
|
|
(when prefix
|
|
|
|
|
;; First, try to find the variable for the first
|
|
|
|
|
;; entry in the prefix list.
|
|
|
|
|
(setq prefix-var (semantic-find-first-tag-by-name
|
|
|
|
|
(car prefix) (oref scope fullscope)))
|
|
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
((and (or (not key) (string= key "?"))
|
|
|
|
|
(> (length prefix) 1))
|
|
|
|
|
;; Variables can have lisp function names.
|
|
|
|
|
(with-mode-local emacs-lisp-mode
|
|
|
|
|
(let ((fcns (semanticdb-find-tags-by-name (car (last prefix)))))
|
|
|
|
|
(setq prefix-function (car (semanticdb-find-result-nth fcns 0)))
|
|
|
|
|
(setq argtype 'elispfcn)))
|
|
|
|
|
)
|
|
|
|
|
((or (string= key "<") (string= key ">"))
|
|
|
|
|
;; Includes have second args that is the template name.
|
|
|
|
|
(if (= (length prefix) 3)
|
|
|
|
|
(let ((contexts (semantic-find-tags-by-class
|
|
|
|
|
'context (current-buffer))))
|
|
|
|
|
(setq prefix-context
|
|
|
|
|
(or (semantic-find-first-tag-by-name
|
|
|
|
|
(nth 1 prefix) contexts)
|
|
|
|
|
;; Calculate from location
|
|
|
|
|
(semantic-tag
|
|
|
|
|
(symbol-name
|
|
|
|
|
(srecode-template-current-context))
|
|
|
|
|
'context)))
|
|
|
|
|
(setq argtype 'template))
|
|
|
|
|
(setq prefix-context
|
|
|
|
|
;; Calculate from location
|
|
|
|
|
(semantic-tag
|
|
|
|
|
(symbol-name (srecode-template-current-context))
|
|
|
|
|
'context))
|
|
|
|
|
(setq argtype 'template)
|
|
|
|
|
)
|
|
|
|
|
;; The last one?
|
|
|
|
|
(when (> (length prefix) 1)
|
|
|
|
|
(let ((toc (srecode-template-find-templates-of-context
|
|
|
|
|
(read (semantic-tag-name prefix-context))))
|
|
|
|
|
)
|
|
|
|
|
(setq prefix-function
|
|
|
|
|
(or (semantic-find-first-tag-by-name
|
|
|
|
|
(car (last prefix)) toc)
|
|
|
|
|
;; Not in this buffer? Search the master
|
|
|
|
|
;; templates list.
|
|
|
|
|
nil))
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(setq prefixsym
|
|
|
|
|
(cond ((= (length prefix) 3)
|
|
|
|
|
(list (or prefix-var (nth 0 prefix))
|
|
|
|
|
(or prefix-context (nth 1 prefix))
|
|
|
|
|
(or prefix-function (nth 2 prefix))))
|
|
|
|
|
((= (length prefix) 2)
|
|
|
|
|
(list (or prefix-var (nth 0 prefix))
|
|
|
|
|
(or prefix-function (nth 1 prefix))))
|
|
|
|
|
((= (length prefix) 1)
|
|
|
|
|
(list (or prefix-var (nth 0 prefix)))
|
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
(setq context-return
|
|
|
|
|
(semantic-analyze-context-functionarg
|
|
|
|
|
:buffer (current-buffer)
|
|
|
|
|
:scope scope
|
|
|
|
|
:bounds bounds
|
|
|
|
|
:prefix (or prefixsym
|
|
|
|
|
prefix)
|
|
|
|
|
:prefixtypes nil
|
|
|
|
|
:prefixclass prefixclass
|
|
|
|
|
:errors nil
|
|
|
|
|
;; Use the functionarg analyzer class so we
|
|
|
|
|
;; can save the current key, and the index
|
|
|
|
|
;; into the macro part we are completing on.
|
|
|
|
|
:function (list key)
|
|
|
|
|
:index (length prefix)
|
|
|
|
|
:argument (list argtype)
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
context-return)))
|
|
|
|
|
|
|
|
|
|
(define-mode-local-override semantic-analyze-possible-completions
|
2021-03-05 21:00:00 -05:00
|
|
|
|
srecode-template-mode (context &rest _flags)
|
2009-09-20 21:06:41 +00:00
|
|
|
|
"Return a list of possible completions based on NONTEXT."
|
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
* cedet/semantic/symref/list.el (semantic-symref-rb-toggle-expand-tag):
* cedet/semantic/symref/grep.el (semantic-symref-perform-search):
* cedet/semantic/bovine/gcc.el (semantic-gcc-query):
* cedet/semantic/bovine/c.el (semantic-c-parse-lexical-token):
* cedet/semantic/analyze/debug.el (semantic-analyzer-debug-add-buttons)
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype)
(semantic-analyzer-debug-insert-include-summary):
* cedet/semantic/util.el (semantic-file-tag-table):
(semantic-describe-buffer-var-helper, semantic-something-to-tag-table)
(semantic-recursive-find-nonterminal-by-name):
* cedet/semantic/tag-ls.el (semantic-tag-calculate-parent-default):
* cedet/semantic/tag-file.el (semantic-prototype-file):
* cedet/semantic/symref.el (semantic-symref-parse-tool-output):
* cedet/semantic/sb.el (semantic-sb-fetch-tag-table):
* cedet/semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
* cedet/semantic/idle.el (semantic-idle-work-for-one-buffer):
(semantic-idle-summary-maybe-highlight):
* cedet/semantic/ia-sb.el (semantic-ia-speedbar)
(semantic-ia-sb-tag-info):
* cedet/semantic/grammar.el (semantic-analyze-possible-completions):
* cedet/semantic/find.el (semantic-brute-find-tag-by-position):
* cedet/semantic/ede-grammar.el (project-compile-target):
(ede-proj-makefile-insert-variables):
* cedet/semantic/debug.el (semantic-debug-set-parser-location):
(semantic-debug-set-source-location, semantic-debug-interface-layout)
(semantic-debug-mode, semantic-debug):
* cedet/semantic/db.el (semanticdb-needs-refresh-p):
* cedet/semantic/db-typecache.el (semanticdb-typecache-refresh-for-buffer):
* cedet/semantic/db-javascript.el (semanticdb-equivalent-mode):
* cedet/semantic/db-find.el (semanticdb-find-log-new-search)
(semanticdb-find-translate-path-includes--internal)
(semanticdb-reset-log, semanticdb-find-log-activity):
* cedet/semantic/db-file.el (object-write):
* cedet/semantic/db-el.el (semanticdb-equivalent-mode):
* cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-C-file-p)
(semanticdb-create-ebrowse-database):
* cedet/semantic/db-debug.el (semanticdb-table-sanity-check):
* cedet/semantic/complete.el (semantic-displayor-focus-request)
(semantic-collector-calculate-completions-raw)
(semantic-complete-read-tag-analyzer):
* cedet/semantic/analyze.el (semantic-analyze-pulse):
* cedet/ede/util.el (ede-update-version-in-source):
* cedet/ede/proj.el (project-delete-target):
* cedet/ede/proj-elisp.el (ede-update-version-in-source)
(ede-proj-flush-autoconf):
* cedet/ede/pconf.el (ede-proj-configure-synchronize)
(ede-proj-configure-synchronize):
* cedet/ede/locate.el (ede-locate-file-in-project-impl):
* cedet/ede/linux.el (ede-linux-version):
* cedet/ede/emacs.el (ede-emacs-version):
* cedet/ede/dired.el (ede-dired-add-to-target):
* cedet/ede.el (ede-buffer-header-file, ede-find-target)
(ede-buffer-documentation-files, ede-project-buffers, ede-set)
(ede-target-buffers, ede-buffers, ede-make-project-local-variable):
* cedet/cedet-idutils.el (cedet-idutils-fnid-call):
(cedet-idutils-lid-call, cedet-idutils-expand-filename)
(cedet-idutils-version-check):
* cedet/cedet-global.el (cedet-gnu-global-call):
(cedet-gnu-global-expand-filename, cedet-gnu-global-root)
(cedet-gnu-global-version-check, cedet-gnu-global-scan-hits):
* cedet/cedet-cscope.el (cedet-cscope-call)
(cedet-cscope-expand-filename, cedet-cscope-version-check):
Use with-current-buffer.
* cedet/ede.el (ede-make-project-local-variable)
(ede-set-project-variables, ede-set): Use dolist.
2009-10-30 02:16:41 +00:00
|
|
|
|
(with-current-buffer (oref context buffer)
|
2019-06-13 18:01:42 +02:00
|
|
|
|
(let* ((prefix (car (last (oref context prefix))))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(prefixstr (cond ((stringp prefix)
|
|
|
|
|
prefix)
|
|
|
|
|
((semantic-tag-p prefix)
|
|
|
|
|
(semantic-tag-name prefix))))
|
|
|
|
|
; (completetext (cond ((semantic-tag-p prefix)
|
|
|
|
|
; (semantic-tag-name prefix))
|
|
|
|
|
; ((stringp prefix)
|
|
|
|
|
; prefix)
|
|
|
|
|
; ((stringp (car prefix))
|
|
|
|
|
; (car prefix))))
|
2019-06-13 18:01:42 +02:00
|
|
|
|
(argtype (car (oref context argument)))
|
2009-09-20 21:06:41 +00:00
|
|
|
|
(matches nil))
|
|
|
|
|
|
|
|
|
|
;; Depending on what the analyzer is, we have different ways
|
|
|
|
|
;; of creating completions.
|
|
|
|
|
(cond ((eq argtype 'template)
|
|
|
|
|
(setq matches (semantic-find-tags-for-completion
|
|
|
|
|
prefixstr (current-buffer)))
|
|
|
|
|
(setq matches (semantic-find-tags-by-class
|
|
|
|
|
'function matches))
|
|
|
|
|
)
|
|
|
|
|
((eq argtype 'elispfcn)
|
|
|
|
|
(with-mode-local emacs-lisp-mode
|
|
|
|
|
(setq matches (semanticdb-find-tags-for-completion
|
|
|
|
|
prefixstr))
|
|
|
|
|
(setq matches (semantic-find-tags-by-class
|
|
|
|
|
'function matches))
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
((eq argtype 'macro)
|
|
|
|
|
(let ((scope (oref context scope)))
|
|
|
|
|
(setq matches
|
|
|
|
|
(semantic-find-tags-for-completion
|
|
|
|
|
prefixstr (oref scope fullscope))))
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
matches)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Utils
|
|
|
|
|
;;
|
|
|
|
|
(defun srecode-template-get-mode ()
|
|
|
|
|
"Get the supported major mode for this template file."
|
|
|
|
|
(let ((m (semantic-find-first-tag-by-name "mode" (current-buffer))))
|
|
|
|
|
(when m (read (semantic-tag-variable-default m)))))
|
|
|
|
|
|
|
|
|
|
(defun srecode-template-get-escape-start ()
|
|
|
|
|
"Get the current escape_start characters."
|
|
|
|
|
(let ((es (semantic-find-first-tag-by-name "escape_start" (current-buffer)))
|
|
|
|
|
)
|
|
|
|
|
(if es (car (semantic-tag-get-attribute es :default-value))
|
|
|
|
|
"{{")))
|
|
|
|
|
|
|
|
|
|
(defun srecode-template-get-escape-end ()
|
|
|
|
|
"Get the current escape_end characters."
|
|
|
|
|
(let ((ee (semantic-find-first-tag-by-name "escape_end" (current-buffer)))
|
|
|
|
|
)
|
|
|
|
|
(if ee (car (semantic-tag-get-attribute ee :default-value))
|
|
|
|
|
"}}")))
|
|
|
|
|
|
|
|
|
|
(defun srecode-template-current-context (&optional point)
|
|
|
|
|
"Calculate the context encompassing POINT."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(when point (goto-char (point)))
|
|
|
|
|
(let ((ct (semantic-current-tag)))
|
|
|
|
|
(when (not ct)
|
|
|
|
|
(setq ct (semantic-find-tag-by-overlay-prev)))
|
|
|
|
|
|
|
|
|
|
;; Loop till we find the context.
|
|
|
|
|
(while (and ct (not (semantic-tag-of-class-p ct 'context)))
|
|
|
|
|
(setq ct (semantic-find-tag-by-overlay-prev
|
|
|
|
|
(semantic-tag-start ct))))
|
|
|
|
|
|
|
|
|
|
(if ct
|
|
|
|
|
(read (semantic-tag-name ct))
|
|
|
|
|
'declaration))))
|
|
|
|
|
|
|
|
|
|
(defun srecode-template-find-templates-of-context (context &optional buffer)
|
|
|
|
|
"Find all the templates belonging to a particular CONTEXT.
|
|
|
|
|
When optional BUFFER is provided, search that buffer."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(when buffer (set-buffer buffer))
|
|
|
|
|
(let ((tags (semantic-fetch-available-tags))
|
|
|
|
|
(cc 'declaration)
|
|
|
|
|
(scan nil)
|
|
|
|
|
(ans nil))
|
|
|
|
|
|
|
|
|
|
(when (eq cc context)
|
|
|
|
|
(setq scan t))
|
|
|
|
|
|
|
|
|
|
(dolist (T tags)
|
|
|
|
|
;; Handle contexts
|
|
|
|
|
(when (semantic-tag-of-class-p T 'context)
|
|
|
|
|
(setq cc (read (semantic-tag-name T)))
|
|
|
|
|
(when (eq cc context)
|
|
|
|
|
(setq scan t)))
|
|
|
|
|
|
|
|
|
|
;; Scan
|
|
|
|
|
(when (and scan (semantic-tag-of-class-p T 'function))
|
|
|
|
|
(setq ans (cons T ans)))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(nreverse ans))))
|
|
|
|
|
|
|
|
|
|
(provide 'srecode/srt-mode)
|
|
|
|
|
|
|
|
|
|
;; The autoloads in this file must go into the global loaddefs.el, not
|
|
|
|
|
;; the srecode one, so that srecode-template-mode can be called from
|
|
|
|
|
;; auto-mode-alist.
|
|
|
|
|
|
|
|
|
|
;; Local variables:
|
|
|
|
|
;; generated-autoload-load-name: "srecode/srt-mode"
|
|
|
|
|
;; End:
|
|
|
|
|
|
|
|
|
|
;;; srecode/srt-mode.el ends here
|