Introduction to EMACS and XEMACS - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to EMACS and XEMACS

Description:

Emacs is a powerful and extensible text editor. Emacs originally was an ... The first Emacs was a set of macros written in 1976 at MIT by Richard M Stallman. ... – PowerPoint PPT presentation

Number of Views:194
Avg rating:3.0/5.0
Slides: 13
Provided by: eric321
Category:

less

Transcript and Presenter's Notes

Title: Introduction to EMACS and XEMACS


1
Introduction to EMACS and XEMACS
  • CMSC 121 Introduction to UNIX
  • Much of the material in these slides was taken
    from
  • Dan Hoods CMSC 121 Lecture Notes.

2
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).

3
XEmacs
  • 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.

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

5
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 GNU.org

6
XEmacs
  • XEmacs is a graphical variant of Emacs.
  • It too is freely available for download
    (http//www.xemacs.org/) and is also licensed
    under the GPL license (http//www.gnu.org/licenses
    /licenses.htmlGPL).
  • 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

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

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

9
Sample CMSC 201 .emacs File
  • (custom-set-faces)
  • (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)

10
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
  • (custom-set-variables
  • '(user-mail-address "your_username_here_at_umbc.edu"
    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)

11
Emacs Modes
  • C Mode Emacs supports C programming with a
    variety of options in C mode.
  • C -gt Comment Out Region
  • C -gt Uncomment Region
  • C -gt Indent Line or Region
  • C -gt Foreword Statement
  • C -gt Backward Statement
  • C Mode C mode also supports the same
    functions as under C mode, but under the C
    menu.
  • HTML Mode
  • Lisp Mode

12
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.
Write a Comment
User Comments (0)
About PowerShow.com