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

5 Interfacing with the Operating System and External Devices

This is part 5 of the XEmacs Frequently Asked Questions list. This section is devoted to the various ways that XEmacs interfaces with the operating system, with other processes and with external devices such as speakers and the printer.


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

5.0: X Window System and Resources


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

Q5.0.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 ‘etc/Emacs.ad’ is supplied, listing the defaults. The file ‘etc/sample.Xresources’ gives a different set of defaults that you might consider for installation in your ‘~/.Xresources’ file. It is nearly the same as ‘etc/Emacs.ad’, but a few entries are altered. Be careful about installing the contents of this file into your ‘.Xresources’ (or legacy ‘.Xdefaults’) file if you use GNU Emacs under X11 as well.


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

Q5.0.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")
  ....
  )

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

Q5.0.3: 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 ‘init.el’:

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

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

Q5.0.4: 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 ‘init.el’:

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


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

Q5.0.5: ‘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")))

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

Q5.0.6: ‘-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 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...


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

Q5.0.7: How can I use antialiased fonts under X11?

The X11 version of XEmacs can use antialiased fonts via the Xft, fontconfig, and freetype libraries. To configure this you need a recent beta version (at least 21.5.24); the more recent, the better. This is beta software, the usual caveats apply. Rebuild xemacs using the following configure options, plus any others you normally use:

--enable-mule --with-xft=emacs,menubars

Xft may work without Mule but the developers working on the Xft code invariably build with Mule. The tab control also supports Xft, and at some date the progress gauge will as well. If they are configured in to XEmacs, you may add ‘tabs’ and ‘gauges’ to the value of the ‘--with-xft’ option (with a comma separating each value from the previous ones). For further details on the XEmacs widgets that support XFT, see the output of ./configure --help. If you use a package manager from your OS distribution, you may need to install development packages for ‘fontconfig’ and ‘Xft’, and possibly for their prequisites.

To specify a particular antialiased font, put something like the following lines in your ‘~/.Xdefaults’ or ‘~/.Xresources’:

 
    XEmacs.default.attributeFont: monospace-12
       XEmacs.bold.attributeFont: monospace-12:style=Bold
     XEmacs.italic.attributeFont: monospace-12:style=Oblique
XEmacs.bold-italic.attributeFont: monospace-12:style=Bold Oblique
   XEmacs.modeline.attributeFont: sans-serif-11
          XEmacs.menubar.xftFont: sans-serif-11
                  XEmacs*XftFont: sans-serif-11

Warning: These resource naming conventions are just hacks to get the code running; you should expect them to change. (Sorry about that, but this is beta software!)

Then run xrdb -merge before starting the new, XFT-enabled xemacs. You can choose the available fonts from the list given by fc-list; try xfd -fa FONTNAME-SIZE to preview a given font. Note that “monospace” and “sans-serif” are generic aliases defined by fontconfig which may correspond to any of many real fonts based on local configuration and availability of the aliased fonts, and so are likely to give good results in a well-set-up system.

Although Customize does not yet handle fontconfig fontspecs, you can pass them as strings directly to ‘set-face-font’ to set fonts from Lisp.


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

5.1: Microsoft Windows


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

Q5.1.1: Does XEmacs rename all the ‘win32-*’ symbols to ‘w32-*’?

In his flavor of Emacs 20, Richard Stallman has renamed all the ‘win32-*’ symbols to ‘w32-*’. Does XEmacs do the same?

We consider such a move counter-productive, thus we do not use the ‘w32’ prefix. (His rather questionable justification was that he did not consider Windows to be a "winning" platform.) However, the name ‘Win32’ is not particularly descriptive outside the Windows world, and using just ‘windows-’ would be too generic. So we chose a compromise, the prefix ‘mswindows-’ for Windows-related variables and functions.

Thus all the XEmacs variables and functions directly related to either the Windows GUI or OS are prefixed ‘mswindows-’ (except for a couple of debugging variables, prefixed ‘debug-mswindows-’). From an architectural perspective, however, we believe that this is mostly a non-issue because there should be a very small number of window-systems-specific variables anyway. Whenever possible, we try to provide generic interfaces that apply to all window systems.


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

Q5.1.2: How do I get Windows Explorer to associate a file type with XEmacs?


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

Associating a new file type with XEmacs.

In Explorer select ‘View->Options->File Types’, press ‘[New Type...]’ and fill in the dialog box, e.g.:

 
        Description of type:    Emacs Lisp source
        Associated extension:   el
        Content Type (MIME):    text/plain

then press ‘[New...]’ and fill in the ‘Action’ dialog box as follows:

 
        Action:
        Open

        Application used to perform action:
        D:\Full\path\for\xemacs.exe "%1"

        [x] Use DDE

        DDE Message:
        open("%1")

        Application:
        <leave blank>

        DDE Application Not Running:
        <leave blank>

        Topic:
        <leave blank>

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

Associating an existing file type with XEmacs.

In Explorer select ‘View->Options->File Types’. Click on the file type in the list and press ‘[Edit...]’. If the file type already has an ‘Open’ action, double click on it and fill in the ‘Action’ dialog box as described above; otherwise create a new action.

If the file type has more than one action listed, you probably want to make the ‘Open’ action that you just edited the default by clicking on it and pressing ‘Set Default’.

Note for Windows 2000 users: Under Windows 2000, get to ‘File Types’ using ‘Control Panel->Folder Options->File Types’.


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

5.2: Printing


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

Q5.2.1: What do I need to change to make printing work?

For regular printing there are two variables that can be customized.

lpr-command

This should be set to a command that takes standard input and sends it to a printer. Something like:

 
(setq lpr-command "lp")
lpr-switches

This should be set to a list that contains whatever the print command requires to do its job. Something like:

 
(setq lpr-switches '("-depson"))

For postscript printing there are three analogous variables to customize.

ps-lpr-command

This should be set to a command that takes postscript on standard input and directs it to a postscript printer.

ps-lpr-switches

This should be set to a list of switches required for ps-lpr-command to do its job.

ps-print-color-p

This boolean variable should be set t if printing will be done in color, otherwise it should be set to nil.

NOTE: It is an undocumented limitation in XEmacs that postscript printing (the Pretty Print Buffer menu item) requires a window system environment. It cannot be used outside of X11.


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

Q5.2.2: How can I print WYSIWYG a font-locked buffer?

Font-lock looks nice. How can I print (WYSIWYG) the highlighted document?

The package ps-print, which is now included with XEmacs, provides the ability to do this. The source code contains complete instructions on its use, in ‘$prefix/share/xemacs/xemacs-packages/lisp/ps-print/ps-print.el’, being the default location of an installed ps-print package.


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

Q5.2.3: Getting M-x lpr to work with postscript printer.

My printer is a Postscript printer and lpr only works for Postscript files, so how do I get M-x lpr-region and M-x lpr-buffer to work?

Put something like this in your ‘init.el’:

 
(setq lpr-command "a2ps")
(setq lpr-switches '("-p" "-1"))

If you don’t use a2ps to convert ASCII to postscript (why not, it’s free?), replace with the command you do use. Note also that some versions of a2ps require a ‘-Pprinter’ to ensure spooling.


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

Q5.2.4: Can you print under MS Windows?

As of 21.4, printing works on Windows, using simply ‘File->Print BUFFER...’, and can be configured with ‘File->Page Setup...’.

Prior to 21.4, there is no built-in support, but there are some clever hacks out there. If you know how, please let us know and we’ll put it here.


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

5.3: Sound


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

Q5.3.1: How do I turn off the sound?

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

 
(setq bell-volume 0)
(setq sound-alist nil)

That will make your XEmacs totally silent—even the default ding sound (TTY beep on TTY-s) will be gone.

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


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

Q5.3.2: How do I get funky sounds instead of a boring beep?

Make sure your XEmacs was compiled with sound support, and then put this in your ‘init.el’:

 
(load-default-sounds)

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

Q5.3.3: What are NAS and ESD (EsounD)?

Network Audio System (NAS) is a client-server sound library for X.

http://radscan.com/nas.html.

To build XEmacs with it, use the ‘configure’ flag ‘--with-sound=nas’ (‘--enable-sound=nas’ in 21.5 or later).

Enlightened Sound Daemon (ESD or EsounD) is yet another sound system.

http://www.tux.org/~ricdude/EsounD.html.

To build XEmacs with it, use the ‘configure’ flag ‘--with-sound=esd’ (‘--enable-sound=esd’ in 21.5 or later).

You can specify support for both with a flag like ‘--with-sound=nas,esd’ (‘--enable-sound=nas,esd’ in 21.5 or later).


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

Q5.3.4: Sunsite sounds don’t play.

I’m having some trouble with sounds I’ve downloaded from sunsite. They play when I run them through showaudio or cat them directly to ‘/dev/audio’, but XEmacs refuses to play them.

Markus Gutschke writes:

[Many of] These files have an (erroneous) 24byte header that tells about the format that they have been recorded in. If you cat them to ‘/dev/audio’, the header will be ignored and the default behavior for /dev/audio will be used. This happens to be 8kHz uLaw. It is probably possible to fix the header by piping through sox and passing explicit parameters for specifying the sampling format; you then need to perform a ’null’ conversion from SunAudio to SunAudio.


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

5.4: Running an Interior Shell, Invoking Subprocesses


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

Q5.4.1: What is an interior shell?

#### Write me.


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

Q5.4.2: How do I start up a second shell buffer?

In the *shell* buffer:

 
M-x rename-buffer <RET> *shell-1* <RET>
M-x shell RET

This will then start a second shell. The key is that no buffer named ‘*shell*’ can exist. It might be preferable to use M-x rename-uniquely to rename the *shell* buffer instead of M-x rename-buffer.

Alternately, you can set the variable shell-multiple-shells. If the value of this variable is non-nil, each time shell mode is invoked, a new shell is made


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

Q5.4.3: Telnet from shell filters too much

I’m using the Emacs M-x shell function, and I would like to invoke and use a telnet session within it. Everything works fine except that now all ‘^M’’s are filtered out by Emacs. Fixes?

Use M-x rsh or M-x telnet to open remote sessions rather than doing rsh or telnet within the local shell buffer. You can also use M-x ssh to open secure remote session if you have ssh installed.


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

Q5.4.4: Strange things are happening in Shell Mode.

Sometimes (i.e. it’s not repeatable, and I can’t work out why it happens) when I’m typing into shell mode, I hit return and only a portion of the command is given to the shell, and a blank prompt is returned. If I hit return again, the rest of the previous command is given to the shell.

Martin Buchholz writes:

There is a known problem with interaction between csh and the filec option and XEmacs. You should add the following to your ‘.cshrc’:

 
if ( "$TERM" == emacs || "$TERM" == unknown ) unset filec

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

Q5.4.5: XEmacs complains "No such file or directory, diff"

or "ispell" or other commands that seem related to whatever you just tried to do (M-x ediff or M-$, for example).

There are a large number of common (in the sense that "everyone has these, they really do") Unix utilities that are not provided with XEmacs. The GNU Project’s implementations are available for Windows in the the Cygwin distribution (http://www.cygwin.com/), which also provides a complete Unix emulation environment (and thus makes ports of Unix utilities nearly trivial). Another implementation is that from MinGW (http://www.mingw.org/msys.shtml). If you know of others, please let us know!


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

Q5.4.6: Cygwin error "fork_copy: linked dll/bss pass 0 failed"

If you are getting an error like

 
17797832 [main] bash 3468 fork_copy: linked dll/bss pass 0 failed,
0x675000..0x6756A0, done 0, windows pid 2708, Win 32 error 487
bash: fork: resource temporarily unavailable

when trying to run bash using M-x shell, then you need to rebase your Cygwin DLL’s. This is a known problem with Cygwin. To fix:

  1. Download the ‘rebase’ utility from Cygwin setup (it’s under ‘System’).
  2. Kill all of your Cygwin processes, including all of your shells and all background processes. Use ps -a to list all the processes you need to kill.
  3. From a DOS prompt, run ‘ash’ (notbash’, ‘tcsh’ or ‘zsh’). Do not try to be clever and exec /bin/ash from your last shell; it won’t work.
  4. Type /bin/rebaseall -v.

The problem should now be fixed – at least, until you install another Cygwin package with DLL’s, in which case you may have to repeat the procedure.


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

5.5: Multiple Device Support


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

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

Use the command M-x make-frame-on-display. This command is also on the File menu in the menubar.

The command make-frame-on-tty also exists, which will establish a connection to any tty-like device. Opening the TTY devices should be left to gnuclient, though.


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

Q5.5.2: Can I really connect to a running XEmacs after calling up over a modem? How?

Yes. Use gnuclient -nw.

Also see How do I disable gnuserv from opening a new frame?.


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

Q5.5.3: How do I disable gnuserv from opening a new frame?

If you set the gnuserv-frame variable to the frame that should be used to display buffers that are pulled up, a new frame will not be created. For example, you could put

 
(setq gnuserv-frame (selected-frame))

early on in your ‘init.el’, to ensure that the first frame created is the one used for your gnuserv buffers.

There is an option to set the gnuserv target to the current frame. See Options->Display->"Other Window" Location->Make Current Frame Gnuserv Target

You can also change this with Customize. Select from the Options menu Advanced (Customize)->Emacs->Environment->Gnuserv->Gnuserv Frame... or type M-x customize <RET> gnuserv <RET>.


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

Q5.5.4: How do I start gnuserv so that each subsequent XEmacs is a client?

Put the following in your ‘init.el’ file to start the server:

 
(gnuserv-start)

Start your first XEmacs as usual. After that, you can do:

 
gnuclient randomfilename

from the command line to get your existing XEmacs process to open a new frame and visit randomfilename in that window. When you’re done editing randomfilename, hit C-x # to kill the buffer and get rid of the frame.

See also man page of gnuclient.


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

Q5.5.5: Is there a way to start a new XEmacs if there’s no gnuserv running, and otherwise use gnuclient?

Jan Vroonhof writes:

Here is one of the solutions, we have this in a script called ‘etc/editclient.sh’.

 
 #!/bin/sh
 if gnuclient -batch -eval t >/dev/null 2>&1
 then
   exec gnuclient ${1+"$@"}
 else
   xemacs -unmapped -f gnuserv-start &
   until gnuclient -batch -eval t >/dev/null 2>&1
   do
      sleep 1
   done
   exec gnuclient ${1+"$@"}
 fi

Note that there is a known problem when running XEmacs and ’gnuclient -nw’ on the same TTY.


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

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