emacs: ed, reverso-history, go to project root

This commit is contained in:
Pavel Korytov 2024-01-14 15:33:45 +03:00
parent 89a97f8ab2
commit d692fde70e
2 changed files with 90 additions and 27 deletions

View file

@ -2405,7 +2405,8 @@ Returns (<buffer> . <workspace-index>) or nil."
:init
(my-leader-def "ar" #'reverso)
:config
(setq reverso-languages '(russian english german)))
(setq reverso-languages '(russian english german))
(reverso-history-mode))
(use-package lispy
:commands (lispy-mode)
@ -4835,7 +4836,7 @@ KEYS is a list of cons cells like (<label> . <time>)."
"l" #'dired-find-file
"=" #'dired-narrow
"-" #'my/dired-create-empty-file-subtree
"~" #'vterm
"~" #'eshell
"M-r" #'wdired-change-to-wdired-mode
"<left>" #'dired-up-directory
"<right>" #'dired-find-file
@ -4978,6 +4979,16 @@ KEYS is a list of cons cells like (<label> . <time>)."
"sQ" 'my/dired-kill-all-subdirs
(kbd "TAB") 'dired-hide-subdir))
(defun my/dired-goto-project-root ()
(interactive)
(dired--find-possibly-alternative-file (projectile-project-root)))
(with-eval-after-load 'dired
(general-define-key
:states '(normal)
:keymaps 'dired-mode-map
"H" #'my/dired-goto-project-root))
(setq tramp-verbose 6)
(defun my/tramp-p (&optional buffer)
@ -5287,7 +5298,9 @@ KEYS is a list of cons cells like (<label> . <time>)."
(general-define-key
:keymaps 'eshell-mode-map
:states '(insert)
"<tab>" 'my/eshell-complete)
"<tab>" 'my/eshell-complete
"M-k" #'eshell-previous-matching-input-from-input
"M-j" #'eshell-next-matching-input-from-input)
(general-define-key
:states '(normal)
@ -5296,8 +5309,8 @@ KEYS is a list of cons cells like (<label> . <time>)."
"C-l" 'evil-window-right
"C-k" 'evil-window-up
"C-j" 'evil-window-down)
;; XXX Did they forget to set it to nil?
(setq eshell-first-time-p nil))
;; XXX Did they forget to set it to nil?
(setq eshell-first-time-p nil))
(use-package eshell
:straight (:type built-in)
@ -5469,15 +5482,20 @@ KEYS is a list of cons cells like (<label> . <time>)."
(my/eshell-overlay-update (line-end-position) suggestion)
(my/eshell-overlay-remove)))
(defun my/eshell-overlay-suggest-enable ()
(interactive)
(add-hook 'after-change-functions #'my/eshell-overlay-suggest nil t)
(add-hook 'company-completion-started-hook #'my/eshell-overlay-suggest nil t)
(add-hook 'company-after-completion-hook #'my/eshell-overlay-suggest nil t)
;; (setq-local company-idle-delay nil)
)
(define-minor-mode my/eshell-overlay-suggest-mode
"Fish-like suggestions for eshell."
:after-hook
(if my/eshell-overlay-suggest-mode
(progn
(add-hook 'after-change-functions #'my/eshell-overlay-suggest nil t)
(add-hook 'company-completion-started-hook #'my/eshell-overlay-suggest nil t)
(add-hook 'company-after-completion-hook #'my/eshell-overlay-suggest nil t))
(remove-hook 'after-change-functions #'my/eshell-overlay-suggest t)
(add-hook 'company-completion-started-hook #'my/eshell-overlay-suggest t)
(add-hook 'company-after-completion-hook #'my/eshell-overlay-suggest t)
(my/eshell-overlay-remove)))
(add-hook 'eshell-mode-hook #'my/eshell-overlay-suggest-enable)
;; (add-hook 'eshell-mode-hook #'my/eshell-overlay-suggest-mode)
(defun my/eshell-complete ()
(interactive)
@ -5512,6 +5530,11 @@ KEYS is a list of cons cells like (<label> . <time>)."
(kill-buffer-and-window)
(select-window window))))))
(defun eshell/prt ()
(if-let ((root (projectile-project-root)))
(eshell/cd root)
(message "Not in a project")))
(general-define-key
:states '(normal)
"`" #'my/eshell-dedicated
@ -8447,3 +8470,7 @@ repositories are marked."
(use-package meme
:straight (:host github :repo "larsmagne/meme" :files (:defaults "images"))
:commands (meme))
(use-package ed-mode
:straight (:host github :repo "ryanprior/ed-mode")
:commands (ed))

View file

@ -3284,7 +3284,8 @@ References:
:init
(my-leader-def "ar" #'reverso)
:config
(setq reverso-languages '(russian english german)))
(setq reverso-languages '(russian english german))
(reverso-history-mode))
#+end_src
** Lisp
[[file:dot-imgs/lisp_cycles.png]]
@ -6741,7 +6742,7 @@ My config mostly follows ranger's and vifm's keybindings which I'm used to.
"l" #'dired-find-file
"=" #'dired-narrow
"-" #'my/dired-create-empty-file-subtree
"~" #'vterm
"~" #'eshell
"M-r" #'wdired-change-to-wdired-mode
"<left>" #'dired-up-directory
"<right>" #'dired-find-file
@ -6926,6 +6927,20 @@ I add my own keybindings and some extra functionality.
"sQ" 'my/dired-kill-all-subdirs
(kbd "TAB") 'dired-hide-subdir))
#+end_src
*** Other functions
Goto project root.
#+begin_src emacs-lisp
(defun my/dired-goto-project-root ()
(interactive)
(dired--find-possibly-alternative-file (projectile-project-root)))
(with-eval-after-load 'dired
(general-define-key
:states '(normal)
:keymaps 'dired-mode-map
"H" #'my/dired-goto-project-root))
#+end_src
*** TRAMP
TRAMP is a package that provides remote editing capacities. It is particularly useful for remote server management.
@ -7368,7 +7383,9 @@ Some initial configuration.
(general-define-key
:keymaps 'eshell-mode-map
:states '(insert)
"<tab>" 'my/eshell-complete)
"<tab>" 'my/eshell-complete
"M-k" #'eshell-previous-matching-input-from-input
"M-j" #'eshell-next-matching-input-from-input)
(general-define-key
:states '(normal)
@ -7377,8 +7394,8 @@ Some initial configuration.
"C-l" 'evil-window-right
"C-k" 'evil-window-up
"C-j" 'evil-window-down)
;; XXX Did they forget to set it to nil?
(setq eshell-first-time-p nil))
;; XXX Did they forget to set it to nil?
(setq eshell-first-time-p nil))
(use-package eshell
:straight (:type built-in)
@ -7631,15 +7648,20 @@ This also hides the overlay if =company= completion is active because =company=
The function can be added in =after-change-functions=, which is executed on every text modification. This shouldn't slow eshell down because =eshell-send-input= sets =inhibit-modification-hooks= to t.
#+begin_src emacs-lisp
(defun my/eshell-overlay-suggest-enable ()
(interactive)
(add-hook 'after-change-functions #'my/eshell-overlay-suggest nil t)
(add-hook 'company-completion-started-hook #'my/eshell-overlay-suggest nil t)
(add-hook 'company-after-completion-hook #'my/eshell-overlay-suggest nil t)
;; (setq-local company-idle-delay nil)
)
(define-minor-mode my/eshell-overlay-suggest-mode
"Fish-like suggestions for eshell."
:after-hook
(if my/eshell-overlay-suggest-mode
(progn
(add-hook 'after-change-functions #'my/eshell-overlay-suggest nil t)
(add-hook 'company-completion-started-hook #'my/eshell-overlay-suggest nil t)
(add-hook 'company-after-completion-hook #'my/eshell-overlay-suggest nil t))
(remove-hook 'after-change-functions #'my/eshell-overlay-suggest t)
(add-hook 'company-completion-started-hook #'my/eshell-overlay-suggest t)
(add-hook 'company-after-completion-hook #'my/eshell-overlay-suggest t)
(my/eshell-overlay-remove)))
(add-hook 'eshell-mode-hook #'my/eshell-overlay-suggest-enable)
;; (add-hook 'eshell-mode-hook #'my/eshell-overlay-suggest-mode)
#+end_src
Finally, a function that inserts the overlay in buffer if it's available and calls =company-complete= if it's not. I've bound it to =<tab>=.
@ -7681,7 +7703,13 @@ Make a dedicated buffer for eshell in the bottom of the screen.
(kill-buffer-and-window)
(select-window window))))))
#+end_src
**** Custom commands
#+begin_src emacs-lisp
(defun eshell/prt ()
(if-let ((root (projectile-project-root)))
(eshell/cd root)
(message "Not in a project")))
#+end_src
**** Global keybindings
#+begin_src emacs-lisp
(general-define-key
@ -11730,6 +11758,14 @@ Generate memes from Emacs.
:commands (meme))
#+end_src
*** Ed
My text editor isn't old enough.
#+begin_src emacs-lisp
(use-package ed-mode
:straight (:host github :repo "ryanprior/ed-mode")
:commands (ed))
#+end_src
* Guix settings
| Guix dependency | Description |
|---------------------+-------------------------------|