Compare commits

...

3 commits

Author SHA1 Message Date
Howard Abrams
f5f374274e Get zshell to work with vterm
Some recent apps need vterm instead of eat.
2025-08-08 19:10:01 -07:00
Howard Abrams
e81a0d8692 Create an evennia-mode
And break out the org-blocks into an ob-evennia source file.

Allows us to have :session and C-c C-c evaluation behavior.

Probably doesn't work flawlessly, and will need tweaks on my main system.
2025-08-08 19:08:29 -07:00
Howard Abrams
2731861d46 Change dashboard and vterm for work laptop 2025-08-04 09:06:57 -07:00
5 changed files with 188 additions and 33 deletions

View file

@ -144,6 +144,14 @@ The [[https://github.com/emacs-dashboard/emacs-dashboard][emacs-dashboard]] proj
(rx " (" (zero-or-more any) eol) "" (emacs-version)))) (rx " (" (zero-or-more any) eol) "" (emacs-version))))
(string-replace "\n" "" smaller-version))) (string-replace "\n" "" smaller-version)))
(setq dashboard-startup-banner
(if (ha-emacs-for-work?)
"~/src/hamacs/support/teal-sticker.png"
;; Choose a random image from my collection of startup images:
(thread-first "~/src/hamacs/support/dashboard"
(directory-files t (rx ".png"))
(seq-random-elt))))
(setq dashboard-banner-logo-title (setq dashboard-banner-logo-title
(format "Emacs %s — %s" (format "Emacs %s — %s"
(if (and (fboundp 'native-comp-available-p) (if (and (fboundp 'native-comp-available-p)
@ -151,10 +159,6 @@ The [[https://github.com/emacs-dashboard/emacs-dashboard][emacs-dashboard]] proj
"with Native Compilation" "") "with Native Compilation" "")
(ha-dashboard-version)) (ha-dashboard-version))
;; Choose a random image from my collection of startup images:
dashboard-startup-banner (thread-first "~/src/hamacs/support/dashboard"
(directory-files t (rx ".png"))
(seq-random-elt))
dashboard-center-content t dashboard-center-content t
dashboard-set-init-info t dashboard-set-init-info t
dashboard-projects-switch-function 'project-switch-project dashboard-projects-switch-function 'project-switch-project

View file

@ -101,7 +101,7 @@ Instead of memorizing all the Emacs-specific keybindings, we use [[https://githu
(">" python-indent-shift-left "Shift Left") (">" python-indent-shift-left "Shift Left")
("<" python-indent-shift-right "Shift Right")) ("<" python-indent-shift-right "Shift Right"))
"Navigate/Eval" "Navigate/Eval"
(("e" python-evaluate/body "Evaluate...") (("e" python-evaluate/body "Eval...")
("g" python-goto/body "Go to...")) ("g" python-goto/body "Go to..."))
"Docs" "Docs"
(("d" python-eldoc-at-point "Docs on Symbol") (("d" python-eldoc-at-point "Docs on Symbol")

View file

@ -121,9 +121,12 @@ I'm not giving up on Eshell, but I am playing around with [[https://github.com/a
VTerm has an issue (at least for me) with ~M-Backspace~ not deleting the previous word, and yeah, I want to make sure that both keystrokes do the same thing. VTerm has an issue (at least for me) with ~M-Backspace~ not deleting the previous word, and yeah, I want to make sure that both keystrokes do the same thing.
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp
(use-package vterm (use-package vterm
:config :config
(setq vterm-shell "zsh"
vterm-kill-buffer-on-exit t)
(ha-leader (ha-leader
"p t" '("terminal" . (lambda () (interactive) (ha-shell (project-root (project-current)))))) "p t" '("terminal" . (lambda () (interactive) (ha-shell (project-root (project-current))))))
@ -154,7 +157,7 @@ The advantage of running terminals in Emacs is the ability to copy text without
** Eat ** Eat
While not as fast as [[https://github.com/akermu/emacs-libvterm][vterm]], the [[https://codeberg.org/akib/emacs-eat][Emulate a Terminal]] project (eat) is fast enough, and doesnt require a dedicate library that requires re-compilation. While offering [[https://elpa.nongnu.org/nongnu-devel/doc/eat.html][online documentation]], Im glad for an [[info:eat#Top][Info version]]. While not as fast as [[https://github.com/akermu/emacs-libvterm][vterm]], the [[https://codeberg.org/akib/emacs-eat][Emulate a Terminal]] project (eat) is fast enough, and doesnt require a dedicate library that requires re-compilation. While offering [[https://elpa.nongnu.org/nongnu-devel/doc/eat.html][online documentation]], Im glad for an [[info:eat#Top][Info version]].
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp :tangle no
(use-package eat (use-package eat
:straight (:host codeberg :repo "akib/emacs-eat" :straight (:host codeberg :repo "akib/emacs-eat"
:files ("*.el" ("term" "term/*.el") "*.texi" :files ("*.el" ("term" "term/*.el") "*.texi"

148
pud.org
View file

@ -2,7 +2,7 @@
#+author: Howard X. Abrams #+author: Howard X. Abrams
#+date: 2025-01-18 #+date: 2025-01-18
#+filetags: emacs hamacs #+filetags: emacs hamacs
#+lastmod: [2025-06-09 Mon] #+lastmod: [2025-08-05 Tue]
A literate programming file for a Comint-based MUD client. A literate programming file for a Comint-based MUD client.
@ -30,13 +30,13 @@ A literate programming file for a Comint-based MUD client.
This project is a simple MUD client for Emacs, based on COM-INT MUD client I learn about on Mickey Petersens [[https://www.masteringemacs.org/article/comint-writing-command-interpreter][essay on Comint]]. This project is a simple MUD client for Emacs, based on COM-INT MUD client I learn about on Mickey Petersens [[https://www.masteringemacs.org/article/comint-writing-command-interpreter][essay on Comint]].
This uses eithr =ssh= or good ol =telnet= for the connection. Surprised that one can still install in on a Mac, like: This uses either =ssh= or good ol =telnet= for the connection. Surprised that one can still install =telnet= on a Mac, like:
#+BEGIN_SRC sh #+BEGIN_SRC sh
brew install telnet brew install telnet
#+END_SRC #+END_SRC
Use your favorite way to install Emacs packages, for instance, with Emacs 30, once can install it, and customize some settings in one go with =use-package=: Use your favorite way to install Emacs packages, for instance, with Emacs 30, one could install and customize settings in one go with =use-package=:
#+BEGIN_SRC emacs-lisp :tangle no :eval no #+BEGIN_SRC emacs-lisp :tangle no :eval no
(use-package pud (use-package pud
@ -428,9 +428,28 @@ Note that =comint-process-echoes=, depending on the mode and the circumstances,
* Org Babel * Org Babel
Wouldnt it be nice to be able to write commands in an Org file, and send the command to the connected Mud? Wouldnt it be nice to be able to write commands in an Org file, and send the command to the connected Mud?
#+begin_src emacs-lisp :exports none :tangle ~/.emacs.d/elisp/ob-evennia.el
;;; ob-evennia --- Evennia source blocks in Org -*- lexical-binding: t; -*-
;;
;; © 2025 Howard X. Abrams
;; Licensed under a Creative Commons Attribution 4.0 International License.
;; See http://creativecommons.org/licenses/by/4.0/
;;
;; Author: Howard X. Abrams <http://gitlab.com/howardabrams>
;; Maintainer: Howard X. Abrams
;; Created: January 18, 2025
;;
;; While obvious, GNU Emacs does not include this file or project.
;;
;; *NB:* Do not edit this file. Instead, edit the original literate file at:
;; /Users/howard/src/hamacs/pud.org
;; And tangle the file to recreate this one.
;;
;;; Code:
#+end_src
Since Im connected to more than one MUD, or at least, I often log in with two different characters as two different characters. Lets have a function that can return all PUD buffers: Since Im connected to more than one MUD, or at least, I often log in with two different characters as two different characters. Lets have a function that can return all PUD buffers:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/elisp/ob-evennia.el
(defun pud-get-all-buffers () (defun pud-get-all-buffers ()
"Return a list of all buffers with a live PUD connection." "Return a list of all buffers with a live PUD connection."
(save-window-excursion (save-window-excursion
@ -444,7 +463,7 @@ Since Im connected to more than one MUD, or at least, I often log in with two
And a wrapper around =completing-read= for choosing one of the buffers: And a wrapper around =completing-read= for choosing one of the buffers:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/elisp/ob-evennia.el
(defun pud-current-world () (defun pud-current-world ()
"Return buffer based on user choice of current PUD connections." "Return buffer based on user choice of current PUD connections."
(let ((pud-buffers (pud-get-all-buffers))) (let ((pud-buffers (pud-get-all-buffers)))
@ -459,7 +478,7 @@ And a wrapper around =completing-read= for choosing one of the buffers:
Given a buffer and a string, use the =comint-send-string=: Given a buffer and a string, use the =comint-send-string=:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/elisp/ob-evennia.el
(defun pud-send-string (buf-name text) (defun pud-send-string (buf-name text)
"Send TEXT to a comint buffer, BUF-NAME." "Send TEXT to a comint buffer, BUF-NAME."
(save-window-excursion (save-window-excursion
@ -472,7 +491,7 @@ Given a buffer and a string, use the =comint-send-string=:
Lets send the current line or region. Lets send the current line or region.
#+BEGIN_SRC emacs-lisp :results silent #+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/elisp/ob-evennia.el
(defun pud-send-line (world) (defun pud-send-line (world)
"Send the current line or region to WORLD." "Send the current line or region to WORLD."
(interactive (list (pud-current-world))) (interactive (list (pud-current-world)))
@ -491,7 +510,7 @@ Lets send the current line or region.
Lets be able to send the current Org block, where all lines in the block are smooshed together to create a single line: Lets be able to send the current Org block, where all lines in the block are smooshed together to create a single line:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/elisp/ob-evennia.el
(defun pud-send-block (world) (defun pud-send-block (world)
"Send the current Org block to WORLD." "Send the current Org block to WORLD."
(interactive (list (pud-current-world))) (interactive (list (pud-current-world)))
@ -503,28 +522,109 @@ Lets be able to send the current Org block, where all lines in the block are
(pud-send-string world (pud-send-string world
(replace-regexp-in-string (replace-regexp-in-string
(rx (one-or-more space)) " " text)))) (rx (one-or-more space)) " " text))))
#+END_SRC #+END_SRC
And code so that we can =(require 'ob-evennia)= to get font-locking working in blocks.
#+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/elisp/ob-evennia.el
(require 'ob)
(defvar org-babel-default-header-args:evennia '())
(defun org-babel-execute:evennia (body params)
"Execute evennia BODY.
PARAMS can contain the following:
:session - The buffer to send the block
Called by `org-babel-execute-src-block'."
(let* ((session (cdr (assq :session params)))
(buffer (or session (pud-current-world))))
(if session
(setq buffer (format "*%s*" session)))
(pud-send-string buffer
(replace-regexp-in-string
(rx (one-or-more space)) " " body))
(message "No connected world.")))
(defun org-babel-prep-session:evennia (_session _params)
"Signal error; Evennia does not (currently) support sessions."
(error "Evennia sessions are nonsensical"))
(provide 'ob-evennia)
#+END_SRC
This should allow this client to simply =require= it:
#+BEGIN_SRC emacs-lisp
(require 'ob-evennia)
#+END_SRC
* Evennia Mode * Evennia Mode
Make a simple mode for basic highlighting of =ev= code. #+begin_src emacs-lisp :exports none :tangle ~/.emacs.d/elisp/evennia-mode.el
;;; evennia-mode --- Syntax coloring for Evennia code -*- lexical-binding: t; -*-
;;
;; © 2025 Howard X. Abrams
;; Licensed under a Creative Commons Attribution 4.0 International License.
;; See http://creativecommons.org/licenses/by/4.0/
;;
;; Author: Howard X. Abrams <http://gitlab.com/howardabrams>
;; Maintainer: Howard X. Abrams
;; Created: January 18, 2025
;;
;; While obvious, GNU Emacs does not include this file or project.
;;
;; *NB:* Do not edit this file. Instead, edit the original literate file at:
;; /Users/howard/src/hamacs/pud.org
;; And tangle the file to recreate this one.
;;
;;; Code:
#+end_src
Make a simple mode for basic highlighting of =ev= code. Based on =ruby= (which seems to be close enough).
#+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/elisp/evennia-mode.el
(define-derived-mode evennia-mode ruby-mode "Evennia"
"Major mode for editing evennia batch command files.
\\{evennia-mode-map}
Turning on Evennia mode runs the normal hook `evennia-mode-hook'."
(setq-local require-final-newline mode-require-final-newline)
(setq-local comment-start "# ")
(setq-local comment-start-skip "#+\\s-*"))
#+END_SRC
And add it to org blocks:
#+BEGIN_SRC emacs-lisp :tangle no #+BEGIN_SRC emacs-lisp :tangle no
(define-derived-mode evennia-mode nil "Evennia" (add-to-list 'org-babel-load-languages '(evennia . t))
"Major mode for editing evennia batch command files.
\\{evennia-mode-map}
Turning on Evennia mode runs the normal hook `evennia-mode-hook'."
(setq-local comment-start "# ")
(setq-local comment-start-skip "#+\\s-*")
(setq-local require-final-newline mode-require-final-newline)
(add-hook 'conevennia-menu-functions 'evennia-mode-conevennia-menu 10 t))
(defvar evennia-mode-font-lock-keywords
`(,(rx line-start "@" (one-or-more alnum))
)
"Additional things to highlight in evennia output.")
#+END_SRC #+END_SRC
Final stuff to require to include this major-mode:
#+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/elisp/evennia-mode.el
;; Add the mode to the auto-mode-alist for specific file extensions
(add-to-list 'auto-mode-alist '("\\.ev\\'" . evennia-mode))
;; Provide the mode for use
(provide 'evennia-mode)
#+END_SRC
How does this look?
#+BEGIN_SRC evennia :tangle /tmp/testing.ev
# Comments, while not used much are comments.
@one two = "three" :four
#+END_SRC
This client can =require= to depend on this mode.
#+BEGIN_SRC emacs-lisp export none
(require 'evennia-mode)
#+END_SRC
* Technical Artifacts :noexport: * Technical Artifacts :noexport:
Let's =provide= a name so we can =require= this file: Let's =provide= a name so we can =require= this file:

View file

@ -328,11 +328,59 @@ With these variables defined, we can create simple aliases:
alias eee="$EMACS --create-frame --no-wait" alias eee="$EMACS --create-frame --no-wait"
#+END_SRC #+END_SRC
** Vterm
To work with [[https://github.com/akermu/emacs-libvterm][VTerm in Emacs]], we need to create this function:
#+BEGIN_SRC zsh
vterm_printf() {
if [ -n "$TMUX" ] \
&& { [ "${TERM%%-*}" = "tmux" ] \
|| [ "${TERM%%-*}" = "screen" ]; }
then
# Tell tmux to pass the escape sequences through
printf "\ePtmux;\e\e]%s\007\e\\" "$1"
elif [ "${TERM%%-*}" = "screen" ]; then
# GNU screen (screen, screen-256color, screen-256color-bce)
printf "\eP\e]%s\007\e\\" "$1"
else
printf "\e]%s\e\\" "$1"
fi
}
#+END_SRC
This allows us to execute Emacs commands:
#+BEGIN_SRC zsh
vterm_cmd() {
local vterm_elisp
vterm_elisp=""
while [ $# -gt 0 ]; do
vterm_elisp="$vterm_elisp""$(printf '"%s" ' "$(printf "%s" "$1" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g')")"
shift
done
vterm_printf "51;E$vterm_elisp"
}
#+END_SRC
For instance:
#+BEGIN_SRC zsh
if [[ "$INSIDE_EMACS" = 'vterm' ]]
then
alias clear='vterm_printf "51;Evterm-clear-scrollback";tput clear'
vim() {
vterm_cmd find-file "$(realpath "${@:-.}")"
}
fi
#+END_SRC
* Aliases * Aliases
Assuming weve installed [[https://github.com/lsd-rs/lsd][lsd]], lets make an alias for it: Assuming weve installed [[https://github.com/lsd-rs/lsd][lsd]], lets make an alias for it:
#+BEGIN_SRC zsh #+BEGIN_SRC zsh
if whence lsd if whence lsd >/dev/null
then then
alias ls=lsd alias ls=lsd
fi fi
@ -341,7 +389,7 @@ Assuming weve installed [[https://github.com/lsd-rs/lsd][lsd]], lets make
The [[https://github.com/jtdaugherty/ccat][ccat project]] (like bat) adds syntax coloring to text files. For big files, it certainly slows down the output, and Im wondering if I want these aliases. The [[https://github.com/jtdaugherty/ccat][ccat project]] (like bat) adds syntax coloring to text files. For big files, it certainly slows down the output, and Im wondering if I want these aliases.
#+BEGIN_SRC zsh #+BEGIN_SRC zsh
if whence cless if whence cless >/dev/null
then then
alias less=cless alias less=cless
alias cat=ccat alias cat=ccat