;; Author: Oleh Krehel <ohwoeowho@gmail.com>
;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.6.0
+;; Version: 0.7.0
;; Package-Requires: ((emacs "24.1"))
;; Keywords: matching
(let* ((enable-recursive-minibuffers t)
(from (ivy--regex ivy-text))
(to (query-replace-read-to from "Query replace" t)))
- (delete-minibuffer-contents)
- (ivy-set-action (lambda (_)
- (with-ivy-window
- (move-beginning-of-line 1)
- (perform-replace from to
- t t nil))))
(swiper--cleanup)
- (exit-minibuffer))))
+ (ivy-exit-with-action
+ (lambda (_)
+ (with-ivy-window
+ (move-beginning-of-line 1)
+ (perform-replace from to
+ t t nil)))))))
(defvar avy-background)
(defvar avy-all-windows)
(error "multiple-cursors isn't installed"))
(let ((cands (nreverse ivy--old-cands)))
(unless (string= ivy-text "")
- (ivy-set-action
+ (ivy-exit-with-action
(lambda (_)
(let (cand)
(while (setq cand (pop cands))
(swiper--action cand)
(when cands
(mc/create-fake-cursor-at-point))))
- (multiple-cursors-mode 1)))
- (setq ivy-exit 'done)
- (exit-minibuffer))))
+ (multiple-cursors-mode 1))))))
(defun swiper-recenter-top-bottom (&optional arg)
"Call (`recenter-top-bottom' ARG)."
occur-edit-mode
bongo-mode
eww-mode
+ twittering-mode
+ vc-dir-mode
w3m-mode)))
(unless (> (buffer-size) 100000)
(if (fboundp 'font-lock-ensure)
(defvar swiper-use-visual-line nil
"When non-nil, use `line-move' instead of `forward-line'.")
+(declare-function outline-show-all "outline")
+
(defun swiper--candidates (&optional numbers-width)
"Return a list of this buffer lines.
(< (buffer-size) 20000))
(progn
(when (eq major-mode 'org-mode)
- (outline-show-all))
+ (require 'outline)
+ (if (fboundp 'outline-show-all)
+ (outline-show-all)
+ (with-no-warnings
+ (show-all))))
(setq swiper-use-visual-line t))
(setq swiper-use-visual-line nil))
(let ((n-lines (count-lines (point-min) (point-max))))
" "
(replace-regexp-in-string
"\t" " "
- (buffer-substring
- (point)
- (if swiper-use-visual-line
+ (if swiper-use-visual-line
+ (buffer-substring
(save-excursion
- (end-of-visual-line)
+ (beginning-of-visual-line)
(point))
+ (save-excursion
+ (end-of-visual-line)
+ (point)))
+ (buffer-substring
+ (point)
(line-end-position)))))))
+ (when (eq major-mode 'twittering-mode)
+ (remove-text-properties 0 (length str) '(field) str))
(put-text-property 0 1 'display
(format swiper--format-spec
(cl-incf line-number))
(point-min)
(save-excursion (beginning-of-visual-line) (point)))
(1- (line-number-at-pos))))
- (minibuffer-allow-text-properties t))
+ (minibuffer-allow-text-properties t)
+ res)
(unwind-protect
- (ivy-read
- "Swiper: "
- candidates
- :initial-input initial-input
- :keymap swiper-map
- :preselect preselect
- :require-match t
- :update-fn #'swiper--update-input-ivy
- :unwind #'swiper--cleanup
- :action #'swiper--action
- :re-builder #'swiper--re-builder
- :history 'swiper-history
- :caller 'swiper)
- (when (null ivy-exit)
+ (setq res
+ (ivy-read
+ "Swiper: "
+ candidates
+ :initial-input initial-input
+ :keymap swiper-map
+ :preselect preselect
+ :require-match t
+ :update-fn #'swiper--update-input-ivy
+ :unwind #'swiper--cleanup
+ :action #'swiper--action
+ :re-builder #'swiper--re-builder
+ :history 'swiper-history
+ :caller 'swiper))
+ (unless res
(goto-char swiper--opoint)))))
(defun swiper-toggle-face-matching ()
(num (if (string-match "^[0-9]+" str)
(string-to-number (match-string 0 str))
0)))
- (goto-char (point-min))
- (when (cl-plusp num)
+ (unless (eq this-command 'ivy-yank-word)
(goto-char (point-min))
- (if swiper-use-visual-line
- (line-move (1- num))
- (forward-line (1- num)))
- (if (and (equal ivy-text "")
- (>= swiper--opoint (line-beginning-position))
- (<= swiper--opoint (line-end-position)))
- (goto-char swiper--opoint)
- (re-search-forward re (line-end-position) t))
- (isearch-range-invisible (line-beginning-position)
- (line-end-position))
- (unless (and (>= (point) (window-start))
- (<= (point) (window-end (ivy-state-window ivy-last) t)))
- (recenter)))
+ (when (cl-plusp num)
+ (goto-char (point-min))
+ (if swiper-use-visual-line
+ (line-move (1- num))
+ (forward-line (1- num)))
+ (if (and (equal ivy-text "")
+ (>= swiper--opoint (line-beginning-position))
+ (<= swiper--opoint (line-end-position)))
+ (goto-char swiper--opoint)
+ (re-search-forward re (line-end-position) t))
+ (isearch-range-invisible (line-beginning-position)
+ (line-end-position))
+ (unless (and (>= (point) (window-start))
+ (<= (point) (window-end (ivy-state-window ivy-last) t)))
+ (recenter))))
(swiper--add-overlays re)))))
(defun swiper--add-overlays (re &optional beg end wnd)
(swiper--ensure-visible)
(when (/= (point) swiper--opoint)
(unless (and transient-mark-mode mark-active)
- (push-mark swiper--opoint t)
- (message "Mark saved where search started"))))))
+ (when (eq ivy-exit 'done)
+ (push-mark swiper--opoint t)
+ (message "Mark saved where search started")))))))
;; (define-key isearch-mode-map (kbd "C-o") 'swiper-from-isearch)
(defun swiper-from-isearch ()