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.

Slides:



Advertisements
Similar presentations
CIMCO Integration Software Products
Advertisements

Whats New in Office 2010?. Major Changes in Office 2010 The Office Ribbon, which first made its appearance in Office 2007, now appears in all Office 2010.
A Guide to Unix Using Linux Fourth Edition
Introduction to the gedit editor. gedit: the Gnome editor Gnome: Gnome is a freely available (i.e., no cost) desktop environment for the UNIX system The.
PacNOG 6: Nadi, Fiji Using Commands in Linux Hervey Allen Network Startup Resource Center.
XEmacs Tips for Programmers A lunchtime seminar. XEmacs Background  XEmacs not Emacs on Linux hosts  XEmacs is a specialized LISP interpreter  Built-in.
The Command Line, Part II, Pine, and Pico CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture.
UNIX Tools and the UNIX File System CMSC 121 Introduction to UNIX The material on submitexec was taken from Dan Hood’s CMSC 121 Lecture Notes.
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.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Microsoft PowerPoint ® 2003 Carl B. Struck Presentation Graphics n Educational, business, sales and other presentations (slide shows) n Combination of.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Linux+ Guide to Linux Certification, Second Edition
Guide To UNIX Using Linux Third Edition
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
With Alex Conger – President of Webmajik.com FrontPage 2002 Level I (Intro & Training) FrontPage 2002 Level I (Intro & Training)
Printing and Page Formatting ITSW 1401, Intro to Word Processing Instructor: Glenda H. Easter.
Module 3 Productivity Programs Common Features and Commands Microsoft Office 2007.
Editing Java programs with the BlueJ IDE. Working environments to develop (= write) programs There are 2 ways to develop (write) computer programs: 1.Using.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
CSCI 330 T HE UNIX S YSTEM Editing files. E DITOR C ONCEPTS Editing a file is to modify the content of a file Text editor: Enter and modify text in a.
Agenda What is Computer Programming? The Programming Process
Using the “CLI” Unix / Linux Preparation Course May 25 Djibouti.
Chapter 3 Mastering Editors
YourClassPage.com TM Inservice Quickstart Guide Getting YOUR classpage up and running!
Website Development with Dreamweaver
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
Presented by Dr. Jack E. Johnson at the 2007 NBEA Annual Convention Thursday, April 5, GDP, Distance Learning, & Word 2007 “Perfect Partners in.
Productivity Programs Common Features and Commands.
Using Commands Unix/IP Preparation Course July 19, 2009 Eugene, Oregon, USA
Introduction to PowerPoint Curriculum Implementation Day Friday, November 3, 2006 K.J. Benoy.
Introduction to Unix – CS 21 Lecture 8. Lecture Overview More detail on emacs and vi Regular expression matching in emacs and vi.
1 ADVANCED MICROSOFT WORD Lesson 14 – Editing in Workgroups Microsoft Office 2003: Advanced.
1 Lesson 13 Editing and Formatting documents Computer Literacy BASICS: A Comprehensive Guide to IC 3, 4 th Edition Morrison / Wells.
Using Commands Unix / Linux Preparation Course May 6, 2012 Serrekunda, The Gambia.
4 Editing files and Emacs Editing files The Emacs editor.
Unix Editors. u Editors in Unix come in two general flavours: –modal editors have "modes" v generally input mode and command mode –input mode allows entry.
EMACS Jim Vallino Proud emacs user since The truth about editors Editors are like religions. Everyone has one that they like.
Chapter Three The UNIX Editors.
CHAPTER 10 Creating a Word Document. Learning Objectives Enter text Undo and redo actions Create documents based on existing documents Select text Edit.
Using the “CLI” Unix / Linux Preparation Course June 9, 2013 Lusaka, Zambia.
Lesson 1 - Understanding the Word Window and Creating a New Document
An Introduction to Forms. The Major Steps of a MicroSoft Access Database  Tables  Queries  Forms  Macros  Reports  Modules On our road map, we are.
Microsoft Word 2000, Introduction ITSW 1401, Intro to Word Processing Instructor: Glenda H. Easter.
Additional Features in Microsoft Word Session Version 1.0 © 2011 Aptech Limited.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Word 2010 Text Basics In this lesson you'll learn the basics of working with text, including how to insert, delete, select, copy, cut, paste, and replace.
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
MICROSOFT WORD PRESENTATION. Word Processing  Software that is designed for the entry, editing, and printing of documents.  Windows Version = Microsoft.
BIF703 FTP (File Transfer Protocol) Utility vi editor Utility.
Basic Navigation in Oracle R12 BY: Muhammad Irfan.
How to Create a Power Point Presentation. Topics that will be covered: 1) Getting Started 2) Common Features 3) Working with Text 4) Working with Graphics.
1. Using word you can create the document and edit them later, as and when required,by adding more text, modifying the existing text, deleting/moving.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Word processing is the software package that enables you to create,edit, print and save documents for future retrieval reference. creating a document.
Chapter 3: Mastering Editors Chapter 3 Mastering Editors (Emacs)
Review Why do we use protection levels? Why do we use constructors?
Being Productive With Emacs Part 2
Excel Tutorial 8 Developing an Excel Application
Chapter 2: The Visual Studio .NET Development Environment
Guide To UNIX Using Linux Third Edition
You do want to create and edit programs?
Lesson 13 Editing and Formatting documents
Introduction to Emacs J. Caldwell, N. McCaw, D. Powell
Linux Operations and Administration
The Emacs Editor Read: Forouzan, Appendix C
CSCI The UNIX System Editing files
Presentation transcript:

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 is a powerful and extensible text editor. Emacs originally was an acronym for Editor MACroS. 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. 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. 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: 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): The terminal-mode (from an ssh connection or without X Window): This mode has no toolbars, and all commands are given via keyboard. 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. 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): The graphical-mode (requires X Window): It looks similar to the terminal-mode, but with some added features for X. 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. 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). You may wish to type emacs& (note the &), as this will free up the shell for other tasks (such as compiling).

XEmacs This version of Emacs that has many enhancements specifically for X Window and should be launched locally. 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. 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&. To invoke XEmacs just type xemacs. If you do not want to tie up the shell, use xemacs&.

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 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. To open a file, type the name after the command, just as above.

Tutorial and References Emacs comes with a built in tutorial. Emacs comes with a built in tutorial. To access it type F1 then T. 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. 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 References - from basic commands to the full manual A BASIC EMACS Reference Card A BASIC EMACS Reference Card A BASIC EMACS Reference Card A BASIC EMACS Reference Card A much more EXTENSIVE EMACS Reference Card A much more EXTENSIVE EMACS Reference Card A much more EXTENSIVE EMACS Reference Card A much more EXTENSIVE EMACS Reference Card The Complete Manual Online - at GNU.org The Complete Manual Online - at GNU.org The Complete Manual Online The Complete Manual Online

XEmacs XEmacs is a graphical variant of Emacs. XEmacs is a graphical variant of Emacs. It too is freely available for download ( and is also licensed under the GPL license ( It too is freely available for download ( and is also licensed under the GPL license ( XEmacs for Windows XEmacs for Windows For those of you who use Windows, that there are MS Windows ports of XEmacs. For those of you who use Windows, that there are MS Windows ports of XEmacs. XEmacs Commands XEmacs Commands Mostly all of the Emacs commands are available to you under XEmacs Mostly all of the Emacs commands are available to you under XEmacs One useful XEmacs command: One useful XEmacs command: Alt-G - Goto Line number Alt-G - Goto Line number

.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. 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): 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):.emacs file.emacs file Automatic formatting - in accordance with coding style standards of many CMSC classes - (ALWAYS check with your instructor as to specific standards) 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 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. A more logical help key - It remaps CTRL-X? to be the new "help" key.

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. 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: 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. 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. 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. I find that I tend to use a mixture of both manual and automatic editing of the ".emacs" file.

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)

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 (custom-set-variables '(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)

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

Compiling in XEmacs One of the nice features of XEmacs is the ability to compile source code from within it. 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: Do the following to compile code from within XEmacs: Click on the Compile button Click on the Compile button Edit the prompt in the window that appears that shows you what the current command is to compile. 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". By default XEmacs suggests the command "make -k". This may or may not be what you want. 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". 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. 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. 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. 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. 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. XEmacs will also make sure that you saved all open files, to avoid compiling the sources without compiling them first.

Wildcards Wildcards allow a single command to act upon multiple files with a name that matches a pattern. Wildcards allow a single command to act upon multiple files with a name that matches a pattern. Primarily, wildcards reduce typing and make commands more reusable. Primarily, wildcards reduce typing and make commands more reusable. * – Matches any sequence of characters. * – Matches any sequence of characters. ? – Matches any single character. ? – Matches any single character.

[ ] - Match Single Character [ ] – Matches any single character included in the list. [ ] – Matches any single character included in the list. The list may contain ranges, specified by a dash. E.g. [a-z] The list may contain ranges, specified by a dash. E.g. [a-z] An exclamation point ! matches any character not in the list. E.g. [!a-z] An exclamation point ! matches any character not in the list. E.g. [!a-z] Example: Example: linux3 [6]# ls file.a file.cgi file.html file.lib file.tk file.z file.c file.h file.l file.pl file.txt To list just the *.c and *.h files: To list just the *.c and *.h files: linux3 [8]# ls *.[c,h] file.c file.h Or you can specify ranges of values, such as... Or you can specify ranges of values, such as... linux3 [10]# ls *.[a-z] file.a file.c file.h file.l file.z

{ } - Match Multiple Characters We can also denote multiple files by using the "{" and "}" characters. We can also denote multiple files by using the "{" and "}" characters. This is the multiple character version of the previous example. This is the multiple character version of the previous example. Given the following directory listing: Given the following directory listing: linux3 [11]# ls file.a file.cgi file.html file.lib file.tk file.z file.c file.h file.l file.pl file.txt To list just the *.cgi, *.pl and *.tk files: To list just the *.cgi, *.pl and *.tk files: linux3 [12]# ls *.{cgi,pl,tk} file.cgi file.pl file.tk This could be very helpful when trying to open up an entire project that consists of multiple files in emacs. This could be very helpful when trying to open up an entire project that consists of multiple files in emacs. For example: emacs *.{c,h,txt} &