Skip to content

Interaction mode for making comint shells

License

Notifications You must be signed in to change notification settings

emacsmirror/shell-maker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 

Repository files navigation

shell-maker

shell-maker is a convenience wrapper around comint mode.

For related packages, see:

A basic shell implementation looks as follows:

(require 'map)
(require 'shell-maker)

(defvar greeter-shell--config
  (make-shell-maker-config
   :name "Greeter"
   :execute-command
   (lambda (command shell)
     (funcall (map-elt shell :write-output)
              (format "Hello \"%s\"." command))
     (funcall (map-elt shell :finish-output) t))))

(defun greeter-shell ()
  "Start a Greeter shell."
  (interactive)
  (shell-maker-start greeter-shell--config))

Invoke shell’s :write-output as many times as needed to stream responses.

(require 'map)
(require 'shell-maker)

(defvar greeter-shell--config
  (make-shell-maker-config
   :name "Greeter"
   :execute-command
   (lambda (command shell)
     (mapc (lambda (char)
             (sit-for 0.008)
             (funcall (map-elt shell :write-output)
                      (format "%c" char)))
           (format "Hello \"%s\". Nice to see you again!

It's been %d days since I last saw you."
                   command (random 30)))
     (funcall (map-elt shell :finish-output) t))))

(defun greeter-shell ()
  "Start a Greeter shell."
  (interactive)
  (shell-maker-start greeter-shell--config))

Support my work

👉 Find my work useful? Support this work via GitHub Sponsors or buy my iOS apps.

My other utilities, packages, apps, writing…

Releases

No releases published

Packages

No packages published