[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 877648a 045/167: ivy.el (ivy-case-fold-search): New defvar
From: |
Oleh Krehel |
Subject: |
[elpa] master 877648a 045/167: ivy.el (ivy-case-fold-search): New defvar |
Date: |
Tue, 08 Dec 2015 10:49:48 +0000 |
branch: master
commit 877648a227fe34e1456776a4e6019029d65fc734
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy-case-fold-search): New defvar
* ivy.el (ivy--reset-state): Set `ivy-case-fold-search' to 'auto.
(ivy-toggle-case-fold): New command.
(ivy--filter): Use `ivy-case-fold-search' to determine `case-fold-search'.
* ivy-hydra.el (hydra-ivy): Bind "C" to `ivy-toggle-case-fold'.
Fixes #259
---
ivy-hydra.el | 19 +++++++++++++------
ivy.el | 24 +++++++++++++++++++++++-
2 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/ivy-hydra.el b/ivy-hydra.el
index 51b4c1a..19deabb 100644
--- a/ivy-hydra.el
+++ b/ivy-hydra.el
@@ -44,14 +44,20 @@
(byte-compile-file (buffer-file-name) t)))
(error "Please install `hydra' and recompile/reinstall
`ivy-hydra'")))))))
+(defun ivy--matcher-desc ()
+ (if (eq ivy--regex-function
+ 'ivy--regex-fuzzy)
+ "fuzzy"
+ "ivy"))
+
(defhydra hydra-ivy (:hint nil
:color pink)
"
-^^^^^^ ^Yes^ ^No^ ^Maybe^ ^Action^
-^^^^^^^^^^^^^^---------------------------------------------------------------
-^ ^ _k_ ^ ^ _f_ollow _i_nsert _c_: calling %-3s(if ivy-calling \"on\"
\"off\") _w_/_s_/_a_: %-14s(ivy-action-name)
-_h_ ^+^ _l_ _d_one _o_ops _m_: matcher %-27s(if (eq
ivy--regex-function 'ivy--regex-fuzzy) \"fuzzy\" \"ivy\")
-^ ^ _j_ ^ ^ _g_o ^ ^ _<_/_>_: shrink/grow _t_runcate:
%-11`truncate-lines
+^^^^^^ ^Yes^ ^No^ ^Maybe^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Action^ ^
+^^^^^^^^^^^^^^----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------
+^ ^ _k_ ^ ^ _f_ollow _i_nsert _c_: calling %-5s(if ivy-calling \"on\"
\"off\") _w_/_s_/_a_: %-14s(ivy-action-name)
+_h_ ^+^ _l_ _d_one _o_ops _m_: matcher
%-5s(ivy--matcher-desc)^^^^^^^^^^^^ _C_ase-fold: %-10`ivy-case-fold-search
+^ ^ _j_ ^ ^ _g_o ^ ^ _<_/_>_:
shrink/grow^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _t_runcate: %-11`truncate-lines
"
;; arrows
("h" ivy-beginning-of-buffer)
@@ -75,7 +81,8 @@ _h_ ^+^ _l_ _d_one _o_ops _m_: matcher %-27s(if (eq
ivy--regex-function
("w" ivy-prev-action)
("s" ivy-next-action)
("a" ivy-read-action)
- ("t" (setq truncate-lines (not truncate-lines))))
+ ("t" (setq truncate-lines (not truncate-lines)))
+ ("C" ivy-toggle-case-fold))
(provide 'ivy-hydra)
diff --git a/ivy.el b/ivy.el
index 71d80cd..98f8eab 100644
--- a/ivy.el
+++ b/ivy.el
@@ -252,6 +252,9 @@ When non-nil, it should contain one %d.")
(defvar ivy--old-text ""
"Store old `ivy-text' for dynamic completion.")
+(defvar ivy-case-fold-search 'auto
+ "Store the current overriding `case-fold-search'.")
+
(defvar Info-current-file)
(defmacro ivy-quit-and-run (&rest body)
@@ -1028,6 +1031,7 @@ This is useful for recursive `ivy-read'."
(setq initial-input (cdr (assoc this-command
ivy-initial-inputs-alist))))
(setq ivy--directory nil)
+ (setq ivy-case-fold-search 'auto)
(setq ivy--regex-function
(or re-builder
(and (functionp collection)
@@ -1558,6 +1562,22 @@ all of the text contained in the minibuffer."
(eval-after-load 'flx
'(setq ivy--flx-cache (flx-make-string-cache)))
+(defun ivy-toggle-case-fold ()
+ "Toggle the case folding between nil and auto.
+In any completion session, the case folding starts in auto:
+
+- when the input is all lower case, `case-fold-search' is t
+- otherwise it's nil.
+
+You can toggle this to make `case-fold-search' nil regardless of input."
+ (interactive)
+ (setq ivy-case-fold-search
+ (if ivy-case-fold-search
+ nil
+ 'auto))
+ ;; reset cache so that the candidate list updates
+ (setq ivy--old-re nil))
+
(defun ivy--filter (name candidates)
"Return all items that match NAME in CANDIDATES.
CANDIDATES are assumed to be static."
@@ -1568,7 +1588,9 @@ CANDIDATES are assumed to be static."
ivy--old-cands
(let* ((re-str (if (listp re) (caar re) re))
(matcher (ivy-state-matcher ivy-last))
- (case-fold-search (string= name (downcase name)))
+ (case-fold-search
+ (and ivy-case-fold-search
+ (string= name (downcase name))))
(cands (cond
(matcher
(funcall matcher re candidates))
- [elpa] master 21b9edf 021/167: Fix up visual-line-mode limitation logic, (continued)
- [elpa] master 21b9edf 021/167: Fix up visual-line-mode limitation logic, Oleh Krehel, 2015/12/08
- [elpa] master 126158d 025/167: ivy.el (ivy--filter): Anchor only for swiper, Oleh Krehel, 2015/12/08
- [elpa] master 800e640 028/167: Fix "M-o k" when switching buffers, Oleh Krehel, 2015/12/08
- [elpa] master b9d0502 026/167: ivy.el (ivy--filter): Fix typo, Oleh Krehel, 2015/12/08
- [elpa] master 6956311 027/167: Adjust ivy-state-preselect for file name completion, Oleh Krehel, 2015/12/08
- [elpa] master 6f4d46b 034/167: Fix preselect for input "^", Oleh Krehel, 2015/12/08
- [elpa] master ef189f1 030/167: ivy.el (ivy-count-format): Extend customize choices, Oleh Krehel, 2015/12/08
- [elpa] master e722d6a 046/167: swiper.el (swiper-mc): Add and bind to "C-7", Oleh Krehel, 2015/12/08
- [elpa] master 3a3b052 036/167: swiper.el: Add a lot of avy declares, Oleh Krehel, 2015/12/08
- [elpa] master 3699fa9 041/167: Don't reset the match to first if the current one still works, Oleh Krehel, 2015/12/08
- [elpa] master 877648a 045/167: ivy.el (ivy-case-fold-search): New defvar,
Oleh Krehel <=
- [elpa] master 340318d 044/167: ivy-count-format must be an empty string instead of nil, Oleh Krehel, 2015/12/08
- [elpa] master 9cc75eb 050/167: Adjust the swiper regexp builder for the display change, Oleh Krehel, 2015/12/08
- [elpa] master 85682ee 048/167: Fix "C-x h" selection and "C-b" bug, Oleh Krehel, 2015/12/08
- [elpa] master 99698e6 035/167: ivy.el (ivy-dispatching-call): Add and bind to "C-M-o", Oleh Krehel, 2015/12/08
- [elpa] master 0630395 043/167: Fix the count when git-grep for "->foo", Oleh Krehel, 2015/12/08
- [elpa] master 4045349 032/167: ivy.el (ivy-use-virtual-buffers): Update docstring, Oleh Krehel, 2015/12/08
- [elpa] master f9df75e 037/167: ivy.el (ivy-index-functions-alist): New variable, Oleh Krehel, 2015/12/08
- [elpa] master 6e3c692 029/167: Fix ivy-state-preselect for file name completion, Oleh Krehel, 2015/12/08
- [elpa] master c69b4b6 033/167: ivy.el (ivy-last): Update docstring, Oleh Krehel, 2015/12/08
- [elpa] master b6d476a 042/167: ivy.el (ivy--recompute-index): Fixup, Oleh Krehel, 2015/12/08