Structure and Interpretation of Classical Mechanics
Scheme Mechanics Installation for GNU/Linux
.
This post assumes that you have already installed the scmutils
library and been able to open it using the standard editor Emacs
.
If not, go to the bottom of this post to click the category scmutils
, so that you can see all the posts in this scmutils
series.
Then go to the post “scmutils, 2.3.2
” to follow the installation and setup instructions.
.
After installing and setting up the scmutils
library, you can start to use it.
However, what if you want to close the Emacs
editor? How to save your scheme
program before closing Emacs
?
By default, you cannot. So I have written a small program to help. Here is the installation instruction:
1. Go to the end of the .emacs
file. Add the following code, if it does not already exist:
(defun mechanics() (interactive) (run-scheme "/usr/local/scmutils/mit-scheme/bin/scheme --library /usr/local/scmutils/mit-scheme/lib" ))
2. Add the following code:
(fset 'set-working-dir (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("(set-working-directory-pathname! \"~/Documents/\")\n" 0 "%d")) arg))) (fset 'load-scm (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("(load \"tt.scm\")" 0 "%d")) arg))) (defun mechan () (interactive) (split-window-below) (windmove-down) (mechanics) (set-working-dir) (comint-send-input) (windmove-up) (find-file "~/Documents/tt.scm") (end-of-buffer) (windmove-down) (cond ((file-exists-p "~/Documents/tt.scm") (interactive) (load-scm) (comint-send-input))) (windmove-up) ) (defun cxce () (interactive) (save-buffer) (windmove-down) (load-scm) (comint-send-input) (windmove-up) ) (global-set-key (kbd "C-x C-e") 'cxce)
3. Close Emacs
. Re-open it.
4. Type the command
M-x mechan
The command M-x
means pressing the Alt
key and x
together. Then type the word mechan
.
5. You will see the Emacs
editor is split into two windows, one up and one down.
The lower window is the scheme
environment. You can type a line of code and the press Enter
to execute it.
The upper window is the editor. You can type multiple lines of code and the type
C-x C-e
to execute it. The command C-x C-e
means pressing Ctrl
and x
together and then Ctrl
and e
.
6. Your scheme
code is saved to the following file
"~/Documents/tt.scm"
In case you need to backup your code, backup this file.
— Me@2020-03-10 10:59:45 PM
.
.
2020.03.10 Tuesday (c) All rights reserved by ACHK
You must be logged in to post a comment.