Emacs : split config for windows environment

This commit is contained in:
2023-04-05 15:16:37 +09:00
parent 9cbb929579
commit c084cff95c
2 changed files with 166 additions and 162 deletions

View File

@ -15,7 +15,7 @@ DesktopNames=exwm
#+begin_src shell #+begin_src shell
#!/bin/sh #!/bin/sh
# Fire it up for WSL # Fire it up for WSL
source ~/scripts/wsl_get_display.sh #source ~/scripts/wsl_get_display.sh
picom -b --config $HOME/.xmonad/scripts/picom.conf & picom -b --config $HOME/.xmonad/scripts/picom.conf &
exec dbus-launch --exit-with-session emacs -mm --debug-init -l ~/.config/emacs/desktop.el exec dbus-launch --exit-with-session emacs -mm --debug-init -l ~/.config/emacs/desktop.el
#+end_src #+end_src
@ -68,108 +68,104 @@ DesktopNames=exwm
(exwm-floating-move (- pos-x) (- pos-y)))) (exwm-floating-move (- pos-x) (- pos-y))))
(use-package exwm (use-package exwm
:ensure t) :config
;; Set the default number of workspaces
(setq exwm-workspace-number 10)
;;(use-package exwm ;; When window "class" updates, use it to set the buffer name
;; :config (add-hook 'exwm-update-class-hook #'efs/exwm-update-class)
;; ;; Set the default number of workspaces
;; (setq exwm-workspace-number 10)
;; ;; When window "class" updates, use it to set the buffer name ;; When window title updates, use it to set the buffer name
;; (add-hook 'exwm-update-class-hook #'efs/exwm-update-class) (add-hook 'exwm-update-title-hook #'efs/exwm-update-title)
;; ;; When window title updates, use it to set the buffer name ;; Configure windows as they're created
;; (add-hook 'exwm-update-title-hook #'efs/exwm-update-title) ;;(add-hook 'exwm-manage-finish-hook #'efs/configure-window-by-class)
;; ;; Configure windows as they're created ;; When EXWM starts up, do some extra confifuration
;; ;;(add-hook 'exwm-manage-finish-hook #'efs/configure-window-by-class) (add-hook 'exwm-init-hook #'efs/exwm-init-hook)
;; ;; When EXWM starts up, do some extra confifuration ;; Automatically send the mouse cursor to the selected workspace's display
;; (add-hook 'exwm-init-hook #'efs/exwm-init-hook) (setq exwm-workspace-warp-cursor t)
;; ;; Automatically send the mouse cursor to the selected workspace's display ;; Window focus should follow the mouse pointer
;; (setq exwm-workspace-warp-cursor t) (setq mouse-autoselect-window t
focus-follows-mouse t)
;; ;; Window focus should follow the mouse pointer (add-hook 'exwm-floating-setup-hook
;; (setq mouse-autoselect-window t (lambda ()
;; focus-follows-mouse t) (exwm-layout-hide-mode-line)))
;; (add-hook 'exwm-floating-setup-hook ;; These keys should always pass through to Emacs
;; (lambda () (setq exwm-input-prefix-keys
;; (exwm-layout-hide-mode-line))) '(?\C-x
?\C-u
?\C-h
?\M-x
?\M-`
?\M-&
?\M-:
?\C-\M-j ;; Buffer list
?\C-\ )) ;; Ctrl+Space
;; ;; These keys should always pass through to Emacs ;; Ctrl+Q will enable the next key to be sent directly
;; (setq exwm-input-prefix-keys (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)
;; '(?\C-x
;; ?\C-u
;; ?\C-h
;; ?\M-x
;; ?\M-`
;; ?\M-&
;; ?\M-:
;; ?\C-\M-j ;; Buffer list
;; ?\C-\ )) ;; Ctrl+Space
;; ;; Ctrl+Q will enable the next key to be sent directly ;; Set up global key bindings. These always work, no matter the input state!
;; (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key) ;; Keep in mind that changing this list after EXWM initializes has no effect.
(setq exwm-input-global-keys
`(
;; Reset to line-mode (C-c C-k switches to char-mode via exwm-input-release-keyboard)
([?\s-r] . exwm-reset)
;; ;; Set up global key bindings. These always work, no matter the input state! ;; Move between windows
;; ;; Keep in mind that changing this list after EXWM initializes has no effect. ([?\s-h] . windmove-left)
;; (setq exwm-input-global-keys ([?\s-l] . windmove-right)
;; `( ([?\s-k] . windmove-up)
;; ;; Reset to line-mode (C-c C-k switches to char-mode via exwm-input-release-keyboard) ([?\s-j] . windmove-down)
;; ([?\s-r] . exwm-reset)
;; ;; Move between windows ;;([s-space] . toggle-frame-fullscreen)
;; ([?\s-h] . windmove-left) ([?\s-f] . exwm-floating-toggle-floating)
;; ([?\s-l] . windmove-right)
;; ([?\s-k] . windmove-up)
;; ([?\s-j] . windmove-down)
;; ;;([s-space] . toggle-frame-fullscreen) ;; Launch applications via shell command
;; ([?\s-f] . exwm-floating-toggle-floating) ([?\s-&] . (lambda (command)
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command)))
;; ;; Launch applications via shell command ([?\s-C] . (lambda () (interactive) (kill-buffer)))
;; ([?\s-&] . (lambda (command)
;; (interactive (list (read-shell-command "$ ")))
;; (start-process-shell-command command nil command)))
;; ([?\s-C] . (lambda () (interactive) (kill-buffer))) ;; App
(,(kbd "<s-return>") . vifon/exwm-terminal)
(,(kbd "<s-SPC>") . app-launcher-run-app)
;; Switch workspace
([?\s-w] . exwm-workspace-switch)
([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0)))
;; ;; App ;; 's-N': Switch to certain workspace with Super (Win) plus a number key (0 - 9)
;; (,(kbd "<s-return>") . vifon/exwm-terminal) ,@(mapcar (lambda (i)
;; (,(kbd "<s-SPC>") . app-launcher-run-app) `(,(kbd (format "s-%d" i)) .
;; ;; Switch workspace (lambda ()
;; ([?\s-w] . exwm-workspace-switch) (interactive)
;; ([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0))) (exwm-workspace-switch-create ,i))))
(number-sequence 0 9))))
;; ;; 's-N': Switch to certain workspace with Super (Win) plus a number key (0 - 9) (exwm-enable))
;; ,@(mapcar (lambda (i)
;; `(,(kbd (format "s-%d" i)) .
;; (lambda ()
;; (interactive)
;; (exwm-workspace-switch-create ,i))))
;; (number-sequence 0 9))))
;; (exwm-enable)) if not wsl
(use-package desktop-environment
;; if not wsl :after exwm
;;(use-package desktop-environment :config (desktop-environment-mode)
;; :after exwm :custom
;; :config (desktop-environment-mode) (desktop-environment-brightness-small-increment "2%+")
;; :custom (desktop-environment-brightness-small-decrement "2%-")
;; (desktop-environment-brightness-small-increment "2%+") (desktop-environment-brightness-normal-increment "5%+")
;; (desktop-environment-brightness-small-decrement "2%-") (desktop-environment-brightness-normal-decrement "5%-"))
;; (desktop-environment-brightness-normal-increment "5%+")
;; (desktop-environment-brightness-normal-decrement "5%-"))
;; Make sure the server is started (better to do this in your main Emacs config!) ;; Make sure the server is started (better to do this in your main Emacs config!)
(server-start) (server-start)
#+end_src #+end_src
** Polybar ** Polybar
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle ~/.config/emacs/desktop.el
;;:tangle ~/.config/emacs/desktop.el
(defvar efs/polybar-process nil (defvar efs/polybar-process nil
"Holds the process of the running Polybar instance, if any") "Holds the process of the running Polybar instance, if any")

View File

@ -214,6 +214,7 @@ Emacs Configuration for emacs 29.50
(require 'custom-keybindings) (require 'custom-keybindings)
(require 'custom-default) (require 'custom-default)
(require 'custom-completion) (require 'custom-completion)
(require 'custom-edit)
(require 'custom-projects) (require 'custom-projects)
(require 'custom-latex) (require 'custom-latex)
(require 'custom-org) (require 'custom-org)
@ -405,7 +406,8 @@ emacs built-in package config
#+end_src #+end_src
**** Setting Transparency **** Setting Transparency
***** emacs 28 ***** emacs 28
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes
;;:tangle ~/.config/emacs/modules/custom-ui.el
(set-frame-parameter (selected-frame) 'alpha '(85 . 50)) (set-frame-parameter (selected-frame) 'alpha '(85 . 50))
(add-to-list 'default-frame-alist '(alpha . '(85 . 50))) (add-to-list 'default-frame-alist '(alpha . '(85 . 50)))
(defun toggle-transparency () (defun toggle-transparency ()
@ -445,8 +447,7 @@ emacs built-in package config
(global-set-key (kbd "C-c t") 'toggle-transparency) (global-set-key (kbd "C-c t") 'toggle-transparency)
#+end_src #+end_src
***** emacs 29 ***** emacs 29
#+begin_src emacs-lisp #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
;;:mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(set-frame-parameter nil 'alpha-background 0.9) (set-frame-parameter nil 'alpha-background 0.9)
(add-to-list 'default-frame-alist '(alpha-background . 0.9)) (add-to-list 'default-frame-alist '(alpha-background . 0.9))
(defun toggle-transparency () (defun toggle-transparency ()
@ -907,6 +908,58 @@ Quick Action in minibuffer
(provide 'custom-completion) (provide 'custom-completion)
;;; custom-completion.el ends here ;;; custom-completion.el ends here
#+end_src #+end_src
*** Edit
**** Helpful
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-edit.el
(use-package helpful
:defer t
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable))
;;:commands (helpful-callable helpful-variable helpful-command helpful-key)
(global-set-key [remap describe-function] #'describe-function)
(global-set-key [remap describe-command] #'helpful-command)
(global-set-key [remap describe-variable] #'describe-variable)
(global-set-key [remap describe-key] #'helpful-key)
#+end_src
**** Avy
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-edit.el
(use-package avy
:defer t
:config
(setq avy-all-windows t))
(ju/leader-key-def
"v" '(:ignore t :which-key "Avy")
"vc" '(avy-goto-char :which-key "Avy Goto Char")
"vw" '(avy-goto-word-0 :which-key "Avy Goto Word")
"vl" '(avy-goto-line :which-key "Avy Goto Line"))
#+end_src
**** Snippet
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-edit.el
(use-package yasnippet
:defer t
:hook (prog-mode . yas-minor-mode)
:config
(defvar yas-snippet-dirs nil)
(add-to-list 'yas-snippet-dirs "~/.config/emacs/snippets")
(yas-global-mode 1))
(ju/leader-key-def
"i s" '(yas-insert-snippet :which-key "snippet"))
#+end_src
**** Emojify
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-edit.el
(use-package emojify
:defer t
:init (global-emojify-mode 1))
(ju/leader-key-def
"i e" '(emojify-insert-emoji :which-key "emoji"))
#+end_src
**** Provide Modules
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-edit.el
(provide 'custom-edit)
;;; custom-completion.el ends here
#+end_src
*** Org Mode *** Org Mode
**** Normal Function **** Normal Function
***** configure org ***** configure org
@ -1542,51 +1595,6 @@ speed-up insertion of environments and math templates.
;;; custom-latex.el ends here ;;; custom-latex.el ends here
#+end_src #+end_src
*** Extra *** Extra
**** Helpful
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-extra.el
(use-package helpful
:defer t
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable))
;;:commands (helpful-callable helpful-variable helpful-command helpful-key)
(global-set-key [remap describe-function] #'describe-function)
(global-set-key [remap describe-command] #'helpful-command)
(global-set-key [remap describe-variable] #'describe-variable)
(global-set-key [remap describe-key] #'helpful-key)
#+end_src
**** Avy
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-extra.el
(use-package avy
:defer t
:config
(setq avy-all-windows t))
(ju/leader-key-def
"v" '(:ignore t :which-key "Avy")
"vc" '(avy-goto-char :which-key "Avy Goto Char")
"vw" '(avy-goto-word-0 :which-key "Avy Goto Word")
"vl" '(avy-goto-line :which-key "Avy Goto Line"))
#+end_src
**** Snippet
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-extra.el
(use-package yasnippet
:defer t
:hook (prog-mode . yas-minor-mode)
:config
(defvar yas-snippet-dirs nil)
(add-to-list 'yas-snippet-dirs "~/.config/emacs/snippets")
(yas-global-mode 1))
(ju/leader-key-def
"i s" '(yas-insert-snippet :which-key "snippet"))
#+end_src
**** Emojify
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-extra.el
(use-package emojify
:defer t
:init (global-emojify-mode 1))
(ju/leader-key-def
"i e" '(emojify-insert-emoji :which-key "emoji"))
#+end_src
**** PDF Tool **** PDF Tool
enhanced PDF viewer on emacs enhanced PDF viewer on emacs
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-extra.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-extra.el