[ Combined Document ] | Contents | Previous | Next
Emacs can run in two different interface modes: the Windows interface, which allows the flexible use and mixture of fonts and colors; and the console interface, which constrains Emacs to the limitations of console windows. The following two sections describe how to specify and change the size, position, font, and color attributes of Emacs in both interface modes.
With the Windows interface, you can change the size, position, font, and color attributes of Emacs using three different mechanisms: using the mouse with the user interface, by specifying them as command line arguments, or by invoking Emacs Lisp functions. You will probably find it convenient to specify command line arguments in the Properties of the shortcut to the runemacs.exe file, and to invoke the lisp functions in your startup file. For information on how to propagate attributes to new frames, see the section below on frames .
To customize the size of specific frames, including the initial frame, see the section on customizing frames below.
emacs -g 80x40
Note that the geometry command can be combined with the position command, as described below.
(set-frame-height (selected-frame) 40)
(set-frame-width (selected-frame) 80)
To customize the position of specific frames, including the initial frame, see the section on customizing frames below.
emacs -g +10+30
To combine the size with position, first specify the size and then the position. The two examples above can be combined as follows:
emacs -g 80x40+10+30
Note that you can also specify position offsets from any of the corners of the screen. See the GEOMETRY SPECIFICATIONS section of the X man page for complete details on the geometry command.
(set-frame-position (selected-frame) 10 30)
As with other windowing attributes, Emacs uses the X Windows color names for specifying colors on the command line and in elisp. One set of these names is a set of abstract color names, e.g., red, green, and blue. These names are the ones you will typically use as arguments on the command line or in elisp functions. Emacs also supports the use of numeric color names; see the COLOR NAMES section of the X man page for complete details on how to specify numeric color names and their color spaces.
To see the abstract color names that Emacs understands and the colors that they map to, use the menu command Edit->Text Properties->Display Colors, or invoke the list-colors-display function in the *scratch* buffer:
If you would like to change the mapping of color names to RGB values, or to add new color names to Emacs, then you will want to modify the alist w32-color-map (win32-color-map in Emacs 19). To make changes, you can simply cons new mappings onto the head of the alist:
(setq win32-color-map (cons '("snow" . 16448255) win32-color-map)) ; Emacs 19 (setq w32-color-map (cons '("snow" . 16448255) w32-color-map)) ; Emacs 20
The number in the element is the logical OR of three values for the red, green, and blue components: (B << 16 | G << 8 | R). In the example above, red is 255, green is 250, and blue is 250. At some point there will be support for reading in files with color mappings to make this process a little easier.
To customize colors for specific frames, see the section on customizing frames below.
To customize colors for color syntax highlighting, see the section on font-lock .
emacs -fg yellow -bg black
This elisp changes the background color to black:
The following elisp changes the mode line foreground to firebrick:
(set-face-foreground 'modeline "firebrick")
The following elisp changes the cursor color to purple:
Emacs uses two alists to determine the default appearances of frames, default-frame-alist and initial-frame-alist. The default-frame-alist variable sets the basic defaults of all frames. Since it is a common Emacs usage to have the initial frame have slightly different properties than other frames (e.g., its position), you can use the initial-frame-alist variable to override properties in default-frame-alist specially for the initial frame. You should definitely read the help text for these variables (C-h v) for more details on the differences between them and how they interact with each other.
Below is an example of using default-frame-alist and initial-frame-alist to configure the appearances of the initial frame and all other frames (you would place this code in your startup file ). With default-frame-alist, we set the top left corner of new frames to be at pixel offset +200+400, the width and height to be 80x40, the cursor to be white, the foreground to be yellow, the background to be black, and the font to be Courier 10. With initial-frame-alist, we override the top left corner of the initial frame to be at pixel offset +10+30, and inherit the remaining properties for the initial frame from default-frame-alist.
(setq default-frame-alist '((top . 200) (left . 400) (width . 80) (height . 40) (cursor-color . "white") (cursor-type . box) (foreground-color . "yellow") (background-color . "black") (font . "-*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1"))) (setq initial-frame-alist '((top . 10) (left . 30)))
You can use the functions x-display-pixel-width and x-display-pixel-height to determine the resolution of your screen. For example:
(and window-system (setq screen-width (x-display-pixel-width) screen-height (x-display-pixel-height)))
Emacs can also run inside a console window. Simply invoke Emacs with the -nw command line option to do so. Although you cannot change the size, font, or color of the window from within Emacs, you can use the window's menu to do so. (If no icon has been created to invoke the Emacs batch file, then you'll have to create one to change these attributes.)
Under NT, go to the upper left hand corner and open the "-" menu of the console window. Select "Screen Size and Position...", and use the dialog to set the window to the size you want. Be sure to check the "Save Window Size and Position" checkbox so that future invocations will retain the new window size. After closing the dialog box, resize the window itself by dragging on the edges.
With Emacs 20.3 and previous version, Emacs uses the size of the console buffer as the frame size. If your console window has buffer larger than the window (e.g., it uses a verical scrollbar), then Emacs' frame will be larger than the console window. To work around this problem, make the console buffer the size of the console window. Or, if you have source, apply this patch to src/w32console.c.
Since version 20.4 this behaviour is now controlled via the variable "w32-use-full-screen-buffer".
So to fix this include the following lines in your .emacs file:
;; Make sure that Emacs in console mode doesn't go beyond the ;; size of the Dos box in use. ;; (Not needed in emacs 20.4+) (setq w32-use-full-screen-buffer nil)
To reposition Emacs, click on the title bar of the console window and drag it.
Under the NT interface, open the "-" menu. Select "Screen Colors...", and use the dialog to choose the colors you want to use for the window. Be sure to check the "Save Configuration" checkbox so that the colors are used in future invocations. Click on "OK". Unfortunately, the colors are not immediately used, but the changes have been made. To use the new colors, simply close the window and use the icon to start Emacs again. Emacs will then come up using the colors you chose before.
I'm not exactly sure how to change the colors on a per-console-window basis under Windows 95.
Font-lock mode is a mode that performs color syntax highlighting for other major modes in Emacs. To use font-lock, place the following in your startup file:
(cond ((fboundp 'global-font-lock-mode) ;; Turn on font-lock in all modes that support it (global-font-lock-mode t) ;; Maximum colors (setq font-lock-maximum-decoration t)))
The above code uses the default faces for decoration. If you would like to customize the attributes of the faces, you can use the following startup code to get started:
(cond ((fboundp 'global-font-lock-mode) ;; Customize face attributes (setq font-lock-face-attributes ;; Symbol-for-Face Foreground Background Bold Italic Underline '((font-lock-comment-face "DarkGreen") (font-lock-string-face "Sienna") (font-lock-keyword-face "RoyalBlue") (font-lock-function-name-face "Blue") (font-lock-variable-name-face "Black") (font-lock-type-face "Black") (font-lock-reference-face "Purple") )) ;; Load the font-lock package. (require 'font-lock) ;; Maximum colors (setq font-lock-maximum-decoration t) ;; Turn on font-lock in all modes that support it (global-font-lock-mode t)))
Also see the help text for the function global-font-lock-mode and the variable font-lock-face-attributes.
To see a list of colors that Emacs understands by name, select the "Edit->Text Properties->Display Colors" menu command.
An alternative to useing font-lock-mode is to use lazy-lock, to do this use the following:
(setq font-lock-support-mode 'lazy-lock-mode)
You can use the htmlize.el package by Hrvoje Niksic <firstname.lastname@example.org> to convert font-lock attributes in buffers to HTML markups. See the comments at the top of the file on how to use it.
If you are using a version of Emacs before 19.34.6 and an 8-bit display, then you should download this version of htmlize.el instead. However, this is likely to become out of date with respect to Hrvoje's version, so I would actually recommend upgrading to 19.34.6.
Gian Uberto Lauri <email@example.com> has modified html-helper-mode to enable font-locking and mode editing of code embedded in HTML documents (ASP, PHP).
The format of the mode line is determined by the variable mode-line-format, a buffer-local variable. To understand how to interpret the mode line, see the Info node "C-h i m emacs RET m mode line RET". For a description of minor modes that provide additional information on the mode line (like line and column number, current time, and mail status), see the Info node "C-h i m emacs RET m optional mode line features".
You can also directly customize the format by assigning a new format string to the mode-line-format variable in your startup file. For a description of the format codes, see the help string for the variable ("C-h v mode-line-format").
You can use either a two- or three-button mouse with Emacs. If you have trouble with either of these working with Emacs, see below.
Emacs assumes that you have a three-button mouse by default. However, if you have a two-button mouse, you can press both buttons at once to emulate the missing middle button expected by Emacs.
Three variables control mouse button emulation under Emacs: w32-num-mouse-buttons, w32-mouse-button-tolerance, and w32-swap-mouse-buttons (win32-num-mouse-buttons, win32-mouse-button-tolerance. If you use help on w32-num-mouse-buttons (i.e., with "C-h v"), it will tell you how many buttons Emacs thinks your mouse has; if w32-num-mouse-buttons is less than 3, then Emacs will emulate the middle mouse button.
Emacs emulates the middle mouse button by treating simultaneous button presses of the left and right buttons as a middle button press. Since both button presses cannot really be simultaneous, Emacs compares button presses within a specified window of time to determine whether it should emulate the middle button. This window of time is controlled using w32-mouse-button-tolerance. Help on this variable will show you the value Emacs uses by default, and you can change this value to suit your needs.
Depending upon the type of two-button mouse, you may find it useful to swap the mapping of middle and right mouse buttons. By default, the middle button is mapped to mouse-2 and the right button is mapped to mouse-3. If you set w32-swap-mouse-buttons to a non-nil value, then you can swap these two mappings.
If you have a three-button mouse, Emacs should recognize and support the third (middle) button automatically. However, some people find that they have a three button mouse, but the middle mouse button does not work for them. First check to see if w32-num-mouse-buttons is set correctly. If so, then check to see whether your mouse has been installed with the proper driver (open Control Panel->Mouse to examine the driver being used). If you have the right driver, then, on NT, check if HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Busmouse\Paramete rs\NumberOfButtons is set to 3, and change it to 3 if it is not. If nothing seems to be amiss, then at the very least you can have Emacs emulate the middle button by setting w32-num-mouse-buttons to 2.
Some people have reported that using a two-button mouse with Emacs sometimes causes problems when they go to click in other windows or the desktop (e.g., double left-clicks are interpreted as a right-click); apparently this is a known bug in Windows 95, and is not confined to using Emacs. If this is happening to you, you might want to flip through a discussion on the topic.
One workaround is to right-click on the desktop, and then left-click on the desktop, and the mouse should be back in its normal state.
To highlight the region between the point and the mark, use the function transient-mark-mode:
To highlight matching parentheses, add the following to your startup file:
Because of the way Emacs currently tries to share the clipboard with other Windows applications, you cannot cut and paste text with null characters embedded in it. David Biesack <firstname.lastname@example.org> describes a way to get around this, at least for cutting and pasting text just within Emacs.
You can use the function set-message-beep to change the sound that Emacs uses for its beep. Emacs allows you to specify one of the Windows system sounds for the beep. For example, to use the ok system sound, place the following in your startup file:
Look up help for the function for a complete description of how to use the function and which sounds it recognizes.
`selection-coding-system' is most likely still at it's default of `iso-latin-1-dos'. You can change this to a more appropriate coding system using `set-selection-coding-system' (C-x RET x), or temporarily with `set-next-selection-coding-system' (C-x RET X). If you NEVER cut and paste between Emacs and other programs, you can make Emacs behave for all languages with:
To copy between Emacs and other apps, you may need to use the appropriate Windows codepage as your coding system. To do this, you need to set up the codepage first:
(codepage-setup 1251) (set-selection-coding-system 'cp1251)
[ Combined Document ]
| Contents |
Steve Kemp, FAQ Maintainer
Last Modified : Thursday 1 August 2002