Scheme Mechanics Installation for GNU/Linux | scmutils, 4
.
1. Folks, the scmutils library is fantastic and it’s available in Ubuntu 24.04. You can install it very easily with this command:
sudo apt-get install scmutils
2. Then, you just run it with this command:
mit-scheme --band mechanics.com

.
Now, let me tell you, there’s no syntax highlighting. Not great! And more importantly, there’s no direct way to save your code. So, what do you do? You use the Emacs editor. It’s the best!
Now, this assumes you know Emacs. If you don’t, it’s a tremendous editor.
3. Open Emacs’ initialization file. It’s located right here:
~/.emacs
4. Add this beautiful code to the file:
(defun mechanics ()
(interactive)
(run-scheme
"mit-scheme --band mechanics.com"))
(setq sicm-file "~/Documents/tt.scm")
(fset 'set-working-file
(lambda (&optional arg)
(interactive "p")
(funcall (lambda ()
(insert
(concat "(define sicm-file \""
sicm-file
"\")\n"))))))
(fset 'load-scm
(lambda (&optional arg)
(interactive "p")
(funcall (lambda ()
(insert "(load sicm-file)")))))
(defun mechan ()
(interactive)
(split-window-below)
(windmove-down)
(mechanics)
(set-working-file)
(comint-send-input)
(windmove-up)
(find-file sicm-file)
(end-of-buffer)
(windmove-down)
(cond ((file-exists-p sicm-file)
(interactive)
(load-scm)
(comint-send-input)))
(windmove-up))
(defun sicm-exec-line ()
(interactive)
(save-buffer)
(windmove-down)
(comint-send-input)
(windmove-up))
(defun sicm-exec-file ()
(interactive)
(save-buffer)
(windmove-down)
(load-scm)
(comint-send-input)
(windmove-up))
(global-set-key (kbd "C-x C-e") 'sicm-exec-line)
(global-set-key (kbd "C-x C-a") 'sicm-exec-file)
5. Close Emacs and then re-open it, folks.
6. Type the command
M-x mechan
Now, listen, when I say M-x, I mean you press the Alt key and x together. Then, just type mechan. It’s easy, believe me!
7. You’ll see the Emacs editor split into two windows, one on top and one on the bottom.
The lower window is the Scheme environment. You can type a line of code and then press Enter to execute it. So simple!

The upper window is the editor. Type multiple lines of code and then hit
C-x C-e
to execute it.
That means pressing Ctrl and x together, then Ctrl and e together. Easy stuff!
8. When you save the current file, your Scheme code will be saved to this location:
~/Documents/tt.scm
If you need to back up your code, just back up this file. It’s that simple, folks!
— Me@2020-03-10 10:59:45 PM
.
.
2024.12.01 Sunday (c) All rights reserved by ACHK
You must be logged in to post a comment.