branch: master
commit 85bd44bc99f35a053900468d52025b2d185afc91
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
swiper.el: Modify the behavior with org-mode and visual-line-mode
* swiper.el (swiper--candidates): Set `swiper-use-visual-line' even for
`org-mode'. In that case, reveal all text to prevent `line-move'
weirdness.
(swiper--ivy): Use `swiper-use-visual-line'.
Re #291
Re #227
---
swiper.el | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/swiper.el b/swiper.el
index 216a50a..f2fe31f 100644
--- a/swiper.el
+++ b/swiper.el
@@ -250,10 +250,14 @@
NUMBERS-WIDTH, when specified, is used for line numbers width
spec, instead of calculating it as the log of the buffer line
count."
- (setq swiper-use-visual-line
- (and (not (eq major-mode 'org-mode))
- visual-line-mode
- (< (buffer-size) 20000)))
+ (if (and visual-line-mode
+ ;; super-slow otherwise
+ (< (buffer-size) 20000))
+ (progn
+ (when (eq major-mode 'org-mode)
+ (outline-show-all))
+ (setq swiper-use-visual-line t))
+ (setq swiper-use-visual-line nil))
(let ((n-lines (count-lines (point-min) (point-max))))
(unless (zerop n-lines)
(setq swiper--width (or numbers-width
@@ -341,7 +345,7 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
(plist-get (text-properties-at (point)) 'face))
(let ((candidates (swiper--candidates))
(preselect
- (if (bound-and-true-p visual-line-mode)
+ (if swiper-use-visual-line
(count-screen-lines
(point-min)
(save-excursion (beginning-of-visual-line) (point)))