introduction to emacs and xemacs l.
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction to EMACS and XEMACS PowerPoint Presentation
Download Presentation
Introduction to EMACS and XEMACS

Loading in 2 Seconds...

play fullscreen
1 / 12

Introduction to EMACS and XEMACS - PowerPoint PPT Presentation

  • Uploaded on

Introduction to EMACS and XEMACS. CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes. Emacs Background. Emacs is a powerful and extensible text editor. Emacs originally was an acronym for E ditor MAC ro S .

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Introduction to EMACS and XEMACS' - Samuel

Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
introduction to emacs and xemacs

Introduction to EMACS and XEMACS

CMSC 121 Introduction to UNIX

Much of the material in these slides was taken from

Dan Hood’s CMSC 121 Lecture Notes.

emacs background
Emacs Background
  • Emacs is a powerful and extensible text editor.
    • Emacs originally was an acronym for Editor MACroS.
    • The first Emacs was a set of macros written in 1976 at MIT by Richard M Stallman.
    • Emacs has become a standard editor used by programmers worldwide.
  • There are several varieties of Emacs, by typing emacs at the command prompt, you are throw into one of two modes:
    • The terminal-mode (from an ssh connection or without X Window):
      • This mode has no toolbars, and all commands are given via keyboard.
      • Do not think that this is a useless mode, as sometimes the only connection that you may have to a machine is remote.
    • The graphical-mode (requires X Window):
      • It looks similar to the terminal-mode, but with some added features for X.
      • There is a toolbar across the top of the window, from which many common tasks can be accessed.
      • You may wish to type emacs& (note the &), as this will free up the shell for other tasks (such as compiling).
  • This version of Emacs that has many enhancements specifically for X Window and should be launched locally.
  • There is a graphical toolbar (like MS Word) for basic options as well as a text driven toolbar for other options.
  • To invoke XEmacs just type xemacs. If you do not want to tie up the shell, use xemacs&.
creating and opening files
Creating and Opening Files
  • To create a file, type the name of the file that you wish to create after the emacs command. Example: emacs foo.c & or xemacs foo.c & (& optional).
  • To open a file, type the name after the command, just as above.
tutorial and references
Tutorial and References
  • Emacs comes with a built in tutorial.
    • To access it type F1 then T.
    • The tutorial covers many of the basic tasks, such as cursor movement to more advanced skills such as searching and replacing text.
  • References - from basic commands to the full manual
    • A BASIC EMACS Reference Card
    • A much more EXTENSIVE EMACS Reference Card
    • The Complete Manual Online - at
  • XEmacs is a graphical variant of Emacs.
  • It too is freely available for download ( and is also licensed under the GPL license (
  • XEmacs for Windows
    • For those of you who use Windows, that there are MS Windows ports of XEmacs.
  • XEmacs Commands
  • Mostly all of the Emacs commands are available to you under XEmacs
  • One useful XEmacs command:
    • Alt-G - Goto Line number
emacs configuration file
.emacs Configuration File
  • When Emacs (or XEmacs) begins, it looks for and reads a file named .emacs in your home directory to obtain configuration information.
  • Save this .emacs file (note the leading "dot") in your UNIX home directory to get the following features (you will need to restart emacs to invoke these options):
    • Automatic formatting - in accordance with coding style standards of many CMSC classes - (ALWAYS check with your instructor as to specific standards)
    • A working backspace key - backspace will now delete to the left of the cursor instead of invoking "help".
    • A more logical help key - It remaps CTRL-X? to be the new "help" key.
customizing emacs
Customizing Emacs
  • The .emacs file contains user specific information and customizations to the XEmacs/Emacs editors. You can set up this file to do all sorts of customizations from building additional menu bars, to highlighting, to utility functionality.
  • There are 2 ways of going about customizing XEmacs/Emacs:
    • Manually edit this configuration file - this requires some knowledge of the language used to configure the editor and requires the user to manually edit the ".emacs" file.
    • Save configuration changes from within the editor - or you can save the changes from within the editor itself, and it writes out settings automatically to the ".emacs" file.
  • I find that I tend to use a mixture of both manual and automatic editing of the ".emacs" file.
sample cmsc 201 emacs file
Sample CMSC 201 .emacs File


(global-set-key "\C-h" 'delete-backward-char)

(global-set-key "\C-x?" 'help-command)

;; set style to "Ellemtel" for C++

(add-hook 'c++-mode-hook

'(lambda () (c-set-style "ellemtel")))

;; set style to "Ellemtel" for C

(add-hook 'c-mode-hook

'(lambda () (c-set-style "ellemtel")))

;; special effects for 'C‘

(add-hook 'c-mode-hook 'turn-on-font-lock)

another emacs file
;; no tabs please

(setq-default indent-tabs-mode nil)

(setq default-tab-width 4)

;; line & col nums

(setq line-number-mode t)

(setq column-number-mode t)

;; font coloring

(setq font-lock-auto-fontify t)

(setq font-lock-mode-maximum-decoration t)

(require 'font-lock)

;; my email


'(user-mail-address "" t)

'(query-user-mail-address nil))

;; some key bindings

(global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word))))

(global-set-key [f2] 'ispell-word)

;; map that mouse wheel

(global-set-key [button4] 'scroll-down)

(global-set-key [button5] 'scroll-up)

;; automatic indentation upon return

(global-set-key [(return)] 'newline-and-indent)

;; stop beeping

(setq visible-bell 1)

;; make sure that every file has a newline

(setq require-final-newline t)

Another .emacs File
emacs modes
Emacs Modes
  • C Mode: Emacs supports C programming with a variety of options in C mode.
    • C -> Comment Out Region
    • C -> Uncomment Region
    • C -> Indent Line or Region
    • C -> Foreword Statement
    • C -> Backward Statement
  • C++ Mode: C++ mode also supports the same functions as under C mode, but under the C++ menu.
  • HTML Mode
  • Lisp Mode
compiling in xemacs
Compiling in XEmacs
  • One of the nice features of XEmacs is the ability to compile source code from within it.
  • Do the following to compile code from within XEmacs:
    • Click on the Compile button
    • Edit the prompt in the window that appears that shows you what the current command is to compile.
      • By default XEmacs suggests the command "make -k".
      • This may or may not be what you want.
      • If you do not have a makefile (or don't know what one is) then you can change the command to something like "gcc -Wall -ansi *.c" by clicking on "Edit command".
  • The Compilation Output – this is where XEmacs is really useful.
    • If you have errors, gcc (for example) will report file and line numbers that the errors occurred on.
    • XEmacs goes a step further and hyperlinks that error containing the file and line number.
    • So when you click on it, it will open that file in the current buffer and jump to that line number.
  • XEmacs will also make sure that you saved all open files, to avoid compiling the sources without compiling them first.