📄 matlab_el.htm
字号:
"Pointer" "PointerShapeCData" "PointerShapeHotSpot" "Position"
"Renderer" "RendererMode" "Resize" "ResizeFcn" "SelectionType"
"ShareColors" "Units" "WindowButtonDownFcn"
"WindowButtonMotionFcn" "WindowButtonUpFcn" "WindowStyle"))
("image" . ("CData" "CDataMapping" "EraseMode" "XData" "YData"))
("light" . ("Position" "Color" "Style"))
("line" .
("Color" "EraseMode" "LineStyle" "LineWidth" "Marker"
"MarkerSize" "MarkerEdgeColor" "MarkerFaceColor" "XData" "YData"
"ZData"))
("patch" .
("CData" "CDataMapping" "FaceVertexCData" "EdgeColor" "EraseMode"
"FaceColor" "Faces" "LineStyle" "LineWidth" "Marker"
"MarkerEdgeColor" "MarkerFaceColor" "MarkerSize" "Vertices"
"XData" "YData" "ZData" "FaceLighting" "EdgeLighting"
"BackFaceLighting" "AmbientStrength" "DiffuseStrength"
"SpecularStrength" "SpecularExponent" "SpecularColorReflectance"
"VertexNormals" "NormalMode"))
("surface" .
("CData" "CDataMapping" "EdgeColor" "EraseMode" "FaceColor"
"LineStyle" "LineWidth" "Marker" "MarkerEdgeColor"
"MarkerFaceColor" "MarkerSize" "MeshStyle" "XData" "YData"
"ZData" "FaceLighting" "EdgeLighting" "BackFaceLighting"
"AmbientStrength" "DiffuseStrength" "SpecularStrength"
"SpecularExponent" "SpecularColorReflectance" "VertexNormals"
"NormalMode"))
("text\\|title\\|xlabel\\|ylabel\\|zlabel" .
("Color" "EraseMode" "Editing" "Extent" "FontAngle" "FontName"
"FontSize" "FontUnits" "FontWeight" "HorizontalAlignment"
"Position" "Rotation" "String" "Units" "Interpreter"
"VerticalAlignment"))
("uicontextmenu" . ("Callback"))
("uicontrol" .
("BackgroundColor" "Callback" "CData" "Enable" "Extent"
"FontAngle" "FontName" "FontSize" "FontUnits" "FontWeight"
"ForegroundColor" "HorizontalAlignment" "ListboxTop" "Max" "Min"
"Position" "String" "Style" "SliderStep" "TooltipString" "Units"
"Value"))
("uimenu" .
("Accelerator" "Callback" "Checked" "Enable" "ForegroundColor"
"Label" "Position" "Separator"))
;; Flesh this out more later.
("uipushtool\\|uitoggletool\\|uitoolbar" .
("Cdata" "Callback" "Separator" "Visible"))
)
"List of property lists on a per object type basis.")
(defvar matlab-unknown-type-commands
"[gs]et\\|findobj\\|waitfor"
"Expression for commands that have unknown types.")
(defun matlab-all-known-properties ()
"Return a list of all properties."
(let ((lst matlab-core-properties)
(tl matlab-property-lists))
(while tl
(setq lst (append lst (cdr (car tl)))
tl (cdr tl)))
(matlab-uniquafy-list lst)))
(defvar matlab-all-known-properties (matlab-all-known-properties)
"List of all the known properties.")
(defmacro matlab-property-function ()
"Regexp of all builtin functions that take property lists."
'(let ((r matlab-unknown-type-commands)
(tl matlab-property-lists))
(while tl
(setq r (concat r "\\|" (car (car tl)))
tl (cdr tl)))
r))
;;; Navigation ===============================================================
(defvar matlab-scan-on-screen-only nil
"When this is set to non-nil, then forward/backward sexp stops off screen.
This is so the block highlighter doesn't gobble up lots of time when
a block is not terminated.")
(defun matlab-backward-sexp (&optional autoend noerror)
"Go backwards one balanced set of MATLAB expressions.
If optional AUTOEND, then pretend we are at an end.
If optional NOERROR, then we return t on success, and nil on failure."
(interactive "P")
(matlab-navigation-syntax
(if (and (not autoend)
(save-excursion (backward-word 1)
(or (not
(and (looking-at
(matlab-block-end-no-function-re))
(matlab-valid-end-construct-p)))
(matlab-cursor-in-string-or-comment))))
;; Go backwards one simple expression
(forward-sexp -1)
;; otherwise go backwards recursively across balanced expressions
;; backup over our end
(if (not autoend) (forward-word -1))
(let ((done nil) (start (point)) (returnme t))
(while (and (not done)
(or (not matlab-scan-on-screen-only)
(pos-visible-in-window-p)))
(if (re-search-backward (matlab-block-scan-re) nil t)
(progn
(goto-char (match-beginning 2))
(if (looking-at (matlab-block-end-no-function-re))
(if (or (matlab-cursor-in-string-or-comment)
(not (matlab-valid-end-construct-p)))
nil
;; we must skip the expression and keep searching
(forward-word 1)
(matlab-backward-sexp))
(if (not (matlab-cursor-in-string-or-comment))
(setq done t))))
(goto-char start)
(if noerror
(setq returnme nil)
(error "Unstarted END construct"))))
returnme))))
(defun matlab-forward-sexp (&optional includeelse)
"Go forward one balanced set of MATLAB expressions.
Optional argument INCLUDEELSE will stop on ELSE if it matches the starting IF."
(interactive "P")
(matlab-navigation-syntax
;; skip over preceeding whitespace
(skip-chars-forward " \t\n;")
(if (or (not (looking-at (concat "\\("
(matlab-block-beg-pre)
"\\|"
(matlab-block-mid-re)
"\\)\\>")))
(matlab-cursor-in-string-or-comment))
;; Go forwards one simple expression
(forward-sexp 1)
;; otherwise go forwards recursively across balanced expressions
(forward-word 1)
(let ((done nil) (s nil)
(expr-scan (if includeelse
(matlab-block-re)
(matlab-block-scan-re)))
(expr-look (matlab-block-beg-pre)))
(while (and (not done)
(setq s (re-search-forward expr-scan nil t))
(or (not matlab-scan-on-screen-only)
(pos-visible-in-window-p)))
(goto-char (match-beginning 2))
(if (looking-at expr-look)
(if (matlab-cursor-in-string-or-comment)
(forward-word 1)
;; we must skip the expression and keep searching
;; NEVER EVER call with value of INCLUDEELSE
(matlab-forward-sexp))
(forward-word 1)
(if (and (not (matlab-cursor-in-string-or-comment))
(matlab-valid-end-construct-p))
(setq done t))))
(if (not s) (error "Unterminated block"))))))
(defun matlab-beginning-of-defun ()
"Go to the beginning of the current function."
(interactive)
(or (re-search-backward matlab-defun-regex nil t)
(goto-char (point-min))))
(defun matlab-end-of-defun ()
"Go to the end of the current function."
(interactive)
(or (progn
(if (looking-at matlab-defun-regex) (goto-char (match-end 0)))
(if (re-search-forward matlab-defun-regex nil t)
(progn (forward-line -1)
t)))
(goto-char (point-max))))
(defun matlab-current-defun ()
"Return the name of the current function."
(save-excursion
(matlab-beginning-of-defun)
(if (looking-at (matlab-match-function-re))
(progn
(goto-char (match-end 0))
(current-word)))))
(defun matlab-beginning-of-command ()
"Go to the beginning of an M command.
Travels across continuations."
(interactive)
(beginning-of-line)
(let ((p nil)
;; This restriction is a wild guess where to end reverse
;; searching for array continuations. The reason is that
;; matlab up list is very slow, and most people would never
;; put a blank line in a matrix. Either way, it's worth the
;; trade off to speed this up for large files.
;; This list of keywords is NOT meant to be comprehensive.
(r (save-excursion
(re-search-backward
"^\\s-*\\(%\\|if\\|else\\(if\\)\\|while\\|for\\|$\\)\\>"
nil t))))
(while (and (or (save-excursion (and (matlab-prev-line)
(matlab-lattr-cont)))
(matlab-ltype-continued-comm)
(setq p (matlab-lattr-array-cont r)))
(save-excursion (beginning-of-line) (not (bobp))))
(if p (goto-char p) (matlab-prev-line))
(setq p nil))
(back-to-indentation)))
(defun matlab-end-of-command (&optional beginning)
"Go to the end of an M command.
Optional BEGINNING is where the command starts from."
(interactive)
(while (and (or (matlab-lattr-cont)
(save-excursion
(forward-line 1)
(and (not (eobp))
(or (matlab-ltype-continued-comm)
(matlab-lattr-array-cont beginning)))))
;; This hack is a short circuit. If a user did not
;; correctly end a matrix, this will short-circuit
;; as soon as somethng that would never appear in a matrix
;; becomes visible.
(not (save-excursion
(beginning-of-line)
(looking-at (matlab-block-scan-re)))))
(forward-line 1))
(end-of-line))
;;; Line types and attributes =================================================
(defun matlab-ltype-empty () ; blank line
"Return t if current line is empty."
(save-excursion
(beginning-of-line)
(looking-at "^[ \t]*$")))
(defun matlab-ltype-comm () ; comment line
"Return t if current line is a MATLAB comment line."
(save-excursion
(beginning-of-line)
(looking-at "[ \t]*%.*$")))
(defun matlab-ltype-comm-ignore () ; comment out a region line
"Return t if current line is a MATLAB comment region line."
(save-excursion
(beginning-of-line)
(looking-at (concat "[ \t]*" matlab-comment-region-s))))
(defun matlab-ltype-help-comm ()
"Return t if the current line is part of the MATLAB help comment."
(save-excursion
(if (not (matlab-ltype-comm))
nil
(while (and (matlab-ltype-comm) (not (bobp))
(matlab-prev-line))
(beginning-of-line))
(matlab-ltype-function-definition))))
(defun matlab-ltype-endfunction-comm ()
"Return t if the current line is an ENDFUNCTION style comment."
(save-excursion
(if (not (matlab-ltype-comm))
nil
(beginning-of-line)
(if (looking-at "^[ \t]*%[ \t]*endfunction")
t
(while (and (or (matlab-ltype-comm)
(matlab-ltype-empty))
(not (eobp)))
(forward-line 1))
(matlab-ltype-function-definition)))))
(defun matlab-ltype-continued-comm ()
"Return column of previous line's comment start, or nil."
(save-excursion
(beginning-of-line)
(if (or (not (matlab-ltype-comm)) (bobp))
nil
;; We use forward-line and not matlab-prev-line because
;; we want blank lines to terminate this indentation method.
(forward-line -1)
(let ((col (matlab-lattr-comm)))
(if col
(progn
(goto-char col)
(current-column))
nil)))))
(defun matlab-ltype-function-definition ()
"Return t if the current line is a function definition."
(save-excursion
(beginning-of-line)
(looking-at matlab-defun-regex)))
(defun matlab-ltype-code () ; line of code
"Return t if current line is a MATLAB code line."
(and (not (matlab-ltype-empty)) (not (matlab-ltype-comm))))
(defun matlab-lattr-comm () ; line has comment
"Return t if current line contain a comment."
(save-excursion (matlab-comment-on-line)))
(defun matlab-lattr-implied-continuation ()
"Return non-nil if this line has implied continuation on the next.
This is only useful for new versions of MATLAB where ... is optional."
(when (not (matlab-lattr-comm))
(let ((imp nil))
(save-excursion
(end-of-line)
(skip-chars-backward " \t")
;; Test for oporator incompleteness.
(setq imp
(/= (point)
;; Careful, - means range in this expression.
(progn (skip-chars-backward "-+=/*.^&~<>")
(point))))
(if (not imp)
;; Test for argument list incompleteness
(condition-case nil
(progn
(end-of-line)
(matlab-up-list -1)
(setq imp (looking-at "(")))
(error nil)))
)
imp)))
(defun matlab-lattr-cont () ; line has continuation
"Retur
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -