[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4 Display Functions

This is part 4 of the XEmacs Frequently Asked Questions list. This section is devoted to the display-related capabilities of XEmacs (fonts, colors, modeline, menubar, toolbar, scrollbar, etc.) and how to customize them.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.0: Textual Fonts and Colors


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.0.1: How do I specify a font?

#### Update me.

In 21.4 and above, you can use the ‘Options’ menu to change the font. You can also do it in your init file, e.g. like this (for MS Windows):

 
    (set-face-font ’default "Lucida Console:Regular:10")
    (set-face-font ’modeline "MS Sans Serif:Regular:10")

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.0.2: How do I set the text, menu and modeline fonts?

#### Update me.

Note that you should use ‘Emacs.’ and not ‘Emacs*’ when setting face values.

In ‘.Xresources’:

 
Emacs.default.attributeFont:  -*-*-medium-r-*-*-*-120-*-*-m-*-*-*
Emacs*menubar*font:           fixed
Emacs.modeline.attributeFont: fixed

This is confusing because ‘default’ and ‘modeline’ are face names, and can be found listed with all faces in the current mode by using M-x set-face-font (enter) ?. They use the face-specific resource ‘attributeFont’.

On the other hand, ‘menubar’ is a normal X thing that uses the resource ‘font’. With Motif it may be necessary to use ‘fontListinstead offont’. In non-Motif configurations with Mule it is necessary to use ‘fontSet’ instead of ‘font’. (Sorry, there just is no simple recipe here.)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.0.3: How can I set color options from ‘init.el’?

How can I set the most commonly used color options from my ‘init.el’ instead of from my ‘.Xresources’?

Like this:

 
(set-face-background 'default      "bisque") ; frame background
(set-face-foreground 'default      "black") ; normal text
(set-face-background 'zmacs-region "red") ; When selecting w/
                                        ; mouse
(set-face-foreground 'zmacs-region "yellow")
(set-face-font       'default      "*courier-bold-r*120-100-100*")
(set-face-background 'highlight    "blue") ; Ie when selecting
                                        ; buffers
(set-face-foreground 'highlight    "yellow")
(set-face-background 'modeline     "blue") ; Line at bottom
                                        ; of buffer
(set-face-foreground 'modeline     "white")
(set-face-font       'modeline     "*bold-r-normal*140-100-100*")
(set-face-background 'isearch      "yellow") ; When highlighting
                                        ; while searching
(set-face-foreground 'isearch      "red")
(setq x-pointer-foreground-color   "black") ; Adds to bg color,
                                        ; so keep black
(setq x-pointer-background-color   "blue") ; This is color
                                        ; you really
                                        ; want ptr/crsr

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.0.4: How can I set the colors when highlighting a region?

How can I set the background/foreground colors when highlighting a region?

You can change the face zmacs-region either in your ‘.Xresources’:

 
Emacs.zmacs-region.attributeForeground: firebrick
Emacs.zmacs-region.attributeBackground: lightseagreen

or in your ‘init.el’:

 
(set-face-background 'zmacs-region "red")
(set-face-foreground 'zmacs-region "yellow")

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.0.5: How can I limit color map usage?

I’m using Netscape (or another color grabber like XEmacs); is there any way to limit the number of available colors in the color map?

Answer: No, but you can start Netscape before XEmacs, and it will use the closest available color if the colormap is full. You can also limit the number of colors Netscape uses, using the flags -mono, -ncols <#> or -install (for mono, limiting to <#> colors, or for using a private color map).

If you have the money, another solution would be to use a truecolor or direct color video.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.0.6: My tty supports color, but XEmacs doesn’t use them.

XEmacs tries to automatically determine whether your tty supports color, but sometimes guesses wrong. In that case, you can make XEmacs Do The Right Thing using this Lisp code:

 
(if (eq 'tty (device-type))
    (set-device-class nil 'color))

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.0.7: Can I have pixmap backgrounds in XEmacs?

Juan Villacis writes:

There are several ways to do it. For example, you could specify a default pixmap image to use in your ‘~/.Xresources’, e.g.,

 
  Emacs*EmacsFrame.default.attributeBackgroundPixmap: /path/to/image.xpm

and then reload ~/.Xresources and restart XEmacs. Alternatively, since each face can have its own pixmap background, a better way would be to set a face’s pixmap within your XEmacs init file, e.g.,

 
  (set-face-background-pixmap 'default "/path/to/image.xpm")
  (set-face-background-pixmap 'bold    "/path/to/another_image.xpm")

and so on. You can also do this interactively via M-x edit-faces.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.0.8: How do I display non-ASCII characters?

If you’re using a Mule-enabled XEmacs, then display is automatic. If you’re not seeing the characters you expect, either (1) you don’t have appropriate fonts available or (2) XEmacs did not correctly detect the coding system (see (xemacs)Recognize Coding). In case (1), install fonts as is customary for your platform. In case (2), you need to tell XEmacs explicitly what coding systems you’re using. (xemacs)Specify Coding.

If your XEmacs is not Mule-enabled, and for some reason getting a Mule-enabled XEmacs seems like the wrong thing to do, all is not lost. You can arrange it by brute force. In ‘event-Xt.c’ (suppress the urge to look in this file—play Doom instead, because you’ll survive longer), it is written:

In a non-Mule world, a user can still have a multi-lingual editor, by doing (set-face-font "-*-iso8859-2" (current-buffer)) for all their Latin-2 buffers, etc.

For the related problem of inputting non-ASCII characters in a non-Mule XEmacs, See section How can you type in special characters in XEmacs?.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.0.9: Font selections in don’t get saved after Save Options.

John Mann writes:

You have to go to ‘Options->Menubars’ and unselect ‘Frame-Local Font Menu’. If this option is selected, font changes are only applied to the current frame and do not get saved when you save options.

Also, set the following in your ‘init.el’:

 
(setq options-save-faces t)

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1: Syntax Highlighting (Font Lock)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.1.1: How can I do source code highlighting using font-lock?

For most modes, font-lock is already set up and just needs to be turned on. This can be done by adding the line:

 
(require 'font-lock)

to your ‘init.el’. (You can turn it on for the current buffer and session only by M-x font-lock-mode.) See the file ‘etc/sample.init.el’ (‘etc/sample.emacs’ in XEmacs versions prior to 21.4) for more information.

See also Syntax Highlighting from the Options menu. Remember to save options.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.1.2: How do I get ‘More’ Syntax Highlighting on by default?

Use the following code in your ‘init.el’:

 
(setq-default font-lock-maximum-decoration t)

See also Syntax Highlighting from the Options menu. Remember to save options.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2: The Modeline


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.2.1: How can I make the modeline go away?

 
(set-specifier has-modeline-p nil)

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.2.2: How do you have XEmacs display the line number in the modeline?

Add the following line to your ‘init.el’ file to display the line number:

 
(line-number-mode 1)

Use the following to display the column number:

 
(column-number-mode 1)

Or select from the Options menu Advanced (Customize)->Emacs->Editing->Basics->Line Number Mode and/or Advanced (Customize)->Emacs->Editing->Basics->Column Number Mode

Or type M-x customize <RET> editing-basics <RET>.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.2.3: How do I get XEmacs to put the time of day on the modeline?

Add the following line to your ‘init.el’ file to display the time:

 
(display-time)

See Customize from the Options menu for customization.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.2.4: How can I change the modeline color based on the mode used?

You can use something like the following:

 
(add-hook 'lisp-mode-hook
          (lambda ()
            (set-face-background 'modeline "red" (current-buffer))))

Then, when editing a Lisp file (i.e. when in Lisp mode), the modeline colors change from the default set in your ‘init.el’. The change will only be made in the buffer you just entered (which contains the Lisp file you are editing) and will not affect the modeline colors anywhere else.

Notes:

There are additional modeline faces, modeline-buffer-id, modeline-mousable, and modeline-mousable-minor-mode, which you may want to customize.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3: The Cursor


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.3.1: Is there a way to make the bar cursor thicker?

I’d like to have the bar cursor a little thicker, as I tend to "lose" it often.

For a 1 pixel bar cursor, use:

 
(setq bar-cursor t)

For a 2 pixel bar cursor, use:

 
(setq bar-cursor 'anything-else)

You can also change these with Customize. Select from the Options menu Advanced (Customize)->Emacs->Environment->Display->Bar Cursor... or type M-x customize <RET> display <RET>.

You can use a color to make it stand out better:

 
Emacs*cursorColor:      Red

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.3.2: Is there a way to get back the block cursor?

 
(setq bar-cursor nil)

You can also change this with Customize. Select from the Options menu Advanced (Customize)->Emacs->Environment->Display->Bar Cursor... or type M-x customize <RET> display <RET>.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.3.3: Can I make the cursor blink?

Yes, like this:

 
(blink-cursor-mode)

This function toggles between a steady cursor and a blinking cursor. You may also set this mode from the menu bar by selecting ‘Options->Display->Blinking Cursor’. Remember to save options.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4: The Menubar


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.4.1: How do I get rid of the menubar?

 
(set-specifier menubar-visible-p nil)

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.4.2: How can I customize the menubar?

For an extensive menubar, add this line to your ‘init.el’:

 
(load "big-menubar")

If you’d like to write your own, this file provides as good a set of examples as any to start from. The file is located in edit-utils package.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.4.3: How do I enable use of the keyboard (Alt) to access menu items?

#### Write me.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.4.4: How do I control how many buffers are listed in the menu Buffers List?

Add the following to your ‘init.el’ (suit to fit):

 
(setq buffers-menu-max-size 20)

For no limit, use an argument of ‘nil’.

You can also change this with Customize. Select from the Options menu Advanced (Customize)->Emacs->Environment->Menu->Buffers Menu->Max Size... or type M-x customize <RET> buffers-menu <RET>.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.4.5: Resources like Emacs*menubar*font are not working?

I am trying to use a resource like Emacs*menubar*font to set the font of the menubar but it’s not working.

In Motif, the use of ‘font’ resources is obsoleted in order to support internationalization. If you are using the real Motif menubar, this resource is not recognized at all; you have to say:

 
Emacs*menubar*fontList: FONT

If you are using the Lucid menubar, for backward compatibility with existing user configurations, the ‘font’ resource is recognized. Since this is not supported by Motif itself, the code is a kludge and the ‘font’ resource will be recognized only if the ‘fontList’ resource resource is unset. This means that the resource

 
*fontList: FONT

will override

 
Emacs*menubar*font: FONT

even though the latter is more specific.

In non-Motif configurations using ‘--with-mule’ and ‘--with-xfs’ it is necessary to use the fontSet resource instead of the font resource. The backward compatibility kludge was never implemented for non-Motif builds. Example:

 
*fontSet: FONT

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5: The Toolbar


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.5.1: How do I get rid of the toolbar?

#### Write me.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.5.2: How can I customize the toolbar?

#### Write me.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.5.3: How can I bind a key to a function to toggle the toolbar?

Try something like:

 
(defun my-toggle-toolbar ()
  (interactive)
  (set-specifier default-toolbar-visible-p
                 (not (specifier-instance default-toolbar-visible-p))))
(global-set-key "\C-xT" 'my-toggle-toolbar)

Thanks to Martin Buchholz for the correct code.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.5.4: ‘Can't instantiate image error...’ in toolbar

Dr. Ram Samudrala writes:

I just installed the XEmacs (20.4-2) RPMS that I downloaded from http://www.xemacs.org/. Everything works fine, except that when I place my mouse over the toolbar, it beeps and gives me this message:

 
 Can't instantiate image (probably cached):
 [xbm :mask-file "/usr/include/X11/bitmaps/leftptrmsk :mask-data
 (16 16 <strange control characters> ...

Kyle Jones writes:

This is problem specific to some Chips and Technologies video chips, when running XFree86. Putting

Option "sw_cursor"

in ‘XF86Config’ gets rid of the problem.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.6: Scrollbars and Scrolling


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.6.1: How can I disable the scrollbar?

To disable them for all frames, add the following line to your ‘.Xresources’:

 
Emacs.scrollBarWidth:  0

Or select ‘Options->Display->Scrollbars’. Remember to save options.

To turn the scrollbar off on a per-frame basis, use the following function:

 
(set-specifier scrollbar-width 0 (selected-frame))

You can actually turn the scrollbars on at any level you want by substituting for (selected-frame) in the above command. For example, to turn the scrollbars off only in a single buffer:

 
(set-specifier scrollbar-width 0 (current-buffer))

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.6.2: How can I change the scrollbar width?

#### Write me.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.6.3: How can I use resources to change scrollbar colors?

Here’s a recap of how to use resources to change your scrollbar colors:

 
! Motif scrollbars

Emacs*XmScrollBar.Background: skyblue
Emacs*XmScrollBar.troughColor: lightgray

! Athena scrollbars

Emacs*Scrollbar.Foreground: skyblue
Emacs*Scrollbar.Background: lightgray

Note the capitalization of Scrollbar for the Athena widget.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.6.4: Moving the scrollbar can move the point; can I disable this?

When I move the scrollbar in an XEmacs window, it moves the point as well, which should not be the default behavior. Is this a bug or a feature? Can I disable it?

The current behavior is a feature, not a bug. Point remains at the same buffer position as long as that position does not scroll off the screen. In that event, point will end up in either the upper-left or lower-left hand corner.

This cannot be changed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.6.5: Scrolling one line at a time.

Can the cursor keys scroll the screen a line at a time, rather than the default half page jump? I tend it to find it disorienting.

Use the following:

 
(setq scroll-step 1)

You can also change this with Customize. Select from the Options menu Advanced (Customize)->Emacs->Environment->Windows->Scroll Step... or type M-x customize <RET> windows <RET>.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.6.6: How can I turn off automatic horizontal scrolling in specific modes?

Do (setq truncate-lines t) in the mode-hooks for any modes in which you want lines truncated.

More precisely: If truncate-lines is nil, horizontal scrollbars will never appear. Otherwise, they will appear only if the value of scrollbar-height for that buffer/window/etc. is non-zero. If you do

 
(set-specifier scrollbar-height 0)

then horizontal scrollbars will not appear in truncated buffers unless the package specifically asked for them.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.6.7: I find auto-show-mode disconcerting. How do I turn it off?

auto-show-mode controls whether or not a horizontal scrollbar magically appears when a line is too long to be displayed. This is enabled by default. To turn it off, put the following in your ‘init.el’:

 
(setq auto-show-mode nil)
(setq-default auto-show-mode nil)

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.7: The Gutter Tabs, The Progress Bar, Widgets


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.7.1: How can I disable the gutter tabs?

#### Write me.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.7.2: How can I disable the progress bar?

#### Write me.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.7.3: There are bugs in the gutter or widgets.

#### Write me.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Q4.7.4: How can I customize the gutter or gutter tabs?

#### Write me.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Aidan Kehoe on December 27, 2016 using texi2html 1.82.