This is part 3 of the XEmacs Frequently Asked Questions list. This section is devoted to Customization and screen settings.
If you have a Web browser, the official hypertext version is at: <URL:http://www.sccon.com/~andreas/xemacs-installation.html>, and also at: <URL:http://www.xemacs.org/faq/xemacs-customization.html>. This version is much nicer than the unofficial hypertext versions that are archived at Utrecht, Oxford, Smart Pages, and other FAQ archives.
Changes this month:
This file was last modified on Feburary 23, 1998.
(setq tab-width 6)
behaves oddly
(face-list)
to a buffer other than the minibuffer since it is too wide to fit?
(define-key global-map [ delete-forward ] 'delete-char)
complain?
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, a simple
(defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))is all you really need to do.
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.
(setq tab-width 6)
behaves oddly(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.
;;; 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:
(setq load-path (cons (expand-file-name "~keithh/.emacsdir") load-path))
(fboundp 'foo)
It's almost always a mistake to test emacs-version or any similar variables.
Instead, use feature-tests, such as
featurep
or boundp
or fboundp
, or
even simple behavioural 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.
(face-list)
to a buffer other than the minibuffer since it is too wide to fit?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.
John Mann <mannj@ll.mit.edu> writes:
You have to go to Options->Menubar 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)
(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)
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.
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.
(when (eq (device-class) 'color) (set-face-foreground 'font-lock-comment-face "Grey") (set-face-foreground 'font-lock-string-face "Red") .... )
(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)
We have switched from using the term 'screen' to using the term frame.
The correct entry for your .Xdefaults is now:
Emacs*EmacsFrame.geometry
Add the following line to your .emacs:
(setq frame-icon-title-format "XEmacs")
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.
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.EmacsFrameinstead of the default
Name: xemacs.shell .container .emacs Class: Emacs .TopLevelEmacsShell.EmacsManager.EmacsFrameIt 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")))
Ben Wing <ben@666.com> 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 ...
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
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.
Emacs.zmacs-region.attributeForeground: firebrick Emacs.zmacs-region.attributeBackground: lightseagreenor in your .emacs:
(set-face-background 'zmacs-region "red") (set-face-foreground 'zmacs-region "yellow")
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 will use the closest available color if the colormap is full, so it's O.K. now to start Netscape first.
(if (eq 'tty (device-type)) (set-device-class nil 'color))
(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.
(setq line-number-mode t)
Use the following to display the column number:
(setq display-column-mode t)
(display-time)
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)
(add-hook 'lisp-mode-hook '(lambda () (set-face-background 'modeline "red" (current-buffer)) (set-face-foreground 'modeline "yellow" (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:
add-hook
, not
(setq c-mode-hook xxxx)
,
otherwise you will erase anything that anybody has already put on the hook.
(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.
XEmacs 19.14 also has the command make-frame-on-tty
which will
establish a connection to any tty-like device.
Starting with XEmacs 20.3, gnuattach and gnudoit functionality will be provided by gnuclient.
(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:
(define-key global-map 'f18 (function (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. Also take a look at the doc for function.
For the FAQ example you could use:
(global-set-key [(control ?.)] (function (lambda () (interactive) (scroll-up 1)))) (global-set-key [(control ?;)] (function (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).
(setq next-line-add-newlines nil)This has been the default setting in XEmacs for some time.
(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 3.5.1 How can I bind complex functions for a better answer).
(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 delbackspace.el package.
New in XEmacs 19.14 is a variable called key-translation-map
which makes it easier to bind Delete. delbackspace.el is a good
example of how to do this correctly.
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)
(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:.
Another way is to use the iso8859-1 package.
(define-key global-map [ delete-forward ] 'delete-char)
complain?(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 bogosity 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.
(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.
Also see Question 3.5.4.
(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@666.com> 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.
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 use a color to make it stand out better:
Emacs*cursorColor: Red
(setq bar-cursor nil)
(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.
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)
[(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)
Use the middle mouse button.
(global-set-key [button3] 'popup-buffer-menu)
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)
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 do the following:
(setq mouse-track-rectangle-p t)Aki Vehtari <Aki.Vehtari@hut.fi> writes:
To actually sweep out rectangular regions with the mouse
you can also use mouse-track-do-rectangle
which is assigned
to M-button1. Then use rectangle commands.
mouse-track-do-rectangle: (event) -- an interactive compiled Lisp function. Like `mouse-track' but selects rectangles instead of regions.
(set-menubar nil)
Starting with XEmacs 19.14 the preferred method is:
(set-specifier menubar-visible-p nil)
(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.
(setq buffers-menu-max-size 20)For no limit, use an argument of nil.
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: FONTIf 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: FONTwill override
Emacs*menubar*font: FONTeven though the latter is more specific.
(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.Buchholz@sun.com> for the correct code.
Emacs.scrollBarWidth: 0
To turn the scrollbar off on a per-frame basis, use the following function:
(set-specifier scrollbar-width (cons (selected-frame) 0))
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 (cons (current-buffer) 0))
Starting with 19.14 you can use the more logical form:
(set-specifier scrollbar-width 0 (selected-frame))
! Motif scrollbars Emacs*XmScrollBar.Background: skyblue Emacs*XmScrollBar.troughColor: lightgray ! Athena scrollbars Emacs*Scrollbar.Foreground: skyblue Emacs*Scrollbar.Background: lightgrayNote the capitalization of Scrollbar for the Athena widget.
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.
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.
Newsflash: Automatic horizontal scrolling is now standard with 19.14.
(setq zmacs-regions nil)
To change the face for selection, look at Options->Customize on the menubar.
You want to use something called pending delete. Pending delete is what happens when you select a region (with the mouse or keyboard) and you press a key to replace the selected region by the key you typed. Usually backspace kills the selected region.
To get this behavior, add the following line to your .emacs:
(require 'pending-del)
Note that this will work with both Backspace and Delete.
Put the following in your .emacs:
(setq isearch-highlight nil)
Note also that isearch-highlight affects query-replace and ispell. Instead of disabling isearch-highlight you may find that a better solution consists of customizing the isearch face.
(setq zmacs-regions nil)
Warning: This command turns off all region highlighting.
Like this:
(defadvice scroll-up (around scroll-up freeze) (interactive "_P") (let ((zmacs-region-stays t)) (if (interactive-p) (condition-case nil ad-do-it (end-of-buffer (goto-char (point-max)))) ad-do-it))) (defadvice scroll-down (around scroll-down freeze) (interactive "_P") (let ((zmacs-region-stays t)) (if (interactive-p) (condition-case nil ad-do-it (beginning-of-buffer (goto-char (point-min)))) ad-do-it)))
Thanks to T. V. Raman <raman@adobe.com> for assistance in deriving this answer.
This FAQ is Copyright © 1998 by various people and edited by Andreas Kaempf. Please send comments, and suggestions to Andreas Kaempf <andreas@sccon.com>.