summaryrefslogtreecommitdiff
path: root/lisp/km-diff.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-08-02 21:29:56 -0400
committerKyle Meyer <kyle@kyleam.com>2017-08-02 21:34:29 -0400
commit3874dace6e37a7d9a86113352e4a4cd05e05106b (patch)
tree43382279af5b2dc7c034803d79675732b1f36734 /lisp/km-diff.el
parentecb163e4d42a524ac70b7de9f0df8ce86c01ae69 (diff)
downloademacs.d-3874dace6e37a7d9a86113352e4a4cd05e05106b.tar.gz
diff-review: Fix function for comment movement
Rework km/diff-review-next-comment's move procedure to avoid an error when the buffer doesn't contain any comments and to short-circuit the recursion when the search function fails. This also introduces a change in behavior when N exceeds the number of comment blocks before/after point: instead of always positioning point at the start of the block, point is positioned at the end of the block for forward movement and the start of the block for backward movement.
Diffstat (limited to 'lisp/km-diff.el')
-rw-r--r--lisp/km-diff.el17
1 files changed, 10 insertions, 7 deletions
diff --git a/lisp/km-diff.el b/lisp/km-diff.el
index 19afba9..73a2424 100644
--- a/lisp/km-diff.el
+++ b/lisp/km-diff.el
@@ -188,13 +188,16 @@ If N is negative, move backward instead."
(letrec ((move
(lambda (n)
(let ((bounds (km/diff-review--comment-bounds)))
- (when bounds
- (goto-char (funcall bound-fn bounds)))
- (funcall search-fn "^:" nil t)
- (if (= n 0)
- (goto-char (car bounds))
- (funcall move
- (funcall incr-func n)))))))
+ (cond ((and (= n 0) bounds)
+ (goto-char (car bounds)))
+ ((/= n 0)
+ (when bounds
+ (goto-char (funcall bound-fn bounds)))
+ (and (funcall search-fn "^:" nil t)
+ (funcall move
+ (funcall incr-func n))))
+ (t
+ (error "Error in movement logic")))))))
(funcall move n)))))
(defun km/diff-review-previous-comment (&optional n)