3 Customization and Options
***************************

   This is part 3 of the XEmacs Frequently Asked Questions list.  This
section is devoted to Customization and screen settings.

Customization---Emacs Lisp and `.emacs':

X Window System & Resources:

Textual Fonts & Colors:

The Modeline:

3.4 Multiple Device Support:

3.5 The Keyboard:

The Cursor:

The Mouse and Highlighting:

The Menubar and Toolbar:

Scrollbars:

Text Selections:

3.0: Customization - Emacs Lisp and .emacs
==========================================

Q3.0.1: What version of Emacs am I running?
-------------------------------------------

   How can `.emacs' determine which of the family of Emacsen I am using?

   To determine if you are currently running GNU Emacs 18, GNU Emacs 19,
XEmacs 19, XEmacs 20, or Epoch, and use appropriate code, check out the
example given in `etc/sample.emacs'.  There are other nifty things in
there as well!

   For all new code, all you really need to do is:

     (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))

Q3.0.2: How can I evaluate Emacs-Lisp expressions?
--------------------------------------------------

   I know I can evaluate Elisp expressions from `*scratch*' buffer with
`C-j' after the expression.  How do I do it from another buffer?

   Press `M-:' (the default binding of `eval-expression'), and enter
the expression to the minibuffer.  In XEmacs prior to 19.15
`eval-expression' used to be a disabled command by default.  If this is
the case, upgrade your XEmacs.

Q3.0.3: `(setq tab-width 6)' behaves oddly.
-------------------------------------------

   If you put `(setq tab-width 6)' in your `.emacs' file it does not
work!  Is there a reason for this?  If you do it at the EVAL prompt it
works fine!! How strange.

   Use `setq-default' instead, since `tab-width' is all-buffer-local.

Q3.0.4: How can I add directories to the `load-path'?
-----------------------------------------------------

   Here are two ways to do that, one that puts your directories at the
front of the load-path, the other at the end:

     ;;; Add things at the beginning of the load-path, do not add
     ;;; duplicate directories:
     (pushnew "bar" load-path :test 'equal)

     (pushnew "foo" load-path :test 'equal)

     ;;; Add things at the end, unconditionally
     (setq load-path (nconc load-path '("foo" "bar")))

   keith (k.p.) hanlan <keithh@nortel.ca> writes:

     To add directories using Unix shell metacharacters use
     `expand-file-name' like this:

          (push (expand-file-name "~keithh/.emacsdir") load-path)

Q3.0.5: How to check if a lisp function is defined?
---------------------------------------------------

   Use the following elisp:

     (fboundp 'foo)

   It's almost always a mistake to test `emacs-version' or any similar
variables.

   Instead, use feature-tests, such as `featurep', `boundp', `fboundp',
or even simple behavioral tests, eg.:

     (defvar foo-old-losing-code-p
       (condition-case nil (progn (losing-code t) nil)
         (wrong-number-of-arguments t)))

   There is an incredible amount of broken code out there which could
work much better more often in more places if it did the above instead
of trying to divine its environment from the value of one variable.

Q3.0.6: Can I force the output of `(face-list)' to a buffer?
------------------------------------------------------------

   It would be good having it in a buffer, as the output of
`(face-list)' is too wide to fit to a minibuffer.

   Evaluate the expression in the `*scratch*' buffer with point after
the rightmost paren and typing `C-j'.

   If the minibuffer smallness is the only problem you encounter, you
can simply press `C-h l' to get the former minibuffer contents in a
buffer.

Q3.0.7: Font selections in don't get saved after `Save Options'.
----------------------------------------------------------------

   For XEmacs 19.14 and previous:

   John Mann <mannj@ll.mit.edu> writes:

     You have to go to Options->Frame Appearance 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.

   For XEmacs 19.15 and later:

   Implement the above as well as set the following in your `.emacs'

     (setq options-save-faces t)

Q3.0.8: How do I get a single minibuffer frame?
-----------------------------------------------

   Vin Shelton <acs@acm.org> writes:

     (setq initial-frame-plist '(minibuffer nil))
     (setq default-frame-plist '(minibuffer nil))
     (setq default-minibuffer-frame
           (make-frame
            '(minibuffer only
     		    width 86
     		    height 1
     		    menubar-visible-p nil
     		    default-toolbar-visible-p nil
     		    name "minibuffer"
     		    top -2
     		    left -2
     		    has-modeline-p nil)))
     (frame-notice-user-settings)

   *Please note:* The single minibuffer frame may not be to everyone's
taste, and there any number of other XEmacs options settings that may
make it difficult or inconvenient to use.

Q3.0.9: What is `Customize'?
----------------------------

   Starting with XEmacs 20.2 there is new system 'Customize' for
customizing XEmacs options.

   You can access `Customize' from the `Options' menu or invoking one
of customize commands by typing eg.  `M-x customize', `M-x
customize-face', `M-x customize-variable' or `M-x customize-apropos'.

   Starting with XEmacs 20.3 there is also new `browser' mode for
Customize.  Try it out with `M-x customize-browse'

3.1: X Window System & Resources
================================

Q3.1.1: Where is a list of X resources?
---------------------------------------

   Search through the `NEWS' file for `X Resources'.  A fairly
comprehensive list is given after it.

   In addition, an `app-defaults' file is supplied, `etc/Emacs.ad'
listing the defaults.  The file `etc/sample.Xdefaults' gives a set of
defaults that you might consider.  It is essentially the same as
`etc/Emacs.ad' but some entries are slightly altered.  Be careful about
installing the contents of this file into your `.Xdefaults' or
`.Xresources' file if you use GNU Emacs under X11 as well.

Q3.1.2: How can I detect a color display?
-----------------------------------------

   You can test the return value of the function `(device-class)', as
in:

     (when (eq (device-class) 'color)
       (set-face-foreground  'font-lock-comment-face "Grey")
       (set-face-foreground  'font-lock-string-face  "Red")
       ....
       )

Q3.1.3: `(set-screen-width)' worked in 19.6, but not in 19.13?
--------------------------------------------------------------

   In Lucid Emacs 19.6 I did `(set-screen-width CHARACTERS)' and
`(set-screen-height LINES)' in my `.emacs' instead of specifying
`Emacs*EmacsScreen.geometry' in my `.Xdefaults' but this does not work
in XEmacs 19.13.

   These two functions now take frame arguments:

     (set-frame-width (selected-frame) CHARACTERS)
     (set-frame-height (selected-frame) LINES)

Q3.1.4: Specifying `Emacs*EmacsScreen.geometry' in `.emacs' does not work in 19.15?
-----------------------------------------------------------------------------------

   In XEmacs 19.11 I specified `Emacs*EmacsScreen.geometry' in my
`.emacs' but this does not work in XEmacs 19.15.

   We have switched from using the term "screen" to using the term
"frame".

   The correct entry for your `.Xdefaults' is now:

     Emacs*EmacsFrame.geometry

Q3.1.5: How can I get the icon to just say `XEmacs'?
----------------------------------------------------

   I'd like the icon to just say `XEmacs', and not include the name of
the current file in it.

   Add the following line to your `.emacs':

     (setq frame-icon-title-format "XEmacs")

Q3.1.6: How can I have the window title area display the full path?
-------------------------------------------------------------------

   I'd like to have the window title area display the full
directory/name of the current buffer file and not just the name.

   Add the following line to your `.emacs':

     (setq frame-title-format "%S: %f")

   A more sophisticated title might be:

     (setq frame-title-format
           '("%S: " (buffer-file-name "%f"
     				 (dired-directory dired-directory "%b"))))

   That is, use the file name, or the dired-directory, or the buffer
name.

Q3.1.7: `xemacs -name junk' doesn't work?
-----------------------------------------

   When I run `xterm -name junk', I get an xterm whose class name
according to xprop, is `junk'.  This is the way it's supposed to work,
I think.  When I run `xemacs -name junk' the class name is not set to
`junk'.  It's still `emacs'.  What does `xemacs -name' really do?  The
reason I ask is that my window manager (fvwm) will make a window sticky
and I use XEmacs to read my mail.  I want that XEmacs window to be
sticky, without having to use the window manager's function to set the
window sticky.  What gives?

   `xemacs -name' sets the application name for the program (that is,
the thing which normally comes from `argv[0]').  Using `-name' is the
same as making a copy of the executable with that new name.  The
`WM_CLASS' property on each frame is set to the frame-name, and the
application-class.  So, if you did `xemacs -name FOO' and then created
a frame named BAR, you'd get an X window with WM_CLASS = `( "BAR",
"Emacs")'.  However, the resource hierarchy for this widget would be:

     Name:    FOO   .shell             .container   .BAR
     Class:   Emacs .TopLevelEmacsShell.EmacsManager.EmacsFrame

   instead of the default

     Name:    xemacs.shell             .container   .emacs
     Class:   Emacs .TopLevelEmacsShell.EmacsManager.EmacsFrame

   It is arguable that the first element of WM_CLASS should be set to
the application-name instead of the frame-name, but I think that's less
flexible, since it does not give you the ability to have multiple frames
with different WM_CLASS properties.  Another possibility would be for
the default frame name to come from the application name instead of
simply being `emacs'.  However, at this point, making that change would
be troublesome: it would mean that many users would have to make yet
another change to their resource files (since the default frame name
would suddenly change from `emacs' to `xemacs', or whatever the
executable happened to be named), so we'd rather avoid it.

   To make a frame with a particular name use:

     (make-frame '((name . "the-name")))

Q3.1.8: `-iconic' doesn't work.
-------------------------------

   When I start up XEmacs using `-iconic' it doesn't work right.  Using
`-unmapped' on the command line, and setting the `initiallyUnmapped' X
Resource don't seem to help much either...

   Ben Wing <ben@xemacs.org> writes:

     Ugh, this stuff is such an incredible mess that I've about given up
     getting it to work.  The principal problem is numerous
     window-manager bugs...

3.2: Textual Fonts & Colors
===========================

Q3.2.1: How can I set color options from `.emacs'?
--------------------------------------------------

   How can I set the most commonly used color options from my `.emacs'
instead of from my `.Xdefaults'?

   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

Q3.2.2: How do I set the text, menu and modeline fonts?
-------------------------------------------------------

   Note that you should use `Emacs.' and not `Emacs*' when setting face
values.

   In `.Xdefaults':

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

   This is confusing because modeline is a face, and can be found listed
with all faces in the current mode by using `M-x set-face-font (enter)
?'.  It uses the face specification of `attributeFont', while menubar
is a normal X thing that uses the specification `font'.  With Motif it
may be necessary to use `fontList' instead of `font'.

Q3.2.3: 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 `.Xdefaults':

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

   or in your `.emacs':

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

Q3.2.4: How can I limit color map usage?
----------------------------------------

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

   XEmacs 19.13 didn't have such a mechanism (unlike netscape, or other
color-hogs).  One solution is to start XEmacs prior to netscape, since
this will prevent Netscape from grabbing all colors (but Netscape will
complain).  You can use the flags for Netscape, like -mono, -ncols <#>
or -install (for mono, limiting to <#> colors, or for using a private
color map).  Since Netscape will take the entire colormap and never
release it, the only reasonable way to run it is with `-install'.

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

   Starting with XEmacs 19.14, XEmacs uses the closest available color
if the colormap is full, so it's O.K. now to start Netscape first.

Q3.2.5: 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))

Q3.2.6: Can I have pixmap backgrounds in XEmacs?
------------------------------------------------

   Juan Villacis <jvillaci@wahnsinnig.extreme.indiana.edu> 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'.

3.3: The Modeline
=================

Q3.3.1: How can I make the modeline go away?
--------------------------------------------

     (set-specifier has-modeline-p nil)

   Starting with XEmacs 19.14 the modeline responds to mouse clicks, so
if you haven't liked or used the modeline in the past, you might want to
try the new version out.

Q3.3.2: How do you have XEmacs display the line number in the modeline?
-----------------------------------------------------------------------

   Add the following line to your `.emacs' 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
`Customize->Emacs->Editing->Basics->Line Number Mode' and/or
`Customize->Emacs->Editing->Basics->Column Number Mode'

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

Q3.3.3: How do I get XEmacs to put the time of day on the modeline?
-------------------------------------------------------------------

   Add the following line to your `.emacs' file to display the time:

     (display-time)

   See `Customize' from the `Options' menu for customization.

Q3.3.4: How do I turn off current chapter from AUC TeX modeline?
----------------------------------------------------------------

   With AUC TeX, fast typing is hard because the current chapter,
section etc. are given in the modeline.  How can I turn this off?

   It's not AUC TeX, it comes from `func-menu' in `func-menu.el'.  Add
this code to your `.emacs' to turn it off:

     (setq fume-display-in-modeline-p nil)

   Or just add a hook to `TeX-mode-hook' to turn it off only for TeX
mode:

     (add-hook 'TeX-mode-hook
     	  '(lambda () (setq fume-display-in-modeline-p nil)))

   David Hughes <dhughes@origin-at.co.uk> writes:

     If you have 19.14 or later, try this instead; you'll still get the
     function name displayed in the modeline, but it won't attempt to
     keep track when you modify the file. To refresh when it gets out
     of synch, you simply need click on the `Rescan Buffer' option in
     the function-menu.

          (setq-default fume-auto-rescan-buffer-p nil)

Q3.3.5: How can one 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 `.emacs'.  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:

   * The hook is the mode name plus `-hook'.  eg. c-mode-hook,
     c++-mode-hook, emacs-lisp-mode-hook (used for your `.emacs' or a
     `xx.el' file), lisp-interaction-mode-hook (the `*scratch*'
     buffer), text-mode-hook, etc.

   * Be sure to use `add-hook', not `(setq c-mode-hook xxxx)',
     otherwise you will erase anything that anybody has already put on
     the hook.

   * You can also do `(set-face-font 'modeline FONT)', eg.
     `(set-face-font 'modeline "*bold-r-normal*140-100-100*"
     (current-buffer))' if you wish the modeline font to vary based on
     the current mode.

   This works in 19.15 as well, but there are additional modeline faces,
`modeline-buffer-id', `modeline-mousable', and
`modeline-mousable-minor-mode', which you may want to customize.

3.4: Multiple Device Support
============================

Q3.4.1: How do I open a frame on another screen of my multi-headed display?
---------------------------------------------------------------------------

   The support for this was revamped for 19.14.  Use the command `M-x
make-frame-on-display'.  This command is also on the File menu in the
menubar.

   XEmacs 19.14 and later also have the command `make-frame-on-tty'
which will establish a connection to any tty-like device.  Opening the
TTY devices should be left to `gnuclient', though.

Q3.4.2: Can I really connect to a running XEmacs after calling up over a modem?  How?
-------------------------------------------------------------------------------------

   If you're not running at least XEmacs 19.14, you can't.  Otherwise
check out the `gnuattach' program supplied with XEmacs.  Starting with
XEmacs 20.3, `gnuattach' and `gnudoit' functionality is provided by
`gnuclient'.

   Also Q5.0.12.

3.5: The Keyboard
=================

Q3.5.1: How can I bind complex functions (or macros) to keys?
-------------------------------------------------------------

   As an example, say you want the `paste' key on a Sun keyboard to
insert the current Primary X selection at point. You can accomplish this
with:

     (define-key global-map [f18] 'x-insert-selection)

   However, this only works if there is a current X selection (the
selection will be highlighted).  The functionality I like is for the
`paste' key to insert the current X selection if there is one,
otherwise insert the contents of the clipboard.  To do this you need to
pass arguments to `x-insert-selection'.  This is done by wrapping the
call in a 'lambda form:

     (global-set-key [f18]
       (lambda () (interactive) (x-insert-selection t nil)))

   This binds the f18 key to a "generic" functional object.  The
interactive spec is required because only interactive functions can be
bound to keys.

   For the FAQ example you could use:

     (global-set-key [(control ?.)]
       (lambda () (interactive) (scroll-up 1)))
     (global-set-key [(control ?		;)]
     			  (lambda () (interactive) (scroll-up -1)))

   This is fine if you only need a few functions within the lambda body.
If you're doing more it's cleaner to define a separate function as in
question 3.5.3 (see Q3.5.3).

Q3.5.2: How can I stop down-arrow from adding empty lines to the bottom of my buffers?
--------------------------------------------------------------------------------------

   Add the following line to your `.emacs' file:

     (setq next-line-add-newlines nil)

   This has been the default setting in XEmacs for some time.

Q3.5.3: How do I bind C-. and C-; to scroll one line up and down?
-----------------------------------------------------------------

   Add the following (Thanks to Richard Mlynarik <mly@adoc.xerox.com>
and Wayne Newberry <wayne@zen.cac.stratus.com>) to `.emacs':

     (defun scroll-up-one-line ()
       (interactive)
       (scroll-up 1))

     (defun scroll-down-one-line ()
       (interactive)
       (scroll-down 1))

     (global-set-key [(control ?.)] 'scroll-up-one-line) ; C-.
     (global-set-key [(control ?		;)] 'scroll-down-one-line) ; C-;

   The key point is that you can only bind simple functions to keys; you
can not bind a key to a function that you're also passing arguments to.
(see Q3.5.1 for a better answer).

Q3.5.4: Globally binding `Delete'?
----------------------------------

   I cannot manage to globally bind my `Delete' key to something other
than the default.  How does one do this?

     (defun foo ()
       (interactive)
       (message "You hit DELETE"))

     (global-set-key 'delete 'foo)

   However, some modes explicitly bind `Delete', so you would need to
add a hook that does `local-set-key' for them.  If what you want to do
is make the Backspace and Delete keys work more PC/Motif-like, then
take a look at the `delbs.el' package.

   New in XEmacs 19.14 is a variable called `key-translation-map' which
makes it easier to bind `Delete'.  `delbs.el' is a good example of how
to do this correctly.

   Also Q3.5.10.

Q3.5.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.

   Try this:

     (defun scroll-one-line-up (&optional arg)
       "Scroll the selected window up (forward in the text) one line (or N lines)."
       (interactive "p")
       (scroll-up (or arg 1)))

     (defun scroll-one-line-down (&optional arg)
       "Scroll the selected window down (backward in the text) one line (or N)."
       (interactive "p")
       (scroll-down (or arg 1)))

     (global-set-key [up]   'scroll-one-line-up)
     (global-set-key [down] 'scroll-one-line-down)

   The following will also work but will affect more than just the
cursor keys (i.e. `C-n' and `C-p'):

     (setq scroll-step 1)

   Starting with XEmacs-20.3 you can also change this with Customize.
Select from the `Options' menu
`Customize->Emacs->Environment->Windows->Scroll Step...' or type `M-x
customize <RET> windows <RET>'.

Q3.5.6: How to map `Help' key alone on Sun type4 keyboard?
----------------------------------------------------------

   The following works in GNU Emacs 19:

     (global-set-key [help] 'help-command);; Help

   The following works in XEmacs 19.15 with the addition of shift:

     (global-set-key [(shift help)] 'help-command);; Help

   But it doesn't work alone.  This is in the file `PROBLEMS' which
should have come with your XEmacs installation: _Emacs ignores the
`help' key when running OLWM_.

   OLWM grabs the `help' key, and retransmits it to the appropriate
client using `XSendEvent'.  Allowing Emacs to react to synthetic events
is a security hole, so this is turned off by default.  You can enable
it by setting the variable `x-allow-sendevents' to t.  You can also
cause fix this by telling OLWM to not grab the help key, with the null
binding `OpenWindows.KeyboardCommand.Help:'.

Q3.5.7: How can you type in special characters in XEmacs?
---------------------------------------------------------

   One way is to use the package `x-compose'.  Then you can use
sequences like `Compose " a' to get ä, etc.

   Another way is to use the `iso-insert' package, provided in XEmacs
19.15 and later. Then you can use sequences like `C-x 8 " a' to get ä,
etc.

   Glynn Clements <glynn@sensei.co.uk> writes:

     It depends upon your X server.

     Generally, the simplest way is to define a key as Multi_key with
     xmodmap, e.g.
          	xmodmap -e 'keycode 0xff20 = Multi_key'

     You will need to pick an appropriate keycode. Use xev to find out
     the keycodes for each key.

     [NB: On a `Windows' keyboard, recent versions of XFree86
     automatically define the right `Windows' key as Multi_key'.]

     Once you have Multi_key defined, you can use e.g.
          	Multi a '	=> á
          	Multi e "	=> ë
          	Multi c ,	=> ç

     etc.

     Also, recent versions of XFree86 define various AltGr-<key>
     combinations as dead keys, i.e.
          	AltGr [		=> dead_diaeresis
          	AltGr ]		=> dead_tilde
          	AltGr ;		=> dead_acute
     etc.

     Running `xmodmap -pk' will list all of the defined keysyms.

Q3.5.8: Why does `(global-set-key [delete-forward] 'delete-char)' complain?
---------------------------------------------------------------------------

   Why does `(define-key global-map [ delete-forward ] 'delete-char)'
complain of not being able to bind an unknown key?

   Try this instead:

     (define-key global-map [delete_forward] 'delete-char)

   and it will work.

   What you are seeing above is a bug due to code that is trying to
check for GNU Emacs syntax like:

   (define-key global-map [C-M-a] 'delete-char)

   which otherwise would cause no errors but would not result in the
expected behavior.

   This bug has been fixed in 19.14.

Q3.5.9: How do I make the Delete key delete forward?
----------------------------------------------------

   With XEmacs-20.2 use the `delbs' package:

     (require 'delbs)

   This will give you the functions `delbs-enable-delete-forward' to
set things up, and `delbs-disable-delete-forward' to revert to "normal"
behavior.  Note that `delbackspace' package is obsolete.

   Starting with XEmacs-20.3 better solution is to set variable
`delete-key-deletes-forward' to t.  You can also change this with
Customize. Select from the `Options' menu
`Customize->Emacs->Editing->Basics->Delete Key Deletes Forward' or type
`M-x customize <RET> editing-basics <RET>'.

   Also Q3.5.4.

Q3.5.10: Can I turn on "sticky" modifier keys?
----------------------------------------------

   Yes, with `(setq modifier-keys-are-sticky t)'.  This will give the
effect of being able to press and release Shift and have the next
character typed come out in upper case.  This will affect all the other
modifier keys like Control and Meta as well.

   Ben Wing <ben@xemacs.org> writes:

     One thing about the sticky modifiers is that if you move the mouse
     out of the frame and back in, it cancels all currently "stuck"
     modifiers.

Q3.5.11: How do I map the arrow keys?
-------------------------------------

   Say you want to map `C-<right>' to forward-word:

   Sam Steingold <sds@usa.net> writes:

          ; both XEmacs and Emacs
          (define-key global-map [(control right)] 'forward-word)
     or
          ; Emacs only
          (define-key global-map [C-right] 'forward-word)
     or
          ; ver > 20, both
          (define-key global-map (kbd "C-<right>") 'forward-word)

3.6: The Cursor
===============

Q3.6.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)

   Starting with XEmacs-20.3 you can also change these with Customize.
Select from the `Options' menu
`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

Q3.6.2: Is there a way to get back the block cursor?
----------------------------------------------------

     (setq bar-cursor nil)

   Starting with XEmacs-20.3 you can also change this with Customize.
Select from the `Options' menu
`Customize->Emacs->Environment->Display->Bar Cursor...' or type `M-x
customize <RET> display <RET>'.

Q3.6.3: Can I make the cursor blink?
------------------------------------

   If you are running a version of XEmacs older than 19.14, no.
Otherwise you can do the following:

     (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 =>
Frame Appearance => Blinking Cursor'.  Remember to save options.

3.7: The Mouse and Highlighting
===============================

Q3.7.1: How can I turn off Mouse pasting?
-----------------------------------------

   I keep hitting the middle mouse button by accident and getting stuff
pasted into my buffer so how can I turn this off?

   Here is an alternative binding, whereby the middle mouse button
selects (but does not cut) the expression under the mouse. Clicking
middle on a left or right paren will select to the matching one.  Note
that you can use `define-key' or `global-set-key'.

     (defun mouse-set-point-and-select (event)
       "Sets the point at the mouse location, then marks following form"
       (interactive "@e")
       (mouse-set-point event)
       (mark-sexp 1))
     (define-key global-map [button2] 'mouse-set-point-and-select)

Q3.7.2: How do I set control/meta/etc modifiers on mouse buttons?
-----------------------------------------------------------------

   Use, for instance, `[(meta button1)]'. For example, here is a common
setting for Common Lisp programmers who use the bundled `ilisp'
package, whereby meta-button1 on a function name will find the file
where the function name was defined, and put you at that location in
the source file.

   [Inside a function that gets called by the lisp-mode-hook and
ilisp-mode-hook]

     (local-set-key [(meta button1)] 'edit-definitions-lisp)

Q3.7.3: Clicking the left button does not do anything in buffer list.
---------------------------------------------------------------------

   I do `C-x C-b' to get a list of buffers and the entries get
highlighted when I move the mouse over them but clicking the left mouse
does not do anything.

   Use the middle mouse button.

Q3.7.4: How can I get a list of buffers when I hit mouse button 3?
------------------------------------------------------------------

   The following code will replace the default popup on button3:

     (global-set-key [button3] 'popup-buffer-menu)

Q3.7.5: Why does cut-and-paste not work between XEmacs and a cmdtool?
---------------------------------------------------------------------

   We don't know.  It's a bug.  There does seem to be a work-around,
however.  Try running xclipboard first.  It appears to fix the problem
even if you exit it.  (This should be mostly fixed in 19.13, but we
haven't yet verified that).

Q3.7.6: How I can set XEmacs up so that it pastes where the text cursor is?
---------------------------------------------------------------------------

   By default XEmacs pastes X selections where the mouse pointer is.
How do I disable this?

   Examine the function `mouse-yank', by typing `C-h f mouse-yank
<RET>'.

   To get XEmacs to paste at the text cursor, add this your `.emacs':

     (setq mouse-yank-at-point t)

   Starting with XEmacs-20.2 you can also change this with Customize.
Select from the `Options' menu `Customize->Emacs->Editing->Mouse->Yank
At Point...' or type `M-x customize <RET> mouse <RET>'.

Q3.7.7: How do I select a rectangular region?
---------------------------------------------

   Just select the region normally, then use the rectangle commands
(e.g.  `kill-rectangle' on it.  The region does not highlight as a
rectangle, but the commands work just fine.

   To actually sweep out rectangular regions with the mouse you can use
`mouse-track-do-rectangle' which is assigned to `M-button1'.  Then use
rectangle commands.

   You can also do the following to change default behavior to sweep out
rectangular regions:

     (setq mouse-track-rectangle-p t)

   Starting with XEmacs-20.2 you can also change this with Customize.
Select from the `Options' menu `Customize->Emacs->Editing->Mouse->Track
Rectangle...' or type `M-x customize <RET> mouse <RET>'.

      mouse-track-do-rectangle: (event)
        -- an interactive compiled Lisp function.
      Like `mouse-track' but selects rectangles instead of regions.

Q3.7.8: Why does `M-w' take so long?
------------------------------------

   It actually doesn't.  It leaves the region visible for a second so
that you can see what area is being yanked.  If you start working,
though, it will immediately complete its operation.  In other words, it
will only delay for a second if you let it.

3.8: The Menubar and Toolbar
============================

Q3.8.1: How do I get rid of the menu (or menubar)?
--------------------------------------------------

   If you are running XEmacs 19.13 and earlier, add this command to your
`.emacs'.

     (set-menubar nil)

   Starting with XEmacs 19.14 the preferred method is:

     (set-specifier menubar-visible-p nil)

Q3.8.2: Can I customize the basic menubar?
------------------------------------------

   For an extensive menubar, add this line to your `.emacs':

     (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
`lisp/packages/big-menubar.el' in the XEmacs installation directory.

Q3.8.3: How do I control how many buffers are listed in the menu `Buffers List'?
--------------------------------------------------------------------------------

   Add the following to your `.emacs' (suit to fit):

     (setq buffers-menu-max-size 20)

   For no limit, use an argument of `nil'.

   Starting with XEmacs-20.3 you can also change this with Customize.
Select from the `Options' menu
`Customize->Emacs->Environment->Menu->Buffers Menu->Max Size...' or
type `M-x customize <RET> buffers-menu <RET>'.

Q3.8.4: 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.

   If you are using the real Motif menubar, this resource is not
recognized; you have to say:

     Emacs*menubar*fontList: FONT

   If you are using the Lucid menubar, the former resource will be
recognized only if the latter resource is unset.  This means that the
resource

     *fontList: FONT

   will override

     Emacs*menubar*font: FONT

   even though the latter is more specific.

Q3.8.5: 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)

   There are redisplay bugs in 19.14 that may make the preceding result
in a messed-up display, especially for frames with multiple windows.
You may need to resize the frame before XEmacs completely realizes the
toolbar is really gone.

   Thanks to Martin Buchholz <martin@xemacs.org> for the correct code.

3.9: Scrollbars
===============

Q3.9.1: How can I disable the scrollbar?
----------------------------------------

   To disable them for all frames, add the following line to your
`.Xdefaults':

     Emacs.scrollBarWidth:  0

   Or select from the `Options' menu `Frame Appearance->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))

   In XEmacs versions prior to 19.14, you had to use the hairier
construct:

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

Q3.9.2: How can one 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.

Q3.9.3: 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.

Q3.9.4: How can I get automatic horizontal scrolling?
-----------------------------------------------------

   By the same token, how can I turn it off in specific modes?

   To do this, add to your `.emacs' file:

     (require 'auto-show)

   Then 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.

   Automatic horizontal scrolling is now standard, starting with 19.14.