diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-15 00:48:12 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-15 00:48:12 +0000 |
commit | 615c3404c0aea4db77c6e417a9a9febdf784f245 (patch) | |
tree | 25c3470574118980e6782e982389ce1fd65fa668 /sx-question-mode.el | |
parent | 64f6115be1a1ca9ae9401af7e68d7f7563fbfb16 (diff) |
n and p skip invisible sections
Diffstat (limited to 'sx-question-mode.el')
-rw-r--r-- | sx-question-mode.el | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el index 8e5d380..5afb2e8 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -459,16 +459,18 @@ If nil, no recentering is performed." "Move down to next section (question or answer) of this buffer. Prefix argument N moves N sections down or up." (interactive "p") - (or n (setq n 1)) - (dotimes (_ (abs n)) - ;; This will either move us to the next section, or move out of - ;; the current one. - (unless (sx-question-mode--goto-propety-change - 'sx-question-mode--section n) - ;; If all we did was move out the current one, then move again - ;; and we're guaranteed to reach the next section. - (sx-question-mode--goto-propety-change - 'sx-question-mode--section n))) + (let ((count (if n (abs n) 1))) + (while (> count 0) + ;; This will either move us to the next section, or move out of + ;; the current one. + (unless (sx-question-mode--goto-propety-change 'section n) + ;; If all we did was move out the current one, then move again + ;; and we're guaranteed to reach the next section. + (sx-question-mode--goto-propety-change 'section n)) + (let ((ov (car-safe (sx-question-mode--section-overlays-at (point))))) + (unless (and (overlayp ov) + (overlay-get ov 'invisible)) + (cl-decf count))))) (when sx-question-mode-recenter-line (let ((ov (car-safe (sx-question-mode--section-overlays-at (line-end-position))))) (when (and (overlayp ov) (> (overlay-end ov) (window-end))) |