matlab-semantic.el:
New fcns needed by matlab-shell.el (matlab-semantic-get-local-functions-for-script): New. Returns fcns from a buffer. Works if semantic isn't enabled. (matlab-semantic-tag-text): get text part of input TAG. (semantic-default-matlab-setup): Add 'type tag class to list of misc things, since we support them now. matlab-shell.el: (matlab-shell-extract-region-to-tmp-file): Use new fcns above. Fix compiler warnings.
This commit is contained in:
parent
78c412586b
commit
36c17d9e57
|
@ -1809,6 +1809,9 @@ When NOSHOW is non-nil, supress output by adding ; to commands."
|
|||
(setq str (concat str "\n")))
|
||||
str))
|
||||
|
||||
(declare-function matlab-semantic-get-local-functions-for-script "semantic-matlab")
|
||||
(declare-function matlab-semantic-tag-text "semantic-matlab")
|
||||
(declare-function semantic-tag-name "semantic/tag")
|
||||
|
||||
(defun matlab-shell-extract-region-to-tmp-file (beg end &optional noshow)
|
||||
"Extract region between BEG & END into a temporary M file.
|
||||
|
@ -1819,6 +1822,7 @@ Scan the extracted region for any functions that are in the original
|
|||
buffer,and include them.
|
||||
Return the name of the temporary file."
|
||||
(interactive "r")
|
||||
(require 'semantic-matlab)
|
||||
(let* ((start (count-lines (point-min) beg))
|
||||
(len (count-lines beg end))
|
||||
(stem (file-name-sans-extension (file-name-nondirectory
|
||||
|
@ -1830,18 +1834,14 @@ Return the name of the temporary file."
|
|||
(buff (find-file-noselect (concat newf ".m")))
|
||||
(intro "%% Automatically craeted temporary file created to run-region")
|
||||
;; These variables are for script / fcn tracking
|
||||
(functions
|
||||
(save-excursion
|
||||
(semantic-refresh-tags-safe)
|
||||
(semantic-find-tags-by-class 'function (current-buffer))))
|
||||
(functions (matlab-semantic-get-local-functions-for-script (current-buffer)))
|
||||
)
|
||||
|
||||
;; TODO : if the directory in which the current buffer is in is READ ONLY
|
||||
;; we should write our tmp buffer to /tmp instead.
|
||||
|
||||
(save-excursion
|
||||
|
||||
(set-buffer buff)
|
||||
(with-current-buffer buff
|
||||
|
||||
(goto-char (point-min))
|
||||
|
||||
;; Clean up old extracted regions.
|
||||
|
@ -1859,9 +1859,7 @@ Return the name of the temporary file."
|
|||
(save-excursion
|
||||
(when (re-search-forward (semantic-tag-name F) nil t)
|
||||
;; Found, copy it in.
|
||||
(let ((ft (with-current-buffer orig
|
||||
(buffer-substring-no-properties (semantic-tag-start F)
|
||||
(semantic-tag-end F)))))
|
||||
(let ((ft (matlab-semantic-tag-text F orig)))
|
||||
(goto-char (point-max))
|
||||
(insert "% Copy of " (semantic-tag-name F) "\n\n")
|
||||
(insert ft)
|
||||
|
|
|
@ -44,9 +44,42 @@
|
|||
(require 'matlab-shell)
|
||||
(require 'semanticdb-matlab)
|
||||
|
||||
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; Utilities
|
||||
;;
|
||||
;; These functions wrap behavior provided by semantic for use in parts of matlab mode
|
||||
;; that need them. Take care of users who don't have cedet/semantic enabled by default.
|
||||
|
||||
(defun matlab-semantic-get-local-functions-for-script (&optional buffer)
|
||||
"Return the list of functions (as semantic tags) for BuFFER.
|
||||
If semantic-mode is not enabled, do something hacky to make it work."
|
||||
(save-excursion
|
||||
(when buffer (set-buffer buffer))
|
||||
|
||||
(let ((tags (save-excursion
|
||||
(semantic-refresh-tags-safe)
|
||||
(semantic-find-tags-by-class 'function (current-buffer)))))
|
||||
(when (and (not tags) (not semantic-mode))
|
||||
;; We got no tags, and semantic isn't enabled.
|
||||
;; Lets fake it.
|
||||
|
||||
;; call the parse region function. It won't be cached, so we have to do the work every
|
||||
;; time, but hopefully it is fast enough for matlab-shell and cell scripts.
|
||||
(setq tags (semantic-matlab-parse-region))
|
||||
|
||||
)
|
||||
tags)))
|
||||
|
||||
(defun matlab-semantic-tag-text (tag buffer)
|
||||
"Return the text string for TAG."
|
||||
(with-current-buffer buffer
|
||||
(buffer-substring-no-properties (semantic-tag-start tag)
|
||||
(semantic-tag-end tag))))
|
||||
|
||||
;;; Configuration
|
||||
;;
|
||||
|
||||
(defvar semantic-matlab-system-paths-include '("toolbox/matlab/funfun" "toolbox/matlab/general")
|
||||
"List of include paths under `semantic-matlab-root-directory'.
|
||||
These paths will be parsed recursively by semantic. Class and
|
||||
|
@ -823,12 +856,13 @@ This will include a list of type/field names when applicable."
|
|||
;; semantic-command-separation-character "."
|
||||
semantic-type-relation-separator-character '(".")
|
||||
semantic-symbol->name-assoc-list '((function . "Function")
|
||||
(type . "Class")
|
||||
)
|
||||
semantic-imenu-expandable-tag-classes '(function)
|
||||
semantic-imenu-expandable-tag-classes '(function type)
|
||||
semantic-imenu-bucketize-file nil
|
||||
semantic-imenu-bucketize-type-members nil
|
||||
senator-step-at-start-end-tag-classes '(function)
|
||||
semantic-stickyfunc-sticky-classes '(function)
|
||||
semantic-stickyfunc-sticky-classes '(function type)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue