aboutsummaryrefslogtreecommitdiffstats
path: root/oni/home/services/emacs.scm
diff options
context:
space:
mode:
Diffstat (limited to 'oni/home/services/emacs.scm')
-rw-r--r--oni/home/services/emacs.scm99
1 files changed, 97 insertions, 2 deletions
diff --git a/oni/home/services/emacs.scm b/oni/home/services/emacs.scm
index 7e6ebad..037b253 100644
--- a/oni/home/services/emacs.scm
+++ b/oni/home/services/emacs.scm
@@ -14,12 +14,16 @@
emacs-dashboard
emacs-eros
emacs-ace-link
- emacs-pinentry))
+ emacs-pinentry
+ emacs-vterm))
#:use-module ((gnu home services)
#:select (service-type
service-extension
home-profile-service-type
home-files-service-type))
+ #:use-module ((gnu home services shells)
+ #:select (home-zsh-extension
+ home-zsh-service-type))
#:use-module ((gnu home services shepherd)
#:select (shepherd-service
home-shepherd-service-type))
@@ -56,7 +60,10 @@
home-emacs-golden-ratio-configuration
home-emacs-pinentry-service-type
- home-emacs-pinentry-configuration))
+ home-emacs-pinentry-configuration
+
+ home-emacs-vterm-service-type
+ home-emacs-vterm-configuration))
(define-maybe string)
@@ -398,3 +405,91 @@
(compose identity)
(default-value (home-emacs-pinentry-configuration))
(description "Install and configure emacs-pinentry.")))
+
+;;; Emacs Vterm
+
+(define-configuration/no-serialization home-emacs-vterm-configuration
+ (package
+ (package emacs-vterm)
+ "Package to use for setting emacs-vterm.")
+ (buffer-name-string
+ maybe-string
+ "Format string for the title of vterm buffers.")
+ (extra-content
+ (text-config '())
+ "Extra content for emacs-pinentry configuration."))
+
+(define (add-emacs-vterm-configuration config)
+ (home-emacs-extension
+ (configurations
+ (append
+ (list (mixed-text-file "vterm-config"
+ ";;;;; vterm-config starts here.\n"
+ (let ((buffer-name-string (home-emacs-vterm-configuration-buffer-name-string config)))
+ (if (maybe-value-set? buffer-name-string)
+ (format #f "(setq vterm-buffer-name-string ~s)\n" buffer-name-string)
+ ""))
+ ";;;;; vterm-config ends here.\n"))
+ (home-emacs-vterm-configuration-extra-content config)))))
+
+(define (add-emacs-vterm-zsh-configuration config)
+ (home-zsh-extension
+ (zshrc
+ (list
+ (mixed-text-file
+ "vterm-config"
+ "##### vterm-config starts here.\n"
+ "vterm_printf() {\n"
+ " if [ -n \"$TMUX\" ] && ([ \"${TERM%%-*}\" = \"tmux\" || [ \"${TERM%%-*}\" = \"screen\" ]); then\n"
+ " # Tell tmux to pass the escape sequence through\n"
+ " printf \"\\ePtmux;\\e\\e]%s\\007\\e\\\\\" \"$1\"\n"
+ " elif [ \"${TERM%%-*}\" = \"screen\" ]; then\n"
+ " # GNU screen (screen, screen-256color, screen-256color-bce)\n"
+ " printf \"\\eP\\e]%s\\007\\e\\\\\" \"$1\"\n"
+ " else\n"
+ " printf \"\\e]%s\\e\\\\\" \"$1\"\n"
+ " fi\n"
+ "}\n"
+ "if [[ \"$INSIDE_EMACS\" = 'vterm' ]]; then\n"
+ " alias clear='vterm_printf \"51;Evterm-clear-scrollback\";tput clear'\n"
+ "fi\n"
+ (if (maybe-value-set? (home-emacs-vterm-configuration-buffer-name-string config))
+ (string-append
+ "autoload -U add-zsh-hook\n"
+ "add-zsh-hook -Uz chpwd (){ print -Pn \"\\e]2;%m:%2~\\a\" }\n")
+ "")
+ "vterm_prompt_end() {\n"
+ " vterm_printf \"51;A$(whoami)@$(hostname):$(pwd)\"\n"
+ "}\n"
+ "setopt PROMPT_SUBST\n"
+ "PROMPT=$PROMPT'%{$(vterm_prompt_end)%}'\n"
+ "vterm_cmd() {\n"
+ " local vterm_elisp\n"
+ " vterm_elisp=\"\"\n"
+ " while [ $# -gt 0]; do\n"
+ " vterm_elisp=\"vterm_elisp\"\"$(printf '\"%s\" ' \"$(printf \"%s\" \"$1\" | sed -e 's|\\\\|\\\\\\\\|g' -e 's|\"|\\\\\"|g')\")\"\n"
+ " shift\n"
+ " done\n"
+ " vterm_printf \"51;E$vterm_elisp\"\n"
+ "}\n"
+ "##### vterm-config ends here.\n")))))
+
+(define (add-emacs-vterm-packages config)
+ (list (home-emacs-vterm-configuration-package config)))
+
+(define home-emacs-vterm-service-type
+ (service-type
+ (name 'home-emacs-vterm)
+ (extensions
+ (list (service-extension
+ home-emacs-service-type
+ add-emacs-vterm-configuration)
+ (service-extension
+ home-zsh-service-type
+ add-emacs-vterm-zsh-configuration)
+ (service-extension
+ home-profile-service-type
+ add-emacs-vterm-packages)))
+ (compose identity)
+ (default-value (home-emacs-vterm-configuration))
+ (description "Install and configure emacs-vterm.")))