Formatting
This commit is contained in:
130
krl-mode.el
130
krl-mode.el
@@ -97,12 +97,12 @@
|
||||
|
||||
(defconst krl-keywords
|
||||
(append
|
||||
(mapcar (lambda (x) (rstrip (nth 0 x))) krl-keywords-toplevel-block-pairs)
|
||||
(mapcar (lambda (x) (rstrip (nth 1 x))) krl-keywords-toplevel-block-pairs)
|
||||
(mapcar (lambda (x) (rstrip (nth 0 x))) krl-keywords-nested-block-pairs)
|
||||
(mapcar (lambda (x) (rstrip (nth 1 x))) krl-keywords-nested-block-pairs)
|
||||
(mapcar (lambda (x) (rstrip (nth 2 x))) krl-keywords-nested-block-middle)
|
||||
krl-keywords-misc
|
||||
(mapcar (lambda (x) (rstrip (nth 0 x))) krl-keywords-toplevel-block-pairs)
|
||||
(mapcar (lambda (x) (rstrip (nth 1 x))) krl-keywords-toplevel-block-pairs)
|
||||
(mapcar (lambda (x) (rstrip (nth 0 x))) krl-keywords-nested-block-pairs)
|
||||
(mapcar (lambda (x) (rstrip (nth 1 x))) krl-keywords-nested-block-pairs)
|
||||
(mapcar (lambda (x) (rstrip (nth 2 x))) krl-keywords-nested-block-middle)
|
||||
krl-keywords-misc
|
||||
))
|
||||
|
||||
(defconst krl-warning-keywords
|
||||
@@ -205,24 +205,24 @@
|
||||
;; Get the string pair for the block we are currently on the end of.
|
||||
(defun krl-get-pair ()
|
||||
(let ((pairs (copy-sequence krl-keywords-nested-block-pairs)) (pair nil))
|
||||
(while (and (not pair) pairs)
|
||||
(when (looking-at (concat "^ *" (nth 1 (car pairs))))
|
||||
(setq pair (car pairs)))
|
||||
(setq pairs (cdr pairs)))
|
||||
;; FIXME: Hack for broken ELSE, CASE.
|
||||
(when (not pair)
|
||||
(let ((triples (copy-sequence krl-keywords-nested-block-middle)))
|
||||
(while (and (not pair) triples)
|
||||
(when (looking-at (concat "^ *" (nth 2 (car triples))))
|
||||
(setq pair (car triples)))
|
||||
(setq triples (cdr triples))
|
||||
(while (and (not pair) pairs)
|
||||
(when (looking-at (concat "^ *" (nth 1 (car pairs))))
|
||||
(setq pair (car pairs)))
|
||||
(setq pairs (cdr pairs)))
|
||||
;; FIXME: Hack for broken ELSE, CASE.
|
||||
(when (not pair)
|
||||
(let ((triples (copy-sequence krl-keywords-nested-block-middle)))
|
||||
(while (and (not pair) triples)
|
||||
(when (looking-at (concat "^ *" (nth 2 (car triples))))
|
||||
(setq pair (car triples)))
|
||||
(setq triples (cdr triples))
|
||||
)))
|
||||
pair))
|
||||
pair))
|
||||
|
||||
(defun krl-indent-of-matching ()
|
||||
(save-excursion
|
||||
(let ((balance 1) (pair (krl-get-pair)))
|
||||
;(message (nth 0 pair))
|
||||
;(message (nth 0 pair))
|
||||
(while (and (/= balance 0) (not (bobp)))
|
||||
(progn
|
||||
(forward-line -1)
|
||||
@@ -265,19 +265,19 @@
|
||||
(forward-line -1)
|
||||
(cond
|
||||
((looking-at krl-indent-regex-toplevel-block-close)
|
||||
;(message "found tlb close")
|
||||
;(message "found tlb close")
|
||||
(setq ind 0))
|
||||
((looking-at krl-indent-regex-toplevel-block-open)
|
||||
;(message "found tlb open")
|
||||
;(message "found tlb open")
|
||||
(setq ind (+ krl-indent-offset (current-indentation))))
|
||||
((looking-at krl-indent-regex-nested-block-close)
|
||||
;(message "found nb close")
|
||||
;(message "found nb close")
|
||||
(setq ind (current-indentation)))
|
||||
((looking-at krl-indent-regex-nested-block-open)
|
||||
;(message "found nb open")
|
||||
;(message "found nb open")
|
||||
(setq ind (+ krl-indent-offset (current-indentation))))
|
||||
(t
|
||||
;(message "found other")
|
||||
;(message "found other")
|
||||
)
|
||||
))
|
||||
ind)))
|
||||
@@ -288,53 +288,53 @@
|
||||
(save-excursion
|
||||
(indent-line-to col))
|
||||
(when (< (current-column) col)
|
||||
(move-to-column col))))
|
||||
(move-to-column col))))
|
||||
|
||||
|
||||
(defun krl-indent-line ()
|
||||
"Indent current line as KRL."
|
||||
(interactive)
|
||||
(let ((ind nil))
|
||||
(save-excursion
|
||||
(progn
|
||||
(beginning-of-line)
|
||||
(if (bobp)
|
||||
(indent-line-to 0)
|
||||
(let (indent-curr)
|
||||
(progn
|
||||
(cond ((looking-at krl-indent-regex-toplevel-block-open)
|
||||
(progn
|
||||
;(message "toplevel open")
|
||||
(setq ind 0)))
|
||||
((looking-at krl-indent-regex-toplevel-block-close)
|
||||
(progn
|
||||
;(message "toplevel close")
|
||||
(setq ind 0)))
|
||||
((looking-at "^ *&")
|
||||
(progn
|
||||
;(message "&")
|
||||
;; HMI editor crud.
|
||||
(setq ind 0)))
|
||||
((looking-at krl-indent-regex-nested-block-close)
|
||||
(progn
|
||||
;(message "nested close")
|
||||
(setq ind (krl-indent-of-matching))))
|
||||
((looking-at krl-indent-regex-nested-block-middle)
|
||||
(progn
|
||||
;(message "annoying stuff")
|
||||
;; (indent-line-to (krl-indent-of-block-opener))))
|
||||
(setq ind (krl-indent-of-matching))))
|
||||
(t
|
||||
(progn
|
||||
;(message "other")
|
||||
;; ;(message krl-indent-regex-toplevel-block-open)
|
||||
;; (indent-line-to (krl-find-hinted-indent))))
|
||||
(let ((hinted-indent (krl-find-hinted-indent)))
|
||||
(when (not hinted-indent)
|
||||
(setq hinted-indent 0))
|
||||
(setq ind hinted-indent))))
|
||||
))))))
|
||||
(indent-and-position ind)))
|
||||
(save-excursion
|
||||
(progn
|
||||
(beginning-of-line)
|
||||
(if (bobp)
|
||||
(indent-line-to 0)
|
||||
(let (indent-curr)
|
||||
(progn
|
||||
(cond ((looking-at krl-indent-regex-toplevel-block-open)
|
||||
(progn
|
||||
;(message "toplevel open")
|
||||
(setq ind 0)))
|
||||
((looking-at krl-indent-regex-toplevel-block-close)
|
||||
(progn
|
||||
;(message "toplevel close")
|
||||
(setq ind 0)))
|
||||
((looking-at "^ *&")
|
||||
(progn
|
||||
;(message "&")
|
||||
;; HMI editor crud.
|
||||
(setq ind 0)))
|
||||
((looking-at krl-indent-regex-nested-block-close)
|
||||
(progn
|
||||
;(message "nested close")
|
||||
(setq ind (krl-indent-of-matching))))
|
||||
((looking-at krl-indent-regex-nested-block-middle)
|
||||
(progn
|
||||
;(message "annoying stuff")
|
||||
;; (indent-line-to (krl-indent-of-block-opener))))
|
||||
(setq ind (krl-indent-of-matching))))
|
||||
(t
|
||||
(progn
|
||||
;(message "other")
|
||||
;; ;(message krl-indent-regex-toplevel-block-open)
|
||||
;; (indent-line-to (krl-find-hinted-indent))))
|
||||
(let ((hinted-indent (krl-find-hinted-indent)))
|
||||
(when (not hinted-indent)
|
||||
(setq hinted-indent 0))
|
||||
(setq ind hinted-indent))))
|
||||
))))))
|
||||
(indent-and-position ind)))
|
||||
|
||||
|
||||
(defun krl-mode ()
|
||||
|
Reference in New Issue
Block a user