Flx-ido and Flx-isearch

Flex-Ido and Flex-Search provide search functionality for mini-buffer dropdowns. You can search recent and other files with fuzzy matching.


;good for ivy

(use-package flx  ;; Improves sorting for fuzzy-matched results
  :after ivy
  :defer t
  :init
  (setq ivy-flx-limit 10000))


;ido mode and supporting
(use-package flx-ido
:init
(ido-mode 1)
;(ido-everywhere 1)
(flx-ido-mode 1)

;~ tilda to go to home directory
(defun my/ido-go-straight-home ()
  (interactive)
  (cond
   ((looking-back "~/") (insert "projects/"))
   ((looking-back "/") (insert "~/"))
   (:else (call-interactively 'self-insert-command))))

(defun recentf-ido-find-file ()
"Find a recent file using Ido."
(interactive)
(let ((file (ido-completing-read "Choose recent file: " recentf-list nil t)))
(when file
(find-file file))))

:bind
;("C-x C-i" . ido-imenu) ; no ido menu library
("C-x M-f" . ido-find-file-other-window)
("C-x F" .  recentf-ido-find-file)
;("C-x C-b" . ibuffer)
(:map ido-file-completion-map
(("C-~"  . my/ido-go-straight-home)
("C-w" . ido-delete-backward-updir)
("C-x C-w" . ido-copy-current-file-name)
("~" . (lambda () (interactive) (if
         (looking-back "/")
         (insert "~/")
         (call-interactively 'self-insert-command))))))
:config
; turning off ido faces and on flex matching faces
(setq ido-enable-flex-matching t)
(setq ido-use-faces nil)
(setq ido-enable-prefix nil
      ido-enable-flex-matching t
      ido-case-fold nil
      ido-auto-merge-work-directories-length -1
      ido-create-new-buffer 'always
      ido-use-filename-at-point nil
      ido-max-prospects 10)
(setq flx-ido-use-faces t)
;; Always rescan buffer for imenu
(set-default 'imenu-auto-rescan t)
(global-unset-key (kbd "C-x TAB"))

);use package flx-ido

;(define-key ido-completion-map (kbd "C-i") 'ido-exit-minibuffer )


(use-package flx-isearch )

Ido Packages

It's still good to have ido-mode kicking around, in case you ever need it.


(use-package ido-at-point)

;ido-ubiquitous has an unsolved bug with declared variables
; unbind them
(defvar ido-cur-item nil)
(defvar ido-default-item nil)
(defvar ido-cur-list nil)
;(defvar predicate nil)
;(defvar inherit-input-method nil)

(use-package ido-ubiquitous)

(use-package ido-vertical-mode
:config
(ido-vertical-mode t)
;; C-n/p is more intuitive in vertical layout
(setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right)
);end use package

(require 'ido-at-point)
(ido-at-point-mode)


;whatever
;; Fix ido-ubiquitous for newer packages
;(defmacro ido-ubiquitous-use-new-completing-read (cmd package)
;   `(eval-after-load ,package
;     '(defadvice ,cmd (around ido-ubiquitous-new activate)
;        (let ((ido-ubiquitous-enable-compatibility nil))
;          ad-do-it))))
;; Ido at point (C-,)
;; Use ido everywhere
;(ido-ubiquitous-mode 1)
;(ido-ubiquitous-use-new-completing-read webjump 'webjump)
;(ido-ubiquitous-use-new-completing-read yas-expand 'yasnippet)
;(ido-ubiquitous-use-new-completing-read yas-visit-snippet-file 'yasnippet)

Ivy is a completion package that complements counsel buffer functionality well.

If you don't include :after ivy in your counsel configuration, the ivy code must appear in the intitialization file before the counsel code.

Ivy


(use-package ivy
;:ensure t
;:commands (ivy-mode)
:config
(setq ivy-wrap t
        ivy-virtual-abbreviate 'full
        ivy-use-virtual-buffers t
        ivy-use-selectable-prompt t
        ivy-count-format "(%d/%d) "
        ivy-re-builders-alist '((read-file-name-internal . ivy--regex-fuzzy)
                                (t . ivy--regex-plus))
        ivy-on-del-error-function nil
        ivy-initial-inputs-alist nil
        enable-recursive-minibuffers t)
;; Use different regex strategies per completion command
;(push '(completion-at-point . ivy--regex-fuzzy) ivy-re-builders-alist) ;; This doesn't seem to work...
;(push '(swiper . ivy--regex-ignore-order) ivy-re-builders-alist)
(push '(counsel-M-x . ivy--regex-ignore-order) ivy-re-builders-alist)
;; Set minibuffer height for different commands
(setf (alist-get 'counsel-projectile-ag ivy-height-alist) 15)
(setf (alist-get 'counsel-projectile-rg ivy-height-alist) 15)
;(setf (alist-get 'swiper ivy-height-alist) 15)
(setf (alist-get 'counsel-switch-buffer ivy-height-alist) 7)
(ivy-mode 1)
:bind (
("C-s"  . isearch-forward)
:map ivy-minibuffer-map
("C-i" . ivy-alt-done)
("C-l" . ivy-dispatching-call); l for list
("C-o" . ivy-dispatching-done); o for other
("C-n" . ivy-next-line)
("C-p" . ivy-previous-line)
:map ivy-switch-buffer-map
("C-l" . ivy-dispatching-call); l for list
("C-o" . ivy-dispatching-done); o for other
("C-n" . ivy-next-line)
("C-p" . ivy-previous-line)
("C-d" . ivy-switch-buffer-kill); d for delete
:map ivy-reverse-i-search-map
("C-p" . ivy-previous-line)
("C-d" . ivy-ivy-kill-buffer))
);end ivy

Ivy Prescient

You only need ivy-prescient if you're using prescient.el to sort and filter candidates.


(use-package ivy-prescient
:after ivy
:commands (ivy-prescient-mode)
;:ensure t
;:init (ivy-prescient-mode)
);end ivy-prescient

Ivy Todo (tagging files)

You can use ivy-todo with an org-mode agenda manager to add todos from your ivy-counsel combo.


(use-package ivy-todo
;:ensure t
:commands (ivy-todo set-ivy-todo-file)
:config
;set default tags
(setq ivy-todo-default-tags '("TODO" "NEXT" "DEADLINE" "DONE" "CANCELLED"))
;set default ivy-todo-file
(setq ivy-todo-file org-agenda-file)
;inhibit ivy guessing
(setq ivy-todo-guess-list nil)

(defun set-ivy-todo-file(astring)
"Paste file path as to replace ivy-todo-file.
Now you use ivy-todo to manage file."
(interactive "sAstring: ")
(setq ivy-todo-file astring))
);end ivy-todo

Smart Meta X (default)

Again, Smart Meta X is good to have around as a backup.


; Smart M-X, still around if you get sick of helm
(use-package smex
:commands (smex sex-major-mode-commands smex-initialize)
:bind
("C-M-x" . smex)
;("M-X" . smex-major-mode-commands)
);end use package smex