summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-06-11 19:43:22 +0100
committerjao <jao@gnu.org>2021-06-11 19:43:22 +0100
commit51c8350be8979bc1e54bb657f155467dbe788bc5 (patch)
tree30b3c1da25e7b6e0bd618dbffd83bbbe4a8b83c3
parente754fd59140725d6fe6ab584f24a44df412cf6a3 (diff)
downloadelibs-51c8350be8979bc1e54bb657f155467dbe788bc5.tar.gz
elibs-51c8350be8979bc1e54bb657f155467dbe788bc5.tar.bz2
vterm to the attic
-rw-r--r--attic/misc.org51
-rw-r--r--exwm.org6
-rw-r--r--init.org167
3 files changed, 126 insertions, 98 deletions
diff --git a/attic/misc.org b/attic/misc.org
index 7dd38cf..b902e18 100644
--- a/attic/misc.org
+++ b/attic/misc.org
@@ -457,3 +457,54 @@
("C-x 4 f" . jao-switch-window-then-find-file)
("C-x 4 b" . jao-switch-window-then-consult-buffer)))
#+end_src
+
+* vterm
+ #+begin_src emacs-lisp
+ (use-package vterm
+ :ensure t
+ :init
+ (setq vterm-kill-buffer-on-exit t
+ vterm-copy-exclude-prompt t
+ vterm-use-vterm-prompt-detection-method t
+ vterm-buffer-name-string nil)
+ :config
+ (define-key vterm-mode-map [(f1)] nil)
+ :bind (:map vterm-mode-map (("C-c C-c" . vterm-send-C-c))))
+
+ (defun jao-exec-in-vterm (cmd &optional name)
+ (vterm)
+ (when name (vterm-send-string "unset PROMPT_COMMAND\n"))
+ (vterm-send-string cmd)
+ (vterm-send-return)
+ (when name (rename-buffer name)))
+
+ (defun jao-exec-in-vterm (cmd &optional name)
+ (ansi-term cmd name))
+
+ (defvar-local jao-vterm--cmd nil)
+
+ (defun jao-vterm--find (cmd)
+ (seq-find (lambda (b)
+ (and (eq (buffer-local-value 'major-mode b) 'vterm-mode)
+ (string= (or (buffer-local-value 'jao-vterm--cmd b) "")
+ cmd)))
+ (buffer-list)))
+
+ (defmacro jao-def-exec-in-vterm (name cmd &rest prelude)
+ `(defun ,(intern (format "jao-vterm-%s" name)) ()
+ (interactive)
+ ,@prelude
+ (if-let ((b (jao-vterm--find ,cmd)))
+ (pop-to-buffer b)
+ (jao-exec-in-vterm (format "%s; exit" ,cmd)
+ ,(when name (format "%s" name)))
+ (setq-local jao-vterm--cmd ,cmd))))
+
+ (jao-def-exec-in-vterm aptitude "aptitude" (jao-afio--goto-scratch))
+ (jao-def-exec-in-vterm htop "htop" (jao-afio--goto-scratch))
+ #+end_src
+*** Vterm repls
+ #+begin_src emacs-lisp
+ (use-package jao-vterm-repl)
+ (jao-define-attached-buffer "^\\* vrepl - .+ \\*.*")
+ #+end_src
diff --git a/exwm.org b/exwm.org
index 34ffb01..d60b408 100644
--- a/exwm.org
+++ b/exwm.org
@@ -459,11 +459,11 @@
("d" jao-exwm-select-pdf "go to doc")
("D" jao-open-doc "open to doc"))
"Packages"
- (("a" jao-vterm-aptitude "aptitude")
+ (("a" jao-term-aptitude "aptitude")
("l" jao-exwm-packages "packages")
("s-w" jao-hydra-exwm/body nil))
"Monitors"
- (("p" jao-vterm-htop "htop")
+ (("p" jao-term-htop "htop")
("x" jao-exwm-xmobar "restart xmobar")
("X" jao-exwm-kill-xmobar "kill xmobar"))
"Network"
@@ -512,7 +512,7 @@
([?\s-b] . jao-hydra-org-blog/body)
([?\s-c] . jao-hydra-chats/body)
([?\s-e] . jao-exwm-firefox-1)
- ([?\s-t] . jao-vterm-here-toggle)
+ ([?\s-t] . jao-term-here-toggle)
([?\s-n] . jao-hydra-ednc/body)
([?\s-O] . jao-transpose-windows)
([?\s-o] . jao-other-window)
diff --git a/init.org b/init.org
index 4da66e4..a2e64e3 100644
--- a/init.org
+++ b/init.org
@@ -766,8 +766,8 @@
(jao-afio--goto-scratch)
(if-let ((b (get-buffer "*wttr*")))
(progn (pop-to-buffer b)
- (vterm-send-string "clear;curl wttr.in\n"))
- (jao-exec-in-vterm "curl wttr.in" "*wttr*"))))
+ (term-send-string "clear;curl wttr.in\n"))
+ (jao-exec-in-term "curl wttr.in" "*wttr*"))))
(global-set-key (kbd "<f5>") #'jao-weather)
#+end_src
*** Timers
@@ -1620,48 +1620,33 @@
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
#+end_src
-*** vterm
+*** term
#+begin_src emacs-lisp
- (use-package vterm
- :ensure t
- :init
- (setq vterm-kill-buffer-on-exit t
- vterm-copy-exclude-prompt t
- vterm-use-vterm-prompt-detection-method t
- vterm-buffer-name-string nil)
- :config
- (define-key vterm-mode-map [(f1)] nil)
- :bind (:map vterm-mode-map (("C-c C-c" . vterm-send-C-c))))
-
- (defun jao-exec-in-vterm (cmd &optional name)
- (vterm)
- (when name (vterm-send-string "unset PROMPT_COMMAND\n"))
- (vterm-send-string cmd)
- (vterm-send-return)
- (when name (rename-buffer name)))
-
- (defvar-local jao-vterm--cmd nil)
+ (defvar-local jao-term--cmd nil)
- (defun jao-vterm--find (cmd)
+ (defun jao-term--find (cmd)
(seq-find (lambda (b)
- (and (eq (buffer-local-value 'major-mode b) 'vterm-mode)
- (string= (or (buffer-local-value 'jao-vterm--cmd b) "")
- cmd)))
+ (with-current-buffer b
+ (and (derived-mode-p 'term-mode)
+ (string= (or jao-term--cmd "") cmd))))
(buffer-list)))
- (defmacro jao-def-exec-in-vterm (name cmd &rest prelude)
- `(defun ,(intern (format "jao-vterm-%s" name)) ()
+ (defun jao-exec-in-term (cmd &optional name)
+ (ansi-term "bash" name)
+ (term-send-string nil (concat cmd "\n")))
+
+ (defmacro jao-def-exec-in-term (name cmd &rest prelude)
+ `(defun ,(intern (format "jao-term-%s" name)) ()
(interactive)
,@prelude
- (if-let ((b (jao-vterm--find ,cmd)))
+ (if-let ((b (jao-term--find ,cmd)))
(pop-to-buffer b)
- (jao-exec-in-vterm (format "%s; exit" ,cmd)
- ,(when name (format "%s" name)))
- (setq-local jao-vterm--cmd ,cmd))))
+ (ansi-term ,cmd ,(format "*%s*" name))
+ (setq-local jao-term--cmd ,cmd))))
- (jao-def-exec-in-vterm aptitude "aptitude" (jao-afio--goto-scratch))
- (jao-def-exec-in-vterm htop "htop" (jao-afio--goto-scratch))
- #+end_src
+ (jao-def-exec-in-term "aptitude" "aptitude" (jao-afio--goto-scratch))
+ (jao-def-exec-in-term "htop" "htop" (jao-afio--goto-scratch))
+ #+end_src
*** Eshell
***** Basic custom
#+begin_src emacs-lisp
@@ -1825,11 +1810,11 @@
(window-list)))))
(select-window w)))
- (defvar jao-shell-here-use-vterm nil)
+ (defvar jao-shell-here-use-term nil)
(defun jao-shell-frame-buffer (&optional b vt)
- (let ((p (if (or vt jao-shell-here-use-vterm)
- 'jao-vterm-buffer
+ (let ((p (if (or vt jao-shell-here-use-term)
+ 'jao-term-buffer
'jao-eshell-buffer)))
(if b (set-frame-parameter nil p b) (frame-parameter nil p))))
@@ -1837,39 +1822,35 @@
(interactive)
(let* ((dir default-directory)
(b (jao-shell-frame-buffer)))
- (if (buffer-live-p b)
- (pop-to-buffer b nil t)
- (if jao-shell-here-use-vterm
- (jao-with-attached-buffer "^vterm$" 35 (vterm))
- (eshell (when (and (boundp 'jao-exwm--use-afio)
- (not jao-exwm--use-afio))
- exwm-workspace-current-index)))
- (jao-shell-frame-buffer (current-buffer)))
- (when (not jao-shell-here-use-vterm)
+ (jao-with-attached-buffer "^\\*\\(ansi-term\\|eshell\\)" 35
+ (if (buffer-live-p b)
+ (pop-to-buffer b nil t)
+ (if jao-shell-here-use-term
+ (jao-exec-in-term "")
+ (eshell (when (and (boundp 'jao-exwm--use-afio)
+ (not jao-exwm--use-afio))
+ exwm-workspace-current-index)))
+ (jao-shell-frame-buffer (current-buffer))))
+ (when (not jao-shell-here-use-term)
(eshell-save-some-history))
(when (not stay)
- (if jao-shell-here-use-vterm
- (progn (vterm-send-C-a)
- (vterm-send-C-k)
- (vterm-send-string (format "cd %s\n" dir)))
+ (if jao-shell-here-use-term
+ (progn (term-send-raw-string "\C-a")
+ (term-send-raw-string "\C-k")
+ (term-send-string (format "cd %s\n" dir)))
(eshell-kill-input)
(eshell/cd dir)
(insert "\n")
(eshell-send-input)))))
- (jao-define-attached-buffer "^\\*eshell\\*" 35)
-
(defun eshell/x ()
(when (derived-mode-p 'eshell-mode)
(when (fboundp 'eshell-autojump-save)
(eshell-autojump-save))
(eshell-save-some-history))
- (if (> (window-height) (1+ (/ (frame-height) 2)))
- (bury-buffer)
- (delete-window)))
-
- (with-eval-after-load "vterm"
- (add-to-list 'vterm-eval-cmds '("x" eshell/x)))
+ (if (> (frame-height) (window-height))
+ (delete-window)
+ (bury-buffer)))
(defun jao-shell-here-toggle ()
(interactive)
@@ -1878,14 +1859,13 @@
(eshell/x)
(jao-shell-here t)))
- (defun jao-vterm-here-toggle ()
+ (defun jao-term-here-toggle ()
(interactive)
- (let ((jao-shell-here-use-vterm t))
+ (let ((jao-shell-here-use-term t))
(call-interactively 'jao-shell-here-toggle)))
(global-set-key (kbd "C-!") #'jao-shell-here)
(global-set-key [(f1)] #'jao-shell-here-toggle)
-
#+end_src
* Version control and CI
*** General options
@@ -2041,11 +2021,6 @@
(add-to-list 'auto-mode-alist '("\\.am\\'" . makefile-mode))
(add-to-list 'auto-mode-alist '("\\.pl\\'\\|\\.pm\\'" . cperl-mode))
#+END_SRC
-*** Vterm repls
- #+begin_src emacs-lisp
- (use-package jao-vterm-repl)
- (jao-define-attached-buffer "^\\* vrepl - .+ \\*.*")
- #+end_src
*** Smart scan
#+begin_src emacs-lisp
(use-package smartscan
@@ -2253,32 +2228,33 @@
(inferior-erlang-shell-type nil)
(erlang-indent-level 4))
- :bind (:map erlang-mode-map (("C-c C-z" . jao-vterm-repl-pop-to-repl)))
+ ;; :bind (:map erlang-mode-map (("C-c C-z" . jao-vterm-repl-pop-to-repl)))
:init
- (require 'jao-vterm-repl)
- (add-to-list 'auto-mode-alist '("^rebar\\.config\\`" . erlang-mode))
- (jao-vterm-repl-register "rebar.config" "rebar3 shell" "^[0-9]+> ")
+ ;; (require 'jao-vterm-repl)
+ ;; (add-to-list 'auto-mode-alist '("^rebar\\.config\\`" . erlang-mode))
+ ;; (jao-vterm-repl-register "rebar.config" "rebar3 shell" "^[0-9]+> ")
:config
- (defun jao-erlang-current-module ()
- (when (save-excursion (goto-char (point-min))
- (re-search-forward "^-module(\\([^)]+\\))" nil t))
- (match-string-no-properties 1)))
-
- (defun jao-erlang-compile (arg)
- (interactive "P")
- (save-some-buffers)
- (when-let ((mname (jao-erlang-current-module)))
- (with-current-buffer (jao-vterm-repl)
- (vterm-send-string (format "c(%s).\n" mname))
- (sit-for 0)
- (setq compilation-last-buffer (current-buffer))
- (when arg (jao-vterm-repl-pop-to-repl)))))
-
- (setq erlang-shell-function #'jao-vterm-repl
- erlang-shell-display-function #'jao-vterm-repl-pop-to-repl
- erlang-compile-function #'jao-erlang-compile))
+ ;; (defun jao-erlang-current-module ()
+ ;; (when (save-excursion (goto-char (point-min))
+ ;; (re-search-forward "^-module(\\([^)]+\\))" nil t))
+ ;; (match-string-no-properties 1)))
+
+ ;; (defun jao-erlang-compile (arg)
+ ;; (interactive "P")
+ ;; (save-some-buffers)
+ ;; (when-let ((mname (jao-erlang-current-module)))
+ ;; (with-current-buffer (jao-vterm-repl)
+ ;; (vterm-send-string (format "c(%s).\n" mname))
+ ;; (sit-for 0)
+ ;; (setq compilation-last-buffer (current-buffer))
+ ;; (when arg (jao-vterm-repl-pop-to-repl)))))
+
+ ;; (setq erlang-shell-function #'jao-vterm-repl
+ ;; erlang-shell-display-function #'jao-vterm-repl-pop-to-repl
+ ;; erlang-compile-function #'jao-erlang-compile)
+ )
#+end_src
*** Idris
#+begin_src emacs-lisp :tangle no
@@ -2297,16 +2273,17 @@
:ensure t
:custom (lsp-clients-elixir-server-executable
(expand-file-name "~/usr/share/elixir-ls/language_server.sh"))
- :bind (:map elixir-mode-map (("C-c C-z" . jao-vterm-repl-pop-to-repl))))
+ ;; :bind (:map elixir-mode-map (("C-c C-z" . jao-vterm-repl-pop-to-repl)))
+ )
(use-package mix
:ensure t
:hook (elixir-mode . mix-minor-mode)
- :init (jao-vterm-repl-register "mix.exs" "iex -S mix" "^iex([0-9]+)> ")
+ ;; :init (jao-vterm-repl-register "mix.exs" "iex -S mix" "^iex([0-9]+)> ")
:diminish ((mix-minor-mode . "")))
(use-package exunit :ensure t)
- #+end_src
+ #+end_src
***** hydra
#+begin_src emacs-lisp
(major-mode-hydra-define elixir-mode nil
@@ -2579,7 +2556,7 @@
(defun jao-ssh ()
(interactive)
(let ((h (completing-read "Host: " (jao-tramp-hosts))))
- (jao-exec-in-vterm (format "ssh %s" h) (format "* %s *" h))))
+ (jao-exec-in-term (format "ssh %s" h) (format "* ssh %s *" h))))
#+end_src
* Chats
*** erc
@@ -3097,7 +3074,7 @@
"go to doc")
("D" jao-open-doc "open to doc"))
"Packages"
- (("a" jao-vterm-aptitude "aptitude")
+ (("a" jao-term-aptitude "aptitude")
("l" list-packages "packages")
("s-w" jao-hydra-emacs-utils/body nil))
"Network"
@@ -3108,7 +3085,7 @@
;; ("v" jao-exwm-proton-vpn "proton vpn")
("c" (jao-chats t) "connect chats"))
"Monitors"
- (("p" jao-vterm-htop "htop")
+ (("p" jao-term-htop "htop")
;; ("P" jao-exwm-proced "proced")
;; ("x" jao-exwm-xmobar "restart xmobar")
;; ("X" jao-exwm-kill-xmobar "kill xmobar")