CERN Accelerating science

This website is no longer maintained. Its content may be obsolete. Please visit http://home.cern/ for current CERN information.



next up previous
Next: More about multi-language Up: Tutorial Section Previous: New specifiers

Initializing Emacs

  Michel Goossens CN/ASD

Emacs 19.22, the latest version of the popular Emacs editor, is not only a major step forward in the area of integration with the X-window system, but it also now supports 8-bit input by default, so that it becomes a lot easier to handle non-English documents containing diacritics (accents, umlauts), as in French or German.

To take advantage of those features, one has to load some files, and define some modes. This is most easily done by defining the necessary commands in a file called .emacs in the user's home directory, since Emacs, when it starts up, executes the Lisp commands in that file. It is also by modifying this file that an Emacs session can be customized. Note that this file is loaded after the system-wide initialization file site.start.el, which is in the directory /usr/local/lib/emacs/site-lisp. This file contains settings, which should be the same for all Emacs users at a site, e.g. at CERN the definition of the Gnus News server has been entered into that file:

;
; gnus configuration setup
;
(setq gnus-nntp-server "dxnews.cern.ch")
(setq gnus-local-domain "cern.ch")

It contains also entries for tcl-mode, the vm mail system, auctex and TeX, and calc. Note also that Emacs loads a site-defined file default.el after executing the user's .emacs

Below is a simple example of an .emacs file, which shows a few definitions that can make your Emacs session more productive, especially in the area of multi-lingual support. For more information about the Emacs Lisp language one should study the Emacs Lisp Reference Manual.

;;;-----------------------------------------------------
;;; .emacs initialization file for X Windows 
;;;-----------------------------------------------------
; Get the version of emacs being initialized
(defconst version
  (cond ((string-match "^18" emacs-version) 18)
	((string-match "^19" emacs-version) 19)       ))
; If version=19, put variable running-emacs19 to true
(defvar running-emacs19 (eq version 19 ))
; Add the directory ~/elisp in front of the search 
; path for files to be loaded. This comes handy if 
; you want to (re)define some Lisp procedures.
(setq load-path (cons "~/elisp" load-path ))
;;;-----------------------------------------------------
;;;-- general
;;;-----------------------------------------------------
; Define global key-binding for some commands 
(global-set-key "\C-=" 'what-line)
(global-set-key "\M-g" 'goto-line)
; local key binding
(define-key ctl-x-map "\C-E" 'compile)
;;;-----------------------------------------------------
;;;-- File abbreviations
;;;-----------------------------------------------------
; Use ll as an abbriation for load-library
(fset 'll (symbol-function 'load-library))
; Use lf as an abbriation for load-file
(fset 'lf (symbol-function 'load-file))
;;;-----------------------------------------------------
;;;-- Modes
;;;-----------------------------------------------------
; Set the default values for the association list which 
; defines the major mode functions to be used for the 
; given file name patterns.
(autoload 'awk-mode "awk" "awk mode" t)
(setq auto-mode-alist 
       (append (list (cons "\\ .awk$" 'awk-mode))
			                 auto-mode-alist))
; Load modes from the given file when required
(autoload 'html-mode     "html-mode" "Edit HTML docs"   t)
(autoload 'w3            "w3"        "WWW Browser"      t)
; some hooks et al.
(setq default-major-mode 'text-mode)
(setq text-mode-hook 'turn-on-auto-fill)
(setq tex-mode-hook 'turn-on-auto-fill)
(setq latex-mode-hook 'turn-on-auto-fill)
; Electric c a la gosling
(add-hook 'c-mode-hook 'elec-c-mode)
(add-hook 'elec-c-mode-hook 'turn-on-auto-fill)
(autoload 'elec-c-mode "elec-c" "Electric C edit mode." t)
;;;-----------------------------------------------------
;;;-- Definitions for use with the Newsreader gnus
;;;-----------------------------------------------------
(setq gnus-local-organization 
    "CERN, European Research Center for Particle Physics")
(setq gnus-article-save-directory 
                      "/afs/cern.ch/user/g/goossens/News")
(setq gnus-use-generic-from "dxcern.cern.ch")
(setq gnus-large-newsgroup 100)
;;;-----------------------------------------------------
;;;-- Definitions for use with View Mail
;;;-----------------------------------------------------
(setq vm-folder-directory "~/vm")
(setq vm-mail-header-from "Michel.Goossens@cern.ch")
;;;-----------------------------------------------------
;;;-- Some specific things for use with emacs-19 only
;;;-----------------------------------------------------
(if running-emacs19
 (progn
  ;; ---------------------------------------------
  ;; Load files containing ISO Latin 1 definitions
  ;; ---------------------------------------------
  ; Display accented European characters (8-bit codes)
  (standard-display-european t)
  (autoload 'iso-tex-minor-mode  "iso-tex"
   "Translate TeX to ISO 8859/1 while visiting  file." t)
  ;; ---------------------------------------------
  ;; Convenient cut and paste and highlighting
  ;; ---------------------------------------------
  (setq transient-mark-mode t)
  (setq mark-even-if-inactive t)
  ;; supercite
  (autoload 'sc-perform-overloads "supercite" 
                                         "Supercite 3.0")
  (setq mail-setup-hook 'sc-perform-overloads)
  (setq mail-yank-hooks 'sc-cite-original)
  (setq news-reply-mode-hook 'sc-perform-overloads)
  ;set hook to keep mark active
  (add-hook 'sc-pre-hook '(lambda () 
                                   (setq mark-active t)))
))
;;;-----------------------------------------------------
;;;-- Define the font to be used for the frame
;;;-----------------------------------------------------
(set-default-font 
 "-adobe-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1")




Janne Saarela
Tue May 16 14:52:44 METDST 1995