]> git.eshelyaron.com Git - dotfiles.git/commitdiff
Remove cape in favour of two custom capfs
authorEshel Yaron <eshel@dazz.io>
Tue, 14 Jun 2022 18:18:25 +0000 (21:18 +0300)
committerEshel Yaron <eshel@dazz.io>
Tue, 14 Jun 2022 18:18:25 +0000 (21:18 +0300)
.emacs.d/esy.org

index c646091c7510b8a94bb8d502af58b1416d75fdb2..51dac9db80caa23568040e2877a0605b46cb325a 100644 (file)
@@ -202,7 +202,7 @@ For further information about Elisp headers, see [[info:elisp#Library
         '(academic-phrases avy ace-window alert
           all-the-icons all-the-icons-completion anzu
           auctex-latexmk bbdb benchmark-init browse-at-remote
-          browse-kill-ring cape corfu command-log-mode dabbrev define-word
+          browse-kill-ring corfu command-log-mode dabbrev define-word
           diff-hl diminish disable-mouse dockerfile-mode elfeed
           embark-consult erlang exec-path-from-shell
           flymake-swi-prolog ggtags git-blamed
@@ -1047,11 +1047,25 @@ does in the shell.
 :END:
 
 #+begin_src emacs-lisp
+  (defun esy/dabbrev-capf ()
+    "Workaround for issue with `dabbrev-capf'."
+    (dabbrev--reset-global-variables)
+    (setq dabbrev-case-fold-search nil)
+    (dabbrev-capf))
+
+  (defun esy/file-capf ()
+    "File completion at point function."
+    (let ((bs (bounds-of-thing-at-point 'filename)))
+      (when bs
+        (let* ((start (car bs))
+               (end   (cdr bs))
+               (file  (buffer-substring-no-properties start end)))
+          `(,start ,end completion--file-name-table . (:exclusive no))))))
+
   (defun esy/setup-completions ()
     "Setup completions related-package."
     (require 'corfu)
     (require 'dabbrev)
-    (require 'cape)
     (require 'marginalia)
     (require 'orderless)
     (require 'all-the-icons)
@@ -1062,7 +1076,8 @@ does in the shell.
           completion-auto-select nil
           completion-styles '(basic orderless)
           completion-show-help nil
-          completions-header-format (propertize "%s candidates:\n" 'face 'shadow)
+          completions-header-format (propertize "%s candidates:\n"
+                                                'face 'shadow)
           completion-auto-help 'visual
           completions-max-height 16
           completion-wrap-movement t)
@@ -1074,8 +1089,10 @@ does in the shell.
                 #'minibuffer-next-completion)
     (global-corfu-mode)
     (marginalia-mode)
-    (add-to-list 'completion-at-point-functions #'cape-file)
-    (add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup)
+    (add-to-list 'completion-at-point-functions #'esy/dabbrev-capf)
+    (add-to-list 'completion-at-point-functions #'esy/file-capf)
+    (add-hook 'marginalia-mode-hook
+              #'all-the-icons-completion-marginalia-setup)
     (add-to-list 'display-buffer-alist
                  '("*Completions*"
                    (display-buffer-reuse-window display-buffer-at-bottom)