mirror of
https://github.com/SqrtMinusOne/dotfiles.git
synced 2025-12-10 19:23:03 +03:00
emacs: minor changes to index & input methods
This commit is contained in:
parent
95267451f8
commit
5a0b48a17f
6 changed files with 116 additions and 79 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
(specifications->manifest
|
(specifications->manifest
|
||||||
'(
|
'(
|
||||||
|
"python-cairosvg"
|
||||||
"python-chess"
|
"python-chess"
|
||||||
"wireshark"
|
"wireshark"
|
||||||
"socat"
|
"socat"
|
||||||
|
|
@ -20,6 +21,7 @@
|
||||||
"openjdk:jdk"
|
"openjdk:jdk"
|
||||||
"node"
|
"node"
|
||||||
"git-filter-repo"
|
"git-filter-repo"
|
||||||
|
"dnsmasq"
|
||||||
"virt-manager"
|
"virt-manager"
|
||||||
"postgresql"
|
"postgresql"
|
||||||
"docker-compose"
|
"docker-compose"
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,5 @@
|
||||||
"python-isort"
|
"python-isort"
|
||||||
"python-black"
|
"python-black"
|
||||||
"python-yapf"
|
"python-yapf"
|
||||||
"plantuml"))
|
"plantuml"
|
||||||
|
"xkb-switch"))
|
||||||
|
|
|
||||||
|
|
@ -362,10 +362,6 @@ DIR is either 'left or 'right."
|
||||||
(when exwm--connection
|
(when exwm--connection
|
||||||
(exwm-input--update-global-prefix-keys)))
|
(exwm-input--update-global-prefix-keys)))
|
||||||
|
|
||||||
(defun my/run-in-background (command)
|
|
||||||
(let ((command-parts (split-string command "[ ]+")))
|
|
||||||
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
|
|
||||||
|
|
||||||
(defhydra my/exwm-apps-hydra (:color blue :hint nil)
|
(defhydra my/exwm-apps-hydra (:color blue :hint nil)
|
||||||
"
|
"
|
||||||
^Apps^
|
^Apps^
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,10 @@
|
||||||
(use-package no-littering
|
(use-package no-littering
|
||||||
:straight t)
|
:straight t)
|
||||||
|
|
||||||
|
(defun my/run-in-background (command)
|
||||||
|
(let ((command-parts (split-string command "[ ]+")))
|
||||||
|
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
|
||||||
|
|
||||||
(setq confirm-kill-emacs 'y-or-n-p)
|
(setq confirm-kill-emacs 'y-or-n-p)
|
||||||
|
|
||||||
(use-package general
|
(use-package general
|
||||||
|
|
@ -537,9 +541,19 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
|
||||||
|
|
||||||
(setq default-input-method "russian-computer")
|
(setq default-input-method "russian-computer")
|
||||||
|
|
||||||
|
(defun my/toggle-input-method ()
|
||||||
|
(interactive)
|
||||||
|
(if (derived-mode-p 'exwm-mode)
|
||||||
|
(my/run-in-background "xkb-switch -n")
|
||||||
|
(if (equal (string-trim
|
||||||
|
(shell-command-to-string "xkb-switch -p"))
|
||||||
|
"us")
|
||||||
|
(toggle-input-method)
|
||||||
|
(my/run-in-background "xkb-switch -s us"))))
|
||||||
|
|
||||||
(general-define-key
|
(general-define-key
|
||||||
:keymaps 'global
|
:keymaps 'global
|
||||||
"M-\\" #'toggle-input-method)
|
"M-\\" #'my/toggle-input-method)
|
||||||
|
|
||||||
(use-package smartparens
|
(use-package smartparens
|
||||||
:straight t)
|
:straight t)
|
||||||
|
|
@ -554,14 +568,14 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
|
||||||
)
|
)
|
||||||
|
|
||||||
(use-package accent
|
(use-package accent
|
||||||
:straight t
|
:straight (:host github :repo "SqrtMinusOne/accent")
|
||||||
:init
|
:init
|
||||||
(general-define-key
|
(general-define-key
|
||||||
:states '(normal)
|
:states '(normal)
|
||||||
"gs" #'accent-menu)
|
"gs" #'accent-company)
|
||||||
(general-define-key
|
(general-define-key
|
||||||
:states '(normal insert)
|
:states '(normal insert)
|
||||||
"M-n" #'accent-menu)
|
"M-n" #'accent-company)
|
||||||
:commands (accent-menu)
|
:commands (accent-menu)
|
||||||
:config
|
:config
|
||||||
(general-define-key
|
(general-define-key
|
||||||
|
|
@ -5419,8 +5433,9 @@ KEYS is a list of cons cells like (<label> . <time>)."
|
||||||
("ll" "ls -la")
|
("ll" "ls -la")
|
||||||
("e" "find-file")))
|
("e" "find-file")))
|
||||||
(setq eshell-banner-message "")
|
(setq eshell-banner-message "")
|
||||||
(setq eshell-visual-commands
|
;; (setq eshell-visual-commands
|
||||||
`(,@eshell-visual-commands "jless")))
|
;; `(,@eshell-visual-commands "jless"))
|
||||||
|
)
|
||||||
|
|
||||||
(defvar-local my/eshell-last-command-start-time nil)
|
(defvar-local my/eshell-last-command-start-time nil)
|
||||||
|
|
||||||
|
|
@ -8164,18 +8179,9 @@ NAV is a structure as defined by `my/index--nav-get'."
|
||||||
(defun my/index-nav (arg &optional func)
|
(defun my/index-nav (arg &optional func)
|
||||||
"Navigate the filesystem index.
|
"Navigate the filesystem index.
|
||||||
|
|
||||||
ARG is the prefix argument. It modifies the behavior of the
|
If ARG is nil, navigate all levels sequentially from the top one.
|
||||||
command as follows:
|
|
||||||
- If not in an indexed directory, or in an indexed directory with no
|
If ARG is '(4), select another directory from the same level.
|
||||||
indexed children:
|
|
||||||
- nil: Select an indexed directory.
|
|
||||||
- '(4): Select an indexed directory, and select a child indexed
|
|
||||||
directory if available.
|
|
||||||
- If in an indexed directory with indexed children (a project):
|
|
||||||
- nil: Select another indexed directory from the project.
|
|
||||||
- '(4): Select a top-level indexed directory (the same as nil for
|
|
||||||
the previous case).
|
|
||||||
- '(16): The same as '(4) for the previous case.
|
|
||||||
|
|
||||||
FUNC is the function to call with the selected path. It defaults
|
FUNC is the function to call with the selected path. It defaults
|
||||||
to `dired' if used interactively."
|
to `dired' if used interactively."
|
||||||
|
|
@ -8184,25 +8190,32 @@ to `dired' if used interactively."
|
||||||
(current-nav (my/index--nav-find-path
|
(current-nav (my/index--nav-find-path
|
||||||
nav (expand-file-name default-directory)))
|
nav (expand-file-name default-directory)))
|
||||||
(current-child-navs (alist-get :child-navs current-nav)))
|
(current-child-navs (alist-get :child-navs current-nav)))
|
||||||
(cond
|
(cond ((null arg)
|
||||||
((or (and (null arg) (null current-child-navs))
|
(let ((selected (my/index--nav-find-path
|
||||||
(and (equal arg '(4)) current-child-navs))
|
nav
|
||||||
(funcall
|
(my/index--nav-prompt nav))))
|
||||||
func
|
(if-let (child-navs (alist-get :child-navs selected))
|
||||||
(my/index--nav-prompt nav)))
|
(funcall func (my/index--nav-prompt child-navs))
|
||||||
((or (and (equal arg '(4)) (null current-child-navs))
|
(funcall func (alist-get :path selected)))))
|
||||||
(and (equal arg '(16)) current-child-navs))
|
((and (equal arg '(4)) current-child-navs)
|
||||||
(let ((selected (my/index--nav-find-path
|
(funcall func (my/index--nav-prompt current-child-navs)))
|
||||||
nav
|
((and (equal arg '(4)) (null current-child-navs))
|
||||||
(my/index--nav-prompt nav))))
|
(funcall func (my/index--nav-prompt nav))))))
|
||||||
(if-let (child-navs (alist-get :child-navs selected))
|
|
||||||
(funcall func (my/index--nav-prompt child-navs))
|
(defun my/index-nav-with-select-file (arg)
|
||||||
(funcall func (alist-get :path selected)))))
|
(interactive (list current-prefix-arg))
|
||||||
((and (null arg) current-child-navs)
|
(my/index-nav
|
||||||
(funcall func (my/index--nav-prompt current-child-navs))))))
|
arg
|
||||||
|
(lambda (dir)
|
||||||
|
(let ((default-directory dir))
|
||||||
|
(projectile-find-file)))))
|
||||||
|
|
||||||
(my-leader-def
|
(my-leader-def
|
||||||
"i" #'my/index-nav)
|
:infix "i"
|
||||||
|
"" '(:wk "index")
|
||||||
|
"i" #'my/index-nav
|
||||||
|
"s" #'my/index-commands-sync
|
||||||
|
"p" #'my/index-nav-with-select-file)
|
||||||
|
|
||||||
(defun my/index-export (file)
|
(defun my/index-export (file)
|
||||||
(interactive (list (read-file-name "File: " "~/logs-sync/data/index.json")))
|
(interactive (list (read-file-name "File: " "~/logs-sync/data/index.json")))
|
||||||
|
|
|
||||||
|
|
@ -902,6 +902,9 @@ And keybindings that are available in both =char-mode= and =line-mode=:
|
||||||
(,(kbd "<XF86AudioPause>") . ,(my/app-command "mpc pause"))
|
(,(kbd "<XF86AudioPause>") . ,(my/app-command "mpc pause"))
|
||||||
(,(kbd "<print>") . ,(my/app-command "flameshot gui"))
|
(,(kbd "<print>") . ,(my/app-command "flameshot gui"))
|
||||||
|
|
||||||
|
;; Input method
|
||||||
|
(,(kbd "M-\\") . my/toggle-input-method)
|
||||||
|
|
||||||
;; Switch workspace
|
;; Switch workspace
|
||||||
(,(kbd "s-q") . my/exwm-switch-to-other-monitor)
|
(,(kbd "s-q") . my/exwm-switch-to-other-monitor)
|
||||||
(,(kbd "s-w") . exwm-workspace-switch)
|
(,(kbd "s-w") . exwm-workspace-switch)
|
||||||
|
|
@ -942,10 +945,6 @@ A function to apply changes to =exwm-input-global-keys=.
|
||||||
*** App shortcuts
|
*** App shortcuts
|
||||||
A +transient+ hydra for shortcuts for the most frequent apps.
|
A +transient+ hydra for shortcuts for the most frequent apps.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun my/run-in-background (command)
|
|
||||||
(let ((command-parts (split-string command "[ ]+")))
|
|
||||||
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
|
|
||||||
|
|
||||||
(defhydra my/exwm-apps-hydra (:color blue :hint nil)
|
(defhydra my/exwm-apps-hydra (:color blue :hint nil)
|
||||||
"
|
"
|
||||||
^Apps^
|
^Apps^
|
||||||
|
|
|
||||||
96
Emacs.org
96
Emacs.org
|
|
@ -268,6 +268,15 @@ By default Emacs and its packages create a lot files in =.emacs.d= and in other
|
||||||
(use-package no-littering
|
(use-package no-littering
|
||||||
:straight t)
|
:straight t)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
** Helper functions
|
||||||
|
*** Run command in background
|
||||||
|
I think I've copied it from somewhere.
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun my/run-in-background (command)
|
||||||
|
(let ((command-parts (split-string command "[ ]+")))
|
||||||
|
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
|
||||||
|
#+end_src
|
||||||
** Prevent Emacs from closing
|
** Prevent Emacs from closing
|
||||||
This adds a confirmation to avoid accidental Emacs closing.
|
This adds a confirmation to avoid accidental Emacs closing.
|
||||||
|
|
||||||
|
|
@ -961,12 +970,30 @@ References:
|
||||||
(setq default-input-method "russian-computer")
|
(setq default-input-method "russian-computer")
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
I also want to call =xkb-switch= in EXWM buffers with the same keybindig.
|
||||||
|
|
||||||
|
| Guix dependency |
|
||||||
|
|-----------------|
|
||||||
|
| xkb-switch |
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun my/toggle-input-method ()
|
||||||
|
(interactive)
|
||||||
|
(if (derived-mode-p 'exwm-mode)
|
||||||
|
(my/run-in-background "xkb-switch -n")
|
||||||
|
(if (equal (string-trim
|
||||||
|
(shell-command-to-string "xkb-switch -p"))
|
||||||
|
"us")
|
||||||
|
(toggle-input-method)
|
||||||
|
(my/run-in-background "xkb-switch -s us"))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
=M-x delete-horizontal-space= doesn't feel that useful to me.
|
=M-x delete-horizontal-space= doesn't feel that useful to me.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(general-define-key
|
(general-define-key
|
||||||
:keymaps 'global
|
:keymaps 'global
|
||||||
"M-\\" #'toggle-input-method)
|
"M-\\" #'my/toggle-input-method)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Other small packages
|
*** Other small packages
|
||||||
|
|
@ -996,14 +1023,14 @@ Input accented characters.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package accent
|
(use-package accent
|
||||||
:straight t
|
:straight (:host github :repo "SqrtMinusOne/accent")
|
||||||
:init
|
:init
|
||||||
(general-define-key
|
(general-define-key
|
||||||
:states '(normal)
|
:states '(normal)
|
||||||
"gs" #'accent-menu)
|
"gs" #'accent-company)
|
||||||
(general-define-key
|
(general-define-key
|
||||||
:states '(normal insert)
|
:states '(normal insert)
|
||||||
"M-n" #'accent-menu)
|
"M-n" #'accent-company)
|
||||||
:commands (accent-menu)
|
:commands (accent-menu)
|
||||||
:config
|
:config
|
||||||
(general-define-key
|
(general-define-key
|
||||||
|
|
@ -7522,8 +7549,9 @@ Some initial configuration.
|
||||||
("ll" "ls -la")
|
("ll" "ls -la")
|
||||||
("e" "find-file")))
|
("e" "find-file")))
|
||||||
(setq eshell-banner-message "")
|
(setq eshell-banner-message "")
|
||||||
(setq eshell-visual-commands
|
;; (setq eshell-visual-commands
|
||||||
`(,@eshell-visual-commands "jless")))
|
;; `(,@eshell-visual-commands "jless"))
|
||||||
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
**** UI
|
**** UI
|
||||||
|
|
@ -11229,18 +11257,9 @@ NAV is a structure as defined by `my/index--nav-get'."
|
||||||
(defun my/index-nav (arg &optional func)
|
(defun my/index-nav (arg &optional func)
|
||||||
"Navigate the filesystem index.
|
"Navigate the filesystem index.
|
||||||
|
|
||||||
ARG is the prefix argument. It modifies the behavior of the
|
If ARG is nil, navigate all levels sequentially from the top one.
|
||||||
command as follows:
|
|
||||||
- If not in an indexed directory, or in an indexed directory with no
|
If ARG is '(4), select another directory from the same level.
|
||||||
indexed children:
|
|
||||||
- nil: Select an indexed directory.
|
|
||||||
- '(4): Select an indexed directory, and select a child indexed
|
|
||||||
directory if available.
|
|
||||||
- If in an indexed directory with indexed children (a project):
|
|
||||||
- nil: Select another indexed directory from the project.
|
|
||||||
- '(4): Select a top-level indexed directory (the same as nil for
|
|
||||||
the previous case).
|
|
||||||
- '(16): The same as '(4) for the previous case.
|
|
||||||
|
|
||||||
FUNC is the function to call with the selected path. It defaults
|
FUNC is the function to call with the selected path. It defaults
|
||||||
to `dired' if used interactively."
|
to `dired' if used interactively."
|
||||||
|
|
@ -11249,28 +11268,35 @@ to `dired' if used interactively."
|
||||||
(current-nav (my/index--nav-find-path
|
(current-nav (my/index--nav-find-path
|
||||||
nav (expand-file-name default-directory)))
|
nav (expand-file-name default-directory)))
|
||||||
(current-child-navs (alist-get :child-navs current-nav)))
|
(current-child-navs (alist-get :child-navs current-nav)))
|
||||||
(cond
|
(cond ((null arg)
|
||||||
((or (and (null arg) (null current-child-navs))
|
(let ((selected (my/index--nav-find-path
|
||||||
(and (equal arg '(4)) current-child-navs))
|
nav
|
||||||
(funcall
|
(my/index--nav-prompt nav))))
|
||||||
func
|
(if-let (child-navs (alist-get :child-navs selected))
|
||||||
(my/index--nav-prompt nav)))
|
(funcall func (my/index--nav-prompt child-navs))
|
||||||
((or (and (equal arg '(4)) (null current-child-navs))
|
(funcall func (alist-get :path selected)))))
|
||||||
(and (equal arg '(16)) current-child-navs))
|
((and (equal arg '(4)) current-child-navs)
|
||||||
(let ((selected (my/index--nav-find-path
|
(funcall func (my/index--nav-prompt current-child-navs)))
|
||||||
nav
|
((and (equal arg '(4)) (null current-child-navs))
|
||||||
(my/index--nav-prompt nav))))
|
(funcall func (my/index--nav-prompt nav))))))
|
||||||
(if-let (child-navs (alist-get :child-navs selected))
|
|
||||||
(funcall func (my/index--nav-prompt child-navs))
|
|
||||||
(funcall func (alist-get :path selected)))))
|
|
||||||
((and (null arg) current-child-navs)
|
|
||||||
(funcall func (my/index--nav-prompt current-child-navs))))))
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Finally, something that I can bind to a key.
|
Finally, something that I can bind to a key.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
(defun my/index-nav-with-select-file (arg)
|
||||||
|
(interactive (list current-prefix-arg))
|
||||||
|
(my/index-nav
|
||||||
|
arg
|
||||||
|
(lambda (dir)
|
||||||
|
(let ((default-directory dir))
|
||||||
|
(projectile-find-file)))))
|
||||||
|
|
||||||
(my-leader-def
|
(my-leader-def
|
||||||
"i" #'my/index-nav)
|
:infix "i"
|
||||||
|
"" '(:wk "index")
|
||||||
|
"i" #'my/index-nav
|
||||||
|
"s" #'my/index-commands-sync
|
||||||
|
"p" #'my/index-nav-with-select-file)
|
||||||
#+end_src
|
#+end_src
|
||||||
*** Export tree
|
*** Export tree
|
||||||
I also need the tree to use in my =sqrt-data=, so let's export this to JSON.
|
I also need the tree to use in my =sqrt-data=, so let's export this to JSON.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue