summaryrefslogtreecommitdiffhomepage
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
parentd96ee795eb8f69dd422bd2aba40599e4d7239568 (diff)
downloadelibs-0adf2da1d62addce56afd5fb8866ecce77147bd5.tar.gz
elibs-0adf2da1d62addce56afd5fb8866ecce77147bd5.tar.bz2
completion.org and minicomp
-rw-r--r--attic/counsel.org63
-rw-r--r--completion.org (renamed from consult.org)161
-rw-r--r--init.org87
-rw-r--r--lib/themes/jao-themes.el2
-rw-r--r--readme.org2
5 files changed, 160 insertions, 155 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
diff --git a/consult.org b/completion.org
index 76ebee7..37d5bbf 100644
--- a/consult.org
+++ b/completion.org
@@ -1,9 +1,82 @@
#+title: Completion configuration using selectrum, consult and friends
-* completion styles
+* company
#+begin_src emacs-lisp
- (setq completion-styles '(basic partial-completion emacs22))
+ (use-package company
+ :ensure t
+ :custom
+ ((company-global-modes '(clojure-mode
+ clojurec-mode
+ emacs-lisp-mode
+ eshell-mode
+ lisp-interaction-mode
+ haskell-mode
+ message-mode
+ org-mode
+ scheme-mode))
+ (company-idle-delay 0.15)
+ (company-lighter "")
+ (company-lighter-base "")
+ (company-show-numbers nil)
+ (company-tooltip-limit 15)
+ (company-tooltip-align-annotations t)
+ (company-transformers '(company-sort-by-occurrence)))
+
+ :config
+ ;; Prevent non-matching input (which will dismiss the completions
+ ;; menu), but only if the user interacts explicitly with Company.
+ (setq company-require-match #'company-explicit-action-p)
+
+ (defun jao-complete-at-point ()
+ "Complete using company unless we're in the minibuffer."
+ (interactive)
+ (if (window-minibuffer-p) (completion-at-point) (company-manual-begin)))
+
+ :bind (([remap completion-at-point] . #'jao-complete-at-point)
+ ([remap complete-symbol] . #'jao-complete-at-point)
+
+ ;; The following are keybindings that take effect whenever
+ ;; the completions menu is visible, even if the user has not
+ ;; explicitly interacted with Company.
+ :map company-active-map
+
+ ([remap scroll-up-command] . nil)
+ ([remap scroll-down-command] . nil)
+
+ ;; Make TAB always complete the current selection, instead of
+ ;; only completing a common prefix.
+ ("<tab>" . #'company-complete-selection)
+ ("TAB" . #'company-complete-selection)
+
+ ("C-h" . #'company-show-doc-buffer)
+ ("M-." . #'company-show-location)
+
+ ;; The following are keybindings that only take effect
+ ;; if not in eshell. Note that `:map' from above is
+ ;; "sticky", and applies also below.
+ ;; Another interesting :filter (company-explicit-action-p)
+
+ :filter (or (not (derived-mode-p 'eshell-mode))
+ (company-explicit-action-p))
+ ("<return>" . #'company-complete-selection)
+ ("RET" . #'company-complete-selection))
+
+ :bind* (;; The default keybinding for `completion-at-point' and
+ ;; `complete-symbol' is M-TAB or equivalently C-M-i. We
+ ;; already remapped those bindings to `company-manual-begin'
+ ;; above. Here we make sure that they definitely invoke
+ ;; `company-manual-begin' even if a minor mode binds M-TAB
+ ;; directly.
+ ("M-TAB" . #'jao-complete-at-point))
+
+ :diminish)
+
+ (use-package company-math :ensure t :after company)
+
+ (global-company-mode 1)
+
#+end_src
+
* orderless
#+begin_src emacs-lisp :load no
(use-package orderless
@@ -14,68 +87,16 @@
:bind
((:map minibuffer-local-completion-map ("SPC" . self-insert-command))))
#+end_src
-* selectrum
+* minicomp
#+begin_src emacs-lisp
- (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)))
-
-
+ (jao-load-path "minicomp")
+ (use-package minicomp
+ :init (setq minicomp-count 20)
: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)))
+ (defun jao-minicomp--orderless (&rest _)
+ (setq-local completion-styles '(orderless)))
+ (add-hook 'minibuffer-setup-hook #'jao-minicomp--orderless))
+ (minicomp-mode 1)
#+end_src
* marginalia
#+begin_src emacs-lisp
@@ -89,6 +110,7 @@
(marginalia-truncate-width 80)
(marginalia-annotators
'(marginalia-annotators-heavy marginalia-annotators-light nil))))
+ (marginalia-mode 1)
#+end_src
* consult
#+begin_src emacs-lisp
@@ -290,7 +312,10 @@
(pop-to-buffer (current-buffer) nil t))
(lambda ()
(embark-kill-buffer-and-window jao-embark--actions-buffer)
- (when selectrum-is-active (select-window (minibuffer-window))))))
+ (when (or (bound-and-true-p selectrum-is-active)
+ (and (boundp 'minicomp--input)
+ (stringp minicomp--input)))
+ (select-window (minibuffer-window))))))
(setq embark-action-indicator #'jao-embark--show-keymap
embark-become-indicator embark-action-indicator)
@@ -394,12 +419,6 @@
("a" espotify-play-candidate-album)
("h" espotify-show-candidate-info))
- (add-to-list 'embark-keymap-alist
- '(spotify-search-item . spotify-item-keymap)))
+ (add-to-list 'embark-keymap-alist
+ '(spotify-search-item . spotify-item-keymap)))
#+end_src
-* startup
- #+begin_src emacs-lisp
- (marginalia-mode 1)
- (selectrum-mode 1)
- (jao-selectrum-orderless)
- #+end_src
diff --git a/init.org b/init.org
index dbf4bff..33b718f 100644
--- a/init.org
+++ b/init.org
@@ -850,89 +850,6 @@
:bind (("s-n" . jao-hydra-ednc/body)
("H-s-n" . jao-hydra-ednc/body)))
#+end_src
-* Completion
-*** company
- #+begin_src emacs-lisp
- (use-package company
- :ensure t
- :custom
- ((company-global-modes '(clojure-mode
- clojurec-mode
- emacs-lisp-mode
- eshell-mode
- lisp-interaction-mode
- haskell-mode
- message-mode
- org-mode
- scheme-mode))
- (company-idle-delay 0.15)
- (company-lighter "")
- (company-lighter-base "")
- (company-show-numbers nil)
- (company-tooltip-limit 15)
- (company-tooltip-align-annotations t)
- (company-transformers '(company-sort-by-occurrence)))
-
- :config
- ;; Prevent non-matching input (which will dismiss the completions
- ;; menu), but only if the user interacts explicitly with Company.
- (setq company-require-match #'company-explicit-action-p)
-
- (defun jao-complete-at-point ()
- "Complete using company unless we're in the minibuffer."
- (interactive)
- (if (window-minibuffer-p) (completion-at-point) (company-manual-begin)))
-
- :bind (([remap completion-at-point] . #'jao-complete-at-point)
- ([remap complete-symbol] . #'jao-complete-at-point)
-
- ;; The following are keybindings that take effect whenever
- ;; the completions menu is visible, even if the user has not
- ;; explicitly interacted with Company.
- :map company-active-map
-
- ([remap scroll-up-command] . nil)
- ([remap scroll-down-command] . nil)
-
- ;; Make TAB always complete the current selection, instead of
- ;; only completing a common prefix.
- ("<tab>" . #'company-complete-selection)
- ("TAB" . #'company-complete-selection)
-
- ("C-h" . #'company-show-doc-buffer)
- ("M-." . #'company-show-location)
-
- ;; The following are keybindings that only take effect
- ;; if not in eshell. Note that `:map' from above is
- ;; "sticky", and applies also below.
- ;; Another interesting :filter (company-explicit-action-p)
-
- :filter (or (not (derived-mode-p 'eshell-mode))
- (company-explicit-action-p))
- ("<return>" . #'company-complete-selection)
- ("RET" . #'company-complete-selection))
-
- :bind* (;; The default keybinding for `completion-at-point' and
- ;; `complete-symbol' is M-TAB or equivalently C-M-i. We
- ;; already remapped those bindings to `company-manual-begin'
- ;; above. Here we make sure that they definitely invoke
- ;; `company-manual-begin' even if a minor mode binds M-TAB
- ;; directly.
- ("M-TAB" . #'jao-complete-at-point))
-
- :diminish)
-
- (use-package company-math :ensure t :after company)
-
- (global-company-mode 1)
-
- #+end_src
-*** completion engine
- We can load either [[./consult.org][consult.org]] or [[./attic/counsel.org][counsel.org]] to configure
- completion engines:
- #+begin_src emacs-lisp
- (jao-load-org "consult")
- #+end_src
* Calendar, diary, weather
*** Diary
#+BEGIN_SRC emacs-lisp
@@ -1136,6 +1053,10 @@
#+END_SRC
* General editing
+*** Completion
+ #+begin_src emacs-lisp
+ (jao-load-org "completion")
+ #+end_src
*** Long lines
[[https://200ok.ch/posts/2020-09-29_comprehensive_guide_on_handling_long_lines_in_emacs.html][Comprehensive guide on handling long lines in Emacs - 200ok]]
#+begin_src emacs-lisp
diff --git a/lib/themes/jao-themes.el b/lib/themes/jao-themes.el
index a78d890..6fa66c0 100644
--- a/lib/themes/jao-themes.el
+++ b/lib/themes/jao-themes.el
@@ -822,6 +822,8 @@
(mm-uu-extract (p hilite) ex)
(minibuffer-line (p f00))
(minibuffer-prompt (p f00))
+ (minicomp-group-title (p dimm))
+ (minicomp-group-separator (p dimm) :strike-through "grey80")
(mode-line-buffer-id nbf (c nil nil))
(mode-line-emphasis (p warning))
(mode-line-highlight (~ mode-line))
diff --git a/readme.org b/readme.org
index 3e621ea..9e2b7fd 100644
--- a/readme.org
+++ b/readme.org
@@ -62,7 +62,7 @@
- [[./init.org][init.org]]: main configuration as a literate org file; it uses
(besides lots of packages), many of my libraries in [[./lib][lib]], and loads
on demand the other org files below.
-- [[./consult.org][consult.org]]: completion setup using selectrum, consult and friends.
+- [[./completion.org][completion.org]]: completion setup using company, consult and friends.
- [[./org.org][org.org]] org mode configuration.
- [[./blog.org][blog.org]]: blogging using org-static-blog.
- [[./gnus.org][gnus.org]]: tangled to gnus.el automatically by init.org, so that it's