aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorAdrian Robert2008-07-15 18:15:18 +0000
committerAdrian Robert2008-07-15 18:15:18 +0000
commitedfda78355c5528eee489fa8a7f9c73bf8e734f2 (patch)
tree78d2414d9791e1efc17ec9b35b438ae35602340a /doc
parent1391cd548782097e34d7856ec4f20ca90bdf2c26 (diff)
downloademacs-edfda78355c5528eee489fa8a7f9c73bf8e734f2.tar.gz
emacs-edfda78355c5528eee489fa8a7f9c73bf8e734f2.zip
merging Emacs.app (NeXTstep port)
Diffstat (limited to 'doc')
-rw-r--r--doc/emacs/ChangeLog5
-rw-r--r--doc/emacs/ns-emacs.texi1019
2 files changed, 1024 insertions, 0 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index 21582c220a0..88bf6e2a08a 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,8 @@
12008-07-15 Adrian Robert <Adrian.B.Robert@gmail.com>
2
3 * ns-emacs.texi: New file, documents features of Emacs port under
4 NeXTstep windowing.
5
12008-07-15 Chong Yidong <cyd@stupidchicken.com> 62008-07-15 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * entering.texi (Entering Emacs): Update prev node. 8 * entering.texi (Entering Emacs): Update prev node.
diff --git a/doc/emacs/ns-emacs.texi b/doc/emacs/ns-emacs.texi
new file mode 100644
index 00000000000..1e8c4fe7512
--- /dev/null
+++ b/doc/emacs/ns-emacs.texi
@@ -0,0 +1,1019 @@
1\input texinfo @c -*-texinfo-*-
2
3@setfilename ../info/ns-emacs
4@settitle Emacs.app
5
6@iftex
7@finalout
8@end iftex
9
10@titlepage
11@sp 10
12@center @titlefont{Emacs.app}
13
14@center (Version 9.0-rc1, April, 2006)
15
16@sp 2
17@center Carl Edman
18@sp 2
19@center Christian Limpach
20@sp 2
21@center Scott Bender
22@sp 2
23@center Christophe de Dinechin
24@sp 2
25@center Adrian Robert
26@sp 2
27
28@end titlepage
29
30@unnumbered Distribution
31@*
32Copyright @copyright{} 1994 Carl Edman.@*
33Copyright @copyright{} 1997 Christian Limpach.
34Copyright @copyright{} 1997 Scott Bender.
35Copyright @copyright{} 2001 Christophe de Dinechin.
36Copyright @copyright{} 2005-07 Adrian Robert.
37
38Permission is granted to make and distribute verbatim copies of
39this manual provided the copyright notice and this permission notice
40are preserved on all copies.
41
42@ignore
43Permission is granted to process this file through Tex and print the
44results, provided the printed document carries copying permission
45notice identical to this one except for the removal of this paragraph
46(this paragraph not being relevant to the printed manual).
47
48@end ignore
49Permission is granted to copy and distribute modified versions of this
50manual under the conditions for verbatim copying, provided that the entire
51resulting derived work is distributed under the terms of a permission
52notice identical to this one.
53
54Permission is granted to copy and distribute translations of this manual
55into another language, under the same conditions as for modified versions.
56
57@ignore
58@menu
59* Introduction::
60* Events::
61* Preferences Panel::
62* Preferences::
63* Tips and Tricks::
64* Thanks::
65@end menu
66@end ignore
67
68@node Top, Introduction, (dir), (dir)
69@top Emacs.app
70
71Emacs.app for GNUstep and MacOS X (http://emacs-app.sf.net) is a version of
72GNU Emacs CVS unicode-2 branch (currently planned to be released as Emacs 23)
73which adds support for the GNUstep and MacOS X systems via the OpenStep APIs
74(referred to as "Cocoa" under OS X). Support for NeXTstep, OpenStep, and
75Rhapsody systems has been dropped. For those systems, use "Emacs-on-Aqua",
76available at http://emacs-on-aqua.sf.net.
77
78This port leaves most of the core functions of Emacs unchanged and is
79fully-compatible with all Emacs Lisp packages, however it has a number of
80step-ish features which do not have any equivalent in Emacs's X11 interface.
81The design aim was to make it look as similar as possible to an X application
82to Emacs Lisp programs and to make it look like a normal GNUstep or MacOS X
83application to users.
84
85(From here on out we refer to this port as "Emacs.app", and the systems
86supported by this port as "NeXTstep", "NS", or "OpenStep", because saying
87GNUstep / MacOS X is too clumsy. Both systems were derived from the NeXTstep
88libraries developed by NeXT, Inc. for its NeXT computer and operating system,
89whose APIs were later published as the OpenStep specification. All classes
90and functions in these APIs start with the letters 'NS' for this historical
91reason.)
92
93Comments and bug reports relating to the window system interface are welcome.
94To report a bug please use the @samp{Help/Report Emacs.app bug...} menu item.
95This sends messages to the maintainer. (Note, please include your email
96address if you don't usually send email from this machine.)
97
98Problems and bugs which do not relate to the NS support (i.e. which can be
99reproduced even in a dumb terminal or under the Carbon port or X11) should be
100reported through the normal Emacs channels.
101
102Also, please inspect the ``Known Issues'' contained in the README file you may
103have received with this distribution or listed at the web site
104http://emacs-app.sf.net .
105
106There is also a developer mailing list for Emacs.app,
107<emacs-app-dev-@@lists.sourceforge.net>. Sign up through the project page at
108http://emacs-app.sf.net. A user mailing list will be added in time and if
109warranted.
110
111
112@menu
113* Introduction:: What you need to know to use and program.
114* Events:: How NS window system events are handled.
115* Preferences Panel:: Using the Preferences Panel to customize Emacs.
116* Customization:: Customization for Emacs.app.
117* Tips and Tricks:: Collected hints from Emacs users
118* Thanks:: The people who helped create Emacs.app
119@end menu
120
121@node Introduction, Events, Top, Top
122@section Introduction
123
124Despite the size and complexity of GNU Emacs, NeXTstep and the NeXTstep
125support code, this manual can be kept mercifully short by saying that
126everything written in the Emacs and the Emacs Lisp manuals about GNU Emacs
127applies equally to this Emacs except as noted here.
128
129@itemize @bullet
130@item
131The ``right-click'' button (usually the right-hand button on a two-button
132mouse) is mapped to Mouse-3, instead of Mouse-2 as earlier versions of
133Emacs.app. This is for compatibility with X versions of emacs. To get some
134of the old behavior back, you can put in your .emacs:
135
136@lisp
137(global-set-key [mouse-3] 'mouse-yank-at-click)
138@end lisp
139
140The other functionality of mouse-3 in a buffer of extending a selection is
141available via shift-click as in other NS applications. To pop up a context
142menu,
143
144@item
145The Alt or Opt key is bound to the traditional emacs "meta" by default, while
146the NS "command" key is bound to 'super', for which a set of keybindings are
147set to mimic other NeXTstep applications. (See @ref{Events}.) You can change
148either of these bindings using the preferences panel (see @ref{Preferences
149Panel}).
150
151@item
152The standard NeXTstep font and color panels are accessible through the Windows
153menu, or through the standard Cmd-t and Cmd-C. These are easier to use than
154Emacs's own methods for setting these items. To use the color panel, drag
155from it to an emacs frame. The foreground (or background, if shift is held
156down) of the face at that point will be changed. To finalize settings for
157either color or font, choose 'Save Preferences' from under the Help menu. To
158discard these settings, create a new frame and close the altered one.
159
160@item
161Opening files / directories and 'Save Buffer As' operated from the menus use
162the standard NS file panels. Likewise if you use Cmd-o or Cmd-S. However,
163if you use the regular Emacs key combinations Ctrl-x,Ctrl-f and Ctrl-x,w for
164these functions, the normal Emacs mode of typing filenames into the minibuffer
165is used.
166
167@item
168On GNUstep, in an X-windows environment you need to use Cmd-c instead of one
169of the Ctrl-w or Meta-w commands to transfer text to the X primary selection.
170(Ordinarily the "clipboard" selection is used, for compatibility with more
171modern Gnome and KDE programs.) Likewise, Cmd-y (instead of Ctrl-y) will
172yank/paste in the X primary selection instead of the kill-ring / clipboard.
173
174@item
175The @code{window-system} variable can now have the value @code{ns} in addition
176to, e.g., @code{x} or @code{nil}. You can use this in your .emacs file:
177
178If you just want to distinguish between cases in which there is a
179window system and in which there isn't, this construct is useful.
180@lisp
181(if window-system
182 ... ;;; evaluate if any window system is running
183 ...) ;;; evaluate only when running on a dumb terminal
184@end lisp
185
186For more detailed control, use this.
187@lisp
188(cond
189 ((eq window-system 'ns) ;;; NS specific instructions
190 ...)
191 ((eq window-system 'x) ;;; X specific instructions
192 ...)
193 (t ;;; Instructions for dumb terminal or other window systems
194 ...))
195@end lisp
196
197@item
198Likewise, you can detect whether you are running in emacs-23 or an earlier
199version with:
200
201@lisp
202 (if (eq emacs-major-version '23) <emacs-23 code> <emacs-22- code>)
203@end lisp
204
205@item
206Most NS specific functions begin with 'ns-'. Do "C-h f ns-[TAB]" to list
207these. Many of these replace equivalent 'x-' functions, while others perform
208uniquely NS things, such as Service invocation.
209
210@item
211There are also NS variables beginning with 'ns-', however in most cases users
212need not pay attention to them since the customizability they provide is also
213available through the defaults system and preferences panel (see
214@ref{Preferences Panel} and @ref{Customization}).
215
216@item
217When Emacs is called by a name which ends in @file{-nw} it will always
218start in terminal mode. For example, a user who needs a terminal only
219emacs would create a symbolic link from @file{emacs} to @file{emacs-nw}.
220When he launches @file{emacs-nw} from the command line, the window
221system will never be involved. (Note, as of rc2, terminal mode is still not
222working under OS X.)
223@end itemize
224
225@node Events, Preferences Panel, Introduction, Top
226@section Events
227
228Under Emacs.app the NeXTstep command key works as the @dfn{super} modifier
229key. In principle users can bind their command keys to whatever function they
230want, but to make the transition for NS users easier the default NS startup
231files bind the most commonly used NS command keys to work just like they do in
232most other NS applications. Some are shown in the menus. Choose "List
233Keybindings" from the Help menu and scroll down to the keys labeled starting
234with 's-' to see all of them.
235
236NS applications receive a number of special events which have no X equivalent.
237These are sent as specially defined ``keys'' (which don't correspond to any
238keyboard stroke combination). Under Emacs these ``key'' events can be bound
239to functions just like ordinary keystrokes. Here is a list of these events.
240
241@table @code
242@item ns-open-file
243This event occurs when another NeXTstep application requests that Emacs
244open a file. A typical reason for this would be a user double-clicking
245a file in the Finder. When this event is registered the
246name of the file to open is found in the variable @code{ns-input-file}.
247
248The behaviour of the default binding is controlled by the variable
249@code{ns-pop-up-frames}. It's default value @code{'fresh} causes Emacs
250to open the new file in the selected frame if the selected buffer is a
251scratch buffer. Otherwise Emacs opens a new frame and displays the file
252in that.
253
254To always get a new frame one would change @code{ns-pop-up-frames} to
255@code{t}. To get the opposite behaviour (i.e. always putting the file into
256the selected frame), change @code{ns-pop-up-frames} to @code{nil}.
257
258@item ns-open-temp-file
259This event occurs when another application requests that Emacs open a
260temporary file. The file name is again in @code{ns-input-file}. By
261default this is handled by just generating a @code{ns-open-file} event
262(which then causes the @code{ns-open-file} function to be called
263whatever that may be).
264
265@lisp
266(define-key global-map [ns-open-temp-file] [ns-open-file])
267@end lisp
268
269@item ns-open-file-line
270Some applications (like e.g. ProjectBuilder or gdb) request not only a
271particular file, but also a particular line or sequence of lines in the
272file. The file name is in @code{ns-input-file}, and
273@code{ns-input-line} is either the line or a cons cell the car of which
274contains the beginning line and the cdr of which the ending line.
275
276@lisp
277(define-key global-map [ns-open-file-line] 'ns-open-file-select-line)
278@end lisp
279
280@item ns-drag-file
281When a user drags files from another application into an Emacs frame
282this event is triggered. Here @code{ns-input-file} is a list of all
283dragged files. The default binding inserts all the dragged files into
284the current buffer.
285
286@lisp
287(define-key global-map [ns-drag-file] 'ns-insert-files)
288@end lisp
289
290@item ns-drag-color
291When a user drags a color from the color well (or some other source)
292Emacs sees this event and @code{ns-input-color} contains the name of the
293dragged color. The default bindings alter the foreground color of the
294area the color was dragged onto (or background color if the color was
295shift dragged).
296
297@lisp
298(define-key global-map [ns-drag-color]
299 'ns-set-foreground-at-mouse)
300(define-key global-map [S-ns-drag-color]
301 'ns-set-background-at-mouse)
302@end lisp
303
304@item ns-change-font
305Emacs.app allows the user to open a standard NS font panel (by default that
306function is bound to @kbd{Cmd-t}). When the user selects a font in that
307panel this event occurs. @code{ns-input-font} will contain the name of
308the selected font and @code{ns-input-fontsize} is its size. The
309default binding causes Emacs to adjust the font of the selected frame.
310
311@lisp
312(define-key global-map [ns-change-font] 'ns-respond-to-changefont)
313@end lisp
314
315@item ns-power-off
316Finally when the user logs out and Emacs is still running it receives
317this event so that it has a chance to save its files before it dies.
318
319@lisp
320(define-key global-map [ns-power-off]
321 '(lambda () (interactive) (save-buffers-kill-emacs t)))
322@end lisp
323
324@end table
325
326Emacs.app also allows users to make use of NeXTstep services programatically,
327in addition to via the Services menu. On the most basic level programmers can
328use the @code{ns-perform-service} to pass arbitrary strings to arbitrary
329services and receive the results back. However convenience functions are
330automatically provided for all services so there should be no need to use
331this. These function names begin with 'ns-service-', and they will either
332operate on marked text (replacing it with the result) or take a string
333argument and return the result as a string. Type "M-x ns-service-[TAB][TAB]"
334to see those currently defined. Note that Emacs may require a restart to
335access newly available services.
336
337
338@node Preferences Panel, Customization, Events, Top
339@section Preferences Panel
340
341The Preferences Panel can be used to set or change some of the settings for
342Emacs such as the text appearance, cursor settings, and key bindings.
343
344To save any settings changed through the Preferences Panel, hit OK;
345this has the same effect as if you had explicitly chosen Help > Save
346Preferences.
347
348To restore Emacs to use its default settings click Reset to Defaults from
349the Preferences Panel.
350
351Additional GNUstep/OS X preferences may be set from the command line using
352the @command{defaults} command. (See @ref{Customization}.)
353
354
355@section Text Rendering Preferences
356
357Font and color settings can be set using the standard NeXTstep font
358and color panels.
359
360@itemize @bullet
361@item
362To set the default font used by Emacs click the Default Font... button
363to launch the Font Panel. Click on a frame before selecting the font
364family, typeface, and size of the default font from the Font Panel.
365
366Note that the default font will not be changed if a frame hasn't been
367selected first.
368
369@item
370To set the default foreground or background color click the
371Colors... button to launch the Color Panel. Choose the color you want
372using any of the color models (color wheel, sliders, palette, image,
373or crayons) available from the Colors toolbar. To apply the color
374drag a swatch from the color bar at the top of the panel to text on
375an Emacs frame. Holding down shift will change the background color
376instead of the foreground.
377
378@item
379To use antialiased text check the Smooth Fonts option. Lighter font
380smoothing can be achieved by checking the Use Quickdraw (lighter)
381smoothing option.
382
383@item
384To change the line height that text is displayed at drag the Expand
385Line Spacing slider. When the slider is set to 0.0 Emacs will use the
386same line height as other Mac OS X applications. To increase the line
387height (and decrease the number of lines that can be displayed on the
388screen) drag the slider towards 1.0. To decrease the line height
389(increases the number of lines that can be displayed) drag the slider
390towards -1.0.
391
392After the line spacing setting has been changed Emacs must be restarted
393to take account of the change.
394
395@end itemize
396
397@section Display Preferences
398
399The Display Preferences can be used to change the appearance of the
400default cursor used by Emacs.
401
402@itemize @bullet
403@item
404The Cursor Type radio buttons can be used to select the style used for the cursor:
405
406@itemize
407@item
408Box - the cursor is displayed as a box
409@item
410Underscore - the cursor is displayed as a horizontal bar
411@item
412Bar - the cursor is displayed as a vertical bar
413@item
414Hollow - the cursor is displayed as a box with an outline but no fill
415@end itemize
416
417@item
418Use the Cursor Blink Rate slider to set the frequency at which the cursor blinks.
419
420@item
421Check the Use System Highlight Color option to use the system default
422color for highlighted text.
423
424@end itemize
425
426@section Modifier Interpretation Preferences
427
428The Modifier Preferences can be used to change the behaviour of the
429Alt/Opt and Command keys. By default the Alt or Opt key is bound to
430the Emacs 'Meta' key, and the Command key is bound to 'super' which
431allows the Command key to function in a way similar to other
432NeXTstep/OS X applications.
433
434@itemize @bullet
435@item
436To re-bind the Alt or Opt key select a keybinding from the Alt/Opt Key
437combo box.
438@item
439To re-bind the Command key select a keybinding from the Command Key
440combo box.
441@end itemize
442
443
444@node Customization, Tips and Tricks, Preferences Panel, Top
445@section Customization
446
447Under X, resources are used to customize the behavior of Emacs to the needs of
448the user. These resources are queried programmatically with the
449@code{x-get-resource} function. Under NS defaults fulfill a similar function.
450They can be read using the @code{ns-get-resource} function. Calls to
451@code{x-get-resource} are automatically mapped to @code{ns-get-resource}.
452From the command line, the command `@code{defaults read Emacs}' will show
453these resources as of last Emacs quit, and individual resources can be
454read/written by commands like `@code{defaults read Emacs Foo}' and
455`@code{defaults write Emacs Foo barvalue}'.
456
457Calling the function @code{ns-save-preferences} in lisp, or selecting ``Save
458Options'' from the 'Options' menu will automatically write out the defaults
459corresponding to the selected window.
460
461In addition, it is also possible to set many of the following customizations
462by setting the @code{default-frame-alist} in the @file{~/.emacs} file.
463
464Many of the preferences relating specifically to the NS windowing system (font
465rendering, cursor type, etc.) can be set using a @ref{Preferences Panel}
466accessed in the standard fashion from the menubar or Cmd-,. It is important
467to note that when you hit 'OK' on this panel, @emph{all} NS settings are saved
468(including font and colors) just as if you had called
469@code{ns-save-preferences}.
470
471Note that if you use the 'Default Font' button on the Preferences panel, you
472must click on a frame before selecting a font, otherwise nothing will happen.
473If you pop up the color panel, you must drag colors to a frame for them to
474have an effect. (Remember to hold down 'shift' to change background instead
475of foreground.)
476
477This is a listing of some of the more useful defaults (and their default
478values). Several of these defaults accept the names of colors as values. For
479a list of all available colors pull up the color panel and look at the color
480list called ``Emacs''. Emacs also accepts color specifications of the form
481@samp{ARGBaarrggbb} where @var{aa}, @var{rr}, @var{gg}, and @var{bb} are two
482hexadecimal digits describing the alpha, red, green, and blue content of the
483color respectively. @samp{HSBhhssbbaa}, @samp{CMYKccmmyykkaa} and
484@samp{GRAYggaa} are the equivalents in @samp{HSB}, @samp{CMYK} and gray
485scales.
486
487@table @samp
488@item InternalBorderWidth
489Width in pixels of the internal border of the NS frame. This acts to separate
490the text area of the window from the fringes, scrollbars, and/or edges.
491
492@example
493defaults write Emacs InternalBorderWidth 2
494@end example
495
496@item VerticalScrollBars
497@samp{YES} or @samp{NO} to enable or disable scroll bars, @samp{left} or
498@samp{right} to explicitly set the side.
499
500@example
501defaults write Emacs VerticalScrollBars YES
502@end example
503
504@item Font
505Name of the default font to be used for new frames (which can be overriden by
506various faces). If this font is not set, Emacs.app will use the system
507wide fixed pitch font. For most users the system fixed pitch font will be
508@samp{Monaco} which doesn't have any bold or italic versions. (Italic will be
509synthesized.)
510
511@item FontSize
512Size of the font to be used for new frames. If not set Emacs for NS will use
513the default size of the system wide fixed pitch font.
514
515@item Foreground
516The default foreground (text) color for new frames.
517
518@example
519defaults write Emacs Foreground "Black"
520@end example
521
522@item Background
523The default background color for new frames.
524
525@example
526defaults write Emacs Background "White"
527@end example
528
529@item Height
530Height in rows of the default window.
531
532@example
533defaults write Emacs Height 48
534@end example
535
536@item Width
537Width in columns of the default window.
538
539@example
540defaults write Emacs Width 80
541@end example
542
543@item CursorType
544Name of the default cursor type for Emacs. Allowed values are
545@samp{box}, @samp{hollow}, @samp{underscore}, @samp{bar}, @samp{line} and @samp{no}.
546
547@example
548defaults write Emacs CursorType box
549@end example
550
551@item CursorBlinkRate
552Users who want their cursor to blink can set the rate (in seconds) with
553this defaults write. Setting it to @samp{NO} disables cursor blinking.
554
555@example
556defaults write Emacs CursorBlinkRate NO
557@end example
558
559@item CursorColor
560Name of the default cursor color for Emacs. Of a particular use for this
561setting is the @samp{Highlight} "color". When it is the cursor color,
562Emacs will draw the cursor using the standard NS highlighting operator.
563
564@example
565defaults write Emacs CursorColor Highlight
566@end example
567
568@item Top
569Distance in pixels from the top of the screen of the upper left corner
570of the default window.
571
572@example
573defaults write Emacs Top 100
574@end example
575
576@item Left
577Distance in pixels from the left edge of the screen to the upper left
578corner of the default window.
579
580@example
581defaults write Emacs Left 100
582@end example
583
584@item HideOnAutoLaunch
585@samp{YES} or @samp{NO} to determine whether Emacs will hide itself when
586autolaunched from the dock.
587
588@example
589defaults write Emacs HideOnAutoLaunch NO
590@end example
591
592@item ExpandSpace
593This lets you expand or shrink the line height used for displaying text. When
594this is set to 0.0, display should look like other NS apps. If you set it
595higher than 0, Emacs will spread the text lines apart, less than 0, compress
596them together. (With settings below zero parts of characters may be chopped
597off in certain fonts.) When using the @ref{Preferences Panel}, this is
598controlled by a slider. You must OK the panel and then restart Emacs.app for
599this default to take effect.
600
601When setting this using @code{"defaults write"}, you can either set a floating
602point value, or @samp{YES}, which is equivalent 0.5, or @samp{NO}, which is
603equivalent to 0.0.
604
605@example
606defaults write Emacs ExpandSpace -0.125
607@end example
608
609@item GSFontAntiAlias
610This turns antialiasing on and off on. Note that, on OS X, even if
611antialiasing is on, Emacs will not antialias text of a size below the system
612preference setting.
613
614@example
615defaults write Emacs GSFontAntiAlias NO
616@end example
617
618@item UseQuickdrawSmoothing
619On OS X 10.3 and higher, this will render fonts using Quickdraw antialiasing,
620which is less heavy than the Quartz antialiasing used by default. Whether
621this is on or off, the system font size threshold for antialiasing (see above)
622is respected.
623
624@example
625defaults write Emacs UseQuickdrawSmoothing YES
626@end example
627
628@item AlternateModifier
629This allows you to set the effect of the Alt or Opt key. The default is
630@samp{meta}, meaning to use as the Emacs 'meta' key. You can also set this to
631@samp{command}, @samp{hyper}, @samp{alt}, or @samp{none}. The last is useful
632for Continental users who normally use this key to enter accented and other
633special characters.
634
635@example
636defaults write Emacs AlternateModifier "none"
637@end example
638
639@item CommandModifier
640This allows you to set the effect of the Command key. The default is
641@samp{super}, which is used in a set of keybindings such as @code{s-o} for
642``open file'' and @code{s-z} for ``undo'' that are similar to other NeXTstep
643applications. On the other hand, some people who use the Alt/Opt key for
644accent entry like to set this to @samp{meta} so they still have easy access to
645Emacs functionality bound to meta keys. You can also set this, like Alt/Opt,
646to @samp{hyper} or @samp{alt}, though there are no bindings to combinations
647using these keys by default. The @samp{none} option is not available for the
648Command key.
649
650@example
651defaults write Emacs CommandModifier "meta"
652@end example
653
654@item fooFrame
655Position and size to use for the frame named @var{foo} when it is
656created. The position and size have to be specified as a space
657separated list: @samp{top}, @samp{left}, @samp{height} and
658@samp{width}. @samp{top} and @samp{left} are expressed in pixels,
659@samp{height} is given in rows and @samp{width} is given in columns.
660Named frames can be created by e.g. @code{(make-frame '((name
661. "FOO")))}.
662
663@example
664defaults write Emacs TestFrame "100 200 30 70"
665@end example
666
667Another default previouly used by many Emacs users is this.
668
669@example
670defaults write Workspace DefaultOpenApp Emacs
671@end example
672
673It caused the NeXTstep Workspace to open files without a registered extension
674in Emacs instead of as usual Edit. For this default to work, Emacs needed to
675be in the application search path of the Workspace (which usually includes
676@file{~/Applications} and @file{~/Applications}). If anyone knows the current
677way to do this under OS X please contact the authors.
678
679@end table
680
681@node Tips and Tricks, Thanks, Customization, Top
682@section Tips and Tricks
683
684Emacs is an extremely customizable editor. You can make it conform to
685virtually any conceivable user idiosyncrasy (and some which are not) by adding
686a few well-chosen lines of emacs lisp to your @file{~/.emacs}. Unfortunately
687even many experienced C developers are unfamiliar with Emacs Lisp. For that
688reason many Emacs.app defaults have been chosen to make it behave as similar
689to TextEdit as possible. But there are some customizations which a majority
690of users probably would hate as much as a minority would love them. This
691section contains a cookbook of such customizations. New contributions by
692Emacs users are very welcome.
693
694@menu
695* Grabbing environment variables::
696* Miscellaneous useful variables::
697* Color adjustments::
698* Evaling in the minibuffer::
699* Highlighting matching parentheses::
700* Dealing with X specific packages::
701* Rebinding the numeric keypad::
702* Improving C mode::
703* Custom menu items::
704* Single line scrolling::
705* Open files by dragging to an Emacs window::
706@ignore
707* Extended font customization::
708@end ignore
709@end menu
710
711@node Grabbing environment variables, Miscellaneous useful variables, Tips and Tricks, Tips and Tricks
712@subsection Grabbing environment variables
713
714Many programs which may run under Emacs like latex or man depend on the
715settings of environment variables. If Emacs is launched from the shell, it
716will automatically inherit these environment variables and its subprocesses
717will inherit them from it. But if Emacs.app is launched from the Finder it
718is not a descendant of any shell, so its environment variables haven't been
719set which often causes the subprocesses it launches to behave differently than
720they would when launched from the shell.
721
722To solve this problem for Emacs.app, there are two solutions. First is to
723run, from the command line:
724
725@example
726.../Emacs.app/Contents/MacOS/bin/mac-fix-env
727@end example
728
729This will pick up your environment settings and save them into a special file
730@file{~/.MacOSX/environment.plist}, which the desktop environment will use to
731set the environment for all launched applications. The drawback of this
732method is it needs to be run again whenever something changes.
733
734The other approach is to use the @code{ns-grabenv} command inside Emacs. This
735function will run a subshell and copy its environment variables into Emacs.
736
737Adding this line to your @file{~/.emacs} will grab the csh environment
738whenever emacs runs under a window system.
739
740@lisp
741(if window-system (ns-grabenv))
742@end lisp
743
744If you have a different shell you will have to give @code{ns-grabenv} some
745arguments. For zsh you would do this.
746
747@lisp
748(if window-system (ns-grabenv "/usr/bin/zsh"
749 "source /etc/zshenv"
750 "source ~/.zshenv"))
751@end lisp
752
753The reason that @code{ns-grabenv} is not done by default is that it adds up
754to a second or two to the Emacs startup time.
755
756@node Miscellaneous useful variables, Color adjustments, Grabbing environment variables, Tips and Tricks
757@subsection Miscellaneous useful variables
758
759This section describes a few variables you might want to set in your
760@file{~/.emacs} each of which doesn't warrant its own section.
761
762There is a conflict between the way the region behaved in emacs in the
763pre-GUI days and the way GUI users expect the selection to work. By
764default that conflict is resolved by having the former adopt the
765behaviour of the latter which most people prefer. However if you are a
766die-hard emacs user you may prefer things the other way around and add
767this line to your @file{~/.emacs}. Experiment with both settings.
768
769@lisp
770(setq transient-mark-mode nil)
771@end lisp
772
773When you try to move beyond the end of a file Emacs used to add newlines as
774needed, however from Emacs-21 on, this was no longer done. If you prefer the
775old behavior, this line in your @file{~/.emacs} will restore it.
776
777@lisp
778(setq next-line-add-newlines t)
779@end lisp
780
781By default when you kill a line with text on it, only the text is
782removed while the line itself remains. You have to kill twice to really
783get rid of the whole line. When this variable is set and you kill a
784line while at the beginning of the line it will go at once.
785
786@lisp
787(setq kill-whole-line t)
788@end lisp
789
790Annoyed by the Emacs startup message ? Add this and you start with a
791tabula rasa.
792
793@lisp
794(setq inhibit-startup-message t)
795@end lisp
796
797@node Color adjustments, Evaling in the minibuffer, Miscellaneous useful variables, Tips and Tricks
798@subsection Color adjustments
799
800A non-elisp hint: The easiest way to adjust your emacs color scheme is to
801bring up a color panel (with @key{Cmd-C}) and drag the color you want over the
802emacs face you want to change. Normal dragging will alter the foreground
803color. Shift dragging will alter the background color. To make the changes
804permanent select the "Save Options" item in the "Options" menu, or run
805@code{ns-save-preferences}. Useful in this context is the listing of all
806faces obtained by @key{M-x} @code{list-faces-display}.
807
808@node Evaling in the minibuffer, Highlighting matching parentheses, Color adjustments, Tips and Tricks
809@subsection Evaling in the minibuffer
810
811Often you (at least if you are an elisp hacker) want to quickly evaluate
812an elisp expression. To accomodate this desire Emacs provides the
813@code{eval-expression} command bound to @key{M-:}. By default it is
814disabled to protect novice users from themselves. These commands
815re-enable it and turn on an extremely powerful completion facility.
816
817@lisp
818(put 'eval-expression 'disabled nil)
819
820(define-key read-expression-map "\t" 'lisp-complete-symbol)
821@end lisp
822
823@node Highlighting matching parentheses, Dealing with X specific packages, Evaling in the minibuffer, Tips and Tricks
824@subsection Highlighting matching parentheses
825
826I doubt that there is anybody who doesn't use this already, but just in
827case:
828
829@lisp
830(show-paren-mode 't)
831@end lisp
832
833In Emacs.app this is currently enhanced by use of the @code{mic-paren} package
834from http://www.docs.uu.se/~mic/emacs.html.
835
836@node Dealing with X specific packages, Rebinding the numeric keypad, Highlighting matching parentheses, Tips and Tricks
837@subsection Dealing with X specific packages
838
839Some emacs lisp packages explicitly call X specific functions instead of
840calling generic functions which call the NS or X versions as appropriate.
841Typically such packages will result in error messages like @samp{Symbol's
842function definition is void: x-foo-bar}. The proper way of dealing with this
843is to have the author fix the code to call the generic functions. Generally
844all that requires is removing the @samp{x-} prefix from all function calls.
845
846However, sometimes that is not possible, or it may be a package internal to
847emacs itself. In this case please report a bug to the Emacs.app maintainers
848(not the main GNU emacs maintainers).
849
850A related problem is font names. For historical reasons, Emacs assumes all
851font names are given ``X style'', as in ``-adobe-courier-....-iso8859-1''.
852Emacs.app tries to work around this as well as possible, and the best thing to
853do is never rely on functions to set font names yourself but to always use the
854font panel.
855
856@node Rebinding the numeric keypad, Improving C mode, Dealing with X specific packages, Tips and Tricks
857@subsection Rebinding the numeric keypad
858
859By default in Emacs the numeric keypad keys are bound to the same
860characters they are in all other NS applications. But it is easy to
861change these bindings to commands many will find more useful. As an
862example here is the code which rebinds the numeric keypad for me.
863
864@lisp
865(global-set-key [kp-0] 'other-window)
866(global-set-key [kp-1] 'end-of-buffer)
867(global-set-key [kp-2] [down])
868(global-set-key [kp-3] 'scroll-up)
869(global-set-key [kp-4] [left])
870(global-set-key [kp-5] 'set-mark-command)
871(global-set-key [kp-6] [right])
872(global-set-key [kp-7] 'beginning-of-buffer)
873(global-set-key [kp-8] [up])
874(global-set-key [kp-9] 'scroll-down)
875(global-set-key [kp-decimal] 'yank)
876(global-set-key [kp-enter] 'set-mark-command)
877(global-set-key [kp-add] 'copy-region-as-kill)
878(global-set-key [kp-subtract] 'kill-region)
879@end lisp
880
881On machines with function keys they can be bound as well. This for example
882would bind @key{F12} to run gnus.
883
884@lisp
885(global-set-key [f12] 'gnus)
886@end lisp
887
888@node Improving C mode, Custom menu items, Rebinding the numeric keypad, Tips and Tricks
889@subsection Improving C mode
890
891That underscores are considered to break words in C mode has been driving me
892insane for a long time. This line fixes the problem.
893
894@lisp
895(modify-syntax-entry ?_ "w" c-mode-syntax-table)
896@end lisp
897
898@node Custom menu items, Single line scrolling, Improving C mode, Tips and Tricks
899@subsection Custom menu items
900
901The tools menu is intended for customization. Adding items to it is
902relatively painless as this example illustrates.
903
904@lisp
905(define-key global-map [menu-bar tools www] '("WWW" . w3-use-hotlist))
906@end lisp
907
908@node Single line scrolling, Open files by dragging to an Emacs window, Custom menu items, Tips and Tricks
909@subsection Single line scrolling
910
911The meta-arrow keys will perform single-line scrolling in Emacs
912just like they did in the old NeXT/OpenStep Stuart.app.
913
914@node Open files by dragging to an Emacs window, , Single line scrolling, Tips and Tricks
915@subsection Open files by dragging to an Emacs window
916
917The default behaviour when a user drags files from another application
918into an Emacs frame is to insert the contents of all the dragged files
919into the current buffer. To remap the @code{ns-drag-file} event to
920open the dragged files in the current frame use the following line:
921
922@lisp
923(define-key global-map [ns-drag-file] 'ns-find-file)
924@end lisp
925
926@ignore
927@node Extended font customization, , Single line scrolling, Tips and Tricks
928@subsection Extended font customization
929
930By default Emacs tries to guess the right font when you ask for a bold,
931italic or bold-italic face. Unfortunately this fails sometimes, for
932example Emacs won't guess that it should use @samp{Courier-Bold} as the
933font for the bold face of @samp{Ohlfs}. As an example here is the code
934which sets up @samp{Courier-Bold}, @samp{Courier-Oblique} and
935@samp{Courier-BoldOblique} as the fonts to be used with @samp{Ohlfs}.
936
937@lisp
938(setq ns-convert-font-trait-alist
939 '(("Ohlfs" "Courier-Bold" "Courier-Oblique"
940 "Courier-BoldOblique")))
941@end lisp
942
943You will still have to set the @samp{DefaultFont}, @samp{BoldFont},
944@samp{ItalicFont} and @samp{Bold-ItalicFont} defaults as Emacs
945initializes the default faces before it reads your @file{~/.emacs}.
946Also Emacs initializes @code{ns-convert-font-trait-alist} from these
947defaults so that normally it's sufficient to set these defaults to get
948correct faces.
949
950@example
951defaults write Emacs DefaultFont Ohlfs
952defaults write Emacs BoldFont Courier-Bold
953defaults write Emacs ItalicFont Courier-Oblique
954defaults write Emacs Bold-ItalicFont Courier-BoldOblique
955@end example
956@end ignore
957
958
959@node Thanks, , Tips and Tricks, Top
960@section Thanks
961A signficant number of people have been involved in the creation of Emacs.app.
962Carl Edman <cedman@@lynx.ps.uci.edu> created and maintained Emacs up to
963version 4.1 and it's reasonable to say that without his work, Emacs.app
964wouldn't exist. Michael Brouwer <michael@@thi.nl> wrote the original version
965(up to and including version 3.x) and was a constant contributor to Emacs.app
966version 4 and above. Christian Limpach <chris@@nice.ch> took over maintenance
967and updating at version 4.2, and made substantial contributions in a number of
968areas. Scott Bender <sbender@@harmony-ds.com> ported the code to OpenStep and
969Rhapsody for version 6.0. Christophe de Dinechin <ddd@@cup.hp.com> ported the
970code to MacOS X for version 7.0 and moved the code base to SourceForge. Leigh
971Smith <leigh@@leighsmith.com> maintained the SourceForge project for a period.
972Adrian Robert <arobert@@cogsci.ucsd.edu> ported the code to GNUstep
973(http://gnustep.org), updated it for post-emacs-20, and maintains it for the
974present.
975
976Also a number of others have contributed code. Steve Nygard
977<nygard@@telusplanet.net> got emacs to dump under OpenStep. The font panel
978code was Andrew Athan's <athan@@object.com> work. Joe Reiss
979<jreiss@@magnus.acs.ohio-state.edu> both created the beautiful icons you see
980and wrote the popup menu and dialog box code as well as much else. (Actually,
981Joe's icon became the one used for the Mac Carbon port..)
982
983Finally, suggestions from Darcy Brockbank, Timothy Bissell, Scott Byer, David
984Griffiths, Scott Hess, Eberhard Mandler, John C. Randolph, and Bradley Taylor
985all helped things along at one point or another. Axel Seibert
986<seiberta@@informatik.tu-muenchen.de> and Paul J. Sanchez
987<paul@@whimsy.umsl.edu> offered their time and machines to make a binary
988release possible.
989
990The GNUstep port was made possible through the assistance of Adam Fedor, Fred
991Kiefer, M. Uli Klusterer, Alexander Malmberg, and Jonas Matton. Gürkan Sengün
992made it accessible to a wider community.
993
994Riccardo Mottola helped with compatibility with MacOS versions 10.1 and 10.2,
995and GNUstep on platforms other than Linux.
996
997Peter Dyballa kept things honest with multilingual support. Rahul Abrol, Adam
998Ratcliffe, David M. Cooke, and Carsten Bormann provided various small patches.
999
1000Then there were a number of people who kept up the constant supply of bug
1001reports, suggested features and praise (which is the main fuel which the
1002development of a project like this runs) and so helped ensure that this
1003program is as bug free (hah !) and feature rich as you see it today. First
1004among them were Hardy Mayer <hardy@@golem.ps.uci.edu>, Gisli Ottarsson
1005<gisli@@timoshenko.eecs.umich.edu>, Anthony Heading <ajrh@@signal.dra.hmg.gb>,
1006David Bau <bau@@cs.cornell.edu>, Jamie Zawinski <jwz@@lucid.com>, Martin
1007Moncrieffe <moncrief@@mayo.edu>, Simson L. Garfinkel
1008<simsong@@next.cambridge.ma.us>, Richard Stallman <rms@@gnu.ai.mit.edu>,
1009Stephen Anderson <anderson@@sapir.cog.jhu.edu>, Ivo Welch
1010<ivo@@next.agsm.ucla.edu>, Magnus Nordborg <magnus@@fisher.Stanford.EDU>, Tom
1011Epperly <epperly@@valeron.che.wisc.edu>, Andreas Koenig
1012<k@@franz.ww.tu-berlin.de>, Yves Arrouye <Yves.Arrouye@@imag.fr>, Anil
1013Somayaji <soma@@hotspur.mit.edu>, Gregor Hoffleit
1014<flight@@mathi.uni-heidelberg.DE> and doubtlessly many more.
1015
1016Finally, let us also thank those few hundred other people on the mailing list
1017from whom we didn't hear much, but the presence of which assured us that maybe
1018this project was actually worth doing.
1019@bye