mirror of
https://github.com/SqrtMinusOne/dotfiles.git
synced 2025-12-11 19:45:25 +03:00
feat(emacs): run commands in perspectives
This commit is contained in:
parent
df2f07f949
commit
c6987720e9
3 changed files with 57 additions and 45 deletions
|
|
@ -720,7 +720,6 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
|
||||||
|
|
||||||
(use-package company-box
|
(use-package company-box
|
||||||
:straight t
|
:straight t
|
||||||
:disabled
|
|
||||||
:if (and (display-graphic-p) (not my/lowpower))
|
:if (and (display-graphic-p) (not my/lowpower))
|
||||||
:after (company)
|
:after (company)
|
||||||
:hook (company-mode . company-box-mode))
|
:hook (company-mode . company-box-mode))
|
||||||
|
|
@ -998,6 +997,16 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
|
||||||
"m" #'my/persp-move-window-and-switch
|
"m" #'my/persp-move-window-and-switch
|
||||||
"f" #'my/persp-copy-window-and-switch))
|
"f" #'my/persp-copy-window-and-switch))
|
||||||
|
|
||||||
|
(defmacro my/command-in-persp (command-name persp-name workspace-index &rest args)
|
||||||
|
`'((lambda ()
|
||||||
|
(interactive)
|
||||||
|
(when (and ,workspace-index (fboundp #'exwm-workspace-switch-create))
|
||||||
|
(exwm-workspace-switch-create ,workspace-index))
|
||||||
|
(persp-switch ,persp-name)
|
||||||
|
(delete-other-windows)
|
||||||
|
,@args)
|
||||||
|
:wk ,command-name))
|
||||||
|
|
||||||
(use-package lsp-mode
|
(use-package lsp-mode
|
||||||
:straight t
|
:straight t
|
||||||
:if (not (or my/slow-ssh my/is-termux my/remote-server))
|
:if (not (or my/slow-ssh my/is-termux my/remote-server))
|
||||||
|
|
@ -2071,6 +2080,11 @@ _r_: Restart frame _uo_: Output _sd_: Down stack frame _bh_: Set
|
||||||
:straight t
|
:straight t
|
||||||
:mode "\\.env\\..*\\'")
|
:mode "\\.env\\..*\\'")
|
||||||
|
|
||||||
|
(use-package gitignore-templates
|
||||||
|
:straight t
|
||||||
|
:commands (gitignore-templates-insert
|
||||||
|
gitignore-templates-new-file))
|
||||||
|
|
||||||
(use-package dockerfile-mode
|
(use-package dockerfile-mode
|
||||||
:mode "Dockerfile\\'"
|
:mode "Dockerfile\\'"
|
||||||
:straight t
|
:straight t
|
||||||
|
|
@ -3174,7 +3188,7 @@ _r_: Restart frame _uo_: Output _sd_: Down stack frame _bh_: Set
|
||||||
|
|
||||||
(my-leader-def
|
(my-leader-def
|
||||||
"ad" #'dired
|
"ad" #'dired
|
||||||
"aD" #'my/dired-home)
|
"aD" (my/command-in-persp "dired $HOME" "dired" nil (dired (expand-file-name "~"))))
|
||||||
|
|
||||||
(use-package diredfl
|
(use-package diredfl
|
||||||
:straight t
|
:straight t
|
||||||
|
|
@ -3487,7 +3501,7 @@ _r_: Restart frame _uo_: Output _sd_: Down stack frame _bh_: Set
|
||||||
:if (not my/remote-server)
|
:if (not my/remote-server)
|
||||||
:commands (elfeed)
|
:commands (elfeed)
|
||||||
:init
|
:init
|
||||||
(my-leader-def "ae" 'elfeed)
|
(my-leader-def "ae" (my/command-in-persp "elfeed" "elfeed" 0 (elfeed)))
|
||||||
:config
|
:config
|
||||||
(setq elfeed-db-directory "~/.elfeed")
|
(setq elfeed-db-directory "~/.elfeed")
|
||||||
(setq elfeed-enclosure-default-dir (expand-file-name "~/Downloads"))
|
(setq elfeed-enclosure-default-dir (expand-file-name "~/Downloads"))
|
||||||
|
|
@ -3651,7 +3665,7 @@ _r_: Restart frame _uo_: Output _sd_: Down stack frame _bh_: Set
|
||||||
(my-leader-def
|
(my-leader-def
|
||||||
:infix "as"
|
:infix "as"
|
||||||
"" '(:which-key "emms")
|
"" '(:which-key "emms")
|
||||||
"s" 'emms-smart-browse
|
"s" (my/command-in-persp "emms" "EMMS" 0 (emms-smart-browse))
|
||||||
"b" 'emms-browser
|
"b" 'emms-browser
|
||||||
"p" 'emms-pause
|
"p" 'emms-pause
|
||||||
"q" 'emms-stop
|
"q" 'emms-stop
|
||||||
|
|
@ -3836,7 +3850,7 @@ _r_: Restart frame _uo_: Output _sd_: Down stack frame _bh_: Set
|
||||||
:commands (erc erc-tls)
|
:commands (erc erc-tls)
|
||||||
:straight (:type built-in)
|
:straight (:type built-in)
|
||||||
:init
|
:init
|
||||||
(my-leader-def "ai" #'erc-tls)
|
(my-leader-def "ai" (my/command-in-persp "erc" "ERC" 0 (erc-tls)))
|
||||||
:config
|
:config
|
||||||
;; Logging
|
;; Logging
|
||||||
(setq erc-log-channels-directory "~/.erc/logs")
|
(setq erc-log-channels-directory "~/.erc/logs")
|
||||||
|
|
@ -4048,8 +4062,8 @@ _r_: Restart frame _uo_: Output _sd_: Down stack frame _bh_: Set
|
||||||
(my-leader-def "ag" 'guix))
|
(my-leader-def "ag" 'guix))
|
||||||
|
|
||||||
(use-package pomm
|
(use-package pomm
|
||||||
;; :straight (:host github :repo "SqrtMinusOne/pomm.el" :files (:defaults "resources"))
|
:straight (:host github :repo "SqrtMinusOne/pomm.el" :files (:defaults "resources"))
|
||||||
:straight (:local-repo "~/Code/Emacs/pomm" :files (:defaults "resources"))
|
;; :straight (:local-repo "~/Code/Emacs/pomm" :files (:defaults "resources"))
|
||||||
:commands (pomm)
|
:commands (pomm)
|
||||||
:init
|
:init
|
||||||
(my-leader-def "ap" #'pomm)
|
(my-leader-def "ap" #'pomm)
|
||||||
|
|
|
||||||
70
Emacs.org
70
Emacs.org
|
|
@ -749,7 +749,7 @@ Change the universal argument to =M-u=. I use =C-u= to scroll up, as I'm used to
|
||||||
:states '(normal motion emacs insert visual)
|
:states '(normal motion emacs insert visual)
|
||||||
"M-u" 'universal-argument)
|
"M-u" 'universal-argument)
|
||||||
#+end_src
|
#+end_src
|
||||||
**** CHECK Profiler
|
**** Profiler
|
||||||
The built-in profiler is a magnificent tool to troubleshoot performance issues.
|
The built-in profiler is a magnificent tool to troubleshoot performance issues.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
|
@ -835,7 +835,7 @@ Evil does a pretty good job of abstracting the first two with a set of vim-like
|
||||||
"ze" 'hs-hide-level
|
"ze" 'hs-hide-level
|
||||||
"TAB" 'evil-toggle-fold)
|
"TAB" 'evil-toggle-fold)
|
||||||
#+end_src
|
#+end_src
|
||||||
**** CHECK Zoom UI
|
**** Zoom UI
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun my/zoom-in ()
|
(defun my/zoom-in ()
|
||||||
"Increase font size by 10 points"
|
"Increase font size by 10 points"
|
||||||
|
|
@ -1242,7 +1242,7 @@ Function to open dired and vterm at given nodes.
|
||||||
(general-nmap "C-p" 'counsel-projectile-find-file)
|
(general-nmap "C-p" 'counsel-projectile-find-file)
|
||||||
#+end_src
|
#+end_src
|
||||||
*** Git & Magit
|
*** Git & Magit
|
||||||
[[https://magit.vc/][Magic]] is a git interface for Emacs. The closest non-Emacs alternative (sans actual clones) I know is [[https://github.com/jesseduffield/lazygit][lazygit]], which I used before Emacs.
|
[[https://magit.vc/][Magit]] is a git interface for Emacs. The closest non-Emacs alternative (sans actual clones) I know is [[https://github.com/jesseduffield/lazygit][lazygit]], which I used before Emacs.
|
||||||
|
|
||||||
[[https://github.com/emacsorphanage/git-gutter][git-gutter]] is a package which shows git changes for each line (added/changed/deleted lines).
|
[[https://github.com/emacsorphanage/git-gutter][git-gutter]] is a package which shows git changes for each line (added/changed/deleted lines).
|
||||||
|
|
||||||
|
|
@ -1430,7 +1430,6 @@ A company frontend with nice icons. Disabled since the base company got icons su
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package company-box
|
(use-package company-box
|
||||||
:straight t
|
:straight t
|
||||||
:disabled
|
|
||||||
:if (and (display-graphic-p) (not my/lowpower))
|
:if (and (display-graphic-p) (not my/lowpower))
|
||||||
:after (company)
|
:after (company)
|
||||||
:hook (company-mode . company-box-mode))
|
:hook (company-mode . company-box-mode))
|
||||||
|
|
@ -1808,7 +1807,7 @@ However, I don't like that list of workspaces is displayed inside the modeline r
|
||||||
"x" 'persp-ivy-switch-buffer
|
"x" 'persp-ivy-switch-buffer
|
||||||
"u" 'persp-ibuffer))
|
"u" 'persp-ibuffer))
|
||||||
#+end_src
|
#+end_src
|
||||||
*** Some functions
|
*** Functions to manage buffers
|
||||||
Move the current buffer to a perspective and switch to it.
|
Move the current buffer to a perspective and switch to it.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun my/persp-move-window-and-switch ()
|
(defun my/persp-move-window-and-switch ()
|
||||||
|
|
@ -1853,6 +1852,21 @@ Add keybindings to the default map.
|
||||||
"m" #'my/persp-move-window-and-switch
|
"m" #'my/persp-move-window-and-switch
|
||||||
"f" #'my/persp-copy-window-and-switch))
|
"f" #'my/persp-copy-window-and-switch))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
*** Automating perspectives
|
||||||
|
I'd like to have various Emacs apps open up in their designated perspectives (also in their designated workspaces when I'm using EXWM).
|
||||||
|
|
||||||
|
So, here is a macro to run something in a given perspective in a given workspace. This is meant to be used in general.el keybindings.
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defmacro my/command-in-persp (command-name persp-name workspace-index &rest args)
|
||||||
|
`'((lambda ()
|
||||||
|
(interactive)
|
||||||
|
(when (and ,workspace-index (fboundp #'exwm-workspace-switch-create))
|
||||||
|
(exwm-workspace-switch-create ,workspace-index))
|
||||||
|
(persp-switch ,persp-name)
|
||||||
|
(delete-other-windows)
|
||||||
|
,@args)
|
||||||
|
:wk ,command-name))
|
||||||
|
#+end_src
|
||||||
* Programming
|
* Programming
|
||||||
** General setup
|
** General setup
|
||||||
*** LSP
|
*** LSP
|
||||||
|
|
@ -2240,31 +2254,6 @@ Some debug templates I frequently use.
|
||||||
:program "${workspaceFolder}/dist/bin/www.js")))
|
:program "${workspaceFolder}/dist/bin/www.js")))
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
*** TabNine
|
|
||||||
A ML-based autocompletion system.
|
|
||||||
|
|
||||||
More often than not gives +really+ somewhat good results, but is slow as hell & consumes a lot of RAM. Also, LSP-provided completions were more useful in my experience.
|
|
||||||
|
|
||||||
References:
|
|
||||||
- [[https://www.tabnine.com/][TabNine Homepage]]
|
|
||||||
#+begin_src emacs-lisp :tangle no
|
|
||||||
(use-package company-tabnine
|
|
||||||
:straight t
|
|
||||||
:if (not my/lowpower)
|
|
||||||
:after company)
|
|
||||||
|
|
||||||
|
|
||||||
(define-minor-mode company-tabnine-mode
|
|
||||||
"Use company-tabnine"
|
|
||||||
:after-hook
|
|
||||||
(progn
|
|
||||||
(if company-tabnine-mode
|
|
||||||
(progn
|
|
||||||
(make-local-variable 'company-backends)
|
|
||||||
(add-to-list 'company-backends 'company-tabnine))
|
|
||||||
(setq company-backends (remove 'company-tabnine company-backends))
|
|
||||||
(kill-local-variable company-backends))))
|
|
||||||
#+end_src
|
|
||||||
*** Reformatter
|
*** Reformatter
|
||||||
A general-purpose package to run formattters on files. While the most popular formatters are already packaged for Emacs, those that aren't can be invoked with this package.
|
A general-purpose package to run formattters on files. While the most popular formatters are already packaged for Emacs, those that aren't can be invoked with this package.
|
||||||
|
|
||||||
|
|
@ -3127,6 +3116,15 @@ A function to start up [[https://www.tensorflow.org/tensorboard][TensorBoard]].
|
||||||
:straight t
|
:straight t
|
||||||
:mode "\\.env\\..*\\'")
|
:mode "\\.env\\..*\\'")
|
||||||
#+end_src
|
#+end_src
|
||||||
|
*** .gitignore
|
||||||
|
A package to quickly create =.gitignore= files.
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package gitignore-templates
|
||||||
|
:straight t
|
||||||
|
:commands (gitignore-templates-insert
|
||||||
|
gitignore-templates-new-file))
|
||||||
|
#+end_src
|
||||||
*** Docker
|
*** Docker
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package dockerfile-mode
|
(use-package dockerfile-mode
|
||||||
|
|
@ -4683,7 +4681,7 @@ My config mostly follows ranger's and vifm's keybindings which I'm used to.
|
||||||
|
|
||||||
(my-leader-def
|
(my-leader-def
|
||||||
"ad" #'dired
|
"ad" #'dired
|
||||||
"aD" #'my/dired-home)
|
"aD" (my/command-in-persp "dired $HOME" "dired" nil (dired (expand-file-name "~"))))
|
||||||
#+end_src
|
#+end_src
|
||||||
*** Addons
|
*** Addons
|
||||||
I used to use [[https://www.emacswiki.org/emacs/DiredPlus][dired+]], which provides a lot of extensions for dired functionality, but it also creates some new problems, so I opt out of it. Fortunately, the one feature I want from this package - adding more colors to dired buffers - is available as a separate package.
|
I used to use [[https://www.emacswiki.org/emacs/DiredPlus][dired+]], which provides a lot of extensions for dired functionality, but it also creates some new problems, so I opt out of it. Fortunately, the one feature I want from this package - adding more colors to dired buffers - is available as a separate package.
|
||||||
|
|
@ -5128,7 +5126,7 @@ Using my own fork until the modifications are merged into master.
|
||||||
:if (not my/remote-server)
|
:if (not my/remote-server)
|
||||||
:commands (elfeed)
|
:commands (elfeed)
|
||||||
:init
|
:init
|
||||||
(my-leader-def "ae" 'elfeed)
|
(my-leader-def "ae" (my/command-in-persp "elfeed" "elfeed" 0 (elfeed)))
|
||||||
:config
|
:config
|
||||||
(setq elfeed-db-directory "~/.elfeed")
|
(setq elfeed-db-directory "~/.elfeed")
|
||||||
(setq elfeed-enclosure-default-dir (expand-file-name "~/Downloads"))
|
(setq elfeed-enclosure-default-dir (expand-file-name "~/Downloads"))
|
||||||
|
|
@ -5328,7 +5326,7 @@ References:
|
||||||
(my-leader-def
|
(my-leader-def
|
||||||
:infix "as"
|
:infix "as"
|
||||||
"" '(:which-key "emms")
|
"" '(:which-key "emms")
|
||||||
"s" 'emms-smart-browse
|
"s" (my/command-in-persp "emms" "EMMS" 0 (emms-smart-browse))
|
||||||
"b" 'emms-browser
|
"b" 'emms-browser
|
||||||
"p" 'emms-pause
|
"p" 'emms-pause
|
||||||
"q" 'emms-stop
|
"q" 'emms-stop
|
||||||
|
|
@ -5627,7 +5625,7 @@ ERC is a built-it Emacs IRC client.
|
||||||
:commands (erc erc-tls)
|
:commands (erc erc-tls)
|
||||||
:straight (:type built-in)
|
:straight (:type built-in)
|
||||||
:init
|
:init
|
||||||
(my-leader-def "ai" #'erc-tls)
|
(my-leader-def "ai" (my/command-in-persp "erc" "ERC" 0 (erc-tls)))
|
||||||
:config
|
:config
|
||||||
;; Logging
|
;; Logging
|
||||||
(setq erc-log-channels-directory "~/.erc/logs")
|
(setq erc-log-channels-directory "~/.erc/logs")
|
||||||
|
|
@ -5925,8 +5923,8 @@ My package for doing Pomodoro timer.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package pomm
|
(use-package pomm
|
||||||
;; :straight (:host github :repo "SqrtMinusOne/pomm.el" :files (:defaults "resources"))
|
:straight (:host github :repo "SqrtMinusOne/pomm.el" :files (:defaults "resources"))
|
||||||
:straight (:local-repo "~/Code/Emacs/pomm" :files (:defaults "resources"))
|
;; :straight (:local-repo "~/Code/Emacs/pomm" :files (:defaults "resources"))
|
||||||
:commands (pomm)
|
:commands (pomm)
|
||||||
:init
|
:init
|
||||||
(my-leader-def "ap" #'pomm)
|
(my-leader-def "ap" #'pomm)
|
||||||
|
|
|
||||||
4
Mail.org
4
Mail.org
|
|
@ -424,7 +424,7 @@ Root keybindings:
|
||||||
(my-leader-def
|
(my-leader-def
|
||||||
:infix "am"
|
:infix "am"
|
||||||
"" '(:which-key "notmuch")
|
"" '(:which-key "notmuch")
|
||||||
"m" 'notmuch)
|
"m" (my/command-in-persp "notmuch" "mail" 0 (notmuch)))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+NAME: root_tags
|
#+NAME: root_tags
|
||||||
|
|
@ -475,7 +475,7 @@ And the following does the same for my general.el definer:
|
||||||
(dolist (tag filter_tags)
|
(dolist (tag filter_tags)
|
||||||
(add-to-list
|
(add-to-list
|
||||||
'bindings
|
'bindings
|
||||||
(format "\"%s\" '((lambda () (interactive) (notmuch-search \"%s\")) :which-key \"%s\")"
|
(format "\"%s\" (my/command-in-persp \"%s\" \"mail\" 0 (notmuch-search \"%s\"))"
|
||||||
(concat (nth 1 root_tag) (nth 1 tag))
|
(concat (nth 1 root_tag) (nth 1 tag))
|
||||||
(concat "tag:" (nth 0 root_tag)
|
(concat "tag:" (nth 0 root_tag)
|
||||||
(unless (string-empty-p (nth 0 tag))
|
(unless (string-empty-p (nth 0 tag))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue