CSE HUJI Emacs Fonts HOWTO

under construction

Contents

1. Intro

Graphical representation of text is very important. Small things, like font you don't like (unclear, too big, too small, etc) may be very annoying. In Emacs such problems can be easily solved. This manual describes almost all ways to change fonts in Emacs. (not xemacs!).

Changes may be temporal and permanent. Temporal changes affect only current session, while permanent ones affect also all future sessions as well.

2. Temporal font changing

These changes will affect only current emacs session and don't require to perform any changes in emacs configuration. Since we don't need to mess with configuration the changes can be done in simplest and quickest way, e.g. choosing new font from predefined list of fonts using either from pop-up menu or font-ring. Non-quick changes shown below are described only for consistency reasons.

2.1. Quick changes

2.1.1. Fonts pop-up menu

Invoke mouse-set-font command by clicking the left mouse button in any emacs window while holding the Shift key. This will pop-up a nice menu of fonts you can choose new font from. Then the default emacs font will be set to new font you choose.

2.1.2 Font-ring

You can also move over predefined list of fonts using font-ring. Each time you press C-c + the next-font command will be invoked and default emacs font will be set to next font from font-ring.

The default list of fonts for font-ring is taken from cse-huji-font-list variable. This variable may be customized to suit your needs. Just M-x customize-option (ENTER) cse-huji-font-list. Note that fonts' names you enter there need to be valid (one of available fonts).

2.2. Non-quick changes

Once again, this section is show only cor consistency. For temporal changes we suggest to use the quick way. The way described here is very likely permanent changes way. The only difference that you don't save changes in your configuration, so the next session of emacs won't be affected.

First you have to choose your preferred font and check that it available in emacs.

The next step is to set the default emacs font to chosen font.The one way to do it is M-x set-default-font (ENTER) font-you-already-choose. Another way is to customize font of default face. Note that in faces customization buffer you need to choose set for current session option instead of save for future sessions one . This will prevent emacs from saving customized option in your custom-file (~/.emacs-options file for thouse who use CSE default emacs configuration) and therefore this change will affect only current emacs session.

3. Permanent font changing

FIXME Those changes will affect all future emacs sessions.

For all font changes you have first to choose your preferred font. Do the following steps:

  1. Choose your preferable font. (If you already know what font you want you can skip this step).

    Use xfontsel utility (invoke xfontsel from you shell) to try out different fonts. After choosing font click select button in xfontsel window. This will copy font name you choose to copy&paste buffer.

  2. Check if the font is available.

    For this switch to *scratch* buffer and perform all described in availability section. You will get list of currently available font you can use in emacs. Try to find already choosen font in that list. Font name you choose using xfontsel utility is already in cut&paste buffer, therefore you can easily paste it via yank or mouse-yank-at-click commands. Repeat first step if you failed to find your font in list of all available fonts. Upon succes you can go to the next step. ........ ..... FIXME

4.Get rid of CSE default font.

Upon startup the CSE default emacs configuration will set your emacs default font to cse-huji-default-font. (You may check its value using describe-variable command). In case you want to avoid this you need to customize the cse-huji-use-default-font variable. Edit it (toggle on/off) and set for current session or save for future sessions.

5. Checking font availability

To check if some font is available in emacs do following:
  1. Switch to *scratch* buffer.
  2. Type: (prin1-to-string (x-list-fonts "font-you-whant-to-check or pattern")).
  3. Place the cursor after the last closing paren and hit C-j. List of the names of available fonts matching given pattern will appear in the current buffer (*scratch*).
  4. For listing of all available fonts use (prin1-to-string (x-list-fonts "*")).

Additional info about x-font-list function and its arguments you can find as usual through describe-function command.

6. Which font emacs uses now ( default font)?

Sometimes you want to know what is your default font (font of default-face), i.e. font you currently use in emacs.

You can do this by performing the following steps :

  1. Switch to *scratch* buffer.
  2. Type: (frame-parameters nil 'font).
  3. Place the cursor after the closing paren and press C-j. Name of default font will appear in current buffer (*scratch*).

7. Customizations

FIXME Customization : menu, default-face, look-and-feel M-x customize-option cse-huji-font-list, cse-huji-use-default-font M-x customize-group cse-huji, default-face, look-and-feel

8. Keys and bindings

key bind to command description
S-down-mouse-1 mouse-set-font Select an emacs font from a list of known good fonts and fontsets
C-j eval-print-last-sexp Evaluate sexp before point and print its value into current buffer
   
C-h v describe-variable Display the full documentation of given function
C-h f describe-function Display the full documentation of given variable
   
mouse-2 mouse-yank-at-click Insert the last stretch of killed text at the position clicked on
C-y yank Reinsert the last stretch of killed text
   
C-c&nbcp;+ next-font Sets default font to next font choosen from font ring.

where mouse-2 is middle-mouse-button (scroll button), S-down-mouse-1 means Shift + left-mouse-click.

9. Additional Info

Emacs faces notes and tips at <http://tiny-tools.sourceforge.net/emacs-font.html>






OLD - to REMOVE

(1) Add the following line to your ~/.Xdefaults:

    Emacs*font: (your-font-name)

    For example,
    Emacs*font: -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1

    Note: reinstalling .Xdefaults will erase this setting.


(2) Add the following line to your ~/.emacs:
    
    (if-not-xemacs (set-default-font "your-font-name"))

    where your-font-name is your font's name as in (1).

    Note: reinstalling .emacs will erase this setting.


(3) In Emacs, type M-x, customize-face (ENTER) default (ENTER), then
    check the options you want to set and set them. After that, you can
    use the State menu in the page to apply the values for the current
    session or all future sessions. (If you want to change the font only
    for the current session, we suggest using option (4) below, as it's
    easier).

    Note: M-x stands for Meta-x, which on most computers means Alt-x.

    Note 2: setting for future sesssions are saved in the file
    .emacs-options in your home directory. Reinstalling this file will
    erase the setting.

>