Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: emacs editors]] [[toc:]] == Using CHICKEN with emacs Various packages exist for supporting Scheme programming with the [[http://www.gnu.org/software/emacs/|Emacs]] editor. The [[https://github.com/chicken-contrib|chicken-contrib]] organization contains several useful Emacs packages. CHICKEN's git repository contains two Emacs modes that can be helpful for writing CHICKEN code: [[http://code.call-cc.org/cgi-bin/gitweb.cgi?p=chicken-core.git;a=blob_plain;f=misc/chicken.el;hb=HEAD|chicken.el]] and [[http://code.call-cc.org/cgi-bin/gitweb.cgi?p=chicken-core.git;a=blob_plain;f=misc/flymake-chicken.el;hb=HEAD|flymake-chicken.el]] === geiser [[http://www.nongnu.org/geiser/|Geiser]] is a Scheme mode that provides eldoc (modeline signatures and symbol evaluation), auto-complete and company-mode support, documentation search, et al. Chicken support for Geiser is near-complete and recommended for use. Geiser is available on [[http://www.nongnu.org/geiser/geiser_2.html#The-easy-and-quick-way|MELPA]] and via [[http://www.nongnu.org/geiser/geiser_2.html#From-the-source_0027s-mouth|Git]]. Chicken support requires some additional steps: 1. Install the necessary support eggs. <enscript highlight="bash"> $ chicken-install -s apropos chicken-doc </enscript> For Chicken 5, you’ll also need SRFI-18. <enscript highlight="bash"> $ chicken-install -s srfi-18 </enscript> 2. Update the Chicken documentation database. <enscript highlight="bash"> $ cd `csi -p '(chicken-home)'` $ curl http://3e8.org/pub/chicken-doc/chicken-doc-repo.tgz | sudo tar zx </enscript> With Chicken 5, this process has changed slightly: <enscript highlight="bash"> $ cd `csi -e '(import (chicken platform)) (display (chicken-home))(newline)'` $ curl https://3e8.org/pub/chicken-doc/chicken-doc-repo-5.tgz | sudo tar zx </enscript> On Windows you will need to remove the sudo command from the above snippets. === scheme-complete Particularly recommended is [[/users/alex-shinn|Alex Shinn's]] [[http://synthcode.com/wiki/scheme-complete|{{scheme-complete}}]], which provides intelligent autocompletion. === Dan's Emacs Extensions [[dans-custom-emacs]] provides a set of extensions that enable full offline auto-complete w/ chicken-doc integration, complete font-lock support including prefixed modules, and support for all presently installed chicken modules. Recommended for those who find themselves coding without a reliable REPL. === paredit [[http://mumble.net/~campbell/emacs/paredit.el|{{paredit}}]] provides structural editing for Scheme and Lisp code. === Quack Neil van Dyke's [[http://www.neilvandyke.org/quack/|Quack]] enhances Emacs support for Scheme and can be used for editing CHICKEN code. [[image://parenteses.org/mario/misc/chicken-repl+emacs.png|quack]] The screenshot above shows [[http://www.gnu.org/software/emacs|GNU Emacs]] using Quack to edit a "hello world" program and the CHICKEN REPL being executed from within Emacs. === Builtin Scheme support Emacs has builtin support for syntax-highlighting of Scheme code and running a Scheme interpreter in an interactive buffer. To use it with CHICKEN, add this to your {{~/.emacs}} file: (setq scheme-program-name "csi -:c") The {{-:c}} is to force interactive mode, which is required on some platforms (most notably Windows). This variable is customizable, which is the preferred way in GNU Emacs and XEmacs to set user preferences: menu Options -> Customize Emacs -> Specific Option, type in {{scheme-program-name}}. Emacs displays a form; fill in {{csi -:c}} for the program name, click "Set for Current Session", and then "Save for Future Sessions". This will update (or create if it does not already exist) the {{custom-set-variables}} section in your {{~/.emacs}} file. === Useful elisp snippets I have these definitions in my {{~/.emacs}} file, which allow loading the current buffer, optionally by compiling it first to native code: <enscript highlight=elisp> (define-key scheme-mode-map "\C-c\C-l" 'scheme-load-current-file) (define-key scheme-mode-map "\C-c\C-k" 'scheme-compile-current-file) (require 'cmuscheme) (define-key scheme-mode-map "\C-c\C-l" 'scheme-load-current-file) (define-key scheme-mode-map "\C-c\C-k" 'scheme-compile-current-file) (defun scheme-load-current-file (&optional switch) (interactive "P") (let ((file-name (buffer-file-name))) (comint-check-source file-name) (setq scheme-prev-l/c-dir/file (cons (file-name-directory file-name) (file-name-nondirectory file-name))) (comint-send-string (scheme-proc) (concat "(load \"" file-name "\"\)\n")) (if switch (switch-to-scheme t) (message "\"%s\" loaded." file-name) ) ) ) (defun scheme-compile-current-file (&optional switch) (interactive "P") (let ((file-name (buffer-file-name))) (comint-check-source file-name) (setq scheme-prev-l/c-dir/file (cons (file-name-directory file-name) (file-name-nondirectory file-name))) (message "compiling \"%s\" ..." file-name) (comint-send-string (scheme-proc) (concat "(compile-file \"" file-name "\"\)\n")) (if switch (switch-to-scheme t) (message "\"%s\" compiled and loaded." file-name) ) ) ) </enscript> ==== Tweaking stock scheme-mode indentation <enscript higlight=elisp> ;; Indenting module body code at column 0 (defun scheme-module-indent (state indent-point normal-indent) 0) (put 'module 'scheme-indent-function 'scheme-module-indent) (put 'and-let* 'scheme-indent-function 1) (put 'parameterize 'scheme-indent-function 1) (put 'handle-exceptions 'scheme-indent-function 1) (put 'when 'scheme-indent-function 1) (put 'unless 'scheme-indent-function 1) (put 'match 'scheme-indent-function 1) </enscript> ==== Auto-inserting portable shebang boilerplate on creating a scheme file See also the [[/writing portable scripts|writing portable scripts]] page. <enscript higlight=elisp> (require 'autoinsert) (add-hook 'find-file-hooks 'auto-insert) (setq auto-insert-alist '(("\\.scm" . (insert "#!/bin/sh\n#| -*- scheme -*-\nexec csi -s $0 \"$@\"\n|#\n")))) </enscript> ==== Mixing scheme and C code [[http://www.ironoxide.ca/|Dan Leslie]] wrote [[emacs-multi-mode]] for easy switching between scheme-mode and c-mode.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 20 from 3?