use-package vterm

This commit is contained in:
larstvei 2023-06-13 02:55:56 +02:00
parent 71190bc7a5
commit 3ea536aea7

View File

@ -207,8 +207,7 @@
(let* ((package--builtins nil) (let* ((package--builtins nil)
(packages (packages
'(vterm ; A terminal via libvterm '(which-key ; Display available keybindings in popup
which-key ; Display available keybindings in popup
z3-mode))) ; z3/SMTLIBv2 interactive development z3-mode))) ; z3/SMTLIBv2 interactive development
(when (memq window-system '(mac ns)) (when (memq window-system '(mac ns))
(push 'exec-path-from-shell packages) (push 'exec-path-from-shell packages)
@ -1370,11 +1369,14 @@
Inspired by [[https://github.com/torenord/.emacs.d][torenord]], I maintain quick access to shell buffers with bindings Inspired by [[https://github.com/torenord/.emacs.d][torenord]], I maintain quick access to shell buffers with bindings
~M-1~ to ~M-9~. In addition, the ~M-z~ toggles between the last visited ~M-1~ to ~M-9~. In addition, the ~M-z~ toggles between the last visited
shell, and the last visited non-shell buffer. The following functions shell, and the last visited non-shell buffer.
facilitate this, and are bound in the [[Key bindings]] section.
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; A terminal via libvterm
(use-package vterm
:defer t
:preface
(let ((last-vterm "")) (let ((last-vterm ""))
(defun toggle-vterm () (defun toggle-vterm ()
(interactive) (interactive)
@ -1398,15 +1400,21 @@
(t (vterm buffer-name) (t (vterm buffer-name)
(rename-buffer buffer-name)))))) (rename-buffer buffer-name))))))
#+end_src :bind (("C-z" . toggle-vterm)
("M-1" . (lambda () (interactive) (switch-vterm 1)))
Don't query whether or not the ~shell~-buffer should be killed, just kill ("M-2" . (lambda () (interactive) (switch-vterm 2)))
it. ("M-3" . (lambda () (interactive) (switch-vterm 3)))
("M-4" . (lambda () (interactive) (switch-vterm 4)))
#+begin_src emacs-lisp ("M-5" . (lambda () (interactive) (switch-vterm 5)))
("M-6" . (lambda () (interactive) (switch-vterm 6)))
("M-7" . (lambda () (interactive) (switch-vterm 7)))
("M-8" . (lambda () (interactive) (switch-vterm 8)))
("M-9" . (lambda () (interactive) (switch-vterm 9))))
:config
;; Don't query about killing vterm buffers, just kill it
(defadvice vterm (after kill-with-no-query nil activate) (defadvice vterm (after kill-with-no-query nil activate)
(set-process-query-on-exit-flag (get-buffer-process ad-return-value) nil)) (set-process-query-on-exit-flag (get-buffer-process ad-return-value) nil)))
#+end_src #+end_src
@ -1831,14 +1839,6 @@
(define-key custom-bindings-map (kbd "C-c j") 'cycle-spacing-delete-newlines) (define-key custom-bindings-map (kbd "C-c j") 'cycle-spacing-delete-newlines)
(define-key custom-bindings-map (kbd "C-c d") 'duplicate-thing) (define-key custom-bindings-map (kbd "C-c d") 'duplicate-thing)
(define-key custom-bindings-map (kbd "<C-tab>") 'tidy) (define-key custom-bindings-map (kbd "<C-tab>") 'tidy)
(define-key custom-bindings-map (kbd "C-z") 'toggle-vterm)
(dolist (n (number-sequence 1 9))
(let ((key (concat "M-" (int-to-string n))))
(with-eval-after-load 'vterm
(define-key vterm-mode-map (kbd key) nil))
(define-key custom-bindings-map (kbd key)
(lambda () (interactive) (switch-vterm n)))))
(with-eval-after-load 'org (with-eval-after-load 'org
(define-key org-mode-map (kbd "C-'") 'org-sync-pdf)) (define-key org-mode-map (kbd "C-'") 'org-sync-pdf))