From 441ab94891ad2717e65105bac83d2d852e0d0dd5 Mon Sep 17 00:00:00 2001
From: Chris Cochrun <chris@cochrun.xyz>
Date: Thu, 4 Jan 2024 15:26:14 -0600
Subject: [PATCH] tweaks to mostly cape and corfu

---
 README.org | 93 ++++++++++++++++++++++++++++++++++--------------------
 init.el    | 90 ++++++++++++++++++++++++++++++++--------------------
 2 files changed, 113 insertions(+), 70 deletions(-)

diff --git a/README.org b/README.org
index 6de0c7fc..8ea3de02 100644
--- a/README.org
+++ b/README.org
@@ -652,6 +652,11 @@ This evil-collection package includes a lot of other evil based things.
     (forward-line -1)
     (indent-according-to-mode))
 
+  (defun chris/find-todo ()
+    "opens my todo file"
+    (interactive)
+    (find-file "/home/chris/docs/todo/todo.org"))
+
   (general-create-definer chris/leader-keys
     :keymaps '(normal visual emacs)
     :prefix "SPC")
@@ -691,6 +696,7 @@ This evil-collection package includes a lot of other evil based things.
     "fb" '(chris/open-bible :which-key "find bible book")
     "fr" '(consult-recent-file :which-key "recent file")
     "fs" '(save-buffer :which-key "save")
+    "ft" '(chris/find-todo :which-key "open todo file")
     "fE" '(consult-file-externally :which-key "find file externally")
     "fe" '(chris/edit-emacs-config :which-key "open config")
     "hf" '(helpful-function :which-key "describe-function")
@@ -813,7 +819,11 @@ Let's start by creating a self contained function of what I'd like started on ev
 
   (set-face-attribute 'org-block-end-line nil :inherit 'org-block-begin-line)
   (set-face-attribute 'org-column nil :background "#242631" :inherit 'fixed-pitch)
-  (set-face-attribute 'org-quote nil :background "#242631" :inherit 'fixed-pitch))
+  (set-face-attribute 'org-quote nil :background "#242631" :inherit 'fixed-pitch)
+
+  ;; Setup better completion functions for org mode
+  (setq-local completion-at-point-functions
+              (list (cape-capf-super #'cape-elisp-block #'cape-dabbrev #'cape-dict))))
 
 (defun chris/org-convert-csv-table (beg end)
   (interactive (list (mark) (point)))
@@ -1415,7 +1425,8 @@ I might try switching to and using denote instead of Org Roam. Denote doesn't us
   :config
   (require 'denote-org-dblock)
   (setq denote-directory "/home/chris/docs/notes"
-        denote-dired-directories "/home/chris/docs/notes"
+        denote-dired-directories '("/home/chris/docs/notes")
+        denote-dired-directories-include-subdirectories t
         denote-modules '(project xref ffap)
         denote-known-keywords '("emacs" "bible" "jesus" "tfc" "lesson" "it" "dev"))
 
@@ -1431,29 +1442,28 @@ I might try switching to and using denote instead of Org Roam. Denote doesn't us
   (setq denote-org-front-matter
         "#+TITLE: %1$s\n#+AUTHOR: Chris Cochrun\n#+CREATED: %2$s\n#+filetags: %3$s\n#+identifier: %4$s\n")
 
-  (add-hook 'dired-mode-hook 'denote-dired-mode)
+  (add-hook 'dired-mode-hook #'denote-dired-mode-in-directories)
 
-  (defvar denote-faces--file-name-regexp
-    (concat "\\(?1:[0-9]\\{8\\}\\)\\(?2:T[0-9]\\{6\\}\\)"
-            "\\(?:\\(?3:==\\)\\(?4:[[:alnum:][:nonascii:]=]*?\\)\\)?"
-            "\\(?:\\(?5:--\\)\\(?6:[[:alnum:][:nonascii:]-]*?\\)\\)?"
-            "\\(?:\\(?7:__\\)\\(?8:[[:alnum:][:nonascii:]_-]*?\\)\\)?"
-            "\\(?9:\\..*\\)?$")
-    "Regexp of file names for fontification.")
+  ;; (defvar denote-faces--file-name-regexp
+  ;;   (concat "\\(?1:[0-9]\\{8\\}\\)\\(?2:T[0-9]\\{6\\}\\)"
+  ;;           "\\(?:\\(?3:==\\)\\(?4:[[:alnum:][:nonascii:]=]*?\\)\\)?"
+  ;;           "\\(?:\\(?5:--\\)\\(?6:[[:alnum:][:nonascii:]-]*?\\)\\)?"
+  ;;           "\\(?:\\(?7:__\\)\\(?8:[[:alnum:][:nonascii:]_-]*?\\)\\)?"
+  ;;           "\\(?9:\\..*\\)?$")
+  ;;   "Regexp of file names for fontification.")
 
-
-  (defconst denote-faces-file-name-keywords
-    `((,(concat "[\t\s]+" denote-faces--file-name-regexp)
-       (1 'denote-faces-date)
-       (2 'denote-faces-time)
-       (3 'denote-faces-delimiter nil t)
-       (4 'denote-faces-signature nil t)
-       (5 'denote-faces-delimiter nil t)
-       (6 'denote-faces-title nil t)
-       (7 'denote-faces-delimiter nil t)
-       (8 'denote-faces-keywords nil t)
-       (9 'denote-faces-extension nil t )))
-    "Keywords for fontification of file names.")
+  ;; (defconst denote-faces-file-name-keywords
+  ;;   `((,(concat "[\t\s]+" denote-faces--file-name-regexp)
+  ;;      (1 'denote-faces-date)
+  ;;      (2 'denote-faces-time)
+  ;;      (3 'denote-faces-delimiter nil t)
+  ;;      (4 'denote-faces-signature nil t)
+  ;;      (5 'denote-faces-delimiter nil t)
+  ;;      (6 'denote-faces-title nil t)
+  ;;      (7 'denote-faces-delimiter nil t)
+  ;;      (8 'denote-faces-keywords nil t)
+  ;;      (9 'denote-faces-extension nil t )))
+  ;;   "Keywords for fontification of file names.")
 
   :general
   (chris/leader-keys
@@ -2676,6 +2686,9 @@ targets."
 #+end_src
 
 *** Corfu
+:PROPERTIES:
+:ID:       20240104T104041.544024
+:END:
 Trying out corfu instead of company
 #+BEGIN_SRC emacs-lisp
 (use-package corfu
@@ -2685,13 +2698,13 @@ Trying out corfu instead of company
   (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
   (corfu-auto t)                 ;; Enable auto completion
   (corfu-separator ?\s)          ;; Orderless field separator
-  (corfu-quit-no-match 'separator)      ;; Never quit, even if there is no match
-  (corfu-preview-current 'insert)    ;; Enable current candidate preview
+  (corfu-quit-no-match nil)      ;; Never quit, even if there is no match
+  (corfu-preview-current nil)    ;; Enable current candidate preview
   (corfu-preselect-first nil)    ;; Enable candidate preselection
   (corfu-on-exact-match 'insert)     ;; Configure handling of exact matches
   (corfu-echo-documentation '(1.0 . 0.2)) ;; Disable documentation in the echo area
   (corfu-scroll-margin 5)        ;; Use scroll margin
-  (corfu-count 15)
+  (corfu-count 10)
   (corfu-auto-prefix 2)
   (corfu-auto-delay 0.5)
 
@@ -2704,6 +2717,7 @@ Trying out corfu instead of company
   ;; This is recommended since dabbrev can be used globally (M-/).
   :init
   (global-corfu-mode)
+  (corfu-echo-mode)
   :general
   ('corfu-map
    "C-j" 'corfu-next
@@ -2774,14 +2788,19 @@ Trying out corfu instead of company
   ;; (add-to-list 'completion-at-point-functions #'cape-tex)
   (add-to-list 'completion-at-point-functions #'cape-keyword)
   (add-to-list 'completion-at-point-functions #'cape-dabbrev)
-  ;;(add-to-list 'completion-at-point-functions #'cape-sgml)
-  ;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
-  ;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
+  ;; (add-to-list 'completion-at-point-functions #'cape-sgml)
+  ;; (defvar completion-at-point-functions '(cape-dabbrev cape-keyword cape-file tempel-complete
+  ;;                                                      pcomplete-completions-at-point
+  ;;                                                      ispell-completion-at-point))
+  
+  ;; (add-to-list 'completion-at-point-functions #'cape-rfc1345)
+  ;; (add-to-list 'completion-at-point-functions #'cape-abbrev)
   ;; (add-to-list 'completion-at-point-functions #'cape-ispell)
-  ;;(add-to-list 'completion-at-point-functions #'cape-dict)
-  (add-to-list 'completion-at-point-functions #'cape-symbol)
-  ;;(add-to-list 'completion-at-point-functions #'cape-line)
-  (remove #'cape-ispell completion-at-point-functions)
+  ;; (add-to-list 'completion-at-point-functions #'cape-dict)
+  ;; (add-to-list 'completion-at-point-functions #'cape-symbol)
+  ;; (add-to-list 'completion-at-point-functions #'cape-line)
+  ;; (remove #'cape-ispell completion-at-point-functions)
+  ;; (remove #'cape-symbol completion-at-point-functions)
 
   :config
   (setq cape-dabbrev-min-length 4)  
@@ -3362,6 +3381,10 @@ I'd like to start learning and using rust if I can.
 *** Web
 For developing websites, I like to use web-mode
 #+begin_src emacs-lisp
+(defun chris/web-mode-setup ()
+  "some setup for web development"
+  (setq-local completion-at-point-functions
+              (list #'cape-dabbrev #'cape-keyword #'tempel-complete)))
 (use-package web-mode
   :mode "\\.html\\'"
   :config
@@ -3378,13 +3401,13 @@ For developing websites, I like to use web-mode
         web-mode-enable-auto-closing t
         web-mode-enable-current-column-highlight t
         web-mode-enable-current-element-highlight t)
+  (add-to-list 'web-mode-hook #'chris/web-mode-setup)
 
   :general
   (general-def 'normal web-mode-map
     "TAB" 'indent-according-to-mode)
   (general-def 'insert web-mode-map
-    "TAB" 'indent-according-to-mode)
-  )
+    "TAB" 'indent-according-to-mode))
 #+end_src
 
 *** Lua
diff --git a/init.el b/init.el
index f9fd785f..ba712058 100644
--- a/init.el
+++ b/init.el
@@ -352,6 +352,11 @@
     (forward-line -1)
     (indent-according-to-mode))
 
+  (defun chris/find-todo ()
+    "opens my todo file"
+    (interactive)
+    (find-file "/home/chris/docs/todo/todo.org"))
+
   (general-create-definer chris/leader-keys
     :keymaps '(normal visual emacs)
     :prefix "SPC")
@@ -391,6 +396,7 @@
     "fb" '(chris/open-bible :which-key "find bible book")
     "fr" '(consult-recent-file :which-key "recent file")
     "fs" '(save-buffer :which-key "save")
+    "ft" '(chris/find-todo :which-key "open todo file")
     "fE" '(consult-file-externally :which-key "find file externally")
     "fe" '(chris/edit-emacs-config :which-key "open config")
     "hf" '(helpful-function :which-key "describe-function")
@@ -507,7 +513,11 @@
 
   (set-face-attribute 'org-block-end-line nil :inherit 'org-block-begin-line)
   (set-face-attribute 'org-column nil :background "#242631" :inherit 'fixed-pitch)
-  (set-face-attribute 'org-quote nil :background "#242631" :inherit 'fixed-pitch))
+  (set-face-attribute 'org-quote nil :background "#242631" :inherit 'fixed-pitch)
+
+  ;; Setup better completion functions for org mode
+  (setq-local completion-at-point-functions
+              (list (cape-capf-super #'cape-elisp-block #'cape-dabbrev #'cape-dict))))
 
 (defun chris/org-convert-csv-table (beg end)
   (interactive (list (mark) (point)))
@@ -935,7 +945,8 @@ much faster. The hope is to also make this a faster version of imenu."
   :config
   (require 'denote-org-dblock)
   (setq denote-directory "/home/chris/docs/notes"
-        denote-dired-directories "/home/chris/docs/notes"
+        denote-dired-directories '("/home/chris/docs/notes")
+        denote-dired-directories-include-subdirectories t
         denote-modules '(project xref ffap)
         denote-known-keywords '("emacs" "bible" "jesus" "tfc" "lesson" "it" "dev"))
 
@@ -951,29 +962,28 @@ much faster. The hope is to also make this a faster version of imenu."
   (setq denote-org-front-matter
         "#+TITLE: %1$s\n#+AUTHOR: Chris Cochrun\n#+CREATED: %2$s\n#+filetags: %3$s\n#+identifier: %4$s\n")
 
-  (add-hook 'dired-mode-hook 'denote-dired-mode)
+  (add-hook 'dired-mode-hook #'denote-dired-mode-in-directories)
 
-  (defvar denote-faces--file-name-regexp
-    (concat "\\(?1:[0-9]\\{8\\}\\)\\(?2:T[0-9]\\{6\\}\\)"
-            "\\(?:\\(?3:==\\)\\(?4:[[:alnum:][:nonascii:]=]*?\\)\\)?"
-            "\\(?:\\(?5:--\\)\\(?6:[[:alnum:][:nonascii:]-]*?\\)\\)?"
-            "\\(?:\\(?7:__\\)\\(?8:[[:alnum:][:nonascii:]_-]*?\\)\\)?"
-            "\\(?9:\\..*\\)?$")
-    "Regexp of file names for fontification.")
+  ;; (defvar denote-faces--file-name-regexp
+  ;;   (concat "\\(?1:[0-9]\\{8\\}\\)\\(?2:T[0-9]\\{6\\}\\)"
+  ;;           "\\(?:\\(?3:==\\)\\(?4:[[:alnum:][:nonascii:]=]*?\\)\\)?"
+  ;;           "\\(?:\\(?5:--\\)\\(?6:[[:alnum:][:nonascii:]-]*?\\)\\)?"
+  ;;           "\\(?:\\(?7:__\\)\\(?8:[[:alnum:][:nonascii:]_-]*?\\)\\)?"
+  ;;           "\\(?9:\\..*\\)?$")
+  ;;   "Regexp of file names for fontification.")
 
-
-  (defconst denote-faces-file-name-keywords
-    `((,(concat "[\t\s]+" denote-faces--file-name-regexp)
-       (1 'denote-faces-date)
-       (2 'denote-faces-time)
-       (3 'denote-faces-delimiter nil t)
-       (4 'denote-faces-signature nil t)
-       (5 'denote-faces-delimiter nil t)
-       (6 'denote-faces-title nil t)
-       (7 'denote-faces-delimiter nil t)
-       (8 'denote-faces-keywords nil t)
-       (9 'denote-faces-extension nil t )))
-    "Keywords for fontification of file names.")
+  ;; (defconst denote-faces-file-name-keywords
+  ;;   `((,(concat "[\t\s]+" denote-faces--file-name-regexp)
+  ;;      (1 'denote-faces-date)
+  ;;      (2 'denote-faces-time)
+  ;;      (3 'denote-faces-delimiter nil t)
+  ;;      (4 'denote-faces-signature nil t)
+  ;;      (5 'denote-faces-delimiter nil t)
+  ;;      (6 'denote-faces-title nil t)
+  ;;      (7 'denote-faces-delimiter nil t)
+  ;;      (8 'denote-faces-keywords nil t)
+  ;;      (9 'denote-faces-extension nil t )))
+  ;;   "Keywords for fontification of file names.")
 
   :general
   (chris/leader-keys
@@ -1892,13 +1902,13 @@ targets."
   (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
   (corfu-auto t)                 ;; Enable auto completion
   (corfu-separator ?\s)          ;; Orderless field separator
-  (corfu-quit-no-match 'separator)      ;; Never quit, even if there is no match
-  (corfu-preview-current 'insert)    ;; Enable current candidate preview
+  (corfu-quit-no-match nil)      ;; Never quit, even if there is no match
+  (corfu-preview-current nil)    ;; Enable current candidate preview
   (corfu-preselect-first nil)    ;; Enable candidate preselection
   (corfu-on-exact-match 'insert)     ;; Configure handling of exact matches
   (corfu-echo-documentation '(1.0 . 0.2)) ;; Disable documentation in the echo area
   (corfu-scroll-margin 5)        ;; Use scroll margin
-  (corfu-count 15)
+  (corfu-count 10)
   (corfu-auto-prefix 2)
   (corfu-auto-delay 0.5)
 
@@ -1911,6 +1921,7 @@ targets."
   ;; This is recommended since dabbrev can be used globally (M-/).
   :init
   (global-corfu-mode)
+  (corfu-echo-mode)
   :general
   ('corfu-map
    "C-j" 'corfu-next
@@ -1981,14 +1992,19 @@ targets."
   ;; (add-to-list 'completion-at-point-functions #'cape-tex)
   (add-to-list 'completion-at-point-functions #'cape-keyword)
   (add-to-list 'completion-at-point-functions #'cape-dabbrev)
-  ;;(add-to-list 'completion-at-point-functions #'cape-sgml)
-  ;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
-  ;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
+  ;; (add-to-list 'completion-at-point-functions #'cape-sgml)
+  ;; (defvar completion-at-point-functions '(cape-dabbrev cape-keyword cape-file tempel-complete
+  ;;                                                      pcomplete-completions-at-point
+  ;;                                                      ispell-completion-at-point))
+  
+  ;; (add-to-list 'completion-at-point-functions #'cape-rfc1345)
+  ;; (add-to-list 'completion-at-point-functions #'cape-abbrev)
   ;; (add-to-list 'completion-at-point-functions #'cape-ispell)
-  ;;(add-to-list 'completion-at-point-functions #'cape-dict)
-  (add-to-list 'completion-at-point-functions #'cape-symbol)
-  ;;(add-to-list 'completion-at-point-functions #'cape-line)
-  (remove #'cape-ispell completion-at-point-functions)
+  ;; (add-to-list 'completion-at-point-functions #'cape-dict)
+  ;; (add-to-list 'completion-at-point-functions #'cape-symbol)
+  ;; (add-to-list 'completion-at-point-functions #'cape-line)
+  ;; (remove #'cape-ispell completion-at-point-functions)
+  ;; (remove #'cape-symbol completion-at-point-functions)
 
   :config
   (setq cape-dabbrev-min-length 4)  
@@ -2450,6 +2466,10 @@ targets."
 (use-package slint-mode
   :mode "\\.slint\\'")
 
+(defun chris/web-mode-setup ()
+  "some setup for web development"
+  (setq-local completion-at-point-functions
+              (list #'cape-dabbrev #'cape-keyword #'tempel-complete)))
 (use-package web-mode
   :mode "\\.html\\'"
   :config
@@ -2466,13 +2486,13 @@ targets."
         web-mode-enable-auto-closing t
         web-mode-enable-current-column-highlight t
         web-mode-enable-current-element-highlight t)
+  (add-to-list 'web-mode-hook #'chris/web-mode-setup)
 
   :general
   (general-def 'normal web-mode-map
     "TAB" 'indent-according-to-mode)
   (general-def 'insert web-mode-map
-    "TAB" 'indent-according-to-mode)
-  )
+    "TAB" 'indent-according-to-mode))
 
 (use-package lua-mode
   :mode ("\\.lua\\'" . lua-mode))