]> code.delx.au - gnu-emacs-elpa/commitdiff
swiper.el: Modify the behavior with org-mode and visual-line-mode
authorOleh Krehel <ohwoeowho@gmail.com>
Tue, 17 Nov 2015 07:27:39 +0000 (08:27 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Tue, 17 Nov 2015 07:27:39 +0000 (08:27 +0100)
* 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

index 216a50a0e39a2995d4c3d568779a9394220b1763..f2fe31f04357ccb2603ac2f26c242f8eee5d4c25 100644 (file)
--- a/swiper.el
+++ b/swiper.el
 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)))