[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 0c2da66 7/7: Merge commit 'ce516073e5e4359b88f98610bae9b15
From: |
Oleh Krehel |
Subject: |
[elpa] master 0c2da66 7/7: Merge commit 'ce516073e5e4359b88f98610bae9b157945eb8e8' from swiper |
Date: |
Thu, 26 Mar 2015 11:30:33 +0000 |
branch: master
commit 0c2da6600ad7913bfc0a329a3e13016dcd7360fa
Merge: 90473ac ce51607
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Merge commit 'ce516073e5e4359b88f98610bae9b157945eb8e8' from swiper
---
packages/swiper/counsel.el | 3 +-
packages/swiper/ivy.el | 60 ++++++++++++++++++++++++++-----------------
packages/swiper/swiper.el | 34 ++++++++++++++++++++++---
3 files changed, 68 insertions(+), 29 deletions(-)
diff --git a/packages/swiper/counsel.el b/packages/swiper/counsel.el
index 07d9a66..28d10bd 100644
--- a/packages/swiper/counsel.el
+++ b/packages/swiper/counsel.el
@@ -51,7 +51,8 @@
(cands (split-string
(shell-command-to-string
"git ls-files --full-name --")
- "\n"))
+ "\n"
+ t))
(file (ivy-read "Find file: " cands)))
(when file
(find-file file))))
diff --git a/packages/swiper/ivy.el b/packages/swiper/ivy.el
index 4d307f3..180f081 100644
--- a/packages/swiper/ivy.el
+++ b/packages/swiper/ivy.el
@@ -4,7 +4,7 @@
;; Author: Oleh Krehel <address@hidden>
;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.1.0
+;; Version: 0.2.0
;; Package-Requires: ((emacs "24.1"))
;; Keywords: matching
@@ -165,7 +165,8 @@ On error (read-only), quit without selecting."
(minibuffer-keyboard-quit))))
;;** Entry Point
-(defun ivy-read (prompt collection &optional initial-input update-fn preselect)
+(defun ivy-read (prompt collection
+ &optional initial-input keymap preselect update-fn)
"Read a string in the minibuffer, with completion.
PROMPT is a string to prompt with; normally it ends in a colon
@@ -179,7 +180,9 @@ If INITIAL-INPUT is non-nil, insert it in the minibuffer
initially.
UPDATE-FN is called each time the current candidate(s) is changed.
If PRESELECT is non-nil select the corresponding candidate out of
-the ones that match INITIAL-INPUT."
+the ones that match INITIAL-INPUT.
+
+KEYMAP is composed together with `ivy-minibuffer-map'."
(cl-case (length collection)
(0 nil)
(1 (car collection))
@@ -203,21 +206,28 @@ the ones that match INITIAL-INPUT."
(concat ivy-count-format prompt))
(t
nil)))
- (unwind-protect
- (minibuffer-with-setup-hook
- #'ivy--minibuffer-setup
- (let ((res (read-from-minibuffer
- prompt
- initial-input
- ivy-minibuffer-map
- nil
- 'ivy-history)))
- (when (eq ivy-exit 'done)
- (pop ivy-history)
- (setq ivy-history
- (cons ivy-text (delete ivy-text ivy-history)))
- res)))
- (remove-hook 'post-command-hook #'ivy--exhibit)))))
+ (setq ivy--action nil)
+ (prog1
+ (unwind-protect
+ (minibuffer-with-setup-hook
+ #'ivy--minibuffer-setup
+ (let ((res (read-from-minibuffer
+ prompt
+ initial-input
+ (make-composed-keymap keymap ivy-minibuffer-map)
+ nil
+ 'ivy-history)))
+ (when (eq ivy-exit 'done)
+ (pop ivy-history)
+ (setq ivy-history
+ (cons ivy-text (delete ivy-text ivy-history)))
+ res)))
+ (remove-hook 'post-command-hook #'ivy--exhibit))
+ (when ivy--action
+ (funcall ivy--action))))))
+
+(defvar ivy--action nil
+ "Store a function to call at the end of `ivy--read'.")
(defun ivy--preselect-index (candidates initial-input preselect)
"Return the index in CANDIDATES filtered by INITIAL-INPUT for PRESELECT."
@@ -401,12 +411,14 @@ CANDIDATES is a list of strings."
(setq ivy--current (copy-sequence (nth index cands)))
(setf (nth index cands)
(ivy--add-face ivy--current 'ivy-current-match))
- (concat "\n" (mapconcat
- (lambda (s)
- (if (> (length s) ww)
- (concat (substring s 0 (- ww 3)) "...")
- s))
- cands "\n"))))))
+ (let ((res (concat "\n" (mapconcat
+ (lambda (s)
+ (if (> (length s) ww)
+ (concat (substring s 0 (- ww 3)) "...")
+ s))
+ cands "\n"))))
+ (put-text-property 0 (length res) 'read-only nil res)
+ res)))))
(provide 'ivy)
diff --git a/packages/swiper/swiper.el b/packages/swiper/swiper.el
index 1be8676..cb8e91b 100644
--- a/packages/swiper/swiper.el
+++ b/packages/swiper/swiper.el
@@ -4,7 +4,7 @@
;; Author: Oleh Krehel <address@hidden>
;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.1.0
+;; Version: 0.2.0
;; Package-Requires: ((emacs "24.1") (ivy "0.1.0"))
;; Keywords: matching
@@ -72,13 +72,38 @@
"Only highlight matches for regexps at least this long."
:type 'integer)
+(defvar swiper-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "M-q") 'swiper-query-replace)
+ map)
+ "Keymap for swiper.")
+
+(defun swiper-query-replace ()
+ "Start `query-replace' with string to replace from last search string."
+ (interactive)
+ (if (null (window-minibuffer-p))
+ (user-error "Should only be called in the minibuffer through
`swiper-map'")
+ (let* ((from (ivy--regex ivy-text))
+ (to (query-replace-read-to from "Query replace" t)))
+ (delete-minibuffer-contents)
+ (setq ivy--action
+ (lambda ()
+ (perform-replace from to
+ t t t)))
+ (swiper--cleanup)
+ (exit-minibuffer))))
+
(defvar swiper--window nil
"Store the current window.")
(defun swiper-font-lock-ensure ()
"Ensure the entired buffer is highlighted."
(unless (or (derived-mode-p 'magit-mode)
- (memq major-mode '(package-menu-mode emms-playlist-mode)))
+ (memq major-mode '(package-menu-mode
+ gnus-summary-mode
+ gnus-article-mode
+ gnus-group-mode
+ emms-playlist-mode erc-mode)))
(if (fboundp 'font-lock-ensure)
(font-lock-ensure)
(font-lock-fontify-buffer))))
@@ -146,8 +171,9 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
"%s" "pattern: " swiper--format-spec)
candidates
initial-input
- #'swiper--update-input-ivy
- preselect))
+ swiper-map
+ preselect
+ #'swiper--update-input-ivy))
(ido-mode 1)
(swiper--cleanup)
(if (null ivy-exit)
- [elpa] master updated (90473ac -> 0c2da66), Oleh Krehel, 2015/03/26
- [elpa] master 2ae5b9c 3/7: swiper.el (swiper-font-lock-ensure): Ignore gnus modes, Oleh Krehel, 2015/03/26
- [elpa] master abb6e0b 5/7: swiper.el (swiper-query-replace): Call only in minibuffer, Oleh Krehel, 2015/03/26
- [elpa] master 764e003 1/7: swiper.el (swiper-font-lock-ensure): Omit erc-mode, Oleh Krehel, 2015/03/26
- [elpa] master fdb0c45 4/7: Add swiper-query-replace, Oleh Krehel, 2015/03/26
- [elpa] master d63ce8f 2/7: Ensure that inserted candidates don't have read-only property, Oleh Krehel, 2015/03/26
- [elpa] master 0c2da66 7/7: Merge commit 'ce516073e5e4359b88f98610bae9b157945eb8e8' from swiper,
Oleh Krehel <=
- [elpa] master ce51607 6/7: Allow to cancel "M-q" with "C-g", Oleh Krehel, 2015/03/26