Emacs

Learning Emacs

Emacs has extensive built-in help. If you are not yet familiar with Emacs, start it up and work through its built-in tutorial. Start the tutorial by pressing C-h t (i.e. press control h then press t) or by clicking on the Help menu and choosing Emacs Tutorial.

Using Emacs

Assuming combo.bin has been burned into your target ARM's flash and that Emacs is running, here is how to start the smart terminal.

All this may seem confusing if you have never used Emacs before, but I believe it is well worth the few minutes of experimenting. I believe you will become comfortable with it soon.

Emacs mode for Riscy Pygness

Unfortunately, there is no Emacs mode for Riscy Pygness yet. However, the Inferior Lisp mode that will be active in the smart terminal window buffer gives you much of what you would want, such as command history and command completion.

Putting the following into your .emacs file will give you most of the rest. It will let you send a highlighted a region of Forth code to the target (via the smart terminal) to be compiled.


;;; Interaction with the Lisp buffer running a smart terminal to the Riscy Pygness ARM Forth
;;; These should be incorporated into a major or minor forth mode or riscy mode.
(defun change-line-breaks-to-spaces (str)
  (replace-regexp-in-string "\n\\|\r" " " str))
(defun change-quotes-to-backslashed-quotes (str)
  (replace-regexp-in-string "\"" "\\\\\"" str))

(defun forth-compile-region (start end &optional and-go)
  "Compile the string represented by the high-lighted
region.  At this time, this only compiles.  So, ordinarily, the
region would start with a colon.  Note, we do not seem to be able
to send multiple lines to the Lisp process, so we change all
line feeds to spaces to make a single (possibly very long) line.
We might then later assign this to the C-c C-k keystroke.
We also change quote marks to backslashed quote marks"
  (interactive "r\nP")
  (let ((reg (buffer-substring-no-properties start end)))
    (let ((whole-string
           (concat
            "LISP (compile-string \""
            (change-quotes-to-backslashed-quotes
             (change-line-breaks-to-spaces reg))
            "\")\n")))
      (comint-send-string (inferior-lisp-proc) whole-string)))
  (if and-go (switch-to-lisp t)))

(global-set-key "\C-ck" 'forth-compile-region)   ;; use C-c k  for now