Function: srecode-parse-this-macro
srecode-parse-this-macro is a byte-compiled function defined in
srt-mode.el.gz.
Signature
(srecode-parse-this-macro &optional POINT)
Documentation
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.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/srecode/srt-mode.el.gz
(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)
;; (raw nil)
)
(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
;; means we are not inside the macro. Return nil.
nil
;; We are inside the macro, extract the text so far.
(let* ((macroend (match-beginning 0))
(raw (buffer-substring-no-properties
macrostart macroend))
(STATE (srecode-compile-state))
(inserter (condition-case nil
(srecode-compile-parse-inserter
raw STATE)
(error nil)))
)
(when inserter
(let ((base
(cons (oref inserter object-name)
(if (and (slot-boundp inserter :secondname)
(oref inserter secondname))
(split-string (oref inserter secondname)
":")
nil)))
(key (when (slot-exists-p inserter 'key)
(oref inserter key))))
(cond ((null key)
;; A plain variable
(cons nil base))
(t
;; A complex variable thingy.
(cons (format "%c" key)
base)))))
)
)))
))