;; -*- lexical-binding: t; -*- (defun roguelike-evil-insert () (interactive) (vterm-reset-cursor-point) (call-interactively #'evil-insert)) (defun roguelike-buffer-setup () (setq-local cursor-type 'box blink-cursor-mode nil evil-insert-state-cursor 'box evil-normal-state-cursor 'hollow evil-motion-state-cursor 'hollow left-fringe-width 0 right-fringe-width 0) (evil-local-set-key 'normal (kbd "i") #'roguelike-evil-insert)) (defun play-roguelike (exe) (unless (executable-find exe) (user-error "%s is not installed" exe)) (let ((buffer (format "*%s*" exe))) (when (get-buffer buffer) (kill-buffer buffer)) (vterm buffer) (with-current-buffer buffer (roguelike-buffer-setup) (vterm-send-string (format "%s; exit" exe)) (vterm-send-return)) (switch-to-buffer buffer))) (defun nethack () (interactive) (play-roguelike "nethack")) (defvar crawl-executable (expand-file-name "~/crawl/crawl-ref/source/crawl")) (defun crawl () (interactive) (play-roguelike crawl-executable)) (provide 'init-games)