summaryrefslogtreecommitdiffhomepage
path: root/attic
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-04-04 21:40:15 +0100
committerjao <jao@gnu.org>2021-04-04 21:41:29 +0100
commit0adf2da1d62addce56afd5fb8866ecce77147bd5 (patch)
tree34b120619309eb93bc39b687ea90e49c086fbf2d /attic
parentd96ee795eb8f69dd422bd2aba40599e4d7239568 (diff)
downloadelibs-0adf2da1d62addce56afd5fb8866ecce77147bd5.tar.gz
elibs-0adf2da1d62addce56afd5fb8866ecce77147bd5.tar.bz2
completion.org and minicomp
Diffstat (limited to 'attic')
-rw-r--r--attic/counsel.org63
1 files changed, 63 insertions, 0 deletions
diff --git a/attic/counsel.org b/attic/counsel.org
index 6fbd591..f6814ae 100644
--- a/attic/counsel.org
+++ b/attic/counsel.org
@@ -1,5 +1,68 @@
#+title: Completion configuration using ivy, counsel and friends
+* selectrum
+ #+begin_src emacs-lisp :load no
+ (use-package selectrum
+ :ensure t
+ :init
+ (defun jao-selectrum--ord-refine (&rest args)
+ (let ((completion-styles '(orderless)))
+ (apply #'selectrum-refine-candidates-using-completions-styles args)))
+
+ (defun jao-selectrum-orderless ()
+ (interactive)
+ (setq selectrum-refine-candidates-function #'jao-selectrum--ord-refine)
+ (setq selectrum-highlight-candidates-function #'orderless-highlight-matches)
+ (setq orderless-skip-highlighting (lambda () selectrum-is-active)))
+
+
+ :config
+ ;; https://github.com/raxod502/selectrum/wiki/Ido,-icomplete(fido)-emulation
+ (defun selectrum-fido-backward-updir ()
+ "Delete char before or go up directory, like `ido-mode'."
+ (interactive)
+ (if (and (eq (char-before) ?/)
+ (eq (selectrum--get-meta 'category) 'file))
+ (save-excursion
+ (goto-char (1- (point)))
+ (when (search-backward "/" (point-min) t)
+ (delete-region (1+ (point)) (point-max))))
+ (call-interactively 'backward-delete-char)))
+
+ (defun selectrum-fido-delete-char ()
+ "Delete char or maybe call `dired', like `ido-mode'."
+ (interactive)
+ (let ((end (point-max)))
+ (if (or (< (point) end) (not (eq (selectrum--get-meta 'category) 'file)))
+ (call-interactively 'delete-char)
+ (dired (file-name-directory (minibuffer-contents)))
+ (exit-minibuffer))))
+
+ (defun selectrum-fido-ret ()
+ "Exit minibuffer or enter directory, like `ido-mode'."
+ (interactive)
+ (let* ((dir (and (eq (selectrum--get-meta 'category) 'file)
+ (file-name-directory (minibuffer-contents))))
+ (current (selectrum-get-current-candidate))
+ (probe (and dir current
+ (expand-file-name (directory-file-name current) dir))))
+ (if (and probe (file-directory-p probe) (not (string= current "./")))
+ (selectrum-insert-current-candidate)
+ (selectrum-select-current-candidate))))
+
+ ;; (define-key selectrum-minibuffer-map (kbd "RET") 'selectrum-fido-ret)
+ (define-key selectrum-minibuffer-map (kbd "DEL") 'selectrum-fido-backward-updir)
+ (define-key selectrum-minibuffer-map (kbd "C-d") 'selectrum-fido-delete-char)
+
+ :custom ((selectrum-complete-in-buffer t)
+ ;; (selectrum-display-action '(display-buffer-at-bottom))
+ (selectrum-extend-current-candidate-highlight t)
+ (selectrum-fix-vertical-window-height nil)
+ (selectrum-max-window-height 20)
+ (selectrum-show-indices nil)
+ (selectrum-count-style 'current/matches))
+ :bind (("C-R" . selectrum-repeat)))
+ #+end_src
* ivy
#+begin_src emacs-lisp
(use-package ivy