Simple Emacs Interface

Here are a few simple lines that you can put in your .emacs file. They associate .fms files with Lisp (actually, this example assumes SLIME is being used) and bind the key sequence "\C-c\C-o" to run the FOMUS command-line program.

Example 2.7. Emacs Init Lines 1


;; fomus extension--editing works well enough in lisp mode
(add-to-list 'auto-mode-alist '("\\.fms$" . lisp-mode))

;; save buffers & invoke fomus
(setq fomus-args "")
(defun run-fomus ()
  (interactive)
  (save-some-buffers)
  (let ((a (read-from-minibuffer "FOMUS arguments: " fomus-args)))
    (setq fomus-args a)
    (shell-command (format "fomus %s %S" a buffer-file-name))))

;; add slime mode hook
(defun custom-slime-mode-hook ()
  (local-set-key "\C-c\C-o" 'run-fomus))
(add-hook 'slime-mode-hook 'custom-slime-mode-hook)
	


Another option would be to use SLIME's SLIME-INTERACTIVE-EVAL function instead of SHELL-COMMAND:

Example 2.8. Emacs Init Lines 2


;; save buffers and invoke fomus in the default Lisp
(setq fomus-args "")
(defun run-fomus ()
  (interactive)
  (save-some-buffers)
  (let ((a (read-from-minibuffer "FOMUS arguments: " fomus-args)))
    (setq fomus-args a)
    (slime-interactive-eval (format "(fomus %S %s)" buffer-file-name a))))