Compare commits
3 commits
4d0c20712e
...
f5f374274e
Author | SHA1 | Date | |
---|---|---|---|
|
f5f374274e | ||
|
e81a0d8692 | ||
|
2731861d46 |
5 changed files with 188 additions and 33 deletions
|
@ -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
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -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 doesn’t require a dedicate library that requires re-compilation. While offering [[https://elpa.nongnu.org/nongnu-devel/doc/eat.html][online documentation]], I’m 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 doesn’t require a dedicate library that requires re-compilation. While offering [[https://elpa.nongnu.org/nongnu-devel/doc/eat.html][online documentation]], I’m 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"
|
||||||
|
|
142
pud.org
142
pud.org
|
@ -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 Petersen’s [[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 Petersen’s [[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
|
||||||
Wouldn’t it be nice to be able to write commands in an Org file, and send the command to the connected Mud?
|
Wouldn’t 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 I’m connected to more than one MUD, or at least, I often log in with two different characters as two different characters. Let’s have a function that can return all PUD buffers:
|
Since I’m connected to more than one MUD, or at least, I often log in with two different characters as two different characters. Let’s 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 I’m 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=:
|
||||||
|
|
||||||
Let’s send the current line or region.
|
Let’s 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 @@ Let’s send the current line or region.
|
||||||
|
|
||||||
Let’s be able to send the current Org block, where all lines in the block are smooshed together to create a single line:
|
Let’s 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 @@ Let’s 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
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp :tangle no
|
Make a simple mode for basic highlighting of =ev= code. Based on =ruby= (which seems to be close enough).
|
||||||
(define-derived-mode evennia-mode nil "Evennia"
|
|
||||||
|
#+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.
|
"Major mode for editing evennia batch command files.
|
||||||
\\{evennia-mode-map}
|
\\{evennia-mode-map}
|
||||||
Turning on Evennia mode runs the normal hook `evennia-mode-hook'."
|
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)
|
(setq-local require-final-newline mode-require-final-newline)
|
||||||
(add-hook 'conevennia-menu-functions 'evennia-mode-conevennia-menu 10 t))
|
(setq-local comment-start "# ")
|
||||||
|
(setq-local comment-start-skip "#+\\s-*"))
|
||||||
(defvar evennia-mode-font-lock-keywords
|
|
||||||
`(,(rx line-start "@" (one-or-more alnum))
|
|
||||||
)
|
|
||||||
"Additional things to highlight in evennia output.")
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
And add it to org blocks:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp :tangle no
|
||||||
|
(add-to-list 'org-babel-load-languages '(evennia . t))
|
||||||
|
#+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:
|
||||||
|
|
52
zshell.org
52
zshell.org
|
@ -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 we’ve installed [[https://github.com/lsd-rs/lsd][lsd]], let’s make an alias for it:
|
Assuming we’ve installed [[https://github.com/lsd-rs/lsd][lsd]], let’s 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 we’ve installed [[https://github.com/lsd-rs/lsd][lsd]], let’s 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 I’m 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 I’m 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
|
||||||
|
|
Loading…
Reference in a new issue