]> git.donarmstrong.com Git - lib.git/commitdiff
Switch from company to corfu; clean up configuration
authorDon Armstrong <don@donarmstrong.com>
Wed, 19 Jul 2023 05:47:08 +0000 (22:47 -0700)
committerDon Armstrong <don@donarmstrong.com>
Wed, 19 Jul 2023 05:47:08 +0000 (22:47 -0700)
emacs_el/configuration/don-configuration.org

index 160c357db1d5e42e65a142fd10097cfd31061cd7..28cd9532b0d5ad70f2d1c127fe9112f72a1dc997 100644 (file)
 #+END_SRC
 ** Add library paths
 #+BEGIN_SRC emacs-lisp
-(eval-when-compile
+(eval-and-compile
+  (let ((default-directory "~/lib/emacs_el/"))
+    (normal-top-level-add-subdirs-to-load-path))
+  )
+(eval-and-compile
   (let ((default-directory "~/var/emacs/elpa"))
     (normal-top-level-add-subdirs-to-load-path))
   )
-(add-to-list 'load-path '"~/lib/emacs_el/")
-(let ((default-directory "~/lib/emacs_el/"))
-  (normal-top-level-add-subdirs-to-load-path))
-(let ((default-directory "~/var/emacs/elpa"))
-  (normal-top-level-add-subdirs-to-load-path))
-(setq package-user-dir "~/var/emacs/elpa")
+(eval-and-compile
+  (add-to-list 'load-path '"~/lib/emacs_el")
+  )
+(eval-and-compile
+  (setq package-user-dir "~/var/emacs/elpa")
+)
+
 #+END_SRC
 * Initial startup stuff
 ** Disable startup screen
 * Package management
 ** package repositories and package manager
 #+BEGIN_SRC emacs-lisp
-  (require 'use-package)
+(require 'use-package)
 (require 'gnutls)
-  (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
-  (setq package-enable-at-startup nil)
-  (setq package--init-file-ensured t)
-  (setq package-user-dir "~/var/emacs/elpa")
-  (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
-                          ("melpa" . "https://melpa.org/packages/")
-                          ("org" . "http://orgmode.org/elpa/")))
-  (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file)))
-
+(add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
+(use-package package
+  :init
+(setq package-enable-at-startup nil)
+(setq package--init-file-ensured t)
+; (setq package-user-dir "~/var/emacs/elpa")
+(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
+                        ("melpa" . "https://melpa.org/packages/")
+                        ("org" . "http://orgmode.org/elpa/")))
+(setq use-package-verbose (not (bound-and-true-p byte-compile-current-file)))
+)
 #+END_SRC
 ** Paradox
 #+BEGIN_SRC emacs-lisp
   :ensure t
   :defer 1
   :after tree-sitter
-  :config
-  (defun dla/python-function-at-point ()
-    "Return a list of function arguments
-
-Borrowed from https://xenodium.com/emacs-generate-a-swift-initializer/
-"
-  (interactive)
-  (cl-assert (seq-contains local-minor-modes 'tree-sitter-mode) "tree-sitter-mode not enabled")
-  (let* ((node (tree-sitter-node-at-point 'function_definition)
-               )
-         (args)
-         (arg)
-         (ret))
-    (unless node
-      (error "Not in function"))
-    (mapc
-     (lambda (item)
-       (cond ((eq 'func_name
-                  (car item))
-              ; (when arg
-              ;   (setq args (append args (list arg)))
-              ;   )
-              (setq arg (list (cons 'function (tsc-node-text
-                                           (cdr item))))))
-             ((eq 'ident
-                  (car item))
-              (setq arg (map-insert arg 'ident (tsc-node-text
-                                               (cdr item)))))
-             ((eq 'ident_type
-                  (car item))
-              (setq arg (map-insert arg 'ident_type (tsc-node-text
-                                               (cdr item)))))
-             ((eq 'ret_type
-                  (car item))
-              (setq arg (map-insert arg 'ret_type (tsc-node-text
-                                               (cdr item)))))
-             ))
-     (tsc-query-captures
-      (tsc-make-query tree-sitter-language
-                      "(function_definition (identifier) @func_name (parameters [(identifier) @ident (typed_parameter (identifier) @ident (type) @ident_type)]) (type)? @ret_type)")
-      (tree-sitter-node-at-point 'function_definition) nil))
-    (when arg
-      (setq args (append args (list arg))))
-    args))
+  :config
+  (defun dla/python-function-at-point ()
+    "Return a list of function arguments
+; 
+Borrowed from https://xenodium.com/emacs-generate-a-swift-initializer/
+"
+  (interactive)
+;   (cl-assert (seq-contains-p local-minor-modes 'tree-sitter-mode) "tree-sitter-mode not enabled")
+  (let* ((node (tree-sitter-node-at-point 'function_definition)
+               )
+         (args)
+         (arg)
+         (ret))
+    (unless node
+      (error "Not in function"))
+    (mapc
+     (lambda (item)
+       (cond ((eq 'func_name
+                  (car item))
+              ; (when arg
+              ;   (setq args (append args (list arg)))
+              ;   )
+              (setq arg (list (cons 'function (tsc-node-text
+                                           (cdr item))))))
+             ((eq 'ident
+                  (car item))
+              (setq arg (map-insert arg 'ident (tsc-node-text
+                                               (cdr item)))))
+             ((eq 'ident_type
+                  (car item))
+              (setq arg (map-insert arg 'ident_type (tsc-node-text
+                                               (cdr item)))))
+             ((eq 'ret_type
+                  (car item))
+              (setq arg (map-insert arg 'ret_type (tsc-node-text
+                                               (cdr item)))))
+             ))
+     (tsc-query-captures
+      (tsc-make-query tree-sitter-language
+                      "(function_definition (identifier) @func_name (parameters [(identifier) @ident (typed_parameter (identifier) @ident (type) @ident_type)]) (type)? @ret_type)")
+      (tree-sitter-node-at-point 'function_definition) nil))
+    (when arg
+      (setq args (append args (list arg))))
+    args))
 
 )
 #+END_SRC
 ** Spacemacs theme
 #+BEGIN_SRC emacs-lisp
-(use-package spacemacs-common
-  :ensure spacemacs-theme
+(use-package spacemacs-theme
   :config
   (load-theme 'spacemacs-dark t)
   )
@@ -468,7 +474,24 @@ value, scrolling continues until there is no more output.
   :defer t
   :commands (lsp lsp-deferred)
   :init (setq lsp-keymap-prefix "C-c l")
-  :hook (python-mode . lsp-deferred))
+  (defun my/orderless-dispatch-flex-first (_pattern index _total)
+    (and (eq index 0) 'orderless-flex))
+
+  (defun my/lsp-mode-setup-completion ()
+    (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
+          '(orderless)))
+
+  ;; Optionally configure the first word as flex filtered.
+  (add-hook 'orderless-style-dispatchers #'my/orderless-dispatch-flex-first nil 'local)
+
+  ;; Optionally configure the cape-capf-buster.
+  ; (setq-local completion-at-point-functions (list (cape-capf-buster #'lsp-completion-at-point)))
+
+  :hook (python-mode . lsp-deferred)
+  (lsp-completion-mode . my/lsp-mode-setup-completion)
+  :custom
+  (lsp-completion-provider :none) ;; we use Corfu!
+)
 ;; Provides visual help in the buffer 
 ;; For example definitions on hover. 
 ;; The `imenu` lets me browse definitions quickly.
@@ -496,264 +519,75 @@ value, scrolling continues until there is no more output.
   :hook ((python-mode . (lambda () 
                           (require 'lsp-pyright) (lsp-deferred)))))
 #+END_SRC
-** Company
-#+BEGIN_SRC emacs-lisp
-(use-package company
-  :ensure t
-  :bind (("M-/" . company-complete))
-  :config
-  (setq company-echo-delay 0     ; remove blinking
-        company-show-numbers t   ; show numbers for easy selection
-        company-selection-wrap-around t
-        company-require-match nil
-        company-dabbrev-ignore-case t
-        company-dabbrev-ignore-invisible t
-        company-dabbrev-other-buffers t
-        company-dabbrev-downcase nil
-        company-dabbrev-code-everywhere t
-        company-tooltip-align-annotations t
-        company-minimum-prefix-length 1
-        company-global-modes '(not)
-        company-lighter-base "(C)")
-  (setq company-backends '(company-capf
-                           company-keywords
-                           company-semantic
-                           company-files
-                           company-etags
-                           company-elisp
-                           company-clang
-                           company-irony-c-headers
-                           company-irony
-                           company-jedi
-                           company-cmake
-                           company-ispell
-                           company-yasnippet))
-  (global-company-mode 1)
-  :bind (:map company-active-map
-              ("C-n" . company-select-next)
-              ("C-p" . company-select-previous)
-              ("M-?" . company-show-doc-buffer)
-              ("M-." . company-show-location)
-              )
-  )
-#+END_SRC
-*** C/C++
-#+BEGIN_SRC emacs-lisp
-(use-package company-c-headers
-  :ensure t
-  :config (progn
-            (defun malb/ede-object-system-include-path ()
-              "Return the system include path for the current buffer."
-              (when ede-object
-                (ede-system-include-path ede-object)))
-
-            (setq company-c-headers-path-system
-                  #'malb/ede-object-system-include-path)))
-#+END_SRC
-*** Python
+** Corfu
 #+BEGIN_SRC emacs-lisp
-(use-package company-jedi
+(use-package corfu
   :ensure t
-  :hook (python-mode  . 'jedi:setup)
-  :config
-  (setq jedi:complete-on-dot t)
-  )
-#+END_SRC
-*** Perl
-#+BEGIN_SRC emacs-lisp
-  (use-package company-plsense
-    :ensure t
-    )
-#+END_SRC
-*** LaTeX
-#+BEGIN_SRC emacs-lisp
-  (use-package company-math
-    :ensure t)
-#+END_SRC
-#+BEGIN_SRC emacs-lisp
-  (use-package company-auctex
-    :ensure t
-    :config (progn
-              (defun company-auctex-labels (command &optional arg &rest ignored)
-                "company-auctex-labels backend"
-                (interactive (list 'interactive))
-                (case command
-                  (interactive (company-begin-backend 'company-auctex-labels))
-                  (prefix (company-auctex-prefix "\\\\.*ref{\\([^}]*\\)\\="))
-                  (candidates (company-auctex-label-candidates arg))))
-
-              (add-to-list 'company-backends
-                           '(company-auctex-macros
-                             company-auctex-environments
-                             company-math-symbols-unicode
-                             company-math-symbols-latex))
-
-              (add-to-list 'company-backends #'company-auctex-labels)
-              (add-to-list 'company-backends #'company-auctex-bibs)
-              )
-    )
-#+END_SRC
-**** Bibtex
-#+BEGIN_SRC emacs-lisp
-  (use-package company-bibtex
-    :ensure t
-    )
+  ;; Optional customizations
+  :custom
+  (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
+  (corfu-auto t)                 ;; Enable auto completion
+  (corfu-separator ?\s)          ;; Orderless field separator
+  (corfu-quit-at-boundary nil)   ;; Never quit at completion boundary
+  (corfu-quit-no-match nil)      ;; Never quit, even if there is no match
+  (corfu-preview-current nil)    ;; Disable current candidate preview
+  (corfu-preselect 'prompt)      ;; Preselect the prompt
+  (corfu-on-exact-match nil)     ;; Configure handling of exact matches
+  (corfu-scroll-margin 5)        ;; Use scroll margin
+
+  ;; Enable Corfu only for certain modes.
+  ;; :hook ((prog-mode . corfu-mode)
+  ;;        (shell-mode . corfu-mode)
+  ;;        (eshell-mode . corfu-mode))
+
+  ;; Recommended: Enable Corfu globally.
+  ;; This is recommended since Dabbrev can be used globally (M-/).
+  ;; See also `corfu-exclude-modes'.
+  :init
+  (global-corfu-mode))
 #+END_SRC
-*** Shell
-
+** Dabbrv
 #+BEGIN_SRC emacs-lisp
-(use-package company-shell
+(use-package dabbrev
   :ensure t
-  :config (progn
-            (setq company-shell-modes '(sh-mode shell-mode))
-            (add-to-list 'company-backends 'company-shell)))
-#+END_SRC
-
-*** YaSnippet
-
-Add YasSippet support for all company backends. ([[https://github.com/syl20bnr/spacemacs/pull/179][source]])
-
-*Note:* Do this at the end of =company-mode= config.
-
-#+BEGIN_SRC emacs-lisp
-(defvar malb/company-mode/enable-yas t
-  "Enable yasnippet for all backends.")
-
-(defun malb/company-mode/backend-with-yas (backend)
-  (if (or (not malb/company-mode/enable-yas)
-          (and (listp backend)
-               (member 'company-yasnippet backend)))
-      backend
-    (append (if (consp backend) backend (list backend))
-            '(:with company-yasnippet))))
-
-(setq company-backends
-      (mapcar #'malb/company-mode/backend-with-yas company-backends))
-#+END_SRC
-
-*** All the words
-
-Enable/disable company completion from ispell dictionaries ([[https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-company.el][source]])
-
-#+BEGIN_SRC emacs-lisp
-(defun malb/toggle-company-ispell ()
-  (interactive)
-  (cond
-   ((member '(company-ispell :with company-yasnippet) company-backends)
-    (setq company-backends (delete '(company-ispell :with company-yasnippet) company-backends))
-    (add-to-list 'company-backends '(company-dabbrev :with company-yasnippet) t)
-    (message "company-ispell disabled"))
-   (t
-    (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
-    (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
-    (message "company-ispell enabled!"))))
-
-(defun malb/company-ispell-setup ()
-  ;; @see https://github.com/company-mode/company-mode/issues/50
-  (when (boundp 'company-backends)
-    (make-local-variable 'company-backends)
-    (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
-    (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
-    ;; https://github.com/redguardtoo/emacs.d/issues/473
-    (if (and (boundp 'ispell-alternate-dictionary)
-             ispell-alternate-dictionary)
-        (setq company-ispell-dictionary ispell-alternate-dictionary))))
-#+END_SRC
-
-*** Tab DWIM
-
- 1. =yas-expand= is run first and does what it has to, then it calls =malb/indent-fold-or-complete=.
-
- 2. This function then hopefully does what I want:
-
-    a. if a region is active, just indent
-    b. if we’re looking at a space after a non-whitespace character, we try some company-expansion
-    c. If =hs-minor-mode= or =outline-minor-mode= is active, try those next
-    d. otherwise call whatever would have been called otherwise.
-
- ([[http://emacs.stackexchange.com/q/21182/8930][source]], [[http://emacs.stackexchange.com/q/7908/8930][source]])
-
-#+BEGIN_SRC emacs-lisp
-(defun malb/indent-fold-or-complete (&optional arg)
-  (interactive "P")
-  (cond
-   ;; if a region is active, indent
-   ((use-region-p)
-    (indent-region (region-beginning)
-                   (region-end)))
-   ;; if the next char is space or eol, but prev char not whitespace
-   ((and (not (active-minibuffer-window))
-         (or (looking-at " ")
-             (looking-at "$"))
-         (looking-back "[^[:space:]]")
-         (not (looking-back "^")))
-
-    (cond (company-mode (company-complete-common))
-          (auto-complete-mode (auto-complete))))
-
-   ;; no whitespace anywhere
-   ((and (not (active-minibuffer-window))
-         (looking-at "[^[:space:]]")
-         (looking-back "[^[:space:]]")
-         (not (looking-back "^")))
-    (cond
-     ((bound-and-true-p hs-minor-mode)
-      (save-excursion (end-of-line) (hs-toggle-hiding)))
-     ((bound-and-true-p outline-minor-mode)
-      (save-excursion (outline-cycle)))))
-
-   ;; by default just call whatever was bound
-   (t
-    (let ((fn (or (if (current-local-map) (lookup-key (current-local-map) (kbd "TAB")))
-                  'indent-for-tab-command)))
-      (if (not (called-interactively-p 'any))
-          (fn arg)
-        (setq this-command fn)
-        (call-interactively fn))))))
-
-(defun malb/toggle-fold ()
-  (interactive)
-  (cond ((eq major-mode 'org-mode)
-         (org-force-cycle-archived))
-        ((bound-and-true-p hs-minor-mode)
-         (save-excursion
-           (end-of-line)
-           (hs-toggle-hiding)))
-
-        ((bound-and-true-p outline-minor-mode)
-         (save-excursion
-           (outline-cycle)))))
-
-(bind-key "<tab>" 'malb/indent-fold-or-complete)
-(bind-key "C-<tab>" 'malb/toggle-fold)
+  ;; Swap M-/ and C-M-/
+  :bind (("M-/" . dabbrev-completion)
+         ("C-M-/" . dabbrev-expand))
+  ;; Other useful Dabbrev configurations.
+  :custom
+  (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
 #+END_SRC
 ** Tinyprocmail
 
 #+BEGIN_SRC emacs-lisp
-  ;; load tinyprocmail
-  (use-package tinyprocmail
-    :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
-    :mode (".procmailrc" . turn-on-tinyprocmail-mode)
-    )
+;; load tinyprocmail
+(use-package tinyprocmail
+  :defer t
+  :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
+  :mode (".procmailrc" . turn-on-tinyprocmail-mode)
+  )
 #+END_SRC
 
 ** Magit
 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
-  (use-package magit
-    :ensure t
-    :bind (("C-x g" . magit-status)
-           ("C-x C-g" . magit-status))
-    :config
-    ;; refine diffs always (hilight words)
-    (setq magit-diff-refine-hunk nil)
-    )
-  (use-package magit-annex
-    :ensure t
-    :load-path "~/lib/emacs_el/magit-annex/"
-    )
-  (use-package magit-vcsh
-    :ensure t
-    )
+(use-package magit
+  :ensure t
+  :defer t
+  :bind (("C-x g" . magit-status)
+         ("C-x C-g" . magit-status))
+  :config
+  ;; refine diffs always (hilight words)
+  (setq magit-diff-refine-hunk nil)
+  )
+(use-package magit-annex
+  :ensure t
+  :defer t
+  :load-path "~/lib/emacs_el/magit-annex/"
+  )
+(use-package magit-vcsh
+  :ensure t
+  :defer t
+  )
 #+END_SRC
 
 *** Forge (github/gitlab)
@@ -853,8 +687,13 @@ Attempts to automatically identify the right indentation for a file
 #+BEGIN_SRC emacs-lisp
 (use-package vertico
   :ensure t
-  :init
+  :demand t
+  :config
   (vertico-mode)
+  ; (define-key vertico-map "\r" #'vertico-directory-enter)
+  ; (define-key vertico-map "\d" #'vertico-directory-delete-char)
+  ; (define-key vertico-map "\M-\d" #'vertico-directory-delete-word)
+  ; (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
 
   ;; Different scroll margin
   ;; (setq vertico-scroll-margin 0)
@@ -870,7 +709,13 @@ Attempts to automatically identify the right indentation for a file
   :custom
   (vertico-grid-separator "       ")
   (vertico-grid-lookahead 50)
-  (vertico-multiform-categories
+  )
+(use-package vertico-multiform
+  :after vertico
+  :config
+  ;(vertico-multiform-mode)
+  :custom
+    (vertico-multiform-categories
    '((file reverse)
      (consult-grep buffer)
      (consult-location)
@@ -886,13 +731,8 @@ Attempts to automatically identify the right indentation for a file
      (consult-flycheck)
      (consult-lsp-diagnostics)
      ))
-  :config
-  (vertico-multiform-mode)
-  (define-key vertico-map "\r" #'vertico-directory-enter)
-  (define-key vertico-map "\d" #'vertico-directory-delete-char)
-  (define-key vertico-map "\M-\d" #'vertico-directory-delete-word)
-  (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
   )
+  
 
 ;; Persist history over Emacs restarts. Vertico sorts by history position.
 (use-package savehist
@@ -917,8 +757,7 @@ Attempts to automatically identify the right indentation for a file
 #+begin_src emacs-lisp
 (use-package marginalia
   :ensure t
-  :bind (("M-A" . marginalia-cycle)
-         :map minibuffer-local-map
+  :bind (:map minibuffer-local-map
          ("M-A" . marginalia-cycle))
   :init
   (marginalia-mode)
@@ -956,24 +795,27 @@ Attempts to automatically identify the right indentation for a file
 #+begin_src emacs-lisp
 (use-package consult
   ;; Replace bindings. Lazily loaded due by `use-package'.
-  :bind (;; C-c bindings (mode-specific-map)
+  :bind (;; C-c bindings in `mode-specific-map'
+         ("C-c M-x" . consult-mode-command)
          ("C-c h" . consult-history)
-         ("C-c m" . consult-mode-command)
          ("C-c k" . consult-kmacro)
-         ;; C-x bindings (ctl-x-map)
+         ("C-c m" . consult-man)
+         ("C-c i" . consult-info)
+         ([remap Info-search] . consult-info)
+         ;; C-x bindings in `ctl-x-map'
          ("C-x M-:" . consult-complex-command)     ;; orig. repeat-complex-command
          ("C-x b" . consult-buffer)                ;; orig. switch-to-buffer
          ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
          ("C-x 5 b" . consult-buffer-other-frame)  ;; orig. switch-to-buffer-other-frame
          ("C-x r b" . consult-bookmark)            ;; orig. bookmark-jump
-         ("C-x p b" . consult-project-buffer)      ;; orig. project-switch-to-buffer
+         ("C-x p b" . consult-project-buffer)      ;; orig. project-switch-to-buffer
          ;; Custom M-# bindings for fast register access
          ("M-#" . consult-register-load)
          ("M-'" . consult-register-store)          ;; orig. abbrev-prefix-mark (unrelated)
          ("C-M-#" . consult-register)
          ;; Other custom bindings
          ("M-y" . consult-yank-pop)                ;; orig. yank-pop
-         ;; M-g bindings (goto-map)
+         ;; M-g bindings in `goto-map'
          ("M-g e" . consult-compile-error)
          ("M-g f" . consult-flymake)               ;; Alternative: consult-flycheck
          ("M-g g" . consult-goto-line)             ;; orig. goto-line
@@ -983,7 +825,7 @@ Attempts to automatically identify the right indentation for a file
          ("M-g k" . consult-global-mark)
          ("M-g i" . consult-imenu)
          ("M-g I" . consult-imenu-multi)
-         ;; M-s bindings (search-map)
+         ;; M-s bindings in `search-map'
          ("M-s d" . consult-find)
          ("M-s D" . consult-locate)
          ("M-s g" . consult-grep)
@@ -1033,22 +875,22 @@ Attempts to automatically identify the right indentation for a file
   ;; Optionally configure preview. The default value
   ;; is 'any, such that any key triggers the preview.
   ;; (setq consult-preview-key 'any)
-  ;; (setq consult-preview-key (kbd "M-."))
-  ;; (setq consult-preview-key (list (kbd "<S-down>") (kbd "<S-up>")))
+  ;; (setq consult-preview-key "M-.")
+  ;; (setq consult-preview-key '("S-<down>" "S-<up>"))
   ;; For some commands and buffer sources it is useful to configure the
   ;; :preview-key on a per-command basis using the `consult-customize' macro.
   (consult-customize
    consult-theme :preview-key '(:debounce 0.2 any)
    consult-ripgrep consult-git-grep consult-grep
-   consult-bookmark consult-recent-file consult-xref
+   consult-bookmark consult-recent-file consult-xref
    consult--source-bookmark consult--source-file-register
    consult--source-recent-file consult--source-project-recent-file
-   ;; :preview-key (kbd "M-.")
+   ;; :preview-key "M-."
    :preview-key '(:debounce 0.4 any))
 
   ;; Optionally configure the narrowing key.
   ;; Both < and C-+ work reasonably well.
-  (setq consult-narrow-key "<") ;; (kbd "C-+")
+  (setq consult-narrow-key "<") ;; "C-+"
 
   ;; Optionally make narrowing help available in the minibuffer.
   ;; You may want to use `embark-prefix-help-command' or which-key instead.
@@ -1056,16 +898,17 @@ Attempts to automatically identify the right indentation for a file
 
   ;; By default `consult-project-function' uses `project-root' from project.el.
   ;; Optionally configure a different project root function.
-  ;; There are multiple reasonable alternatives to chose from.
   ;;;; 1. project.el (the default)
   ;; (setq consult-project-function #'consult--default-project--function)
-  ;;;; 2. projectile.el (projectile-project-root)
-  ;; (autoload 'projectile-project-root "projectile")
-  ;; (setq consult-project-function (lambda (_) (projectile-project-root)))
-  ;;;; 3. vc.el (vc-root-dir)
+  ;;;; 2. vc.el (vc-root-dir)
   ;; (setq consult-project-function (lambda (_) (vc-root-dir)))
-  ;;;; 4. locate-dominating-file
+  ;;;; 3. locate-dominating-file
   ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
+  ;;;; 4. projectile.el (projectile-project-root)
+  ;; (autoload 'projectile-project-root "projectile")
+  ;; (setq consult-project-function (lambda (_) (projectile-project-root)))
+  ;;;; 5. No project support
+  ;; (setq consult-project-function nil)
 )
 #+end_src
 ** Projectile -- Project management
@@ -1531,7 +1374,6 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
   :hook
   (python-mode . pyenv-mode)
   (python-mode . flycheck-mode)
-  (python-mode . company-mode)
   (python-mode . blacken-mode)
   (python-mode . yas-minor-mode)
   (python-mode . anaconda-mode)
@@ -1818,16 +1660,16 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
   (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
   (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
   ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
-  (defun org-agenda-timeline-all (&optional arg)
-    (interactive "P")
-    (with-temp-buffer
-      (dolist (org-agenda-file org-agenda-files)
-        (insert-file-contents org-agenda-file nil)
-        (goto-char (point-max))
-        (newline))
-      (write-file "/tmp/timeline.org")
-      (org-agenda arg "L")))
-  (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
+  (defun org-agenda-timeline-all (&optional arg)
+    (interactive "P")
+    (with-temp-buffer
+      (dolist (org-agenda-file org-agenda-files)
+        (insert-file-contents org-agenda-file nil)
+        (goto-char (point-max))
+        (newline))
+      (write-file "/tmp/timeline.org")
+      (org-agenda arg "L")))
+  (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
 
 #+END_SRC
 ** General config
@@ -2990,7 +2832,7 @@ emacs, and use a different desktop file to restore history
           (or (getenv "EMACS_SERVER_NAME")
               "server"))
     (unless (server-running-p)
-      (global-set-key "\C-xp" 'server-edit)
+      (global-set-key "\C-xp" 'server-edit)
       (server-start)))
 #+END_SRC
 
@@ -2998,5 +2840,5 @@ emacs, and use a different desktop file to restore history
 
 * END
 #+BEGIN_SRC emacs-lisp
-  (provide 'don-configuration)
+(provide 'don-configuration)
 #+END_SRC