mirror of
https://github.com/larstvei/dot-emacs.git
synced 2024-11-26 07:28:31 +00:00
use-package vterm
This commit is contained in:
parent
71190bc7a5
commit
3ea536aea7
80
init.org
80
init.org
@ -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,43 +1369,52 @@
|
|||||||
|
|
||||||
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
|
||||||
|
|
||||||
(let ((last-vterm ""))
|
;; A terminal via libvterm
|
||||||
(defun toggle-vterm ()
|
(use-package vterm
|
||||||
(interactive)
|
:defer t
|
||||||
(cond ((string-match-p "^\\vterm<[1-9][0-9]*>$" (buffer-name))
|
:preface
|
||||||
(goto-non-vterm-buffer))
|
(let ((last-vterm ""))
|
||||||
((get-buffer last-vterm) (switch-to-buffer last-vterm))
|
(defun toggle-vterm ()
|
||||||
(t (vterm (setq last-vterm "vterm<1>")))))
|
(interactive)
|
||||||
|
(cond ((string-match-p "^\\vterm<[1-9][0-9]*>$" (buffer-name))
|
||||||
|
(goto-non-vterm-buffer))
|
||||||
|
((get-buffer last-vterm) (switch-to-buffer last-vterm))
|
||||||
|
(t (vterm (setq last-vterm "vterm<1>")))))
|
||||||
|
|
||||||
(defun goto-non-vterm-buffer ()
|
(defun goto-non-vterm-buffer ()
|
||||||
(let* ((r "^\\vterm<[1-9][0-9]*>$")
|
(let* ((r "^\\vterm<[1-9][0-9]*>$")
|
||||||
(vterm-buffer-p (lambda (b) (string-match-p r (buffer-name b))))
|
(vterm-buffer-p (lambda (b) (string-match-p r (buffer-name b))))
|
||||||
(non-vterms (cl-remove-if vterm-buffer-p (buffer-list))))
|
(non-vterms (cl-remove-if vterm-buffer-p (buffer-list))))
|
||||||
(when non-vterms
|
(when non-vterms
|
||||||
(switch-to-buffer (car non-vterms)))))
|
(switch-to-buffer (car non-vterms)))))
|
||||||
|
|
||||||
(defun switch-vterm (n)
|
(defun switch-vterm (n)
|
||||||
(let ((buffer-name (format "vterm<%d>" n)))
|
(let ((buffer-name (format "vterm<%d>" n)))
|
||||||
(setq last-vterm buffer-name)
|
(setq last-vterm buffer-name)
|
||||||
(cond ((get-buffer buffer-name)
|
(cond ((get-buffer buffer-name)
|
||||||
(switch-to-buffer buffer-name))
|
(switch-to-buffer buffer-name))
|
||||||
(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)))
|
||||||
|
("M-2" . (lambda () (interactive) (switch-vterm 2)))
|
||||||
|
("M-3" . (lambda () (interactive) (switch-vterm 3)))
|
||||||
|
("M-4" . (lambda () (interactive) (switch-vterm 4)))
|
||||||
|
("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))))
|
||||||
|
|
||||||
Don't query whether or not the ~shell~-buffer should be killed, just kill
|
:config
|
||||||
it.
|
;; Don't query about killing vterm buffers, just kill it
|
||||||
|
(defadvice vterm (after kill-with-no-query nil activate)
|
||||||
#+begin_src emacs-lisp
|
(set-process-query-on-exit-flag (get-buffer-process ad-return-value) nil)))
|
||||||
|
|
||||||
(defadvice vterm (after kill-with-no-query nil activate)
|
|
||||||
(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))
|
||||||
|
Loading…
Reference in New Issue
Block a user