LearningGNUEmacs,3rdEdition
ByDebraCameron,JamesElliott,
MarcLoy
Publisher :O'Reilly
PubDate :December2004
Tableof
•
ISBN :0-596-00648-9
Contents
Pages :534
• Index
• Reviews
Reader
•
Reviews ThethirdeditionofLearningGNUEmacsdescribesEmacs21.3
fromthegroundup,includingnewuserinterfacefeaturessuchas
anicon-basedtoolbarandaninteractiveinterfacetoEmacs
• Errata
customization.AnewchapterdetailshowtoinstallandrunEmacs
• Academic onMacOSX,Windows,andLinux,includingtipsforusingEmacs
effectivelyonthoseplatforms.
Tableof
•
Contents
• Index
• Reviews
Reader
•
Reviews
• Errata
• Academic
LearningGNUEmacs,3rdEdition
ByDebraCameron,JamesElliott,
MarcLoy
Publisher :O'Reilly
PubDate :December2004
ISBN :0-596-00648-9
Pages :534
Copyright
Preface
WhyReadThisBook?
WhichEmacsIsWhich?
What'sNewinThisEdition?
AnApproachtoLearningEmacs
TheMetaKey
HowtoContactUs
GNUEmacsandtheFreeSoftwareFoundation
WhatWeHaven'tIncluded
ConventionsUsedinThisBook
Acknowledgments
Chapter1.EmacsBasics
Section1.1.IntroducingEmacs!
Section1.2.UnderstandingFilesandBuffers
Section1.3.AWordAboutModes
Section1.5.AbouttheEmacsDisplay
Section1.4.StartingEmacs
Section1.6.EmacsCommands
Section1.7.OpeningaFile
Section1.9.LeavingEmacs
Section1.8.SavingFiles
Section1.10.GettingHelp
Section1.11.Summary
Chapter2.Editing
Section2.1.MovingtheCursor
Section2.2.DeletingText
Section2.4.EmacsandtheClipboard
Section2.6.CancelingCommandsandUndoingChanges
Section2.3.MarkingTexttoDelete,Move,orCopy
Section2.5.EditingTricksandShortcuts
Section2.7.MakingEmacsWorktheWayYouWant
Chapter3.SearchandReplace
Section3.1.DifferentKindsofSearches
Section3.2.SearchandReplace
Section3.3.CheckingSpellingUsingIspell
Section3.4.WordAbbreviations
Chapter4.UsingBuffers,Windows,andFrames
Section4.1.UnderstandingBuffers,Windows,andFrames
Section4.2.WorkingwithMultipleBuffers
Section4.3.WorkingwithWindows
Section4.5.MoreAboutBuffers
Section4.4.WorkingwithFrames
Section4.6.MoreAboutWindows
Section4.7.HoldingYourPlacewithBookmarks
Chapter5.EmacsasaWorkEnvironment
Section5.1.ExecutingCommandsinShellBuffers
Section5.2.UsingDired,theDirectoryEditor
Section5.4.ReadingManpagesinEmacs
Section5.3.PrintingfromEmacs
Section5.5.UsingTimeManagementTools
Chapter6.WritingMacros
Section6.1.DefiningaMacro
Section6.2.TipsforCreatingGoodMacros
Section6.3.AMoreComplicatedMacroExample
Section6.5.TheMacroRing
Section6.4.EditingaMacro
Section6.6.BindingYourMacrotoaKey
Section6.7.Naming,Saving,andExecutingYourMacros
Section6.8.BuildingMoreComplicatedMacros
Section6.9.ExecutingMacrosonaRegion
Section6.10.BeyondMacros
Chapter7.SimpleTextFormattingandSpecializedEditing
Section7.1.UsingTabs
Section7.2.IndentingText
Section7.4.UsingOutlineMode
Section7.3.CenteringText
Section7.5.RectangleEditing
Section7.6.MakingSimpleDrawings
Chapter8.MarkupLanguageSupport
Section8.1.Comments
Section8.2.Font-LockMode
Section8.4.WritingXML
Section8.3.WritingHTML
Section8.5.MarkingupTextforTEXandLATEX
Chapter9.ComputerLanguageSupport
Section9.1.EmacsasanIDE
Section9.2.WritingCode
Section9.3.CandC++Support
Section9.5.TheJavaDevelopmentEnvironmentforEmacs(JDEE)
Section9.7.SQLSupport
Section9.4.JavaSupport
Section9.6.PerlSupport
Section9.8.TheLispModes
Chapter10.CustomizingEmacs
Section10.1.UsingCustom
Section10.2.Modifyingthe.emacsFileDirectly
Section10.3.ModifyingFontsandColors
Section10.5.SettingEmacsVariables
Section10.7.StartingModesviaAuto-ModeCustomization
Section10.4.CustomizingYourKeyBindings
Section10.6.FindingEmacsLispPackages
Section10.8.MakingEmacsWorktheWayYouThinkItShould
Chapter11.EmacsLispProgramming
Section11.1.IntroductiontoLisp
Section11.2.LispPrimitiveFunctions
Section11.3.UsefulBuilt-inEmacsFunctions
Section11.4.BuildinganAutomaticTemplateSystem
Section11.5.ProgrammingaMajorMode
Section11.6.CustomizingExistingModes
Section11.7.BuildingYourOwnLispLibrary
Chapter12.VersionControl
Section12.1.TheUsesofVersionControl
Section12.2.VersionControlConcepts
Section12.4.EditingCommentBuffers
Section12.6.VCModeIndicators
Section12.8.IndividualVCCommands
Section12.10.ExtendingVC
Section12.12.UsingVCEffectively
Section12.3.HowVCHelpswithBasicOperations
Section12.5.VCCommandSummary
Section12.7.WhichVersionControlSystem?
Section12.9.CustomizingVC
Section12.11.WhatVCIsNot
Section12.13.ComparingwithEdiff
Chapter13.Platform-SpecificConsiderations
Section13.1.EmacsandUnix
Section13.2.EmacsandMacOSX
Section13.3.EmacsandWindows
Chapter14.TheHelpSystem
Section14.1.UsingtheTutorial
Section14.2.HelpCommands
Section14.4.NavigatingEmacsDocumentation
Section14.3.HelpwithComplexEmacsCommands
Section14.5.Completion
AppendixA.EmacsVariables
AppendixB.EmacsLispPackages
AppendixC.BugsandBugFixes
AppendixD.OnlineResources
AppendixE.QuickReference
Colophon
Index
Copyright©2005O'ReillyMedia,Inc.Allrightsreserved.
PrintedintheUnitedStatesofAmerica.
PublishedbyO'ReillyMedia,Inc.,1005GravensteinHighway
North,Sebastopol,CA95472.
O'Reillybooksmaybepurchasedforeducational,business,or
salespromotionaluse.Onlineeditionsarealsoavailablefor
mosttitles().Formoreinformation,
contactourcorporate/institutionalsalesdepartment:(800)
998-9938or
NutshellHandbook,theNutshellHandbooklogo,andthe
O'ReillylogoareregisteredtrademarksofO'ReillyMedia,Inc.
LearningGNUEmacs,theimageofthegnu,andrelatedtrade
dressaretrademarksofO'ReillyMedia,Inc.
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarks.Where
thosedesignationsappearinthisbook,andO'ReillyMedia,Inc.
wasawareofatrademarkclaim,thedesignationshavebeen
printedincapsorinitialcaps.
Whileeveryprecautionhasbeentakeninthepreparationofthis
book,thepublisherandauthorsassumenoresponsibilityfor
errorsoromissions,orfordamagesresultingfromtheuseof
theinformationcontainedherein.
Preface
Emacsisthemostpowerfultexteditoravailabletoday.Unlike
mostothereditors(inparticular,unlikethestandardUnix
editor,vi),Emacsisacompleteworkingenvironment.No
matterwhatyoudo,youcanstartEmacsinthemorning,work
alldayandallnight,andneverleaveit:youcanuseittoedit,
rename,delete,andorganizefiles;tocompileprograms;torun
shellcommands;andsoon.BeforewindowingsystemslikeX
andMicrosoftWindowsbecamepopular,Emacsoftenservedas
acompletewindowingsystemofitsown.Allyouneededwasa
terminal,andyoucouldlivewithinEmacsforever.Emacsisalso
infinitelyflexible;youcanwriteyourowncommands,change
thekeysthatareassociatedwithcommands,and(ifyouare
willingtotakethetime)dojustaboutanythingyouwant.
WhyReadThisBook?
Becauseitdoessomuch,Emacshasareputationforbeing
extremelycomplicated.Wedon'tthinkthat'swarranted;we
teachyouEmacsfromthegroundup,coveringfirstthebasics
andthensomeofthemoreadvancedfeatures.
Inthisbook,wehavetriedtoreachasbroadanaudienceas
possible:fromcasualuserstoprofessionalwritersandweb
authorstoprogrammerstosystemadministrators.Nomatter
whatyoudowithEmacs,youwillfindit'seasytolearn;after
oneortwosessions,you'llknowthebasicsofeditinganyfile.
Afteryoulearnthebasics,youcangoontolearnaboutmore
advancedtopicsthatprovidetherealbenefitsofusingEmacs.
Theseinclude:
Usingmultiplewindowsandbufferssoyoucanworkon
severalfilesatonce
Customizingkeyboardcommands
TailoringEmacstofityourworkstyle
MakingEmacsyourworkenvironmentwhereyoucandoall
youreverydaytasks,suchasorganizingfiles,compiling
programs,andissuingshellcommands
Creatingmacrostostreamlinerepetitivetasks
UsingEmacstosupportprogramminginmanylanguages
(includingC,C++,Lisp,Java,andPerl)
Formattingfileswithvariousmarkuplanguages,suchas
HTMLandXML
Usingwordabbreviationstoavoidspellingoutlongphrases
ortocorrectcommonmisspellings
Ofcourse,manyofthetopicsmaynotapplytoyou;some
topicsmaybeappropriateforasecondreadingbutnotforthe
first.Towardtheendofthepreface,we'llsketchseveral
differentwaystoapproachthebook,dependingonyour
interestsandexperience.
WhichEmacsIsWhich?
NumerousversionsofEmacsareavailable,offeringawide
rangeoffeatures,buttwoareinwidespreadusetoday:GNU
EmacsandXEmacs.(AnexhaustivelistofEmacs
implementationscanbefoundat
XEmacswas
originallytailoredforGUIusageandhasafairlywideuserbase,
butlackssomeofthefeaturesofGNUEmacs.[1]
[1]QuiteafewissuescomeupindiscussionsofGNUEmacsversusXEmacs,withcharacter
encodingschemes,userinterfacedifferences,andcopyrightissuesamongthem.We'renot
interestedintakingsidesinthebattlesbetweentheseemacsen.
ThisbookcoversGNUEmacs.Sinceitsappearance,GNUEmacs
hasbecomethemostpopular,powerful,andflexibleEmacs,
andthere'snoreasontobelievethatthissituationwillchange.
IfyouknowGNUEmacs,youwillbeabletoadapttoanyother
Emacsimplementationwithnotrouble;it'snotsoeasytogoin
theotherdirection.
Thisbook,however,isn'tlimitedtoGNUEmacsusers.Because
ofthesimilaritiesbetweendifferentEmacsimplementations,
thisbookshouldhelpyougetstartedwithanyEmacseditor.
Thebasickeyboardcommandschangelittlefromoneeditorto
anotheryou'llfindthatC-n(forCtrl-n)almostalwaysmeans
"movetothenextline."Emacseditorstendtodifferinthe
moreadvancedcommandsandfeatures,butifyouareusing
thesemoreadvancedfacilitiesandyouaren'tusingGNUEmacs,
youshouldconsidermakingtheswitch.
What'sNewinThisEdition?
ThisthirdeditioncoversGNUEmacs21,specifically21.3and
evenmorespecifically21.3.5.[2]Thisneweditionhasbeen
completelyrevisedandexpandedtocovernewfeaturesandto
meettheevolvingneedsofEmacsusers.
[2]Typicallywewouldnotfindtheneedtobequitesospecific,buttheuserinterfacechangedat
Emacs21.3.5;inparticularyou'llnoticedifferenttoolbariconsifyouhaveanearlierversion.
Herearesomeofthehighlightsofwhatwe'vechanged:
Userinterfacechanges,includingtheadditionofaniconbasedtoolbar,extensivechangestomenus,andamore
graphicalinterface(Chapter1)
HowEmacsinteractswiththeoperatingsystemclipboard,
includingspecificclipboard-relatedcommands(Chapter2)
Dynamicabbreviations(Chapter3)
Expandedcoverageofthedirectoryeditor,Dired,tohelp
youorganizeandworkwithfilesmoreefficiently(Chapter
5)
ChangestothewayEmacshandlestabsandindentation
andhowtogetEmacstodowhatyouwantitto(Chapter7)
Artistmodefordrawingwiththemouse(Chapter7)
InsertingcharactersfromothercharactersetsinHTMLfiles
(Chapter8)
Usingfont-lockmodeforcoloringtextforeasierediting
(Chapter9)
ExpandedJavacoverage,includinghowtoinstallanduse
theJavaDevelopmentEnvironmentforEmacs(JDEE)
(Chapter9)
PerlsupportwithCperlmode(Chapter9)
Managingchangestolarge,multiplefileprojectsmore
effectivelyusingetags(Chapter9)
CustomizingEmacsthroughtheinteractiveCustom
interfaceorthroughthe.emacsstartupfile(Chapter10)
Expandedcoverageofhowversioncontrolmodeconnects
withavarietyofchangecontrolsystems,includingCVS,
RCS,Subversion,andSCCS(Chapter12)
Anewchapteronplatform-specificconsiderations,including
detailsonhowtoinstallthelatestversionofEmacsonUnix,
Windows,andMacOSX(Chapter13)
GNUEmacsandtheFreeSoftwareFoundation
Youdon'tneedtoknowitshistorytouseGNUEmacs,butits
originsareaninterestingpartofcomputerhistory.TheFree
SoftwareFoundation(FSF),whichmaintainsanddistributes
GNUEmacs,hasbecomeanimportantpartofcomputerculture.
Alongtimeago(1975)atMIT,RichardStallmanwrotethefirst
Emacseditor.Accordingtothefolklore,theoriginalEmacs
editorwasasetofmacrosforTECO,analmost
incomprehensibleandnowobsoletelineeditor.Thename
Emacsstandsfor"EditingMacros."Traditionalsohasitthat
Emacsisaplayonthenameofafavoriteicecreamstore.Much
hashappenedsince1975.TECOhasslippedintodeserved
obscurity,andEmacshasbeenrewrittenasanindependent
program.SeveralcommercialversionsofEmacsappeared,of
whichUnipressEmacsandCCAEmacswerethemost
important.Forseveralyears,thesecommercial
implementationsweretheEmacseditorsyouweremostlikely
torunacrossoutsideoftheacademicworld.
Stallman'sEmacsbecameprominentwiththebirthoftheFree
SoftwareFoundation(FSF)andtheGNUProjectin1984.GNU
standsfor"GNU'sNotUnix"andreferstoacompleteUnix-like
operatingsystem(OS)thatStallmanandhisassociateswere
building.
StallmanfoundedtheFSFtoguaranteethatsomesoftware
wouldalwaysremainfree.NotethatFreedoesnotnecessarily
meancheap(youmayhavetopayafeetocoverthecostof
distribution);itmostdefinitelydoesmeanliberatedfrom
restrictionsabouthowitcanbeusedandspecificallyhowitcan
beshared.
Stallmaniswidelyrecognizedasthefounderofthefree
softwaremovement,whichwasanimportantpredecessorofthe
opensourcemovement.Linuxisnowthemostprominent
exampleofopensourcesoftware,anditfallsundertheGNU
PublicLicenseorGPL(availableonlineat
Stallmanarguesthat
muchofLinuxoutsidethekernelitselfisGNUsoftwareandso
hereferstoitasGNU/Linux.Allcontroversiesaside,Stallman's
contributiontotheopensourcemovementcannotbe
underestimated.GNUsoftwareandopensourcesoftware
distributedundertheGPLareamainstayfordevelopersand
computerusersallovertheworld.
TheFSFwascreatedpreciselytodistributeprogramsunder
termsthatencourageyoutoshare,ratherthanhoard,
software.TheGPLisdesignedtopreventanunfortunately
commonpracticenamely,acompanytakingpublicdomaincode,
makingafewmodificationsandbugfixes,andthen
copyrightingthemodifiedversion.Onceacompanydoesthis,
theprogramhasessentiallybecomeprivatepropertyand
disappearsfromthepublicdomain.Stallmanformedthe
foundationbecausehefindsthispracticeabhorrent.Ashe
explainsintheGNUManifesto,"Icannotingoodconscience
signanondisclosureagreementorasoftwarelicense
agreement...SothatIcancontinuetousecomputerswithout
dishonor,Ihavedecidedtoputtogetherasufficientbodyof
freesoftwaresothatIwillbeabletogetalongwithoutany
softwarethatisnotfree."Elsewhereinthemanifesto,Stallman
callssharingsoftwarethe"fundamentalactoffriendshipamong
programmers."Theirsoftwareisfreebecauseitcanbeshared
andwillalwaysbeshareablewithoutrestriction.FSFsoftwareis
notunderrestrictivecopyrightlaws,whichStallmanobjectsto
inprinciple.Infact,hecoinedthetermcopylefttodescribethe
FSF'ssharablesoftwarebase.[3]
[3]FSFprogramssuchasEmacsareoftendistributedwithcommercialsystems.Eveninthese
cases,theGeneralPublicLicenseguaranteesyourrighttouseandgiveawaytheirprograms
withoutrestriction.Ofcourse,thelicensedoesnotapplytootherproprietarysoftwarewithwhich
GNUtoolshavebeenshipped.
SinceGNUEmacswasfirstreleased,manyotherpiecesofthe
GNUoperatingenvironmenthavefallenintoplace:CandC++
compilers(gccandg++),averypowerfuldebugger(gdb),
substitutesforlexandyacc(calledflexandbison,
respectively),aUnixshell(bash,whichstandsfor"BourneAgainShell"),theGimp(agraphicstoolcomparabletoAdobe
PhotoShop),GNOME(adesktopenvironmentforLinux),and
manyotherprogramsandlibraries.Manyimportantopen
sourceprojectsthatoriginallyusedvariantsoftheGPLorother
licensingschemeshaveadoptedtheGPLastheirlicense,
includingPython,Mozilla,andZope.AuthorDavidWheeler
arguesthatallopensourceprojectsshouldreleasetheir
softwareunderaGPL-compatiblelicense[4](see
forhis
viewsandsomestatisticsaboutGPL'dsoftware).WithLinux,
GNUtools,andotherGPL'dsoftware,it'spossibletohavea
completeoperatingenvironmentconsistentwiththevaluesset
forthbytheFSF.
[4]GPL-compatibleisacriticaldistinctionformanyorganizations.AsourreviewerMikeTrent
pointsout,manyorganizationsreleasetheirsoftwareunderamodifiedGPLbecausetheGPL's
licenseisactually"viral."Thatis,ifonelineofGPL'dcodeappearsinaproject,theentireproject
mustbeGPL'd.Thismeanscorporationsinterestedinprotectingtheirassetsbutstillwantingto
sharecodewiththeopensourcecommunitycannotusetheGPLwithoutsomemodification.
AnApproachtoLearningEmacs
ThisbookisdesignedtogetyoustartedwithEmacsasquickly
aspossible,whetheryouareanexperiencedcomputeruserora
novice.Thefirsttwochaptersgiveyouthebasicsyouneedto
know,andtherestofthebookbuildsonthesebasics.Afterthe
firsttwochapters,youdon'thavetoreadtherest
consecutively;youcanskiptothetopicsthatinterestyou.
Additionally,thebookisdesignedtogiveyoujustthelevelof
hand-holdingyouwant;youcaneitherreadthebookindetail
orskimit,lookingfortablesofcommandsandexamples.
Herearesomereadingpathsyoucouldtake:
If
Read
Youareacasualuser
Preface,Chapter1-Chapter3,Chapter14
Youareaprogrammerorsystem
administrator
Preface,Chapter1-Chapter5,Chapter9Chapter12
Youareawriterorproductionperson
Preface,Chapter1-Chapter3,Chapter7,
Chapter8,Chapter14
YouwanttocustomizeEmacs
Chapter10andpossiblyChapter11
YouwriteHTMLorXML
Preface,Chapter1-Chapter3,Chapter8
Youwanttouseoperatingsystem
commandsinEmacs
Chapter5
YouuseEmacsonWindowsorMacOSX Chapter13
Thesereadingpathsareofferedonlyasaguideline.Emacsis
onegigantic,functionallyricheditor.We'vedivideditupinto
digestiblebitesforyou,soyoudon'thavetobeputoffbyits
sizeandscope.ThebestwaytolearnEmacsisincrementally;
learnalittlenow,thenlearnmorefeaturesasyougetcurious
aboutthem.Ifyouneedtodosomethinganddon'tknowhow
todoitinEmacs,Emacsprobablyalreadydoesit;ifitdoesn't,
youcanlearnhowtowriteaLispfunctiontoaddittoEmacs
(seeChapter11fordetails).Theonlinehelpsystemisan
excellentplacetolearnaboutnewfeaturesonthefly;online
helpisdiscussedinChapter1andinmoredetailinChapter14.
Here'salistofsomefeaturesyoumightwanttolearnabouton
arainyday:
HowtousemultipleEmacsbuffers,windows,andframes
(Chapter4)
Wordabbreviationmode(Chapter3)
Macros(Chapter6)
HowtomapfunctionkeystoEmacscommands(Chapter
10)
Howtoissue(andedit)shellcommands(Chapter5)
HowtoorganizefilesinEmacs(Chapter5)
Usingedifftocomparefiles(Chapter12)
Here'saquicksummaryofwhat'sineachchapter:
Chapter1,EmacsBasics,tellsyouhowtostartEmacsandhow
toworkwithfiles.Italsoprovidesaquickintroductiontothe
onlinehelpsystem.
Chapter2,Editing,explainscommandsformovingaround,
copyingandpastingtext,andundoingchanges.Italso
introducesverybasiccustomization.
Chapter3,SearchandReplace,coversmoreeditingfeatures,
includingsearchandreplace,wordabbreviationmode,andspell
checking.
Chapter4,UsingBuffers,Windows,andFrames,describeshow
tousemultiplebuffersandwindows,bothEmacs-stylewindows
(thatdivideasingleOSwindow)andtraditionalOSwindows
(whichEmacsreferstoasframes).Italsodiscusseshowto
bookmarkyourplaceinlargefiles.
Chapter5,EmacsasaWorkEnvironment,talksaboutissuing
commandsfromwithinEmacs,workingwithfilesand
directories,andusingbasictimemanagementtoolssuchasthe
calendaranddiary.
Chapter6,WritingMacros,discussesusingmacrostoeliminate
repetitivetasks.
Chapter7,SimpleTextFormattingandSpecializedEditing,
coversbasictextformatting(suchastabs,indentation,and
centering)aswellassomeofthemorerarefiedfeatures,like
outlinemodeandrectangleediting.
Chapter8,MarkupLanguageSupport,describesEmacssupport
forHTML,XML,TEX,andLATEX..
Chapter9,ComputerLanguageSupport,coversEmacsasa
programmingenvironment,includingeditingsupportforC,
Java,Lisp,Perl,andSQL,aswellastheinterfacetocompilers
andtheUnixmakeutility.ItalsodescribestheJava
DevelopmentEnvironmentforEmacs(JDEE).
Chapter10,CustomizingEmacs,describesEmacs's
customizationfacilities.TheinteractiveCustomtoolallowsyou
tochangevariableswithouteditingyourstartupfile.The
chapteralsoexplainshowtosetupyour.emacscustomization
file.Itdescribeshowtomodifyyourdisplay,keyboard
commands,andeditingenvironmentaswellashowtoloadLisp
packagesforextrafunctionality.
Chapter11,EmacsLispProgramming,describesthebasicsof
EmacsLisp,thelanguageyoucanusetofurthercustomize
Emacs.
Chapter12,VersionControl,describesVCmodeforversion
controlanditsinterfacetoCVS,RCS,Subversion,andSCCS.
Chapter13,Platform-SpecificConsiderations,discusseshowto
installEmacsonUnix,Windows,andMacOSX.Italsoprovides
platform-specificinformationforWindowsandMacOSX.
Chapter14,TheHelpSystem,describesEmacs'srich,
comprehensiveonlinehelpfacilities.
AppendixA,EmacsVariables,listsmanyimportantEmacs
variables,includingallthevariablesmentionedinthisbook.
AppendixB,EmacsLispPackages,listssomeofthemostuseful
LisppackagesthatcomewithEmacs.
AppendixC,BugsandBugFixes,tellsyouhow(andwhen)to
reportbugsyoufindinEmacs.Italsodescribeshowto
contributetotheGNUProject,whetherthroughcode
enhancementsormonetarily.
AppendixD,OnlineResources,givesatourofsomeimportant
Emacs-relatedwebsites.
AppendixE,QuickReference,providesbriefdescriptionsofthe
mostimportantEmacscommandsdiscussedinthisbook.
ThebookconcludeswithaglossarythatdefinesEmacsterms
you'llencounter,anindex,andadetachablequickreference
cardthatsummarizesimportantcommandsforeasyaccess.
WhatWeHaven'tIncluded
GNUEmacsisalargeandpowerfuleditor;inthisbook,wegive
youonlyasampleofwhatitdoes.Manyfeatureshavebeenleft
out,andmorefeaturesareaddedallthetime.Sometopics,
however,arenotcovered:
Compatibilitymodes
GNUEmacsprovidescompatibilitymodesforvi,for
example.We'veleftadiscussionofthesemodesout.Ifyou
reallywanttousevioranothereditor,doso.You'rebetter
offgettingtoknowEmacsonitsowntermsratherthan
pretendingitissomethingelse.
Manyprogramminglanguagemodes
Inthisbook,wediscusseditingmodesforC++,Java,Lisp,
Perl,andSQL.Therearemanymodesforotherlanguages,
includingrarelanguageslikeScheme.There'snowaywe
coulddiscusseverything.
AdvancedLispprogramming
GNUEmacsincorporatesacompleteLispinterpreter.We
giveaverybasicandbriefintroductiontoEmacsLisp;
Chapter11shouldbeenoughtogetyoustarted,butit
reallyonlyscratchesthesurface.WerecommendtheFSF's
EmacsLispReferenceManual,nowincludedintheEmacs
distribution.
UsingEmacstoaccesstheInternet
Whenourlasteditioncameout,itwascommontouse
EmacstoaccessInternetresourcesorreademail.Nowthat
isn'tsocommon;bettermailers,browsers,andothertools
arecommonlyinuseonallplatforms.
Unicodesupport
Atpresent,EmacsisonitswaytofullUnicodesupport;that
isthemostimportantchangeslatedforthenextmajor
release.Atthiswriting,Unicodesupportisspotty.
Gamesandamusements
GNUEmacsincludesaneclecticbunchofgamesand
amusements,includingtheabilitytopiperandom
quotationsfromZippythePinheadintothefamous"Eliza"
pseudopsychoanalyst.Emacs21includesaGamesmenu
underToolswithseveralcoolwaystowastetimeinEmacs
(anditdoesn'tevenincludeEmacs'sversionofpong,oneof
ourfavorites).Alas,wehadtodrawthelinesomewhere.
TheMetaKey
Emacscommandsconsistofamodifier,suchasControl,which
youholddownasyouwouldtheShiftkey,andaseriesof
keystrokes.Forexample,Control-xControl-ssavesafile.
TheothermodifierEmacsusesistheMetakey.Fewkeyboards
havekeyslabeledMeta.Becauseofthis,inpreviouseditionsof
thisbook,werefusedtotalkabouttheMetakeyand
substitutedEscinallourinstructions.
Inthisedition,wewantyoutolearnwheretheMetakeyis.
TypicallyMetakeysaretotheimmediateleftandrightofthe
Spacebar.OnLinuxandWindowskeyboards,theAltkeyisthe
Metakey.OnMackeyboards,theApplekey,oftencalled
CommandistheMetakeybydefault.
WhylearnaboutandusetheMetakey?Thereasonisspeed.
Weemphasizekeybindingsinthisbook.Newusersmayfind
iconsandmenushelpful,butinthelongrun,learninghowto
keepyourhandsonthekeyboardallowsyoutogainspeedand
boostsyourproductivity.TheMetakeywillhelpyougainthat
speedandmakeiteasyforyoutouseEmacshelp,whichrefers
toMeta.
Dependingonyourstyle,youmaystillprefertouseEscinstead
ofMeta.JustbearinmindthatwithEscyoupressandrelease
thekey,thenpressthenextkey.
ConventionsUsedinThisBook
Thissectioncoverstheconventionsusedinthisbook.
KeystrokeNotation
Emacscommandsconsistofamodifier,suchasCtrlorMeta,
followedbyoneortwocharacters.Commandsshowninthis
bookabbreviateCtrltoCandMetatoM:
C-g
HolddowntheCtrlkeyandpressg.
M-x
HolddowntheMetakeyandpressx.
SometimesMetaisfollowedbyaliteralhyphencharacter.In
thesecases,wespelloutMeta:
MetaHolddowntheMetakeyandpress-.
TocompleteacommandyoumayneedtopressEnter.(This
keymaybelabeledReturn.)
Enter
PresstheEnterkey.
Esc
CanbeusedasanalternativetoMeta.PressEsc,release
it,thenpressthenextkey.
AfewmousecommandsusetheShiftkeyasamodifier,often
incombinationwiththeCtrlkey.Thisisabbreviatedas:
S-right
HolddownShiftandclicktherightmousebutton.
C-S-right
HolddownShiftandCtrlandclicktherightmousebutton.
AllEmacscommands,eventhesimplestones,haveafull
name;forexample,forward-wordisequivalenttothe
keystrokesM-f,andforward-charisequivalenttoC-f.This
tyingofacommandtoakeystrokecombinationiscalledakey
binding.Somecommandshaveonlyfullnames,withno
correspondingkeybinding.
Whenwediscussacommand,we'llgivebothitsfullnameand
thekeystrokes(ifany)thatyoucantypetoinvokeit.
CommandTables