~thecatster/.emacs.d

76a9de834a8d73ac570a1758e3b17131c3bd1669 — Daniel Rose 2 years ago 8f1de15
Add windmove keybindings, use EXWM once again
5 files changed, 60 insertions(+), 212 deletions(-)

M emacs.org
M exwm.org
M exwm/exwm_screen_layout
M init.el
M lisp/catsters-exwm.el
M emacs.org => emacs.org +28 -103
@@ 670,25 670,17 @@ The minimal completion engine.
Allows for annotations of commands, files, and more.

#+BEGIN_SRC emacs-lisp
;; Enable richer annotations using the Marginalia package
(use-package marginalia
  ;; Either bind `marginalia-cycle` globally or only in the minibuffer
  :bind (("M-A" . marginalia-cycle)
         :map minibuffer-local-map
         ("M-A" . marginalia-cycle))

  ;; The :init configuration is always executed (Not lazy!)
  :init

  ;; Must be in the :init section of use-package such that the mode gets
  ;; enabled right away. Note that this forces loading the package.
  (marginalia-mode))
#+END_SRC
*** Consult
#+BEGIN_SRC emacs-lisp
;; Example configuration for Consult
(use-package consult
  ;; Replace bindings. Lazily loaded due by `use-package'.
  :bind (;; C-c bindings (mode-specific-map)
         ("C-c h" . consult-history)
         ("C-c m" . consult-mode-command)


@@ 734,49 726,26 @@ Allows for annotations of commands, files, and more.
         ("M-s e" . consult-isearch)               ;; orig. isearch-edit-string
         ("M-s l" . consult-line))                 ;; needed by consult-line to detect isearch

  ;; Enable automatic preview at point in the *Completions* buffer.
  ;; This is relevant when you use the default completion UI,
  ;; and not necessary for Vertico, Selectrum, etc.
  :hook (completion-list-mode . consult-preview-at-point-mode)

  ;; The :init configuration is always executed (Not lazy)
  :init

  ;; Optionally configure the register formatting. This improves the register
  ;; preview for `consult-register', `consult-register-load',
  ;; `consult-register-store' and the Emacs built-ins.
  (setq register-preview-delay 0
        register-preview-function #'consult-register-format)

;; Use `consult-completion-in-region' if Vertico is enabled.
 (add-hook 'vertico-mode-hook (lambda ()
                                (setq completion-in-region-function
                                      (if vertico-mode
                                          #'consult-completion-in-region
                                        #'completion--in-region))))

   ;; Optionally tweak the register preview window.
   ;; This adds thin lines, sorting and hides the mode line of the window.
 (advice-add #'register-preview :override #'consult-register-window)

  ;; Optionally replace `completing-read-multiple' with an enhanced version.
 (advice-add #'completing-read-multiple :override #'consult-completing-read-multiple)

  ;; Use Consult to select xref locations with preview
 (setq xref-show-xrefs-function #'consult-xref
       xref-show-definitions-function #'consult-xref)

  ;; Configure other variables and modes in the :config section,
  ;; after lazily loading the package.
 :config

  ;; 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>")))
  ;; 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)


@@ 785,30 754,14 @@ Allows for annotations of commands, files, and more.
  consult--source-file consult--source-project-file consult--source-bookmark
  :preview-key (kbd "M-."))

  ;; Optionally configure the narrowing key.
  ;; Both < and C-+ work reasonably well.
 (setq consult-narrow-key "<") ;; (kbd "C-+")

  ;; Optionally make narrowing help available in the minibuffer.
  ;; You may want to use `embark-prefix-help-command' or which-key instead.
  ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)

  ;; Optionally configure a function which returns the project root directory.
  ;; There are multiple reasonable alternatives to chose from.
  ;;;; 1. project.el (project-roots)
 (setq consult-project-root-function
       (lambda ()
         (when-let (project (project-current))
           (car (project-roots project))))))
  ;;;; 2. projectile.el (projectile-project-root)
  ;; (autoload 'projectile-project-root "projectile")
  ;; (setq consult-project-root-function #'projectile-project-root)
  ;;;; 3. vc.el (vc-root-dir)
  ;; (setq consult-project-root-function #'vc-root-dir)
  ;;;; 4. locate-dominating-file
  ;; (setq consult-project-root-function (lambda () (locate-dominating-file "." ".git")))

#+END_SRC

*** Embark
#+BEGIN_SRC emacs-lisp
(use-package embark


@@ 818,84 771,56 @@ Allows for annotations of commands, files, and more.
   ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'

  :init

  ;; Optionally replace the key help with a completing-read interface
  (setq prefix-help-command #'embark-prefix-help-command)

  :config

  ;; Hide the mode line of the Embark live/completions buffers
  (add-to-list 'display-buffer-alist
               '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
                 nil
                 (window-parameters (mode-line-format . none)))))

;; Consult users will also want the embark-consult package.
(use-package embark-consult
  :after (embark consult)
  :demand t ; only necessary if you have the hook below
  ;; if you want to have consult previews as you move around an
  ;; auto-updating embark collect buffer
  :demand t
  :hook
  (embark-collect-mode . consult-preview-at-point-mode))
#+END_SRC

*** Corfu
#+BEGIN_SRC emacs-lisp
(use-package corfu
  ;; Optional customizations
  ;; :custom
  ;; (corfu-cycle t)            ;; Enable cycling for `corfu-next/previous'
  ;; (corfu-auto t)             ;; Enable auto completion
  ;; (corfu-quit-at-boundary t) ;; Automatically quit at word boundary
  ;; (corfu-quit-no-match t)    ;; Automatically quit if there is no match

  ;; Optionally use TAB for cycling, default is `corfu-complete'.
  ;; :bind (:map corfu-map
  ;;        ("TAB" . corfu-next)
  ;;        ([tab] . corfu-next)
  ;;        ("S-TAB" . corfu-previous)
  ;;        ([backtab] . corfu-previous))

  ;; You may want to 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-/).
  :custom
  (corfu-cycle t)            ;; Enable cycling for `corfu-next/previous'
  (corfu-auto t)             ;; Enable auto completion
  (corfu-quit-at-boundary t) ;; Automatically quit at word boundary
  (corfu-quit-no-match t)    ;; Automatically quit if there is no match
  :bind (:map corfu-map
          ("TAB" . corfu-next)
          ([tab] . corfu-next)
          ("S-TAB" . corfu-previous)
          ([backtab] . corfu-previous))
  :init
  (corfu-global-mode))

;; Optionally use the `orderless' completion style.
;; Enable `partial-completion' for files to allow path expansion.
;; You may prefer to use `initials' instead of `partial-completion'.
(use-package orderless
  :init
  (setq completion-styles '(orderless)
        completion-category-defaults nil
        completion-category-overrides '((file (styles . (partial-completion))))))

;; Dabbrev works with Corfu
(use-package dabbrev
  ;; Swap M-/ and C-M-/
  :bind (("M-/" . dabbrev-completion)
         ("C-M-/" . dabbrev-expand)))

;; A few more useful configurations...
(use-package emacs
  :init
  ;; TAB cycle if there are only few candidates
  (setq completion-cycle-threshold 3)

  ;; Emacs 28: Hide commands in M-x which do not work in the current mode.
  ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
  ;; (setq read-extended-command-predicate
  ;;       #'command-completion-default-include-p)

  ;; Enable indentation+completion using the TAB key.
  ;; `completion-at-point' is often bound to M-TAB.
  (setq completion-cycle-threshold 3)
  (setq read-extended-command-predicate
         #'command-completion-default-include-p)
  (setq tab-always-indent 'complete))
#+END_SRC

*** Affe
Async fzf in pure Elisp!



@@ 910,6 835,7 @@ Async fzf in pure Elisp!
  ;; Manual preview key for `affe-grep'
  (consult-customize affe-grep :preview-key (kbd "M-.")))
#+END_SRC

** Which Key
Especially when learning the Emacs keybindings, Which Key is quite helpful.



@@ 959,18 885,17 @@ package as well. Great, because it's one of my most used!
  (global-set-key [remap kill-whole-line] #'crux-kill-whole-line))
#+END_SRC

** Ace Window
** Windmove
   Quickly switch between buffers and windows instead of ~C-x o~.

   #+BEGIN_SRC emacs-lisp
     (use-package ace-window
       :bind (("M-o" . ace-window))
       :custom
       (aw-scope 'frame)
       (aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
       (aw-minibuffer-flag t)
       :config
       (ace-window-display-mode 1))
   (use-package windmove
     :bind (:prefix "M-o"
            :prefix-map my-helper-map
            ("h" . windmove-left)
            ("j" . windmove-down)
            ("k" . windmove-up)
            ("l" . windmove-right)))
   #+END_SRC

** No Littering


@@ 1792,6 1717,7 @@ phenomenal, allowing for a proper debugging experience within Emacs
  :config
  (setq  lsp-keymap-prefix "C-c l"
         lsp-eslint-run "onSave"
         lsp-completion-provider :capf
         lsp-log-io nil
         lsp-idle-delay 1
         lsp-headerline-breadcrumb-enable nil))


@@ 2060,7 1986,6 @@ else I'll eventually need.

  (flycheck-add-mode 'typescript-tslint 'web-mode)

  (add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
  (add-hook 'rjsx-mode-hook #'(lambda () (electric-indent-local-mode -1)))
#+END_SRC
*** MIT/GNU Scheme


@@ 2458,7 2383,7 @@ Although EXWM is in another file, I still need to require it in my
main config.

#+BEGIN_SRC emacs-lisp
(setq catster/use-exwm nil)
(setq catster/use-exwm t)

(when catster/use-exwm
   (require 'catsters-exwm))

M exwm.org => exwm.org +1 -1
@@ 856,7 856,7 @@ Below is my main configuration for EXWM, with 10 workspaces (0-9).
            ;; (,(kbd "s-g") . )
            ;; (,(kbd "s-g") . )
            (,(kbd "s-g") . grep) ;; Grep search in files
            (,(kbd "s-d") . app-launcher) ;; Start an application using dmenu
            (,(kbd "s-d") . app-launcher-run-app) ;; Start an application using dmenu
            ;; (,(kbd "s-W") . )
            (,(kbd "s-m") . (lambda () ;; Toggle display of mode-line and minibuffer, in an EXWM window
                              (interactive)

M exwm/exwm_screen_layout => exwm/exwm_screen_layout +7 -5
@@ 4,13 4,13 @@
# by X11_SCREEN_PREFERRED and that screen is available.
# The primary screen is the default screen used for EXWM workspaces.
# It will also be sorted first in Xinerama and RANDR geometry requests.
export X11_SCREEN_LIST="eDP1 HDMI1"
export X11_SCREEN_LIST="eDP1 HDMI1 DP1-1"
# xrandr --mode for each screen in X11_SCREEN_LIST
export X11_SCREEN_MODE_LIST="1920x1080 1920x1080"
export X11_SCREEN_MODE_LIST="1920x1080 1920x1080 1920x1080"
# xrandr --rate for each screen in X11_SCREEN_LIST
export X11_SCREEN_RATE_LIST="60.00 60.00"
export X11_SCREEN_RATE_LIST="60.00 60.00 60.00"
# How screens are arranged from left to right. Vertical order, and "--same-as" not yet implemented.
export X11_SCREEN_ORDER_LIST="eDP1 HDMI1"
export X11_SCREEN_ORDER_LIST="eDP1 HDMI1 DP1-1"
# X11 screens (graphics outputs) that should always be explicitly turned off, if available.
export X11_SCREEN_DISABLED_LIST="VIRTUAL1"
# Primary X11 screen, if available


@@ 27,5 27,7 @@ export X11_DISPLAY_DPI=96
# List of pairs "workspace-number screen"
# Used to construct exwm-randr-workspace-monitor-plist in emacs.
# If a screen in this list is unavailable, the workspace will be mapped to the primary screen.
# When not using the dock, use the following:
# export EXWM_WORKSPACE_LIST="0 eDP1 1 HDMI1 2 eDP1 3 HDMI1 4 eDP1 5 HDMI1 6 eDP1 7 HDMI1 8 eDP1 9 HDMI1"
# When using the dock, use the following:
export EXWM_WORKSPACE_LIST="0 eDP1 1 HDMI1 2 eDP1 3 HDMI1 4 eDP1 5 HDMI1 6 eDP1 7 HDMI1 8 eDP1 9 HDMI1"
export EXWM_WORKSPACE_LIST="0 eDP1 1 DP1-1 2 eDP1 3 DP1-1 4 eDP1 5 DP1-1 6 eDP1 7 DP1-1 8 eDP1 9 DP1-1"

M init.el => init.el +23 -102
@@ 386,23 386,15 @@

  (setq enable-recursive-minibuffers t))

;; Enable richer annotations using the Marginalia package
(use-package marginalia
  ;; Either bind `marginalia-cycle` globally or only in the minibuffer
  :bind (("M-A" . marginalia-cycle)
         :map minibuffer-local-map
         ("M-A" . marginalia-cycle))

  ;; The :init configuration is always executed (Not lazy!)
  :init

  ;; Must be in the :init section of use-package such that the mode gets
  ;; enabled right away. Note that this forces loading the package.
  (marginalia-mode))

;; Example configuration for Consult
(use-package consult
  ;; Replace bindings. Lazily loaded due by `use-package'.
  :bind (;; C-c bindings (mode-specific-map)
         ("C-c h" . consult-history)
         ("C-c m" . consult-mode-command)


@@ 448,49 440,26 @@
         ("M-s e" . consult-isearch)               ;; orig. isearch-edit-string
         ("M-s l" . consult-line))                 ;; needed by consult-line to detect isearch

  ;; Enable automatic preview at point in the *Completions* buffer.
  ;; This is relevant when you use the default completion UI,
  ;; and not necessary for Vertico, Selectrum, etc.
  :hook (completion-list-mode . consult-preview-at-point-mode)

  ;; The :init configuration is always executed (Not lazy)
  :init

  ;; Optionally configure the register formatting. This improves the register
  ;; preview for `consult-register', `consult-register-load',
  ;; `consult-register-store' and the Emacs built-ins.
  (setq register-preview-delay 0
        register-preview-function #'consult-register-format)

;; Use `consult-completion-in-region' if Vertico is enabled.
 (add-hook 'vertico-mode-hook (lambda ()
                                (setq completion-in-region-function
                                      (if vertico-mode
                                          #'consult-completion-in-region
                                        #'completion--in-region))))

   ;; Optionally tweak the register preview window.
   ;; This adds thin lines, sorting and hides the mode line of the window.
 (advice-add #'register-preview :override #'consult-register-window)

  ;; Optionally replace `completing-read-multiple' with an enhanced version.
 (advice-add #'completing-read-multiple :override #'consult-completing-read-multiple)

  ;; Use Consult to select xref locations with preview
 (setq xref-show-xrefs-function #'consult-xref
       xref-show-definitions-function #'consult-xref)

  ;; Configure other variables and modes in the :config section,
  ;; after lazily loading the package.
 :config

  ;; 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>")))
  ;; 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)


@@ 499,28 468,11 @@
  consult--source-file consult--source-project-file consult--source-bookmark
  :preview-key (kbd "M-."))

  ;; Optionally configure the narrowing key.
  ;; Both < and C-+ work reasonably well.
 (setq consult-narrow-key "<") ;; (kbd "C-+")

  ;; Optionally make narrowing help available in the minibuffer.
  ;; You may want to use `embark-prefix-help-command' or which-key instead.
  ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)

  ;; Optionally configure a function which returns the project root directory.
  ;; There are multiple reasonable alternatives to chose from.
  ;;;; 1. project.el (project-roots)
 (setq consult-project-root-function
       (lambda ()
         (when-let (project (project-current))
           (car (project-roots project))))))
  ;;;; 2. projectile.el (projectile-project-root)
  ;; (autoload 'projectile-project-root "projectile")
  ;; (setq consult-project-root-function #'projectile-project-root)
  ;;;; 3. vc.el (vc-root-dir)
  ;; (setq consult-project-root-function #'vc-root-dir)
  ;;;; 4. locate-dominating-file
  ;; (setq consult-project-root-function (lambda () (locate-dominating-file "." ".git")))

(use-package embark
  :bind


@@ 529,80 481,50 @@
   ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'

  :init

  ;; Optionally replace the key help with a completing-read interface
  (setq prefix-help-command #'embark-prefix-help-command)

  :config

  ;; Hide the mode line of the Embark live/completions buffers
  (add-to-list 'display-buffer-alist
               '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
                 nil
                 (window-parameters (mode-line-format . none)))))

;; Consult users will also want the embark-consult package.
(use-package embark-consult
  :after (embark consult)
  :demand t ; only necessary if you have the hook below
  ;; if you want to have consult previews as you move around an
  ;; auto-updating embark collect buffer
  :demand t
  :hook
  (embark-collect-mode . consult-preview-at-point-mode))

(use-package corfu
  ;; Optional customizations
  ;; :custom
  ;; (corfu-cycle t)            ;; Enable cycling for `corfu-next/previous'
  ;; (corfu-auto t)             ;; Enable auto completion
  ;; (corfu-quit-at-boundary t) ;; Automatically quit at word boundary
  ;; (corfu-quit-no-match t)    ;; Automatically quit if there is no match

  ;; Optionally use TAB for cycling, default is `corfu-complete'.
  ;; :bind (:map corfu-map
  ;;        ("TAB" . corfu-next)
  ;;        ([tab] . corfu-next)
  ;;        ("S-TAB" . corfu-previous)
  ;;        ([backtab] . corfu-previous))

  ;; You may want to 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-/).
  :custom
  (corfu-cycle t)            ;; Enable cycling for `corfu-next/previous'
  (corfu-auto t)             ;; Enable auto completion
  (corfu-quit-at-boundary t) ;; Automatically quit at word boundary
  (corfu-quit-no-match t)    ;; Automatically quit if there is no match
  :bind (:map corfu-map
          ("TAB" . corfu-next)
          ([tab] . corfu-next)
          ("S-TAB" . corfu-previous)
          ([backtab] . corfu-previous))
  :init
  (corfu-global-mode))

;; Optionally use the `orderless' completion style.
;; Enable `partial-completion' for files to allow path expansion.
;; You may prefer to use `initials' instead of `partial-completion'.
(use-package orderless
  :init
  (setq completion-styles '(orderless)
        completion-category-defaults nil
        completion-category-overrides '((file (styles . (partial-completion))))))

;; Dabbrev works with Corfu
(use-package dabbrev
  ;; Swap M-/ and C-M-/
  :bind (("M-/" . dabbrev-completion)
         ("C-M-/" . dabbrev-expand)))

;; A few more useful configurations...
(use-package emacs
  :init
  ;; TAB cycle if there are only few candidates
  (setq completion-cycle-threshold 3)

  ;; Emacs 28: Hide commands in M-x which do not work in the current mode.
  ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
  ;; (setq read-extended-command-predicate
  ;;       #'command-completion-default-include-p)

  ;; Enable indentation+completion using the TAB key.
  ;; `completion-at-point' is often bound to M-TAB.
  (setq completion-cycle-threshold 3)
  (setq read-extended-command-predicate
         #'command-completion-default-include-p)
  (setq tab-always-indent 'complete))

(use-package affe


@@ 648,14 570,13 @@
  (global-set-key (kbd "C-<backspace>") #'crux-kill-line-backwards)
  (global-set-key [remap kill-whole-line] #'crux-kill-whole-line))

(use-package ace-window
  :bind (("M-o" . ace-window))
  :custom
  (aw-scope 'frame)
  (aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
  (aw-minibuffer-flag t)
  :config
  (ace-window-display-mode 1))
(use-package windmove
  :bind (:prefix "M-o"
         :prefix-map my-helper-map
         ("h" . windmove-left)
         ("j" . windmove-down)
         ("k" . windmove-up)
         ("l" . windmove-right)))

(use-package no-littering
  :config


@@ 1245,6 1166,7 @@
  :config
  (setq  lsp-keymap-prefix "C-c l"
         lsp-eslint-run "onSave"
         lsp-completion-provider :capf
         lsp-log-io nil
         lsp-idle-delay 1
         lsp-headerline-breadcrumb-enable nil))


@@ 1442,7 1364,6 @@

(flycheck-add-mode 'typescript-tslint 'web-mode)

(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
(add-hook 'rjsx-mode-hook #'(lambda () (electric-indent-local-mode -1)))

(use-package geiser-mit)


@@ 1749,7 1670,7 @@
      (if (and b e (< (point) e)) (setq rlt nil)))
    (setq ad-return-value rlt)))

(setq catster/use-exwm nil)
(setq catster/use-exwm t)

(when catster/use-exwm
   (require 'catsters-exwm))

M lisp/catsters-exwm.el => lisp/catsters-exwm.el +1 -1
@@ 330,7 330,7 @@ See also `process-lines'."
            ;; (,(kbd "s-g") . )
            ;; (,(kbd "s-g") . )
            (,(kbd "s-g") . grep) ;; Grep search in files
            (,(kbd "s-d") . app-launcher) ;; Start an application using dmenu
            (,(kbd "s-d") . app-launcher-run-app) ;; Start an application using dmenu
            ;; (,(kbd "s-W") . )
            (,(kbd "s-m") . (lambda () ;; Toggle display of mode-line and minibuffer, in an EXWM window
                              (interactive)