(user-error "Should only be called in the minibuffer through `swiper-map'")
(let* ((enable-recursive-minibuffers t)
(from (ivy--regex ivy-text))
- (to (query-replace-read-to from "Query replace" t)))
+ (to (minibuffer-with-setup-hook
+ (lambda ()
+ (setq minibuffer-default
+ (if (string-match "\\`\\\\_<\\(.*\\)\\\\_>\\'" ivy-text)
+ (match-string 1 ivy-text)
+ ivy-text)))
+ (read-from-minibuffer (format "Query replace %s with: " from)))))
(swiper--cleanup)
(ivy-exit-with-action
(lambda (_)
(declare-function mc/create-fake-cursor-at-point "ext:multiple-cursors-core")
(declare-function multiple-cursors-mode "ext:multiple-cursors-core")
-;;;###autoload
(defun swiper-mc ()
- (interactive)
(unless (require 'multiple-cursors nil t)
(error "multiple-cursors isn't installed"))
(let ((cands (nreverse ivy--old-cands)))
(buffer-substring
(point)
(line-end-position)))))))
- (when (eq major-mode 'twittering-mode)
- (remove-text-properties 0 (length str) '(field) str))
+ (remove-text-properties 0 (length str) '(field) str)
(put-text-property 0 1 'display
(format swiper--format-spec
(cl-incf line-number))
(declare-function string-trim-right "subr-x")
-(defun swiper-occur ()
- "Generate a custom occur buffer for `swiper'."
- (let* ((fname (propertize
+(defun swiper-occur (&optional revert)
+ "Generate a custom occur buffer for `swiper'.
+When REVERT is non-nil, regenerate the current *ivy-occur* buffer."
+ (let* ((buffer (ivy-state-buffer ivy-last))
+ (fname (propertize
(with-ivy-window
- (file-name-nondirectory
- (buffer-file-name
- (ivy-state-buffer ivy-last))))
+ (if (buffer-file-name buffer)
+ (file-name-nondirectory
+ (buffer-file-name buffer))
+ (buffer-name buffer)))
'face
'compilation-info))
(cands (mapcar
(get-text-property 0 'display s))
'face 'compilation-line-number)
(substring s 1)))
- ivy--old-cands)))
+ (if (null revert)
+ ivy--old-cands
+ (setq ivy--old-re nil)
+ (let ((ivy--regex-function 'swiper--re-builder))
+ (ivy--filter
+ (progn (string-match "\"\\(.*\\)\"" (buffer-name))
+ (match-string 1 (buffer-name)))
+ (with-current-buffer buffer
+ (swiper--candidates))))))))
(unless (eq major-mode 'ivy-occur-grep-mode)
(ivy-occur-grep-mode)
(font-lock-mode -1))
(ivy--occur-insert-lines
(mapcar
(lambda (cand) (concat "./" cand))
- cands))))
+ cands))
+ (goto-char (point-min))
+ (forward-line 4)))
(ivy-set-occur 'swiper 'swiper-occur)