3 summary:: Using SuperCollider in Emacs
5 section:: Keyboard shortcuts
6 Here is a more extensive and elaborate overview of useful shortcuts in the Emacs Editor. For a general reference to Emacs shortcut, check out this link::http://lpn.rnbhq.org/tools/xemacs/emacs_ref.html##Emacs reference::.
8 ## C-g || Abort current action
9 ## C-h || General help on emacs
11 subsection:: Interpreting code
14 (C-c C-c) || Interpret Selection
15 (only if transient-mark-mode is on)
16 ## C-c C-c || Interpret current line
17 ## C-c C-e || Evaluate expression (in minibuffer)
18 ## C-M-x || Interpret defun
19 ## C-c C-f || Interpret current document
21 subsection:: Control the interpreter
23 ## C-c C-s || Stop (CmdPeriod) / Main.stop
24 ## C-c C-r || Main.run
25 ## C-c C-l || Recompile library
26 ## M-x sclang-stop || Stop interpreter
27 ## C-c C-p p || Show server panels
29 subsection:: Postbuffer and workspace
31 ## C-c C-w || Switch to workspace
32 ## C-c < || Clear postbuffer
33 ## C-c > || Show postbuffer
35 subsection:: Help files
37 ## C-M-h || Show help browser
38 ## C-c C-h || Open help file. You do not need to select a word before using the shortcut. It will suggest the word at the current cursor position, or lets you type a word in the minibuffer. There is autocompletion by typing <TAB>.
39 ## E (in the help browser) || open the help file as plain text (in sclang-mode), so it can be edited.
40 ## C-c C-v (in the help browser) || edit the help file as html code.
42 subsection:: Finding things in class source files
44 ## C-c : || Find definitions (method or class). Again, you can type the word you want to look for in the minibuffer and it suggests the word at the current cursor position.
45 ## C-c ; || Find references to (method or class). (ditto)
46 ## C-c C-k || Open current file at the svn development path location. You need to have set the devpath variable in Platform for this to work properly, e.g.
47 thisProcess.platform.devpath = "~/svn/SuperCollider3".standardizePath;
49 subsection:: Current code completion and interface
51 ## C-c [ || Dump interface
52 ## C-c { || Dump full interface
53 ## C-c C-m / C-c RET || Show method arguments (in minibuffer)
54 ## C-c C-n / M-TAB || Autocomplete keyword (either puts in the one possible completion, or pops up a buffer with possibilities from which you can choose one)
56 subsection:: Files and buffers
58 ## C-x C-f || Open file or new file
59 ## C-x C-s || Save file
60 ## C-x C-w || Save file as
61 ## C-x C-v || Open another file in this buffer
62 ## C-x i || Insert a file at cursor position
63 ## C-x b || Create/switch buffers
64 ## C-x C-b || Show buffer list
65 ## C-x k || Kill buffer
66 ## C-z || Suspend emacs
67 ## C-x C-c || Close down emacs
69 subsection:: Undo and recovery
71 ## C-x u / C-_ || Undo
72 ## C-x u / C-_ || Redo
73 ## M-x revert-buffer RETURN || undo all changes since last save
74 ## M-x recover-file RETURN || Recover text from an autosave-file
75 ## M-x recover-session RETURN || Recover text from an autosave-files if you edited several files
82 ## C-x C-o || Delete blank lines
84 subsection:: Search and replace
86 ## C-s || Search / find. This allows you to set a string in the mini-buffer. The occurences in the text will be highlighted and you can press C-s again and again to jump to next occurences
87 ## C-r || Search / find backwards.
88 ## M-% || Replace and find next
91 subsection:: Navigating and selecting
93 ## M-g g || Goto line ...
94 ## C-x a || Select all
95 ## C-M-f || zips you forward to matching parenthesis, so if you hover over the opening bracket, hit
96 C-<space>, C-M-f, C-c C-c you can quickly execute a block.
97 ## C-M-b || zips you backward to matching parenthesis. If you are just to the right of closing brackets this is handier if you've just finished some code.
98 ## C-f || Move forward a character
99 ## C-b || Move backward a character
100 ## M-f || Move forward a word
101 ## M-b || Move backward a word
102 ## C-n || Move to next line
103 ## C-p || Move to previous line
104 ## C-a || Move to beginning of line
105 ## C-e || Move to end of line
106 ## M-a || Move back to beginning of sentence
107 ## M-e || Move forward to end of sentence
109 subsection:: Formatting
111 ## M-x show-paren-mode || Paren match highlighting. Can also be set from the options menu.
112 ## M-; || Add comment. If you have a text selected, then that text will become a comment. It will remove the commenting // when you have selected a commented text.
113 ## C-M-j || Continue the comment on the next line.
114 ## C-u M-; || Remove comment. This removes the whole comment, so also the text!
115 ## M-x comment-region || Comments the selected region
116 ## M-x uncomment-region || Uncomments the selected region
117 ## TAB || Auto-aligns tabs according to code.
121 (info from EmacsWiki)
122 subsection:: set-mark-command (`C-SPC')
123 A nice feature that not all know about is what happens if you feed it with a universal argument: ‘C-u C-SPC’. It’s an easy way to navigate back to your previous editing spots by jumping to the positions stored in the buffer’s local mark ring. Repeated calls will cycle through the ring of marks.
125 If you use TransientMarkMode and you want to set the mark but don’t want to subsequently see the region highlighting, you can use ‘C-SPC C-g’ to set the mark and then deactivate it.
127 subsection:: pop-global-mark (`C-x C-SPC')
128 In addition to the ordinary mark ring that belongs to each buffer, Emacs has a single global mark ring. It records a sequence of buffers in which you have recently set the mark, so you can go back to those buffers.
130 Setting the mark always makes an entry on the current buffer’s mark ring. If you have switched buffers since the previous mark setting, the new mark position makes an entry on the global mark ring also. The result is that the global mark ring records a sequence of buffers that you have been in, and, for each buffer, a place where you set the mark.
132 ‘C-x C-SPC’ (‘pop-global-mark’) jumps to the buffer and position of the latest entry in the global mark ring. It also rotates the ring, so that successive uses of ‘C-x C-SPC’ take you to earlier and earlier buffers.
134 section:: Customsing Emacs' behaviour
136 You can customize the behaviour of Emacs, by putting things in the startup file of emacs. This file is code:: ~/.emacs ::. You can define options there, for example:
138 (custom-set-variables
139 '(case-fold-search t)
140 '(global-font-lock-mode t nil (font-lock))
141 '(sclang-runtime-directory "~/SuperCollider/")
142 '(show-paren-mode t nil (paren))
143 '(transient-mark-mode t)
146 nil means that an option is turned off, t or 1 means that it is turned on.
148 '(sclang-eval-line-forward nil)
150 Configure the text cursor NOT to move after hitting C-c C-c
152 subsection:: Customize w3m
154 Normally w3m uses the arrow keys to jump between hyperlinks. For browsing SC help files this is not very useful.
156 (eval-after-load "w3m"
158 (define-key w3m-mode-map [left] 'backward-char)
159 (define-key w3m-mode-map [right] 'forward-char)
160 (define-key w3m-mode-map [up] 'previous-line)
161 (define-key w3m-mode-map [down] 'next-line)
162 (setq w3m-auto-show 1)
166 subsection:: Automatically complete brackets and parentheses
168 (setq skeleton-pair t)
169 (global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
170 (global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
171 (global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
172 (global-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
173 (global-set-key (kbd "'") 'skeleton-pair-insert-maybe)
176 subsection:: Scrollwheel support
178 ;;; scrollwheel support
179 (defun scroll-up-half ()
180 "Scroll up half a page."
182 (scroll-up (/ (window-height) 2))
185 (defun scroll-down-half ()
186 "Scroll down half a page."
188 (scroll-down (/ (window-height) 2))
190 (global-set-key [(mouse-5)] 'scroll-up-half)
191 (global-set-key [(mouse-4)] 'scroll-down-half)
194 subsection:: Recent files menu
196 Recentf is a minor mode that builds a list of recently opened files. This list is is automatically saved across Emacs sessions. You can then access this list through a menu. Put this in your `~/.emacs’:
201 For adding a shortcut (C-x C-r) to open a recent file add this code as well:
203 (defun recentf-open-files-compl ()
205 (let* ((all-files recentf-list)
206 (tocpl (mapcar (function
207 (lambda (x) (cons (file-name-nondirectory x) x))) all-files))
208 (prompt (append '("File name: ") tocpl))
209 (fname (completing-read (car prompt) (cdr prompt) nil nil)))
210 (find-file (cdr (assoc-ignore-representation fname tocpl)))))
212 (global-set-key "\C-x\C-r" 'recentf-open-files-compl)
215 section:: More info on Emacs
217 See the link::http://www.emacswiki.org/cgi-bin/wiki##Emacs Wiki::