Next: , Previous: , Up: Mac OS / GNUstep   [Contents][Index]

F.3 Windowing System Events under Mac OS / GNUstep

Nextstep applications receive a number of special events which have no X equivalent. These are sent as specially defined “keys”, which do not correspond to any sequence of keystrokes. Under Emacs, these “key” events can be bound to functions just like ordinary keystrokes. Here is a list of these events.

ns-open-file

This event occurs when another Nextstep application requests that Emacs open a file. A typical reason for this would be a user double-clicking a file in the Finder application. By default, Emacs responds to this event by opening a new frame and visiting the file in that frame (ns-find-file). As an exception, if the selected buffer is the *scratch* buffer, Emacs visits the file in the selected frame.

You can change how Emacs responds to a ns-open-file event by changing the variable ns-pop-up-frames. Its default value, ‘fresh’, is what we have just described. A value of t means to always visit the file in a new frame. A value of nil means to always visit the file in an existing frame.

ns-open-temp-file

This event occurs when another application requests that Emacs open a temporary file. By default, this is handled by just generating a ns-open-file event, the results of which are described above.

ns-open-file-line

Some applications, such as ProjectBuilder and gdb, request not only a particular file, but also a particular line or sequence of lines in the file. Emacs handles this by visiting that file and highlighting the requested line (ns-open-file-select-line).

ns-drag-file

This event occurs when a user drags files from another application into an Emacs frame. The default behavior is to insert the contents of all the dragged files into the current buffer (ns-insert-files). The list of dragged files is stored in the variable ns-input-file.

ns-drag-color

This event occurs when a user drags a color from the color well (or some other source) into an Emacs frame. The default behavior is to alter the foreground color of the area the color was dragged onto (ns-set-foreground-at-mouse). If this event is issued with a Shift modifier, Emacs changes the background color instead (ns-set-background-at-mouse). The name of the dragged color is stored in the variable ns-input-color.

ns-change-font

This event occurs when the user selects a font in a Nextstep font panel (which can be opened with Cmd-t). The default behavior is to adjust the font of the selected frame (ns-respond-to-changefont). The name and size of the selected font are stored in the variables ns-input-font and ns-input-fontsize, respectively.

ns-power-off

This event occurs when the user logs out and Emacs is still running, or when ‘Quit Emacs’ is chosen from the application menu. The default behavior is to save all file-visiting buffers.

Emacs also allows users to make use of Nextstep services, via a set of commands whose names begin with ‘ns-service-’ and end with the name of the service. Type M-x ns-service-TAB to see a list of these commands. These functions either operate on marked text (replacing it with the result) or take a string argument and return the result as a string. You can also use the Lisp function ns-perform-service to pass arbitrary strings to arbitrary services and receive the results back. Note that you may need to restart Emacs to access newly-available services.

Next: , Previous: , Up: Mac OS / GNUstep   [Contents][Index]