summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2014-11-09 09:50:22 -0700
committerCraig Earls <enderw88@gmail.com>2014-11-09 09:50:22 -0700
commit2ef1c092100d53ad2882a59b9668cd183226c28f (patch)
treeecfb9c800c529720d03af7d3cf1c1234acf9f122 /lisp
parent8a87fd1310c69133506d4e428abd02de07d29ac9 (diff)
downloadfork-ledger-2ef1c092100d53ad2882a59b9668cd183226c28f.tar.gz
fork-ledger-2ef1c092100d53ad2882a59b9668cd183226c28f.tar.bz2
fork-ledger-2ef1c092100d53ad2882a59b9668cd183226c28f.zip
Handle block comments as blocks rather than individual lines.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ledger-navigate.el54
1 files changed, 50 insertions, 4 deletions
diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index 5c89480a..5bc18373 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -95,10 +95,56 @@ Requires empty line separating xacts."
(defun ledger-navigate-find-directive-extents (pos)
(goto-char pos)
- (list (progn (beginning-of-line)
- (point))
- (progn (end-of-line)
- (point))))
+ (let ((begin (progn (beginning-of-line)
+ (point)))
+ (end (progn (end-of-line)
+ (point))))
+ ;; handle block comments here
+ (beginning-of-line)
+ (if (looking-at " *;")
+ (progn
+ (while (and (looking-at " *;")
+ (> (point) (point-min)))
+ (forward-line -1))
+ ;; We are either at the beginning of the buffer, or we found
+ ;; a line outside the comment. If we are not at the
+ ;; beginning of the buffer then we need to move forward a
+ ;; line.
+ (if (> (point) (point-min))
+ (progn (forward-line 1)
+ (beginning-of-line)))
+ (setq begin (point))
+ (goto-char pos)
+ (beginning-of-line)
+ (while (and (looking-at " *;")
+ (< (point) (point-max)))
+ (forward-line 1))
+ (setq end (point))))
+ (list begin end)))
+
+(defun ledger-navigate-block-comment (pos)
+ (interactive "d")
+ (goto-char pos)
+ (let ((begin (progn (beginning-of-line)
+ (point)))
+ (end (progn (end-of-line)
+ (point))))
+ ;; handle block comments here
+ (beginning-of-line)
+ (if (looking-at " *;")
+ (progn
+ (while (and (looking-at " *;")
+ (> (point) (point-min)))
+ (forward-line -1))
+ (setq begin (point))
+ (goto-char pos)
+ (beginning-of-line)
+ (while (and (looking-at " *;")
+ (< (point) (point-max)))
+ (forward-line 1))
+ (setq end (point))))
+ (list begin end)))
+
(defun ledger-navigate-find-element-extents (pos)
"return list containing beginning and end of the entity surrounding point"