Skip to content

Commit

Permalink
Untabified, reorganized alphabetically: parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
Nidish96 authored and jcs090218 committed Dec 13, 2023
1 parent 44a237a commit dd36cd3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
22 changes: 11 additions & 11 deletions ts-fold-parsers.el
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@
"Rule set for LaTex."
'((generic_environment . ts-fold-range-latex-environment)
(math_environment . ts-fold-range-latex-environment)
(section . ts-fold-range-latex-section)
(subsection . ts-fold-range-latex-section)
(subsubsection . ts-fold-range-latex-section)
(curly_group . ts-fold-range-seq)
(section . ts-fold-range-latex-section)
(subsection . ts-fold-range-latex-section)
(subsubsection . ts-fold-range-latex-section)
(curly_group . ts-fold-range-seq)
(line_comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "%")))))
Expand Down Expand Up @@ -512,13 +512,13 @@
"Rule set for MATLAB."
'((expression_list . ts-fold-range-seq)
(function_definition . ts-fold-range-matlab-function)
(class_definition . ts-fold-range-matlab-function)
(if_statement . ts-fold-range-matlab-statements)
(for_statement . ts-fold-range-matlab-statements)
(while_statement . ts-fold-range-matlab-statements)
(switch_statement . ts-fold-range-matlab-statements)
(try_statement . ts-fold-range-matlab-statements)
(comment . ts-fold-range-matlab-blocks)))
(class_definition . ts-fold-range-matlab-function)
(if_statement . ts-fold-range-matlab-statements)
(for_statement . ts-fold-range-matlab-statements)
(while_statement . ts-fold-range-matlab-statements)
(switch_statement . ts-fold-range-matlab-statements)
(try_statement . ts-fold-range-matlab-statements)
(comment . ts-fold-range-matlab-blocks)))

(defun ts-fold-parsers-qss ()
"Rule set for QSS."
Expand Down
8 changes: 4 additions & 4 deletions ts-fold-summary.el
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ type of content by checking the word boundary's existence."
"Extract summary from DOC-STR in Python."
(ts-fold-summary--generic doc-str "\"\"\""))

(defun ts-fold-summary-matlab-doc (doc-str)
"Extract summary from MATLAB DOC-STR."
(ts-fold-summary--generic doc-str "%"))

(defun ts-fold-summary-rst-doc (doc-str)
"Extract summary from DOC-STR in reStructuredText."
(ts-fold-summary--generic doc-str ".."))
Expand Down Expand Up @@ -174,6 +170,10 @@ type of content by checking the word boundary's existence."
"Extract summary from DOC-STR in Markdown block."
(ts-fold-summary--doc-extract doc-str '("-" "```")))

(defun ts-fold-summary-matlab-doc (doc-str)
"Extract summary from MATLAB DOC-STR."
(ts-fold-summary--generic doc-str "%"))

(defun ts-fold-summary-mermaid (doc-str)
"Extract summary from DOC-STR in Mermaid comment."
(ts-fold-summary--generic doc-str '("%%")))
Expand Down
52 changes: 26 additions & 26 deletions ts-fold.el
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,22 @@ more information."
(end (tsc-node-end-position last-child)))
(ts-fold--cons-add (cons beg end) offset)))

(defun ts-fold-range-matlab-blocks (node offset)
"Define fold range for MATLAB blocks.
Each block is delimited by a line starting with '%%'.
For arguments NODE and OFFSET, see function `ts-fold-range-line-comment' for
more information."
(when (string-prefix-p "%%" (tsc-node-text node))
(let* ((beg (tsc-node-end-position node))
(end (or (save-excursion
(progn (goto-char beg)
(when (re-search-forward "^\s*\^L%%" nil t)
(forward-line -1) (end-of-line)
(point))))
(tsc-node-end-position (tsc-get-parent node)))))
(ts-fold--cons-add (cons beg end) offset))))

(defun ts-fold-range-matlab-function (node offset)
"Define fold range for MATLAB function definitions.
Expand Down Expand Up @@ -1009,22 +1025,6 @@ more information."
(end (tsc-node-start-position (car (ts-fold-find-children node "end")))))
(ts-fold--cons-add (cons beg end) offset)))

(defun ts-fold-range-matlab-blocks (node offset)
"Define fold range for MATLAB blocks.
Each block is delimited by a line starting with '%%'.
For arguments NODE and OFFSET, see function `ts-fold-range-line-comment' for
more information."
(when (string-prefix-p "%%" (tsc-node-text node))
(let* ((beg (tsc-node-end-position node))
(end (or (save-excursion
(progn (goto-char beg)
(when (re-search-forward "^\s*\^L%%" nil t)
(forward-line -1) (end-of-line)
(point))))
(tsc-node-end-position (tsc-get-parent node)))))
(ts-fold--cons-add (cons beg end) offset))))

(defun ts-fold-range-mermaid-diagram (node offset)
"Define fold range for any diagram in Mermaid.
Expand Down Expand Up @@ -1154,16 +1154,6 @@ more information."
(end (tsc-node-end-position node)))
(ts-fold--cons-add (cons (+ beg 3) (- end 3)) offset)))

(defun ts-fold-range-latex-section (node offset)
"Define fold range for latex section.
For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
more information."
(when-let* ((lab-node (car (ts-fold-find-children node "curly_group")))
(beg (tsc-node-end-position lab-node))
(end (tsc-node-end-position node)))
(ts-fold--cons-add (cons beg end) offset)))

(defun ts-fold-range-latex-environment (node offset)
"Define fold range for latex environments.
Expand All @@ -1175,6 +1165,16 @@ more information."
(end (tsc-node-start-position end-node)))
(ts-fold--cons-add (cons beg end) offset)))

(defun ts-fold-range-latex-section (node offset)
"Define fold range for latex section.
For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
more information."
(when-let* ((lab-node (car (ts-fold-find-children node "curly_group")))
(beg (tsc-node-end-position lab-node))
(end (tsc-node-end-position node)))
(ts-fold--cons-add (cons beg end) offset)))

(defun ts-fold-range-rst-body (node offset)
"Define fold range for `body' in reStructuredText.
Expand Down

0 comments on commit dd36cd3

Please sign in to comment.