Emacs 21 for Mac OS X
Latest News, FAQ, Files, Links, and other Resources.
Latest News

Introduction

Obtaining and Building Emacs

FAQ

Resources


Emacs Home Page

Emacs Project Page on Savannah

Emacs for Mac OS Classic Project Page


My OS X Programming Blog

   
Emacs 21 for Mac OS X FAQ


FAQ Revised: Thursday 21 August 2003 18:02:28


Table of Contents

1. INSTALLATION AND GENERAL QUESTIONS
2. GENERAL USER QUESTIONS
3. INTERNATIONAL CHARACTER SETS AND KEYBOARD SUPPORT

1. INSTALLATION AND GENERAL QUESTIONS

1.1. How do I install Emacs?

The sequence of commands to obtain and build texinfo and Emacs (assuming that you already have Developer Tools installed) should look something like this:

  curl -O ftp://ftp.gnu.org/gnu/texinfo/texinfo-4.2.tar.gz
  tar zxf texinfo-4.2.tar.gz
  cd texinfo-4.2
  ./configure
  make
  sudo make install

cd .. cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/emacs login cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/emacs co emacs cd emacs ./configure --with-carbon --without-x make bootstrap sudo make install

For specialized methods of building Emacs, such as building it to run on the X Window System, read the file mac/INSTALL.

1.2. The build fails saying "No rule to make target ... abbrev.elc". Why?

You're probably not doing a make bootstrap at the top-level directory while you got this error message. Otherwise lisp/abbrev.elc would have already been created. The top-level Makefile will not try to create ../etc/DOC before that happens.

Check that you are in fact doing a make bootstrap.

Try running make extraclean; ./configure ...whatever...; make bootstrap.

1.3. Why does the build fail to makeinfo saying "Unknown command `copying'"?

You need makeinfo from texinfo version 4.2. Earlier versions will not work. Check your version of texinfo by typing

  makeinfo --version


1.4. After I rebuild Emacs, its icon in the dock doesn't work. Why?

Perhaps you can try rebuilding the launch service database as described here:

  http://developer.apple.com/carbon/tipsandtricks.html#RebuildLS

Basically, type

  rm ~/Library/Preferences/LS*
  rm ~/Library/Preferences/.LS*	

and reboot.

1.5. Do the warning messages regarding precompiled headers matter?

Those messages just mean that the compiler needs to read and parse the header files, instead of being able to use the pre-compiled headers. In any case, the compiler is doing the right thing using the new definitions for vfork and select rather than those in the pre-compiled headers. So it is normal to see them.

1.6. Can binaries built on Mac OS X 10.1 run on 10.2 (or vice versa)?

No.

1.7. How do I install a font in Mac OS X?

I put it in my Mac OS 9 System Folder so both systems 9 and X can see it. You can also try putting it in ~/Library/Fonts/ for only that user to see or /Library/Fonts/ for all users to see.

1.8. How do I install an earlier version of Emacs in the CVS?

You say something like this:

  cvs update -D "29 Sep 2002 11:00:00 -0600"

for example. Note however, that once you've used the -D option, your copy will be `stuck' at that date. To update to a later version subsequently, do this:

  cvs update -A


1.9. I have some Fink packages installed and Emacs fails to build. Why?

There being so many Fink packages, it is hard to give a definitive answer. Furthermore, I build everything from source! So I know nothing about Fink.

But in general, development software and libraries installed by Fink can affect the build. If so, perhaps it is possible to remove them and try. Also check whether your environment variables (such as PATH, CFLAGS, CC, LD_LIBRARY_PATH, etc.) are set by these packages.

1.10. Can I put all the support files in the Emacs.app application bundle?

Yes. Copy the directories etc, leim, lisp, and site-lisp, which are by default installed into /usr/local/share/emacs/<emacs-version>/, into Emacs.app/Contents/Resources/.

Copy the files installed into /usr/local/bin and /usr/local/libexec/emacs/<emacs-version>/<system-configuration>/ into Emacs.app/Contents/MacOS/bin/ and Emacs.app/Contents/MacOS/libexec/, respectively.

Copy the files installed into /usr/local/info/ into Emacs.app/Contents/Resources/info/.

Now the application bundle (as a whole) can be moved around anywhere you want. A script to automatically construct such an application bundle will follow.

1.11. Why don't you provide a binary distribution?
I don't have the time and resources to do that.

I will provide one at ftp.gnu.org when the Mac OS X code becomes part of a standard Emacs source distribution. This will probably not happen until version 21.4, however.

1.12. Are there other ports of Emacs to the Mac OS X?

Emacs on Aqua

http:XEmacs

XEmacs 19.14 for Macintosh

1.13. What do you consider to be the strength of your implementation?

It is based on and will be part of the standard Emacs 21 distribution. It is highly stable. It runs natively as a GUI application and does not require X Window to run (although it can be compiled to run under X Window).


2. GENERAL USER QUESTIONS

2.1. How can I learn to use Emacs?

If you are learning to use Emacs, you should read the Emacs FAQ (C-h C-f), the tutorial (C-h t), and the online manual (C-h i).

The book Learning GNU Emacs by Cameron, Rosenblatt, and Raymond provides a good introduction, although dated.

2.2. How can I learn to write Emacs Lisp programs?

Read the Emacs Lisp online manual (C-h i g ( Elisp ) RET).

The O'Reilly book GNU Emacs Extensions by Bob Glickstein is also a good source of information, although dated.

2.3. Can I transfer text yanked to the kill ring to another application and back?

There are routines that connect the Mac clipboard and the Emacs kill ring.

The most recent kill is copied to the clipboard when Emacs is suspended and the contents of the clipboard is inserted into the kill ring when Emacs resumes. The result is that you can yank a piece of text and paste it to another Mac application or cut or copy one in another Mac application and yank it into a Emacs buffer.

2.4. How do I change a file's end-of-line style?

Emacs detects and selects the correct characters to be interpreted as end of line. It should automatically and correctly handle Mac-, Unix-, and DOS-style end of line characters in files it edits and saves them in their original end-of-line styles.

To change a file's end-of-line style, visit it and determine its coding by evaluating the expression buffer-file-coding-system. Then change the suffix to the desired end-of-line style and save the file using by typing M-x set-buffer-file-coding-system. For example if the coding of the file is undecided-mac, changing it to undecided-dos and saving the file will cause the file to use DOS end-of-lines.

2.5. How do I set the option key (or command key) as meta key?

Emacs can use either the option key or command key as the meta key. The Lisp variable mac-command-key-is-meta can be set dynamically to a non-nil value (e.g., in .emacs) to make Emacs recognize the command key as the meta key. The default value of this variable is nil, which means that the option key is the meta key.

Most people, however, should want to use the Mac command key as the meta key so dead key processing with the Mac option key will still work.

2.6. What colors does Emacs support?

All X colors defined in .../etc/rgb.txt are supported (type M-x list-colors-display to see them). Therefore modes and packages that require color support like font lock mode, hilit mode, and customize will be displayed in color.

It also supports old-style RGB color specs (i.e., #RRGGBB).

2.7. How do I set the foreground and background color?

Here's an example. Evaluate the following expressions

  (set-background-color "snow")
  (set-foreground-color "firebrick4")


2.8. How does Emacs choose the font it starts up in?

It looks for

  -etl-fixed-medium-r-normal--16-160-75-75-m-160-iso8859-1

and if that's not installed on the system, it looks for 12-pt Monaco.

2.9. How do I modify the width and/or height of a frame?

Like its font, the width and height of a frame can be changed dynamically. E.g., to specify a 100 x 44 initial frame, add the follow line to .emacs:

  (setq initial-frame-alist '((width . 100) (height . 44)))

To set the width and height of a frame after it has been created, evaluate the expression

  (modify-frame-parameters
   (selected-frame)
   '((width . 100) (height . 44)))

Note that there must be at least one space before and after the period.

2.10. How can I change the default file open path ?

That's easy. Just put

  (cd "whatever/pathname/you/want")

at the end of your .emacs file.

2.11. How do I start Emacs as a GUI application from the command line?

Replace the binary /usr/local/bin/emacs (or wherever you installed it) with a file containing the following two lines (of course you need to change the pathname according to where you have put the Emacs.app application bundle).

#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$@"

Then typing emacs (provided /usr/local/bin is include in your PATH environment variable) will start Emacs in GUI mode. Typing emacs -nw will start Emacs in terminal mode.

2.12. Why is the output of subprocesses being chopped off?

Try doing this:

  (setq process-connection-type nil)

There seems to be a problem with the pty implementation in Mac OS X. Unfortunately some Emacs packages (like ange-ftp) depends on it.

2.13. Can command-h be sent to Emacs (as M-h) instead of being processed by the Finder as the Hide Emacs shortcut?

Try setting

  mac-pass-command-to-system

to nil. Another variable mac-pass-control-to-system determines whether control keys are sent first to the system for processing.

2.14. How do I get printing to work?

Once you have set up the Unix command lpr <filename> to work correctly (for both text files and Postscript files), you should be able to use all the printing commands in Emacs.

There are different bits information on the web on how to do this. You will probably need to experiment a little. Try this one (for 10.1), e.g., or this one (for 10.2).


3. INTERNATIONAL CHARACTER SETS AND KEYBOARD SUPPORT

3.1. Does Emacs recognize the setting of the Keyboard Control Panel?

Yes. Emacs recognizes the setting in the Keyboard control panel and should support international and alternative keyboard layouts (e.g., Dvorak). Note that the Mac toolbox still performs deadkey processing (see Inside Macintosh: Event Manager) which affects the characters that Emacs actually receives.

3.2. How do I directly enter ISO Latin-1 characters using the Mac keyboard?

To use the Mac keyboard (which ordinarily generates characters in the MacRoman encoding) for entering ISO Latin-1 characters, evaluate the following expression

  (setq mac-keyboard-text-encoding kTextEncodingISOLatin1)

and select one of the layouts from the keyboard layout pull-down menu. Note also that not all Mac Roman characters that can be entered at the keyboard can be converted to ISO Latin-1 characters.

3.3. How do I directly enter ISO Latin-2 characters using the Mac keyboard?

This experimental feature allows you to enter ISO Latin-2 characters directly using the Mac keyboard. To do this evaluate the expression

  (setq mac-keyboard-text-encoding kTextEncodingISOLatin2)

Then type M-x set-keyboard-coding-system RET iso-latin-2 RET. Please let me know if this works. I have no way of testing it.

3.4. How do I input and display traditional Chinese characters?

To edit a file in Big-5 Traditional Chinese encoding, set the language environment to Chinese-BIG5 and set a LEIM Big-5 input method (e.g., chinese-b5-tsangchi). This can be achieved by placing the following lines into your .emacs file.

  (set-language-environment 'Chinese-BIG5)
 
  (set-input-method 'chinese-b5-tsangchi)

You can then input Chinese characters using the LEIM input method.

3.5. How do I use a Traditional Chinese input method provided by Mac OS X?

To use a Traditional Chinese input method supported by Mac OS X, evaluate the following expression

  (set-keyboard-coding-system 'chinese-big5)

and select one of the Traditional Chinese input methods the keyboard layout pull-down menu.

3.6. How do I input and display Japanese characters?

To edit a file in iso-2022-jp or SJIS, set the language environment to Japanese. This can be achieved by evaluating the following expressions.

  (set-language-environment 'Japanese)


3.7. How do I use a Japanese input method provided by the Mac OS X?

To use a Japanese input method supported by Mac OS X, evaluate the following expression

  (set-keyboard-coding-system 'sjis)

and select one of the Japanese input methods the keyboard layout pull-down menu.

3.8. How do I specify a font to Emacs?

Fonts must be specified to Emacs using the long X font spec format. I.e.,

  -FOUNDRY-FAMILY-WEIGHT-SLANT-WIDTH--PIXELS-POINTS-
    HRES-VRES-SPACING-AVEWIDTH-CHARSET

where the fields are foundry, font family, weight, slant, width, pixels, point size, horizontal resolution, vertical resolution, spacing, average width, and character set, respectively.

With respect to Emacs, there are two types of fonts on the Mac: normal fonts, like Monaco, Taipei, Osaka and those that are converted from GNU fonts. The latter have foundry, family, and character sets encoded in their names. E.g., the converted font ETL-Fixed-ISO8859-1 is identified by the name

  -ETL-Fixed-*-*-*-*-*-*-*-*-*-*-ISO8859-1

The names of normal Mac fonts do not provide information about their encoding. The Mac OS determines that from the number of their FOND resources, which implies that the font should be use for a certain script by examining the range of values into which this number falls. Internally, the Mac font Taipei is referred to by the name

  -*-Taipei-*-*-*-*-*-*-*-*-*-*-big5

because it is used for Traditional Chinese.

The plain, bold, italic, bold-italic variants of an X font are represented by the long font specs of the forms

  -*-*-medium-r-*-*-*-*-*-*-*-*-*
  -*-*-bold-r-*-*-*-*-*-*-*-*-*
  -*-*-medium-i-*-*-*-*-*-*-*-*-*
  -*-*-bold-i-*-*-*-*-*-*-*-*-*

respectively. However, each Mac font is assumed to already contain all four variants and if a certain bitmap is absent, the font manager will create it as it is needed.

3.9. How do I set the font for a frame?

A frame can be set to use a certain font by evaluating the expression of the form

  (modify-frame-parameters (selected-frame)
    '((font . "-*-Monaco-*-100-*")))

The above example shows how to set the Monaco font of size 10. Evaluating the expression

  (modify-frame-parameters (selected-frame)
    '((font . "-ETL-Fixed-*-140-*-ISO8859-1")))

makes the front most frame use the size-14 version of the converted font ETL-Fixed-ISO8859-1.

The font used for the initial frame and subsequently created frames can be set by changing the value of the initial-frame-alist and default-frame-alist as described in Emacs documentation.

3.10. How do I set the fontset for a frame?

A frame can be set to use a fontset by evaluating the expression

  (modify-frame-parameters (selected-frame)
    '((font . "fontset-mac")))

A list of fontsets can be obtained by typing M-x list-fontsets. Two fontsets are created by default: fontset-standard and fontset-mac.

To see which fonts are used for the codings in fontset-mac, e.g., type

  M-x describe-fontset RET
  -*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-mac RET


3.11. How can I make latin-1 and other non-ASCII characters display correctly?

The simplest way is to install the GNU intlfonts (see download link below). Then latin-1 characters should be displayed correctly by default. If you want to use Monaco instead, make sure you have that font installed in your system and set your font to fontset-mac. To find out how to do this, read about default-frame-alist in the on-line manual. The most flexible method of setting which fonts to use for characters in different codings is to define your own fontsets. Please read about the function create-fontset-from-fontset-spec in the manual and use fontset-mac as an example.

3.12. How do I create my own fontset?

To properly display latin-1 characters using 9-pt Monaco, do this:

  (create-fontset-from-fontset-spec
"-apple-monaco-medium-r-normal--9-*-*-*-*-*-fontset-monaco,
ascii:-apple-monaco-medium-r-normal--9-90-75-75-m-90-mac-roman,
latin-iso8859-1:-apple-monaco-medium-r-normal--9-90-75-75-m-90-mac-roman")

and set-frame-font to fontset-monaco.

You can also use any other font that has non-zero size in the list returned by the function x-list-fonts.

3.13. Why are some of the fonts in the HELLO file not supported?

I've written an MPW tool to convert fixed-width BDF fonts to Mac NFNT fonts. Because of the limitation of the NFNT format, this program will work only for fonts with no more than 256 code points.

Font sets with more than 256 code points cannot be represented in the NFNT format. I have also written another MPW tool to convert BDF fonts to the "bitmap" variant of TrueType fonts (the one that uses a 'bhed' table instead of a 'head' table). Of course the conversion will not generate any font outlines. I have not finished testing this tool and the fonts generated by it.

An alternatively method of get more fonts to work is by implementing our own font cache as done in w32bdf.c. It is not easy to adapt the code in w32bdf.c directly because it depends on the ability of Windows to map a portion of virtual memory to a file.

3.14. What about international text in the clipboard?

Ikegami Tsutomu suggested the addition of the following lines to .emacs to enable kill-yank region (and clipboard transfer) containing Japanese characters

  ; translate clipboard 
  (set-selection-coding-system 'sjis-mac) 

(setq interprogram-cut-function '(lambda (str push) (mac-cut-function (encode-coding-string str selection-coding-system t) push)))

(setq interprogram-paste-function '(lambda () (decode-coding-string (mac-paste-function) selection-coding-system t)))



3.15. How do I execute an AppleScript from Emacs?

The Emacs Lisp function do-applescript allows one to run an AppleScript from Emacs by writing, e.g.,

  (do-applescript "tell application "iTunes" to activate")

Since the Mac using 'r' as end lines, multiple-line script should be written in the form, e.g.,

  (do-applescript "tell application "iTunes"r  activaterend tell")



For more information about this faq, please contact <akochoi-emacs at shaw.ca>.

Copyright © 2002, 2003 Andrew Choi

This list of questions and answers was generated by makefaq.


Copyright © 2003 Andrew Choi <akochoi-emacs at shaw.ca> Created with
BlogMax
emacs Made on a Mac