Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed indent line and fixed docstring #7

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions d2-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@
;; By default `d2` will use `/tmp` to store tmp-files.
;; You can change that by setting the variable `d2-tmp-dir`.

;; This code was inspired by mermaid-mode @
;; This code was heavily inspired by mermaid-mode @
;; https://github.com/abrochard/mermaid-mode


;; STATE: Currently this is a work in progress
;;
;; Code
Expand Down Expand Up @@ -109,7 +108,7 @@
(defun org-babel-execute:d2 (body params)
"Execute command with BODY and PARAMS from src block."
(let* ((out-file (or (cdr (assoc :file params))
(error "Mermaid requires a \":file\" header argument")))
(error "d2 requires a \":file\" header argument")))
(temp-file (org-babel-temp-file "d2-"))
(cmd (concat (shell-quote-argument d2-location)
" -o " (org-babel-process-file-name out-file)
Expand All @@ -129,26 +128,7 @@ STR is the declaration."
(cons (- l (line-number-at-pos)) (current-indentation))
(cons -1 -1)))))

;; (defun d2-indent-line ()
;; "Indent the current line."
;; (interactive)
;; (save-excursion
;; (end-of-line)
;; (let ((graph (d2--locate-declaration "^graph\\|sequenceDiagram"))
;; (subgraph (d2--locate-declaration "subgraph \\|loop \\|alt \\|opt"))
;; (both (d2--locate-declaration "^graph \\|^sequenceDiagram$\\|subgraph \\|loop \\|alt \\|opt"))
;; (else (d2--locate-declaration "else "))
;; (end (d2--locate-declaration "^ *end *$")))
;; (indent-line-to
;; (cond ((equal (car graph) 0) 0) ;; this is a graph declaration
;; ((equal (car end) 0) (cdr subgraph)) ;; this is "end", indent to nearest subgraph
;; ((equal (car subgraph) 0) (+ 4 (cdr graph))) ;; this is a subgraph
;; ((equal (car else) 0) (cdr subgraph)) ;; this is "else:, indent to nearest alt
;; ;; everything else
;; ((< (car end) 0) (+ 4 (cdr both))) ;; no end in sight
;; ((< (car both) (car end)) (+ 4 (cdr both))) ;; (sub)graph declaration closer, +4
;; (t (cdr end)) ;; end declaration closer, same indent
;; )))))
;; TODO: Indent line code

(defun d2-compile ()
"Compile the current d2 file using d2."
Expand Down