emacs.texi 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. @c Emacs integration
  2. @node Emacs integration
  3. @section Emacs integration
  4. Emacs is the canonical development environment for Scheme48. The
  5. @file{scheme.el} and @file{cmuscheme.el} packages provide support for
  6. editing Scheme code and running inferior Scheme processes,
  7. respectively. Also, the @file{scheme48.el} package provides more
  8. support for integrating directly with
  9. Scheme48.@footnote{@file{scheme48.el} is based on the older
  10. @file{cmuscheme48.el}, which is bundled with Scheme48 in the
  11. @file{emacs/} directory. Since @file{cmuscheme48.el} is older and less
  12. developed, it is not documented here.} @file{scheme.el} and
  13. @file{cmuscheme.el} come with GNU Emacs; @file{scheme48.el} is
  14. available separately from
  15. @display
  16. @uref{http://www.emacswiki.org/cgi-bin/wiki/download/scheme48.el}.@end display
  17. To load @file{scheme48.el} if it is in the directory @var{emacs-dir},
  18. add these lines to your @file{.emacs}:
  19. @lisp
  20. (add-to-list 'load-path "@var{emacs-dir}/")
  21. (autoload 'scheme48-mode "scheme48"
  22. "Major mode for improved Scheme48 integration."
  23. t)
  24. (add-hook 'hack-local-variables-hook
  25. (lambda ()
  26. (if (and (boundp 'scheme48-package)
  27. scheme48-package)
  28. (progn (scheme48-mode)
  29. (hack-local-variables-prop-line)))))@end lisp
  30. The @code{add-hook} call sets Emacs up so that any file with a
  31. @code{scheme48-package} local variable specified in the file's
  32. @code{-*-} line or @code{Local Variables} section will be entered in
  33. Scheme48 mode. Files should use the @code{scheme48-package} variable
  34. to enable Scheme48 mode; they should not specify Scheme48 mode
  35. explicitly, since this would fail in Emacs instances without
  36. @file{scheme48.el}. That is, put this at the tops of files:
  37. @lisp
  38. ;;; -*- Mode: Scheme; scheme48-package: ... -*-@end lisp
  39. @noindent
  40. Avoid this at the tops of files:
  41. @lisp
  42. ;;; -*- Mode: Scheme48 -*- @end lisp
  43. There is also SLIME48, the Superior Lisp Interaction Mode for Emacs
  44. with Scheme48. It provides a considerably higher level of integration
  45. the other Emacs packages do, although it is less mature. It is at
  46. @display
  47. @uref{http://mumble.net/~campbell/scheme/slime48.tar.gz};@end display
  48. @noindent
  49. there is also a Darcs repository@footnote{Darcs is a revision control
  50. system; see
  51. @display
  52. @uref{http://www.darcs.net/}@end display
  53. @noindent
  54. for more details.} at
  55. @display
  56. @uref{http://mumble.net/~campbell/darcs/slime48/}.@end display
  57. Finally, @file{paredit.el} implements pseudo-structural editing
  58. facilities for S-expressions: it automatically balances parentheses and
  59. provides a number of high-level operations on S-expressions.
  60. @file{Paredit.el} is available on the web at
  61. @display
  62. @uref{http://mumble.net/~campbell/emacs/paredit.el}.@end display
  63. @file{cmuscheme.el} defines these:
  64. @deffn {Emacs command} run-scheme [scheme-prog]
  65. Starts an inferior Scheme process or switches to a running one. With
  66. no argument, this uses the value of @code{scheme-program-name} to run
  67. the inferior Scheme system; with a prefix argument @var{scheme-prog},
  68. this invokes @var{scheme-prog}.
  69. @end deffn
  70. @defvr {Emacs variable} scheme-program-name
  71. The Scheme program to invoke for inferior Scheme processes.
  72. @end defvr
  73. Under @code{scheme48-mode} with @file{scheme.el}, @file{cmuscheme.el},
  74. and @file{scheme48.el}, these keys are defined:
  75. @table @asis
  76. @item @kbd{C-M-f} --- @code{forward-sexp}
  77. @itemx @kbd{C-M-b} --- @code{backward-sexp}
  78. @itemx @kbd{C-M-k} --- @code{kill-sexp}
  79. @itemx @kbd{@key{ESC} C-@key{DEL}} (@emph{not} @kbd{C-M-@key{DEL}}) --- @code{backward-kill-sexp}
  80. @itemx @kbd{C-M-q} --- @code{indent-sexp}
  81. @itemx @kbd{C-M-@@} --- @code{mark-sexp}
  82. @itemx @kbd{C-M-@key{SPC}} --- @code{mark-sexp}
  83. S-expression manipulation commands. @kbd{C-M-f} moves forward by one
  84. S-expression; @kbd{C-M-b} moves backward by one. @kbd{C-M-k} kills the
  85. S-expression following the point; @kbd{@key{ESC} C-@key{DEL}} kills the
  86. S-expression preceding the point. @kbd{C-M-q} indents the S-expression
  87. following the point. @kbd{C-M-@@} & @kbd{C-M-@key{SPC}}, equivalent to
  88. one another, mark the S-expression following the point.
  89. @item @kbd{C-c z} --- @code{switch-to-scheme}
  90. Switches to the inferior Scheme process buffer.
  91. @item @kbd{C-c C-l} --- @code{scheme48-load-file}
  92. Loads the file corresponding with the current buffer into Scheme48. If
  93. that file was not previously loaded into Scheme48 with @kbd{C-c C-l},
  94. Scheme48 records the current interaction environment in place as it
  95. loads the file; if the file was previously recorded, it is loaded into
  96. the recorded environment. @xref{Emacs integration commands}.
  97. @item @kbd{C-c C-r} --- @code{scheme48-send-region}
  98. @itemx @kbd{C-c M-r} --- @code{scheme48-send-region-and-go}
  99. @kbd{C-c C-r} sends the currently selected region to the current
  100. inferior Scheme process. The file of the current buffer is recorded as
  101. in the @kbd{C-c C-l} command, and code is evaluated in the recorded
  102. package. @kbd{C-c M-r} does similarly, but subsequently also switches
  103. to the inferior Scheme process buffer.
  104. @item @kbd{C-M-x} --- @code{scheme48-send-definition}
  105. @itemx @kbd{C-c C-e} --- @code{scheme48-send-definition}
  106. @itemx @kbd{C-c M-e} --- @code{scheme48-send-definition-and-go}
  107. @kbd{C-M-x} (GNU convention) and @kbd{C-c C-e} send the top-level
  108. definition that the current point is within to the current inferior
  109. Scheme process. @kbd{C-c M-e} does similarly, but subsequently also
  110. switches to the inferior Scheme process buffer. @kbd{C-c C-e} and
  111. @kbd{C-c M-e} also respect Scheme48's file/environment mapping.
  112. @item @kbd{C-x C-e} --- @code{scheme48-send-last-sexp}
  113. Sends the S-expression preceding the point to the inferior Scheme
  114. process. This also respects Scheme48's file/environment mapping.
  115. @end table