faq.texi 153 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441
  1. \input texinfo @c -*- mode: texinfo; -*-
  2. @c %**start of header
  3. @setfilename ../../info/efaq
  4. @settitle GNU Emacs FAQ
  5. @c %**end of header
  6. @include emacsver.texi
  7. @c This file is maintained by Romain Francoise <rfrancoise@gnu.org>.
  8. @c Feel free to install changes without prior permission (but I'd
  9. @c appreciate a notice if you do).
  10. @copying
  11. Copyright @copyright{} 2001-2012 Free Software Foundation, Inc.@*
  12. Copyright @copyright{} 1994, 1995, 1996, 1997, 1998, 1999, 2000
  13. Reuven M. Lerner@*
  14. Copyright @copyright{} 1992, 1993 Steven Byrnes@*
  15. Copyright @copyright{} 1990, 1991, 1992 Joseph Brian Wells@*
  16. @quotation
  17. This list of frequently asked questions about GNU Emacs with answers
  18. (``FAQ'') may be translated into other languages, transformed into other
  19. formats (e.g. Texinfo, Info, WWW, WAIS), and updated with new information.
  20. The same conditions apply to any derivative of the FAQ as apply to the FAQ
  21. itself. Every copy of the FAQ must include this notice or an approved
  22. translation, information on who is currently maintaining the FAQ and how to
  23. contact them (including their e-mail address), and information on where the
  24. latest version of the FAQ is archived (including FTP information).
  25. The FAQ may be copied and redistributed under these conditions, except that
  26. the FAQ may not be embedded in a larger literary work unless that work
  27. itself allows free copying and redistribution.
  28. [This version has been heavily edited since it was included in the Emacs
  29. distribution.]
  30. @end quotation
  31. @end copying
  32. @dircategory Emacs
  33. @direntry
  34. * Emacs FAQ: (efaq). Frequently Asked Questions about Emacs.
  35. @end direntry
  36. @c The @titlepage stuff only appears in the printed version
  37. @titlepage
  38. @sp 10
  39. @center @titlefont{GNU Emacs FAQ}
  40. @c The following two commands start the copyright page.
  41. @page
  42. @vskip 0pt plus 1filll
  43. @insertcopying
  44. @end titlepage
  45. @contents
  46. @node Top, FAQ notation, (dir), (dir)
  47. @top The GNU Emacs FAQ
  48. @c FIXME @today is just the day we ran `makeinfo'.
  49. This is the GNU Emacs FAQ, last updated on @today{}.
  50. This FAQ is maintained as a part of GNU Emacs. If you find any errors,
  51. or have any suggestions, please use @kbd{M-x report-emacs-bug} to report
  52. them.
  53. This is the version of the FAQ distributed with Emacs @value{EMACSVER}, and
  54. mainly describes that version. Although there is some information on
  55. older versions, details about very old releases (now only of historical
  56. interest) have been removed. If you are interested in this, consult
  57. either the version of the FAQ distributed with older versions of Emacs,
  58. or the history of this document in the Emacs source repository.
  59. Since Emacs releases are very stable, we recommend always running the
  60. latest release.
  61. This FAQ is not updated very frequently. When you have a question about
  62. Emacs, the Emacs manual is often the best starting point.
  63. @ifnottex
  64. @insertcopying
  65. @end ifnottex
  66. @menu
  67. * FAQ notation::
  68. * General questions::
  69. * Getting help::
  70. * Status of Emacs::
  71. * Common requests::
  72. * Bugs and problems::
  73. * Compiling and installing Emacs::
  74. * Finding Emacs and related packages::
  75. * Key bindings::
  76. * Alternate character sets::
  77. * Mail and news::
  78. * Concept index::
  79. @end menu
  80. @c ------------------------------------------------------------
  81. @node FAQ notation
  82. @chapter FAQ notation
  83. @cindex FAQ notation
  84. This chapter describes notation used in the GNU Emacs FAQ, as well as in
  85. the Emacs documentation. Consult this section if this is the first time
  86. you are reading the FAQ, or if you are confused by notation or terms
  87. used in the FAQ.
  88. @menu
  89. * Basic keys::
  90. * Extended commands::
  91. * Emacs manual::
  92. * File-name conventions::
  93. * Common acronyms::
  94. @end menu
  95. @node Basic keys
  96. @section What do these mean: @kbd{C-h}, @kbd{C-M-a}, @key{RET}, @kbd{@key{ESC} a}, etc.?
  97. @cindex Basic keys
  98. @cindex Control key, notation for
  99. @cindex @key{Meta} key, notation for
  100. @cindex Control-Meta characters, notation for
  101. @cindex @kbd{C-h}, definition of
  102. @cindex @kbd{C-M-h}, definition of
  103. @cindex @key{DEL}, definition of
  104. @cindex @key{ESC}, definition of
  105. @cindex @key{LFD}, definition of
  106. @cindex @key{RET}, definition of
  107. @cindex @key{SPC}, definition of
  108. @cindex @key{TAB}, definition of
  109. @cindex Notation for keys
  110. @itemize @bullet
  111. @item
  112. @kbd{C-x}: press the @key{x} key while holding down the @key{Control} key
  113. @item
  114. @kbd{M-x}: press the @key{x} key while holding down the @key{Meta} key
  115. (if your computer doesn't have a @key{Meta} key, @pxref{No Meta key})
  116. @item
  117. @kbd{M-C-x}: press the @key{x} key while holding down both @key{Control}
  118. and @key{Meta}
  119. @item
  120. @kbd{C-M-x}: a synonym for the above
  121. @item
  122. @key{LFD}: Linefeed or Newline; same as @kbd{C-j}
  123. @item
  124. @key{RET}: @key{Return}, sometimes marked @key{Enter}; same as @kbd{C-m}
  125. @item
  126. @key{DEL}: @key{Delete}, usually @strong{not} the same as
  127. @key{Backspace}; same as @kbd{C-?} (see @ref{Backspace invokes help}, if
  128. deleting invokes Emacs help)
  129. @item
  130. @key{ESC}: Escape; same as @kbd{C-[}
  131. @item
  132. @key{TAB}: Tab; same as @kbd{C-i}
  133. @item
  134. @key{SPC}: Space bar
  135. @end itemize
  136. Key sequences longer than one key (and some single-key sequences) are
  137. written inside quotes or on lines by themselves, like this:
  138. @display
  139. @kbd{M-x frobnicate-while-foo RET}
  140. @end display
  141. @noindent
  142. Any real spaces in such a key sequence should be ignored; only @key{SPC}
  143. really means press the space key.
  144. The @acronym{ASCII} code sent by @kbd{C-x} (except for @kbd{C-?}) is the value
  145. that would be sent by pressing just @key{x} minus 96 (or 64 for
  146. upper-case @key{X}) and will be from 0 to 31. On Unix and GNU/Linux
  147. terminals, the @acronym{ASCII} code sent by @kbd{M-x} is the sum of 128 and the
  148. @acronym{ASCII} code that would be sent by pressing just @key{x}. Essentially,
  149. @key{Control} turns off bits 5 and 6 and @key{Meta} turns on bit
  150. 7@footnote{
  151. DOS and Windows terminals don't set bit 7 when the @key{Meta} key is
  152. pressed.}.
  153. @kbd{C-?} (aka @key{DEL}) is @acronym{ASCII} code 127. It is a misnomer to call
  154. @kbd{C-?} a ``control'' key, since 127 has both bits 5 and 6 turned ON.
  155. Also, on very few keyboards does @kbd{C-?} generate @acronym{ASCII} code 127.
  156. @c FIXME I cannot understand the previous sentence.
  157. @xref{Keys,,, emacs, The GNU Emacs Manual}.
  158. @node Extended commands
  159. @section What does @file{M-x @var{command}} mean?
  160. @cindex Extended commands
  161. @cindex Commands, extended
  162. @cindex M-x, meaning of
  163. @kbd{M-x @var{command}} means type @kbd{M-x}, then type the name of the
  164. command, then type @key{RET}. (@xref{Basic keys}, if you're not sure
  165. what @kbd{M-x} and @key{RET} mean.)
  166. @kbd{M-x} (by default) invokes the command
  167. @code{execute-extended-command}. This command allows you to run any
  168. Emacs command if you can remember the command's name. If you can't
  169. remember the command's name, you can type @key{TAB} and @key{SPC} for
  170. completion, @key{?} for a list of possibilities, and @kbd{M-p} and
  171. @kbd{M-n} (or up-arrow and down-arrow) to see previous commands entered.
  172. An Emacs @dfn{command} is an @dfn{interactive} Emacs function.
  173. @cindex @key{Do} key
  174. Your system administrator may have bound other key sequences to invoke
  175. @code{execute-extended-command}. A function key labeled @kbd{Do} is a
  176. good candidate for this, on keyboards that have such a key.
  177. If you need to run non-interactive Emacs functions, see @ref{Evaluating
  178. Emacs Lisp code}.
  179. @node Emacs manual
  180. @section How do I read topic XXX in the Emacs manual?
  181. @cindex Emacs manual, reading topics in
  182. @cindex Reading topics in the Emacs manual
  183. @cindex Finding topics in the Emacs manual
  184. @cindex Info, finding topics in
  185. When we refer you to some @var{topic} in the Emacs manual, you can
  186. read this manual node inside Emacs (assuming nothing is broken) by
  187. typing @kbd{C-h i m emacs @key{RET} m @var{topic} @key{RET}}.
  188. This invokes Info, the GNU hypertext documentation browser. If you don't
  189. already know how to use Info, type @key{?} from within Info.
  190. If we refer to @var{topic}:@var{subtopic}, type @kbd{C-h i m emacs
  191. @key{RET} m @var{topic} @key{RET} m @var{subtopic} @key{RET}}.
  192. If these commands don't work as expected, your system administrator may
  193. not have installed the Info files, or may have installed them
  194. improperly. In this case you should complain.
  195. If you are reading this FAQ in Info, you can simply press @key{RET} on a
  196. reference to follow it.
  197. @xref{Getting a printed manual}, if you would like a paper copy of the
  198. Emacs manual.
  199. @node File-name conventions
  200. @section What are @file{src/config.h}, @file{site-lisp/default.el}, etc.?
  201. @cindex File-name conventions
  202. @cindex Conventions for file names
  203. @cindex Directories and files that come with Emacs
  204. These are files that come with Emacs. The Emacs distribution is divided
  205. into subdirectories; e.g. @file{etc}, @file{lisp}, and @file{src}.
  206. Some of these (e.g. @file{etc} and @file{lisp}) are present both in
  207. an installed Emacs and in the sources, but some (e.g. @file{src}) are
  208. only found in the sources.
  209. If you use Emacs, but don't know where it is kept on your system, start
  210. Emacs, then type @kbd{C-h v data-directory @key{RET}}. The directory
  211. name displayed by this will be the full pathname of the installed
  212. @file{etc} directory. (This full path is recorded in the Emacs variable
  213. @code{data-directory}, and @kbd{C-h v} displays the value and the
  214. documentation of a variable.)
  215. The location of your Info directory (i.e., where Info documentation
  216. is stored) is kept in the variable @code{Info-default-directory-list}. Use
  217. @kbd{C-h v Info-default-directory-list @key{RET}} to see the value of
  218. this variable, which will be a list of directory names. The last
  219. directory in that list is probably where most Info files are stored. By
  220. default, Emacs Info documentation is placed in @file{/usr/local/share/info}.
  221. For information on some of the files in the @file{etc} directory,
  222. @pxref{Informational files for Emacs}.
  223. @node Common acronyms
  224. @section What are FSF, LPF, GNU, RMS, FTP, and GPL?
  225. @cindex FSF, definition of
  226. @cindex LPF, definition of
  227. @cindex GNU, definition of
  228. @cindex RMS, definition of
  229. @cindex Stallman, Richard, acronym for
  230. @cindex Richard Stallman, acronym for
  231. @cindex FTP, definition of
  232. @cindex GPL, definition of
  233. @cindex Acronyms, definitions for
  234. @cindex Common acronyms, definitions for
  235. @table @asis
  236. @item FSF
  237. Free Software Foundation
  238. @item LPF
  239. League for Programming Freedom
  240. @item GNU
  241. GNU's Not Unix
  242. @item RMS
  243. Richard Matthew Stallman
  244. @item FTP
  245. File Transfer Protocol
  246. @item GPL
  247. GNU General Public License
  248. @end table
  249. Avoid confusing the FSF and the LPF. The LPF opposes
  250. look-and-feel copyrights and software patents. The FSF aims to make
  251. high quality free software available for everyone.
  252. The word ``free'' in the title of the Free Software Foundation refers to
  253. ``freedom,'' not ``zero cost.'' Anyone can charge any price for
  254. GPL-covered software that they want to. However, in practice, the
  255. freedom enforced by the GPL leads to low prices, because you can always
  256. get the software for less money from someone else, since everyone has
  257. the right to resell or give away GPL-covered software.
  258. @c ------------------------------------------------------------
  259. @node General questions
  260. @chapter General questions
  261. @cindex General questions
  262. This chapter contains general questions having to do with Emacs, the
  263. Free Software Foundation, and related organizations.
  264. @menu
  265. * The LPF::
  266. * Real meaning of copyleft::
  267. * Guidelines for newsgroup postings::
  268. * Newsgroup archives::
  269. * Reporting bugs::
  270. * Unsubscribing from Emacs lists::
  271. * Contacting the FSF::
  272. @end menu
  273. @node The LPF
  274. @section What is the LPF?
  275. @cindex LPF, description of
  276. @cindex League for Programming Freedom
  277. @cindex Software patents, opposition to
  278. @cindex Patents for software, opposition to
  279. The LPF opposes the expanding danger of software patents and
  280. look-and-feel copyrights. More information on the LPF's views is
  281. available at @uref{http://progfree.org/, the LPF home page}.
  282. @node Real meaning of copyleft
  283. @section What is the real legal meaning of the GNU copyleft?
  284. @cindex Copyleft, real meaning of
  285. @cindex GPL, real meaning of
  286. @cindex General Public License, real meaning of
  287. @cindex Discussion of the GPL
  288. The real legal meaning of the GNU General Public License (copyleft) will
  289. only be known if and when a judge rules on its validity and scope.
  290. There has never been a copyright infringement case involving the GPL to
  291. set any precedents. Although legal actions have been brought against
  292. companies for violating the terms of the GPL, so far all have been
  293. settled out of court (in favor of the plaintiffs). Please take any
  294. discussion regarding this issue to the newsgroup
  295. @uref{news:gnu.misc.discuss}, which was created to hold the extensive
  296. flame wars on the subject.
  297. RMS writes:
  298. @quotation
  299. The legal meaning of the GNU copyleft is less important than the spirit,
  300. which is that Emacs is a free software project and that work pertaining
  301. to Emacs should also be free software. ``Free'' means that all users
  302. have the freedom to study, share, change and improve Emacs. To make
  303. sure everyone has this freedom, pass along source code when you
  304. distribute any version of Emacs or a related program, and give the
  305. recipients the same freedom that you enjoyed.
  306. @end quotation
  307. @node Guidelines for newsgroup postings
  308. @section What are appropriate messages for the various Emacs newsgroups?
  309. @cindex Newsgroups, appropriate messages for
  310. @cindex GNU newsgroups, appropriate messages for
  311. @cindex Usenet groups, appropriate messages for
  312. @cindex Mailing lists, appropriate messages for
  313. @cindex Posting messages to newsgroups
  314. @cindex GNU mailing lists
  315. The file @file{etc/MAILINGLISTS} describes the purpose of each GNU
  316. mailing list (@pxref{Informational files for Emacs}). For those lists
  317. which are gatewayed with newsgroups, it lists both the newsgroup name
  318. and the mailing list address. The Emacs mailing lists are also
  319. described at @uref{http://savannah.gnu.org/mail/?group=emacs, the Emacs
  320. Savannah page}.
  321. The newsgroup @uref{news:comp.emacs} is for discussion of Emacs programs
  322. in general. The newsgroup @uref{news:gnu.emacs.help} is specifically
  323. for GNU Emacs. It therefore makes no sense to cross-post to both
  324. groups, since only one can be appropriate to any question.
  325. Messages advocating ``non-free'' software are considered unacceptable on
  326. any of the @code{gnu.*} newsgroups except for @uref{news:gnu.misc.discuss},
  327. which was created to hold the extensive flame-wars on the subject.
  328. ``Non-free'' software includes any software for which the end user can't
  329. freely modify the source code and exchange enhancements. Be careful to
  330. remove the @code{gnu.*} groups from the @samp{Newsgroups:} line when
  331. posting a followup that recommends such software.
  332. @uref{news:gnu.emacs.bug} is a place where bug reports appear, but avoid
  333. posting bug reports to this newsgroup directly (@pxref{Reporting bugs}).
  334. @node Newsgroup archives
  335. @section Where can I get old postings to @uref{news:gnu.emacs.help} and other GNU groups?
  336. @cindex Archived postings from @code{gnu.emacs.help}
  337. @cindex Usenet archives for GNU groups
  338. @cindex Old Usenet postings for GNU groups
  339. The FSF has maintained archives of all of the GNU mailing lists for many
  340. years, although there may be some unintentional gaps in coverage. The
  341. archive can be browsed over the web at
  342. @uref{http://lists.gnu.org/archive/html/, the GNU mail archive}. Raw
  343. files can be downloaded from @uref{ftp://lists.gnu.org/}.
  344. Web-based Usenet search services, such as
  345. @uref{http://groups.google.com/groups/dir?q=gnu&, Google}, also
  346. archive the @code{gnu.*} groups.
  347. You can also read the archives of the @code{gnu.*} groups and post new
  348. messages at @uref{http://gmane.org/, Gmane}. Gmane is a service that
  349. presents mailing lists as newsgroups (even those without a traditional
  350. mail-to-news gateway).
  351. @node Reporting bugs
  352. @section Where should I report bugs and other problems with Emacs?
  353. @cindex Bug reporting
  354. @cindex Good bug reports
  355. @cindex How to submit a bug report
  356. @cindex Reporting bugs
  357. The correct way to report Emacs bugs is to use the command
  358. @kbd{M-x report-emacs-bug}. It sets up a mail buffer with the
  359. essential information and the correct e-mail address, which is
  360. @email{bug-gnu-emacs@@gnu.org} for the released versions of Emacs.
  361. Anything sent to @email{bug-gnu-emacs@@gnu.org} also appears in the
  362. newsgroup @uref{news:gnu.emacs.bug}, but please use e-mail instead of
  363. news to submit the bug report. This ensures a reliable return address
  364. so you can be contacted for further details.
  365. Be sure to read the ``Bugs'' section of the Emacs manual before reporting
  366. a bug! The manual describes in detail how to submit a useful bug
  367. report (@pxref{Bugs, , Reporting Bugs, emacs, The GNU Emacs Manual}).
  368. (@xref{Emacs manual}, if you don't know how to read the manual.)
  369. RMS says:
  370. @quotation
  371. Sending bug reports to @email{help-gnu-emacs@@gnu.org} (which has the
  372. effect of posting on @uref{news:gnu.emacs.help}) is undesirable because
  373. it takes the time of an unnecessarily large group of people, most of
  374. whom are just users and have no idea how to fix these problem.
  375. @email{bug-gnu-emacs@@gnu.org} reaches a much smaller group of people
  376. who are more likely to know what to do and have expressed a wish to
  377. receive more messages about Emacs than the others.
  378. @end quotation
  379. RMS says it is sometimes fine to post to @uref{news:gnu.emacs.help}:
  380. @quotation
  381. If you have reported a bug and you don't hear about a possible fix,
  382. then after a suitable delay (such as a week) it is okay to post on
  383. @code{gnu.emacs.help} asking if anyone can help you.
  384. @end quotation
  385. If you are unsure whether you have found a bug, consider the following
  386. non-exhaustive list, courtesy of RMS:
  387. @quotation
  388. If Emacs crashes, that is a bug. If Emacs gets compilation errors
  389. while building, that is a bug. If Emacs crashes while building, that
  390. is a bug. If Lisp code does not do what the documentation says it
  391. does, that is a bug.
  392. @end quotation
  393. @node Unsubscribing from Emacs lists
  394. @section How do I unsubscribe from a mailing list?
  395. @cindex Unsubscribing from GNU mailing lists
  396. @cindex Removing yourself from GNU mailing lists
  397. If you are receiving a GNU mailing list named @var{list}, you should be
  398. able to unsubscribe from it by sending a request to the address
  399. @email{@var{list}-request@@gnu.org}. Mailing lists mails normally
  400. contain information in either the message header
  401. (@samp{List-Unsubscribe:}) or as a footer that tells you how to
  402. unsubscribe.
  403. @node Contacting the FSF
  404. @section How do I contact the FSF?
  405. @cindex Contracting the FSF
  406. @cindex Free Software Foundation, contacting
  407. For up-to-date information, see
  408. @uref{http://www.fsf.org/about/contact.html, the FSF contact web-page}.
  409. You can send general correspondence to @email{info@@fsf.org}.
  410. @cindex Ordering GNU software
  411. For details on how to order items directly from the FSF, see the
  412. @uref{http://shop.fsf.org/, FSF on-line store}.
  413. @c ------------------------------------------------------------
  414. @node Getting help
  415. @chapter Getting help
  416. @cindex Getting help
  417. This chapter tells you how to get help with Emacs.
  418. @menu
  419. * Basic editing::
  420. * Learning how to do something::
  421. * Getting a printed manual::
  422. * Emacs Lisp documentation::
  423. * Installing Texinfo documentation::
  424. * Printing a Texinfo file::
  425. * Viewing Info files outside of Emacs::
  426. * Informational files for Emacs::
  427. * Help installing Emacs::
  428. * Obtaining the FAQ::
  429. @end menu
  430. @node Basic editing
  431. @section I'm just starting Emacs; how do I do basic editing?
  432. @cindex Basic editing with Emacs
  433. @cindex Beginning editing
  434. @cindex Tutorial, invoking the
  435. @cindex Self-paced tutorial, invoking the
  436. @cindex Help system, entering the
  437. Type @kbd{C-h t} to invoke the self-paced tutorial. Just typing
  438. @kbd{C-h} enters the help system. Starting with Emacs 22, the tutorial
  439. is available in many foreign languages such as French, German, Japanese,
  440. Russian, etc. Use @kbd{M-x help-with-tutorial-spec-language @key{RET}}
  441. to choose your language and start the tutorial.
  442. Your system administrator may have changed @kbd{C-h} to act like
  443. @key{DEL} to deal with local keyboards. You can use @kbd{M-x
  444. help-for-help} instead to invoke help. To discover what key (if any)
  445. invokes help on your system, type @kbd{M-x where-is @key{RET}
  446. help-for-help @key{RET}}. This will print a comma-separated list of key
  447. sequences in the echo area. Ignore the last character in each key
  448. sequence listed. Each of the resulting key sequences (e.g. @key{F1} is
  449. common) invokes help.
  450. Emacs help works best if it is invoked by a single key whose value
  451. should be stored in the variable @code{help-char}.
  452. @node Learning how to do something
  453. @section How do I find out how to do something in Emacs?
  454. @cindex Help for Emacs
  455. @cindex Learning to do something in Emacs
  456. @cindex Reference card for Emacs
  457. @cindex Overview of help systems
  458. There are several methods for finding out how to do things in Emacs.
  459. @itemize @bullet
  460. @cindex Reading the Emacs manual
  461. @item
  462. The complete text of the Emacs manual is available via the Info
  463. hypertext reader. Type @kbd{C-h r} to display the manual in Info mode.
  464. Typing @key{h} immediately after entering Info will provide a short
  465. tutorial on how to use it.
  466. @cindex Lookup a subject in a manual
  467. @cindex Index search in a manual
  468. @item
  469. To quickly locate the section of the manual which discusses a certain
  470. issue, or describes a command or a variable, type @kbd{C-h i m emacs
  471. @key{RET} i @var{topic} @key{RET}}, where @var{topic} is the name of the
  472. topic, the command, or the variable which you are looking for. If this
  473. does not land you on the right place in the manual, press @kbd{,}
  474. (comma) repeatedly until you find what you need. (The @kbd{i} and
  475. @kbd{,} keys invoke the index-searching functions, which look for the
  476. @var{topic} you type in all the indices of the Emacs manual.)
  477. @cindex Apropos
  478. @item
  479. You can list all of the commands whose names contain a certain word
  480. (actually which match a regular expression) using @kbd{C-h a} (@kbd{M-x
  481. command-apropos}).
  482. @cindex Command description in the manual
  483. @item
  484. The command @kbd{C-h F} (@code{Info-goto-emacs-command-node}) prompts
  485. for the name of a command, and then attempts to find the section in the
  486. Emacs manual where that command is described.
  487. @cindex Finding commands and variables
  488. @item
  489. You can list all of the functions and variables whose names contain a
  490. certain word using @kbd{M-x apropos}.
  491. @item
  492. You can list all of the functions and variables whose documentation
  493. matches a regular expression or a string, using @kbd{M-x
  494. apropos-documentation}.
  495. @item
  496. You can order a hardcopy of the manual from the FSF. @xref{Getting a
  497. printed manual}.
  498. @cindex Reference cards, in other languages
  499. @item
  500. You can get a printed reference card listing commands and keys to
  501. invoke them. You can order one from the FSF for $2 (or 10 for $18),
  502. or you can print your own from the @file{etc/refcards/refcard.tex} or
  503. @file{etc/refcards/refcard.pdf} files in the Emacs distribution.
  504. Beginning with version 21.1, the Emacs distribution comes with
  505. translations of the reference card into several languages; look for
  506. files named @file{etc/refcards/@var{lang}-refcard.*}, where @var{lang}
  507. is a two-letter code of the language. For example, the German version
  508. of the reference card is in the files @file{etc/refcards/de-refcard.tex}
  509. and @file{etc/refcards/de-refcard.pdf}.
  510. @item
  511. There are many other commands in Emacs for getting help and
  512. information. To get a list of these commands, type @samp{?} after
  513. @kbd{C-h}.
  514. @end itemize
  515. @node Getting a printed manual
  516. @section How do I get a printed copy of the Emacs manual?
  517. @cindex Printed Emacs manual, obtaining
  518. @cindex Manual, obtaining a printed or HTML copy of
  519. @cindex Emacs manual, obtaining a printed or HTML copy of
  520. You can order a printed copy of the Emacs manual from the FSF. For
  521. details see the @uref{http://shop.fsf.org/, FSF on-line store}.
  522. The full Texinfo source for the manual also comes in the @file{doc/emacs}
  523. directory of the Emacs distribution, if you're daring enough to try to
  524. print out this several-hundred-page manual yourself (@pxref{Printing a Texinfo
  525. file}).
  526. If you absolutely have to print your own copy, and you don't have @TeX{},
  527. you can get a PostScript or PDF (or HTML) version from
  528. @uref{http://www.gnu.org/software/emacs/manual/}
  529. @xref{Learning how to do something}, for how to view the manual from Emacs.
  530. @node Emacs Lisp documentation
  531. @section Where can I get documentation on Emacs Lisp?
  532. @cindex Documentation on Emacs Lisp
  533. @cindex Function documentation
  534. @cindex Variable documentation
  535. @cindex Emacs Lisp Reference Manual
  536. @cindex Reference manual for Emacs Lisp
  537. Within Emacs, you can type @kbd{C-h f} to get the documentation for a
  538. function, @kbd{C-h v} for a variable.
  539. For more information, the Emacs Lisp Reference Manual is available
  540. in Info format (@pxref{Top, Emacs Lisp,, elisp, The
  541. Emacs Lisp Reference Manual}).
  542. You can also order a hardcopy of the manual from the FSF, for details
  543. see the @uref{http://shop.fsf.org/, FSF on-line store}. (This manual is
  544. not always in print.)
  545. An HTML version of the Emacs Lisp Reference Manual is available at
  546. @uref{http://www.gnu.org/software/emacs/elisp-manual/elisp.html}
  547. @node Installing Texinfo documentation
  548. @section How do I install a piece of Texinfo documentation?
  549. @cindex Texinfo documentation, installing
  550. @cindex Installing Texinfo documentation
  551. @cindex New Texinfo files, installing
  552. @cindex Documentation, installing new Texinfo files
  553. @cindex Info files, how to install
  554. Emacs releases come with pre-built Info files, and the normal install
  555. process places them in the correct location. This is true for most
  556. applications that provide Info files. The following section is only
  557. relevant if you want to install extra Info files by hand.
  558. First, you must turn the Texinfo source files into Info files. You may
  559. do this using the stand-alone @file{makeinfo} program, available as part
  560. of the Texinfo package at
  561. @uref{http://www.gnu.org/software/texinfo/}
  562. For information about the Texinfo format, read the Texinfo manual which
  563. comes with the Texinfo package. This manual also comes installed in
  564. Info format, so you can read it from Emacs; type @kbd{C-h i m texinfo
  565. @key{RET}}.
  566. @c FIXME is this a complete alternative?
  567. @c Probably not, given that we require makeinfo to build Emacs.
  568. Alternatively, you could use the Emacs command @kbd{M-x
  569. texinfo-format-buffer}, after visiting the Texinfo source file of the
  570. manual you want to convert.
  571. Neither @code{texinfo-format-buffer} nor @file{makeinfo} installs the
  572. resulting Info files in Emacs's Info tree. To install Info files,
  573. perform these steps:
  574. @enumerate
  575. @item
  576. Move the files to the @file{info} directory in the installed Emacs
  577. distribution. @xref{File-name conventions}, if you don't know where that
  578. is.
  579. @item
  580. Run the @code{install-info} command, which is part of the Texinfo
  581. distribution, to update the main Info directory menu, like this:
  582. @example
  583. install-info --info-dir=@var{dir-path} @var{dir-path}/@var{file}
  584. @end example
  585. @noindent
  586. where @var{dir-path} is the full path to the directory where you copied
  587. the produced Info file(s), and @var{file} is the name of the Info file
  588. you produced and want to install.
  589. If you don't have the @code{install-info} command installed, you can
  590. edit the file @file{info/dir} in the installed Emacs distribution, and
  591. add a line for the top level node in the Info package that you are
  592. installing. Follow the examples already in this file. The format is:
  593. @example
  594. * Topic: (relative-pathname). Short description of topic.
  595. @end example
  596. @end enumerate
  597. If you want to install Info files and you don't have the necessary
  598. privileges, you have several options:
  599. @itemize @bullet
  600. @item
  601. Info files don't actually need to be installed before being used.
  602. You can use a prefix argument for the @code{info} command and specify
  603. the name of the Info file in the minibuffer. This goes to the node
  604. named @samp{Top} in that file. For example, to view a Info file named
  605. @file{@var{info-file}} in your home directory, you can type this:
  606. @example
  607. @kbd{C-u C-h i ~/@var{info-file} @key{RET}}
  608. @end example
  609. Alternatively, you can feed a file name to the @code{Info-goto-node}
  610. command (invoked by pressing @key{g} in Info mode) by typing the name
  611. of the file in parentheses, like this:
  612. @example
  613. @kbd{C-h i g (~/@var{info-file}) @key{RET}}
  614. @end example
  615. @item
  616. You can create your own Info directory. You can tell Emacs where that
  617. Info directory is by adding its pathname to the value of the variable
  618. @code{Info-default-directory-list}. For example, to use a private Info
  619. directory which is a subdirectory of your home directory named @file{Info},
  620. you could put this in your @file{.emacs} file:
  621. @lisp
  622. (add-to-list 'Info-default-directory-list "~/Info")
  623. @end lisp
  624. You will need a top-level Info file named @file{dir} in this directory
  625. which has everything the system @file{dir} file has in it, except it
  626. should list only entries for Info files in that directory. You might
  627. not need it if (fortuitously) all files in this directory were
  628. referenced by other @file{dir} files. The node lists from all
  629. @file{dir} files in @code{Info-default-directory-list} are merged by the
  630. Info system.
  631. @end itemize
  632. @node Printing a Texinfo file
  633. @section How do I print a Texinfo file?
  634. @cindex Printing a Texinfo file
  635. @cindex Texinfo file, printing
  636. @cindex Printing documentation
  637. You can't get nicely printed output from Info files; you must still have
  638. the original Texinfo source file for the manual you want to print.
  639. Assuming you have @TeX{} installed on your system, follow these steps:
  640. @enumerate
  641. @item
  642. Make sure the first line of the Texinfo file looks like this:
  643. @example
  644. \input texinfo
  645. @end example
  646. You may need to change @samp{texinfo} to the full pathname of the
  647. @file{texinfo.tex} file, which comes with Emacs as
  648. @file{doc/misc/texinfo.tex} (or copy or link it into the current directory).
  649. @item
  650. Type @kbd{texi2dvi @var{texinfo-source}}, where @var{texinfo-source} is
  651. the name of the Texinfo source file for which you want to produce a
  652. printed copy. The @samp{texi2dvi} script is part of the GNU Texinfo
  653. distribution.
  654. Alternatively, @samp{texi2pdf} produces PDF files.
  655. @item
  656. Print the DVI file @file{@var{texinfo-source}.dvi} in the normal way for
  657. printing DVI files at your site. For example, if you have a PostScript
  658. printer, run the @code{dvips} program to print the DVI file on that
  659. printer.
  660. @end enumerate
  661. To get more general instructions, retrieve the latest Texinfo package
  662. (@pxref{Installing Texinfo documentation}).
  663. @node Viewing Info files outside of Emacs
  664. @section Can I view Info files without using Emacs?
  665. @cindex Viewing Info files
  666. @cindex Info file viewers
  667. @cindex Alternative Info file viewers
  668. Yes. Here are some alternative programs:
  669. @itemize @bullet
  670. @item
  671. @code{info}, a stand-alone version of the Info program, comes as part of
  672. the Texinfo package. @xref{Installing Texinfo documentation}, for
  673. details.
  674. @item
  675. Tkinfo, an Info viewer that runs under X Window system and uses Tcl/Tk.
  676. You can get Tkinfo at
  677. @uref{http://math-www.uni-paderborn.de/~axel/tkinfo/}.
  678. @end itemize
  679. @node Informational files for Emacs
  680. @section What informational files are available for Emacs?
  681. @cindex Informational files included with Emacs
  682. @cindex Files included with Emacs
  683. @cindex @file{COPYING}, description of file
  684. @cindex @file{DISTRIB}, description of file
  685. @cindex @file{GNU}, description of file
  686. @cindex @file{INTERVIEW}, description of file
  687. @cindex @file{MACHINES}, description of file
  688. @cindex @file{MAILINGLISTS}, description of file
  689. @cindex @file{NEWS}, description of file
  690. This isn't a frequently asked question, but it should be! A variety of
  691. informational files about Emacs and relevant aspects of the GNU project
  692. are available for you to read.
  693. The following files (and others) are available in the @file{etc}
  694. directory of the Emacs distribution (see @ref{File-name conventions}, if
  695. you're not sure where that is). Many of these files are available via
  696. the Emacs @samp{Help} menu, or by typing @kbd{C-h ?} (@kbd{M-x
  697. help-for-help}).
  698. @table @file
  699. @item COPYING
  700. GNU General Public License
  701. @item DISTRIB
  702. Emacs Availability Information
  703. @item GNU
  704. The GNU Manifesto
  705. @item INTERVIEW
  706. Richard Stallman discusses his public-domain UNIX-compatible software
  707. system with BYTE editors
  708. @item MACHINES
  709. Status of Emacs on Various Machines and Systems
  710. @item MAILINGLISTS
  711. GNU Project Electronic Mailing Lists
  712. @item NEWS
  713. Emacs news, a history of recent user-visible changes
  714. @end table
  715. More GNU information, including back issues of the @cite{GNU's
  716. Bulletin}, are at
  717. @uref{http://www.gnu.org/bulletins/bulletins.html} and
  718. @uref{http://www.cs.pdx.edu/~trent/gnu/gnu.html}
  719. @node Help installing Emacs
  720. @section Where can I get help in installing Emacs?
  721. @cindex Installation help
  722. @cindex Help installing Emacs
  723. @xref{Installing Emacs}, for some basic installation hints, and see
  724. @ref{Problems building Emacs}, if you have problems with the installation.
  725. @uref{http://www.fsf.org/resources/service/, The GNU Service directory}
  726. lists companies and individuals willing to sell you help in installing
  727. or using Emacs and other GNU software.
  728. @node Obtaining the FAQ
  729. @section Where can I get the latest version of this FAQ?
  730. @cindex FAQ, obtaining the
  731. @cindex Latest FAQ version, obtaining the
  732. The Emacs FAQ is distributed with Emacs in Info format. You can read it
  733. by selecting the @samp{Emacs FAQ} option from the @samp{Help} menu of
  734. the Emacs menu bar at the top of any Emacs frame, or by typing @kbd{C-h
  735. C-f} (@kbd{M-x view-emacs-FAQ}). The very latest version is available
  736. in the Emacs development repository (@pxref{Latest version of Emacs}).
  737. @c ------------------------------------------------------------
  738. @node Status of Emacs
  739. @chapter Status of Emacs
  740. @cindex Status of Emacs
  741. This chapter gives you basic information about Emacs, including the
  742. status of its latest version.
  743. @menu
  744. * Origin of the term Emacs::
  745. * Latest version of Emacs::
  746. * New in Emacs 24::
  747. * New in Emacs 23::
  748. * New in Emacs 22::
  749. * New in Emacs 21::
  750. * New in Emacs 20::
  751. @end menu
  752. @node Origin of the term Emacs
  753. @section Where does the name ``Emacs'' come from?
  754. @cindex Origin of the term ``Emacs''
  755. @cindex Emacs name origin
  756. @cindex TECO
  757. @cindex Original version of Emacs
  758. Emacs originally was an acronym for Editor MACroS. RMS says he ``picked
  759. the name Emacs because @key{E} was not in use as an abbreviation on ITS at
  760. the time.'' The first Emacs was a set of macros written in 1976 at MIT
  761. by RMS for the editor TECO (Text Editor and COrrector, originally Tape
  762. Editor and COrrector) under ITS (the Incompatible Timesharing System) on
  763. a PDP-10. RMS had already extended TECO with a ``real-time''
  764. full-screen mode with reprogrammable keys. Emacs was started by
  765. @email{gls@@east.sun.com, Guy Steele} as a project to unify the many
  766. divergent TECO command sets and key bindings at MIT, and completed by
  767. RMS.
  768. Many people have said that TECO code looks a lot like line noise; you
  769. can read more at @uref{news:alt.lang.teco}. Someone has written a TECO
  770. implementation in Emacs Lisp (to find it, see @ref{Packages that do not
  771. come with Emacs}); it would be an interesting project to run the
  772. original TECO Emacs inside of Emacs.
  773. @cindex Why Emacs?
  774. For some not-so-serious alternative reasons for Emacs to have that
  775. name, check out the file @file{etc/JOKES} (@pxref{File-name
  776. conventions}).
  777. @node Latest version of Emacs
  778. @section What is the latest version of Emacs?
  779. @cindex Version, latest
  780. @cindex Latest version of Emacs
  781. @cindex Development, Emacs
  782. @cindex Repository, Emacs
  783. @cindex Bazaar repository, Emacs
  784. Emacs @value{EMACSVER} is the current version as of this writing. A version
  785. number with two components (e.g. @samp{22.1}) indicates a released
  786. version; three components indicate a development
  787. version (e.g. @samp{23.0.50} is what will eventually become @samp{23.1}).
  788. Emacs is under active development, hosted at
  789. @uref{http://savannah.gnu.org/projects/emacs/, Savannah}. The source
  790. code can be retrieved anonymously following the
  791. @uref{http://savannah.gnu.org/bzr/?group=emacs, instructions}.
  792. The repository is GNU Bazaar.
  793. Because Emacs undergoes many changes before a release, the version
  794. number of a development version is not especially meaningful. It is
  795. better to refer to the date on which the sources were retrieved from the
  796. development repository. The development version is usually quite robust
  797. for every-day use, but if stability is more important to you than the
  798. latest features, you may want to stick to the releases.
  799. The following sections list some of the major new features in the last
  800. few Emacs releases. For full details of the changes in any version of
  801. Emacs, type @kbd{C-h C-n} (@kbd{M-x view-emacs-news}). As of Emacs 22,
  802. you can give this command a prefix argument to read about which features
  803. were new in older versions.
  804. @node New in Emacs 24
  805. @section What is different about Emacs 24?
  806. @cindex Differences between Emacs 23 and Emacs 24
  807. @cindex Emacs 24, new features in
  808. @itemize
  809. @cindex packages, installing more
  810. @item
  811. Emacs now includes a package manager. Type @kbd{M-x list-packages} to
  812. get started. You can use this to download and automatically install
  813. many more Lisp packages.
  814. @cindex lexical binding
  815. @item
  816. Emacs Lisp now supports lexical binding on a per-file basis. In
  817. @emph{lexical binding}, variable references must be located textually
  818. within the binding construct. This contrasts with @emph{dynamic
  819. binding}, where programs can refer to variables defined outside their
  820. local textual scope. A Lisp file can use a local variable setting of
  821. @code{lexical-binding: t} to indicate that the contents should be
  822. interpreted using lexical binding. See the Emacs Lisp Reference
  823. Manual for more details.
  824. @cindex bidirectional display
  825. @cindex right-to-left languages
  826. @item
  827. Some human languages, such as English, are written from left to right.
  828. Others, such as Arabic, are written from right to left. Emacs now has
  829. support for any mixture of these forms---this is ``bidirectional text''.
  830. @item
  831. Handling of text selections has been improved, and now integrates
  832. better with external clipboards.
  833. @cindex themes
  834. @item
  835. A new command @kbd{customize-themes} allows you to easily change the
  836. appearance of your Emacs.
  837. @item
  838. Emacs can be compiled with the GTK+ 3 toolkit.
  839. @item
  840. Support for several new external libraries can be included at compile
  841. time:
  842. @itemize
  843. @item
  844. ``Security-Enhanced Linux'' (SELinux) is a Linux kernel feature that
  845. provides more sophisticated file access controls than ordinary
  846. ``Unix-style'' file permissions.
  847. @item
  848. The ImageMagick display library. This allows you to display many more
  849. image format in Emacs, as well as carry out transformations such as
  850. rotations.
  851. @item
  852. The GnuTLS library for secure network communications. Emacs uses this
  853. transparently for email if your mail server supports it.
  854. @item
  855. The libxml2 library for parsing XML structures.
  856. @end itemize
  857. @item
  858. Much more flexibility in the handling of windows and buffer display.
  859. @end itemize
  860. As always, consult the @file{NEWS} file for more information.
  861. @node New in Emacs 23
  862. @section What is different about Emacs 23?
  863. @cindex Differences between Emacs 22 and Emacs 23
  864. @cindex Emacs 23, new features in
  865. @itemize
  866. @cindex Anti-aliased fonts
  867. @cindex Freetype fonts
  868. @item
  869. Emacs has a new font code that can use multiple font backends,
  870. including freetype and fontconfig. Emacs can use the Xft library for
  871. anti-aliasing, and the otf and m17n libraries for complex text layout and
  872. text shaping.
  873. @cindex Unicode
  874. @cindex Character sets
  875. @item
  876. The Emacs character set is now a superset of Unicode. Several new
  877. language environments have been added.
  878. @cindex Multi-tty support
  879. @cindex X and tty displays
  880. @item
  881. Emacs now supports using both X displays and ttys in the same session
  882. (@samp{multi-tty}).
  883. @cindex Daemon mode
  884. @item
  885. Emacs can be started as a daemon in the background.
  886. @cindex NeXTstep port
  887. @cindex GNUstep port
  888. @cindex Mac OS X Cocoa
  889. @item
  890. There is a new NeXTstep port of Emacs. This supports GNUstep and Mac OS
  891. X (via the Cocoa libraries). The Carbon port of Emacs, which supported
  892. Mac OS X in Emacs 22, has been removed.
  893. @cindex Directory-local variables
  894. @item
  895. Directory-local variables can now be defined, in a similar manner to
  896. file-local variables.
  897. @item
  898. Transient Mark mode (@pxref{Highlighting a region}) is on by default.
  899. @end itemize
  900. @noindent
  901. Other changes include: support for serial port access; D-Bus bindings; a
  902. new Visual Line mode for line-motion; improved completion; a new mode
  903. (@samp{DocView}) for viewing of PDF, PostScript, and DVI documents; nXML
  904. mode (for editing XML documents) is included; VC has been updated for
  905. newer version control systems; etc.
  906. @node New in Emacs 22
  907. @section What is different about Emacs 22?
  908. @cindex Differences between Emacs 21 and Emacs 22
  909. @cindex Emacs 22, new features in
  910. @itemize
  911. @cindex GTK+ Toolkit
  912. @cindex Drag-and-drop
  913. @item
  914. Emacs can be built with GTK+ widgets, and supports drag-and-drop
  915. operation on X.
  916. @cindex Supported systems
  917. @item
  918. Emacs 22 features support for GNU/Linux systems on S390 and x86-64
  919. machines, as well as support for the Mac OS X and Cygwin operating
  920. systems.
  921. @item
  922. The native MS-Windows, and Mac OS X builds include full support
  923. for images, toolbar, and tooltips.
  924. @item
  925. Font Lock mode, Auto Compression mode, and File Name Shadow Mode are
  926. enabled by default.
  927. @item
  928. The maximum size of buffers is increased: on 32-bit machines, it is
  929. 256 MBytes for Emacs 23.1, and 512 MBytes for Emacs 23.2 and above.
  930. @item
  931. Links can be followed with @kbd{mouse-1}, in addition to @kbd{mouse-2}.
  932. @cindex Mouse wheel
  933. @item
  934. Mouse wheel support is enabled by default.
  935. @item
  936. Window fringes are customizable.
  937. @item
  938. The mode line of the selected window is now highlighted.
  939. @item
  940. The minibuffer prompt is displayed in a distinct face.
  941. @item
  942. Abbrev definitions are read automatically at startup.
  943. @item
  944. Grep mode is separate from Compilation mode and has many new options and
  945. commands specific to grep.
  946. @item
  947. The original Emacs macro system has been replaced by the new Kmacro
  948. package, which provides many new commands and features and a simple
  949. interface that uses the function keys F3 and F4. Macros are stored in a
  950. macro ring, and can be debugged and edited interactively.
  951. @item
  952. The Grand Unified Debugger (GUD) can be used with a full graphical user
  953. interface to GDB; this provides many features found in traditional
  954. development environments, making it easy to manipulate breakpoints, add
  955. watch points, display the call stack, etc. Breakpoints are visually
  956. indicated in the source buffer.
  957. @item
  958. @cindex New modes
  959. Many new modes and packages have been included in Emacs, such as Calc,
  960. TRAMP, URL, IDO, CUA, ERC, rcirc, Table, Image-Dired, SES, Ruler, Org,
  961. PGG, Flymake, Password, Printing, Reveal, wdired, t-mouse, longlines,
  962. savehist, Conf mode, Python mode, DNS mode, etc.
  963. @cindex Multilingual Environment
  964. @item
  965. Leim is now part of Emacs. Unicode support has been much improved, and
  966. the following input methods have been added: belarusian, bulgarian-bds,
  967. bulgarian-phonetic, chinese-sisheng, croatian, dutch, georgian,
  968. latin-alt-postfix, latin-postfix, latin-prefix, latvian-keyboard,
  969. lithuanian-numeric, lithuanian-keyboard, malayalam-inscript, rfc1345,
  970. russian-computer, sgml, slovenian, tamil-inscript, ucs,
  971. ukrainian-computer, vietnamese-telex, and welsh.
  972. The following language environments have also been added: Belarusian,
  973. Bulgarian, Chinese-EUC-TW, Croatian, French, Georgian, Italian, Latin-6,
  974. Latin-7, Latvian, Lithuanian, Malayalam, Russian, Slovenian, Swedish,
  975. Tajik, Tamil, UTF-8, Ukrainian, Welsh, and Windows-1255.
  976. @cindex Documentation
  977. @cindex Emacs Lisp Manual
  978. @item
  979. In addition, Emacs 22 now includes the Emacs Lisp Reference Manual
  980. (@pxref{Emacs Lisp documentation}) and the Emacs Lisp Intro.
  981. @end itemize
  982. @node New in Emacs 21
  983. @section What is different about Emacs 21?
  984. @cindex Differences between Emacs 20 and Emacs 21
  985. @cindex Emacs 21, new features in
  986. @cindex Variable-size fonts
  987. @cindex Toolbar support
  988. Emacs 21 features a thorough rewrite of the display engine. The new
  989. display engine supports variable-size fonts, images, and can play sounds
  990. on platforms which support that. As a result, the visual appearance of
  991. Emacs, when it runs on a windowed display, is much more reminiscent of
  992. modern GUI programs, and includes 3D widgets (used for the mode line and
  993. the scroll bars), a configurable and extensible toolbar, tooltips
  994. (a.k.a.@: balloon help), and other niceties.
  995. @cindex Colors on text-only terminals
  996. @cindex TTY colors
  997. In addition, Emacs 21 supports faces on text-only terminals. This means
  998. that you can now have colors when you run Emacs on a GNU/Linux console
  999. and on @code{xterm} with @kbd{emacs -nw}.
  1000. @node New in Emacs 20
  1001. @section What is different about Emacs 20?
  1002. @cindex Differences between Emacs 19 and Emacs 20
  1003. @cindex Emacs 20, new features in
  1004. The differences between Emacs versions 18 and 19 were rather dramatic;
  1005. the introduction of frames, faces, and colors on windowing systems was
  1006. obvious to even the most casual user.
  1007. There are differences between Emacs versions 19 and 20 as well, but many
  1008. are more subtle or harder to find. Among the changes are the inclusion
  1009. of MULE code for languages that use non-Latin characters and for mixing
  1010. several languages in the same document; the ``Customize'' facility for
  1011. modifying variables without having to use Lisp; and automatic conversion
  1012. of files from Macintosh, Microsoft, and Unix platforms.
  1013. @c ------------------------------------------------------------
  1014. @node Common requests
  1015. @chapter Common requests
  1016. @cindex Common requests
  1017. @menu
  1018. * Setting up a customization file::
  1019. * Using Customize::
  1020. * Colors on a TTY::
  1021. * Debugging a customization file::
  1022. * Displaying the current line or column::
  1023. * Displaying the current file name in the titlebar::
  1024. * Turning on abbrevs by default::
  1025. * Associating modes with files::
  1026. * Highlighting a region::
  1027. * Replacing highlighted text::
  1028. * Controlling case sensitivity::
  1029. * Working with unprintable characters::
  1030. * Searching for/replacing newlines::
  1031. * Yanking text in isearch::
  1032. * Wrapping words automatically::
  1033. * Turning on auto-fill by default::
  1034. * Changing load-path::
  1035. * Using an already running Emacs process::
  1036. * Compiler error messages::
  1037. * Indenting switch statements::
  1038. * Customizing C and C++ indentation::
  1039. * Horizontal scrolling::
  1040. * Overwrite mode::
  1041. * Turning off beeping::
  1042. * Turning the volume down::
  1043. * Automatic indentation::
  1044. * Matching parentheses::
  1045. * Hiding #ifdef lines::
  1046. * Repeating commands::
  1047. * Valid X resources::
  1048. * Evaluating Emacs Lisp code::
  1049. * Changing the length of a Tab::
  1050. * Inserting text at the beginning of each line::
  1051. * Forcing the cursor to remain in the same column::
  1052. * Forcing Emacs to iconify itself::
  1053. * Using regular expressions::
  1054. * Replacing text across multiple files::
  1055. * Documentation for etags::
  1056. * Disabling backups::
  1057. * Disabling auto-save-mode::
  1058. * Going to a line by number::
  1059. * Modifying pull-down menus::
  1060. * Deleting menus and menu options::
  1061. * Turning on syntax highlighting::
  1062. * Scrolling only one line::
  1063. * Editing MS-DOS files::
  1064. * Filling paragraphs with a single space::
  1065. * Escape sequences in shell output::
  1066. * Fullscreen mode on MS-Windows::
  1067. @end menu
  1068. @node Setting up a customization file
  1069. @section How do I set up a @file{.emacs} file properly?
  1070. @cindex @file{.emacs} file, setting up
  1071. @cindex @file{.emacs} file, locating
  1072. @cindex Init file, setting up
  1073. @cindex Customization file, setting up
  1074. @xref{Init File,,, emacs, The GNU Emacs Manual}.
  1075. In general, new Emacs users should not be provided with @file{.emacs}
  1076. files, because this can cause confusing non-standard behavior. Then
  1077. they send questions to @email{help-gnu-emacs@@gnu.org} asking why Emacs
  1078. isn't behaving as documented.
  1079. Emacs includes the Customize facility (@pxref{Using Customize}). This
  1080. allows users who are unfamiliar with Emacs Lisp to modify their
  1081. @file{.emacs} files in a relatively straightforward way, using menus
  1082. rather than Lisp code.
  1083. While Customize might indeed make it easier to configure Emacs,
  1084. consider taking a bit of time to learn Emacs Lisp and modifying your
  1085. @file{.emacs} directly. Simple configuration options are described
  1086. rather completely in @ref{Init File,,, emacs, The GNU Emacs Manual},
  1087. for users interested in performing frequently requested, basic tasks.
  1088. Sometimes users are unsure as to where their @file{.emacs} file should
  1089. be found. Visiting the file as @file{~/.emacs} from Emacs will find
  1090. the correct file.
  1091. @node Using Customize
  1092. @section How do I start using Customize?
  1093. @cindex Customize groups
  1094. @cindex Customizing variables
  1095. @cindex Customizing faces
  1096. The main Customize entry point is @kbd{M-x customize @key{RET}}. This
  1097. command takes you to a buffer listing all the available Customize
  1098. groups. From there, you can access all customizable options and faces,
  1099. change their values, and save your changes to your init file.
  1100. @xref{Easy Customization,,, emacs, The GNU Emacs Manual}.
  1101. If you know the name of the group in advance (e.g. ``shell''), use
  1102. @kbd{M-x customize-group @key{RET}}.
  1103. If you wish to customize a single option, use @kbd{M-x customize-option
  1104. @key{RET}}. This command prompts you for the name of the option to
  1105. customize, with completion.
  1106. @node Colors on a TTY
  1107. @section How do I get colors and syntax highlighting on a TTY?
  1108. @cindex Colors on a TTY
  1109. @cindex Syntax highlighting on a TTY
  1110. @cindex Console, colors
  1111. In Emacs 21.1 and later, colors and faces are supported in non-windowed mode,
  1112. i.e.@: on Unix and GNU/Linux text-only terminals and consoles, and when
  1113. invoked as @samp{emacs -nw} on X, and MS-Windows. (Colors and faces were
  1114. supported in the MS-DOS port since Emacs 19.29.) Emacs automatically
  1115. detects color support at startup and uses it if available. If you think
  1116. that your terminal supports colors, but Emacs won't use them, check the
  1117. @code{termcap} entry for your display type for color-related
  1118. capabilities.
  1119. The command @kbd{M-x list-colors-display} pops up a window which
  1120. exhibits all the colors Emacs knows about on the current display.
  1121. Syntax highlighting is on by default since version 22.1.
  1122. @node Debugging a customization file
  1123. @section How do I debug a @file{.emacs} file?
  1124. @cindex Debugging @file{.emacs} file
  1125. @cindex @file{.emacs} debugging
  1126. @cindex Init file debugging
  1127. @cindex @samp{-debug-init} option
  1128. Start Emacs with the @samp{-debug-init} command-line option. This
  1129. enables the Emacs Lisp debugger before evaluating your @file{.emacs}
  1130. file, and places you in the debugger if something goes wrong. The top
  1131. line in the @file{trace-back} buffer will be the error message, and the
  1132. second or third line of that buffer will display the Lisp code from your
  1133. @file{.emacs} file that caused the problem.
  1134. You can also evaluate an individual function or argument to a function
  1135. in your @file{.emacs} file by moving the cursor to the end of the
  1136. function or argument and typing @kbd{C-x C-e} (@kbd{M-x
  1137. eval-last-sexp}).
  1138. Use @kbd{C-h v} (@kbd{M-x describe-variable}) to check the value of
  1139. variables which you are trying to set or use.
  1140. @node Displaying the current line or column
  1141. @section How do I make Emacs display the current line (or column) number?
  1142. @cindex @code{line-number-mode}
  1143. @cindex Displaying the current line or column
  1144. @cindex Line number, displaying the current
  1145. @cindex Column, displaying the current
  1146. @cindex @code{mode-line-format}
  1147. By default, Emacs displays the current line number of the point in the
  1148. mode line. You can toggle this feature off or on with the command
  1149. @kbd{M-x line-number-mode}, or by setting the variable
  1150. @code{line-number-mode}. Note that Emacs will not display the line
  1151. number if the buffer's size in bytes is larger than the value of the
  1152. variable @code{line-number-display-limit}.
  1153. You can similarly display the current column with
  1154. @kbd{M-x column-number-mode}, or by putting the form
  1155. @lisp
  1156. (setq column-number-mode t)
  1157. @end lisp
  1158. @noindent
  1159. in your @file{.emacs} file. This feature is off by default.
  1160. The @code{"%c"} format specifier in the variable @code{mode-line-format}
  1161. will insert the current column's value into the mode line. See the
  1162. documentation for @code{mode-line-format} (using @kbd{C-h v
  1163. mode-line-format @key{RET}}) for more information on how to set and use
  1164. this variable.
  1165. @cindex Set number capability in @code{vi} emulators
  1166. The @samp{linum} package (distributed with Emacs since version 23.1)
  1167. displays line numbers in the left margin, like the ``set number''
  1168. capability of @code{vi}. The packages @samp{setnu} and
  1169. @samp{wb-line-number} (not distributed with Emacs) also implement this
  1170. feature.
  1171. @node Displaying the current file name in the titlebar
  1172. @section How can I modify the titlebar to contain the current file name?
  1173. @cindex Titlebar, displaying the current file name in
  1174. @cindex File name, displaying in the titlebar
  1175. @cindex @code{frame-title-format}
  1176. The contents of an Emacs frame's titlebar is controlled by the variable
  1177. @code{frame-title-format}, which has the same structure as the variable
  1178. @code{mode-line-format}. (Use @kbd{C-h v} or @kbd{M-x
  1179. describe-variable} to get information about one or both of these
  1180. variables.)
  1181. By default, the titlebar for a frame does contain the name of the buffer
  1182. currently being visited, except if there is a single frame. In such a
  1183. case, the titlebar contains Emacs invocation name and the name of the
  1184. machine at which Emacs was invoked. This is done by setting
  1185. @code{frame-title-format} to the default value of
  1186. @lisp
  1187. (multiple-frames "%b" ("" invocation-name "@@" system-name))
  1188. @end lisp
  1189. To modify the behavior such that frame titlebars contain the buffer's
  1190. name regardless of the number of existing frames, include the following
  1191. in your @file{.emacs}:
  1192. @lisp
  1193. (setq frame-title-format "%b")
  1194. @end lisp
  1195. @node Turning on abbrevs by default
  1196. @section How do I turn on abbrevs by default just in mode @var{mymode}?
  1197. @cindex Abbrevs, turning on by default
  1198. Abbrev mode expands abbreviations as you type them. To turn it on in a
  1199. specific buffer, use @kbd{M-x abbrev-mode}. To turn it on in every
  1200. buffer by default, put this in your @file{.emacs} file:
  1201. @lisp
  1202. (setq-default abbrev-mode t)
  1203. @end lisp
  1204. @noindent To turn it on in a specific mode, use:
  1205. @lisp
  1206. (add-hook '@var{mymode}-mode-hook
  1207. (lambda ()
  1208. (setq abbrev-mode t)))
  1209. @end lisp
  1210. @noindent If your Emacs version is older then 22.1, you will also need to use:
  1211. @lisp
  1212. (condition-case ()
  1213. (quietly-read-abbrev-file)
  1214. (file-error nil))
  1215. @end lisp
  1216. @node Associating modes with files
  1217. @section How do I make Emacs use a certain major mode for certain files?
  1218. @cindex Associating modes with files
  1219. @cindex File extensions and modes
  1220. @cindex @code{auto-mode-alist}, modifying
  1221. @cindex Modes, associating with file extensions
  1222. If you want to use a certain mode @var{foo} for all files whose names end
  1223. with the extension @file{.@var{bar}}, this will do it for you:
  1224. @lisp
  1225. (add-to-list 'auto-mode-alist '("\\.@var{bar}\\'" . @var{foo}-mode))
  1226. @end lisp
  1227. Alternatively, put this somewhere in the first line of any file you want to
  1228. edit in the mode @var{foo} (in the second line, if the first line begins
  1229. with @samp{#!}):
  1230. @example
  1231. -*- @var{foo} -*-
  1232. @end example
  1233. @cindex Major mode for shell scripts
  1234. The variable @code{interpreter-mode-alist} specifies which mode to use
  1235. when loading an interpreted script (e.g. shell, python, etc.). Emacs
  1236. determines which interpreter you're using by examining the first line of
  1237. the script. Use @kbd{C-h v} (or @kbd{M-x describe-variable}) on
  1238. @code{interpreter-mode-alist} to learn more.
  1239. @node Highlighting a region
  1240. @section How can I highlight a region of text in Emacs?
  1241. @cindex Highlighting text
  1242. @cindex Text, highlighting
  1243. @cindex @code{transient-mark-mode}
  1244. @cindex Region, highlighting a
  1245. You can cause the region to be highlighted when the mark is active by
  1246. including
  1247. @lisp
  1248. (transient-mark-mode 1)
  1249. @end lisp
  1250. @noindent
  1251. in your @file{.emacs} file. Since Emacs 23.1, this feature is on by default.
  1252. @node Replacing highlighted text
  1253. @section How can I replace highlighted text with what I type?
  1254. @cindex @code{delete-selection-mode}
  1255. @cindex Replacing highlighted text
  1256. @cindex Highlighting and replacing text
  1257. Use @code{delete-selection-mode}, which you can start automatically by
  1258. placing the following Lisp form in your @file{.emacs} file:
  1259. @lisp
  1260. (delete-selection-mode 1)
  1261. @end lisp
  1262. According to the documentation string for @code{delete-selection-mode}
  1263. (which you can read using @kbd{M-x describe-function @key{RET}
  1264. delete-selection-mode @key{RET}}):
  1265. @quotation
  1266. When Delete Selection mode is enabled, Transient Mark mode is also
  1267. enabled and typed text replaces the selection if the selection is
  1268. active. Otherwise, typed text is just inserted at point regardless of
  1269. any selection.
  1270. @end quotation
  1271. This mode also allows you to delete (not kill) the highlighted region by
  1272. pressing @key{DEL}.
  1273. @node Controlling case sensitivity
  1274. @section How do I control Emacs's case-sensitivity when searching/replacing?
  1275. @cindex @code{case-fold-search}
  1276. @cindex Case sensitivity of searches
  1277. @cindex Searching without case sensitivity
  1278. @cindex Ignoring case in searches
  1279. @c FIXME
  1280. The value of the variable @code{case-fold-search} determines whether
  1281. searches are case sensitive:
  1282. @lisp
  1283. (setq case-fold-search nil) ; make searches case sensitive
  1284. (setq case-fold-search t) ; make searches case insensitive
  1285. @end lisp
  1286. @cindex Case sensitivity in replacements
  1287. @cindex Replacing, and case sensitivity
  1288. @cindex @code{case-replace}
  1289. Similarly, for replacing, the variable @code{case-replace} determines
  1290. whether replacements preserve case.
  1291. You can also toggle case sensitivity at will in isearch with @kbd{M-c}.
  1292. To change the case sensitivity just for one major mode, use the major
  1293. mode's hook. For example:
  1294. @lisp
  1295. (add-hook '@var{foo}-mode-hook
  1296. (lambda ()
  1297. (setq case-fold-search nil)))
  1298. @end lisp
  1299. @node Working with unprintable characters
  1300. @section How do I search for, delete, or replace unprintable (eight-bit or control) characters?
  1301. @cindex Unprintable characters, working with
  1302. @cindex Working with unprintable characters
  1303. @cindex Control characters, working with
  1304. @cindex Eight-bit characters, working with
  1305. @cindex Searching for unprintable characters
  1306. @cindex Regexps and unprintable characters
  1307. To search for a single character that appears in the buffer as, for
  1308. example, @samp{\237}, you can type @kbd{C-s C-q 2 3 7}.
  1309. Searching for @strong{all} unprintable characters is best done with a
  1310. regular expression (@dfn{regexp}) search. The easiest regexp to use for
  1311. the unprintable chars is the complement of the regexp for the printable
  1312. chars.
  1313. @itemize @bullet
  1314. @item
  1315. Regexp for the printable chars: @samp{[\t\n\r\f -~]}
  1316. @item
  1317. Regexp for the unprintable chars: @samp{[^\t\n\r\f -~]}
  1318. @end itemize
  1319. To type these special characters in an interactive argument to
  1320. @code{isearch-forward-regexp} or @code{re-search-forward}, you need to
  1321. use @kbd{C-q}. (@samp{\t}, @samp{\n}, @samp{\r}, and @samp{\f} stand
  1322. respectively for @key{TAB}, @key{LFD}, @key{RET}, and @kbd{C-l}.) So,
  1323. to search for unprintable characters using @code{re-search-forward}:
  1324. @kbd{M-x re-search-forward @key{RET} [^ @key{TAB} C-q @key{LFD} C-q @key{RET} C-q C-l @key{SPC} -~] @key{RET}}
  1325. Using @code{isearch-forward-regexp}:
  1326. @kbd{C-M-s [^ @key{TAB} @key{LFD} C-q @key{RET} C-q C-l @key{SPC} -~]}
  1327. To delete all unprintable characters, simply use replace-regexp:
  1328. @kbd{M-x replace-regexp @key{RET} [^ @key{TAB} C-q @key{LFD} C-q @key{RET} C-q C-l @key{SPC} -~] @key{RET} @key{RET}}
  1329. Replacing is similar to the above. To replace all unprintable
  1330. characters with a colon, use:
  1331. M-x replace-regexp @key{RET} [^ @key{TAB} C-q @key{LFD} C-q @key{RET} C-q C-l @key{SPC} -~] @key{RET} : @key{RET}
  1332. @node Searching for/replacing newlines
  1333. @section How do I input a newline character in isearch or query-replace?
  1334. @cindex Searching for newlines
  1335. @cindex Replacing newlines
  1336. Use @kbd{C-q C-j}. For more information,
  1337. @pxref{Special Isearch,, Special Input for Incremental Search, emacs,
  1338. The GNU Emacs Manual}.
  1339. @node Yanking text in isearch
  1340. @section How do I copy text from the kill ring into the search string?
  1341. @cindex Yanking text into the search string
  1342. @cindex isearch yanking
  1343. Use @kbd{M-y}. @xref{Isearch Yank,,, emacs, The GNU Emacs Manual}.
  1344. @node Wrapping words automatically
  1345. @section How do I make Emacs wrap words for me?
  1346. @cindex Wrapping word automatically
  1347. @cindex Wrapping lines
  1348. @cindex Line wrap
  1349. @cindex @code{auto-fill-mode}, introduction to
  1350. @cindex Maximum line width, default value
  1351. @cindex @code{fill-column}, default value
  1352. Use @code{auto-fill-mode}, activated by typing @kbd{M-x auto-fill-mode}.
  1353. The default maximum line width is 70, determined by the variable
  1354. @code{fill-column}. To learn how to turn this on automatically, see
  1355. @ref{Turning on auto-fill by default}.
  1356. @node Turning on auto-fill by default
  1357. @section How do I turn on @code{auto-fill-mode} by default?
  1358. @cindex @code{auto-fill-mode}, activating automatically
  1359. @cindex Filling automatically
  1360. @cindex Automatic entry to @code{auto-fill-mode}
  1361. To turn on @code{auto-fill-mode} just once for one buffer, use @kbd{M-x
  1362. auto-fill-mode}.
  1363. To turn it on for every buffer in a certain mode, you must use the hook
  1364. for that mode. For example, to turn on @code{auto-fill} mode for all
  1365. text buffers, including the following in your @file{.emacs} file:
  1366. @lisp
  1367. (add-hook 'text-mode-hook 'turn-on-auto-fill)
  1368. @end lisp
  1369. If you want @code{auto-fill} mode on in all major modes, do this:
  1370. @lisp
  1371. (setq-default auto-fill-function 'do-auto-fill)
  1372. @end lisp
  1373. @node Changing load-path
  1374. @section How do I change @code{load-path}?
  1375. @cindex @code{load-path}, modifying
  1376. @cindex Modifying @code{load-path}
  1377. @cindex Adding to @code{load-path}
  1378. In general, you should only add to the @code{load-path}. You can add
  1379. directory @var{/dir/subdir} to the load path like this:
  1380. @lisp
  1381. (add-to-list 'load-path "/dir/subdir/")
  1382. @end lisp
  1383. To do this relative to your home directory:
  1384. @lisp
  1385. (add-to-list 'load-path "~/mysubdir/")
  1386. @end lisp
  1387. @node Using an already running Emacs process
  1388. @section How do I use an already running Emacs from another window?
  1389. @cindex @code{emacsclient}
  1390. @cindex Emacs server functions
  1391. @cindex Using an existing Emacs process
  1392. @code{emacsclient}, which comes with Emacs, is for editing a file using
  1393. an already running Emacs rather than starting up a new Emacs. It does
  1394. this by sending a request to the already running Emacs, which must be
  1395. expecting the request.
  1396. @itemize @bullet
  1397. @item
  1398. Setup:
  1399. Emacs must have executed the @code{server-start} function for
  1400. @samp{emacsclient} to work. This can be done either by a command line
  1401. option:
  1402. @example
  1403. emacs -f server-start
  1404. @end example
  1405. or by invoking @code{server-start} from @file{.emacs}:
  1406. @lisp
  1407. (if (@var{some conditions are met}) (server-start))
  1408. @end lisp
  1409. When this is done, Emacs creates a Unix domain socket named
  1410. @file{server} in @file{/tmp/emacs@var{userid}}. See
  1411. @code{server-socket-dir}.
  1412. To get your news reader, mail reader, etc., to invoke
  1413. @samp{emacsclient}, try setting the environment variable @code{EDITOR}
  1414. (or sometimes @code{VISUAL}) to the value @samp{emacsclient}. You may
  1415. have to specify the full pathname of the @samp{emacsclient} program
  1416. instead. Examples:
  1417. @example
  1418. # csh commands:
  1419. setenv EDITOR emacsclient
  1420. # using full pathname
  1421. setenv EDITOR /usr/local/emacs/etc/emacsclient
  1422. # sh command:
  1423. EDITOR=emacsclient ; export EDITOR
  1424. @end example
  1425. @item
  1426. Normal use:
  1427. When @samp{emacsclient} is run, it connects to the socket and passes its
  1428. command line options to Emacs, which at the next opportunity will visit
  1429. the files specified. (Line numbers can be specified just like with
  1430. Emacs.) The user will have to switch to the Emacs window by hand. When
  1431. the user is done editing a file, the user can type @kbd{C-x #} (or
  1432. @kbd{M-x server-edit}) to indicate this. If there is another buffer
  1433. requested by @code{emacsclient}, Emacs will switch to it; otherwise
  1434. @code{emacsclient} will exit, signaling the calling program to continue.
  1435. @cindex @code{gnuserv}
  1436. There is an alternative version of @samp{emacsclient} called
  1437. @samp{gnuserv}, written by @email{ange@@hplb.hpl.hp.com, Andy Norman}
  1438. (@pxref{Packages that do not come with Emacs}). @samp{gnuserv} uses
  1439. Internet domain sockets, so it can work across most network connections.
  1440. The most recent @samp{gnuserv} package is available at
  1441. @uref{http://meltin.net/hacks/emacs/}
  1442. @end itemize
  1443. @node Compiler error messages
  1444. @section How do I make Emacs recognize my compiler's funny error messages?
  1445. @cindex Compiler error messages, recognizing
  1446. @cindex Recognizing non-standard compiler errors
  1447. @cindex Regexps for recognizing compiler errors
  1448. @cindex Errors, recognizing compiler
  1449. Customize the @code{compilation-error-regexp-alist} variable.
  1450. @node Indenting switch statements
  1451. @section How do I change the indentation for @code{switch}?
  1452. @cindex @code{switch}, indenting
  1453. @cindex Indenting of @code{switch}
  1454. Many people want to indent their @code{switch} statements like this:
  1455. @example
  1456. f()
  1457. @{
  1458. switch(x) @{
  1459. case A:
  1460. x1;
  1461. break;
  1462. case B:
  1463. x2;
  1464. break;
  1465. default:
  1466. x3;
  1467. @}
  1468. @}
  1469. @end example
  1470. @noindent To achieve this, add the following line to your @file{.emacs}:
  1471. @lisp
  1472. (c-set-offset 'case-label '+)
  1473. @end lisp
  1474. @node Customizing C and C++ indentation
  1475. @section How to customize indentation in C, C@t{++}, and Java buffers?
  1476. @cindex Indentation, how to customize
  1477. @cindex Customize indentation
  1478. The Emacs @code{cc-mode} features an interactive procedure for
  1479. customizing the indentation style, which is fully explained in the
  1480. @cite{CC Mode} manual that is part of the Emacs distribution, see
  1481. @ref{Customizing Indentation, , Customization Indentation, ccmode,
  1482. The CC Mode Manual}. Here's a short summary of the procedure:
  1483. @enumerate
  1484. @item
  1485. Go to the beginning of the first line where you don't like the
  1486. indentation and type @kbd{C-c C-o}. Emacs will prompt you for the
  1487. syntactic symbol; type @key{RET} to accept the default it suggests.
  1488. @item
  1489. Emacs now prompts for the offset of this syntactic symbol, showing the
  1490. default (the current definition) inside parentheses. You can choose
  1491. one of these:
  1492. @table @code
  1493. @item 0
  1494. No extra indentation.
  1495. @item +
  1496. Indent one basic offset.
  1497. @item -
  1498. Outdent one basic offset.
  1499. @item ++
  1500. Indent two basic offsets
  1501. @item --
  1502. Outdent two basic offsets.
  1503. @item *
  1504. Indent half basic offset.
  1505. @item /
  1506. Outdent half basic offset.
  1507. @end table
  1508. @item
  1509. After choosing one of these symbols, type @kbd{C-c C-q} to reindent
  1510. the line or the block according to what you just specified.
  1511. @item
  1512. If you don't like the result, go back to step 1. Otherwise, add the
  1513. following line to your @file{.emacs}:
  1514. @lisp
  1515. (c-set-offset '@var{syntactic-symbol} @var{offset})
  1516. @end lisp
  1517. @noindent
  1518. where @var{syntactic-symbol} is the name Emacs shows in the minibuffer
  1519. when you type @kbd{C-c C-o} at the beginning of the line, and
  1520. @var{offset} is one of the indentation symbols listed above (@code{+},
  1521. @code{/}, @code{0}, etc.) that you've chosen during the interactive
  1522. procedure.
  1523. @item
  1524. Go to the next line whose indentation is not to your liking and repeat
  1525. the process there.
  1526. @end enumerate
  1527. It is recommended to put all the resulting @code{(c-set-offset ...)}
  1528. customizations inside a C mode hook, like this:
  1529. @lisp
  1530. (defun my-c-mode-hook ()
  1531. (c-set-offset ...)
  1532. (c-set-offset ...))
  1533. (add-hook 'c-mode-hook 'my-c-mode-hook)
  1534. @end lisp
  1535. @noindent
  1536. Using @code{c-mode-hook} avoids the need to put a @w{@code{(require
  1537. 'cc-mode)}} into your @file{.emacs} file, because @code{c-set-offset}
  1538. might be unavailable when @code{cc-mode} is not loaded.
  1539. Note that @code{c-mode-hook} runs for C source files only; use
  1540. @code{c++-mode-hook} for C@t{++} sources, @code{java-mode-hook} for
  1541. Java sources, etc. If you want the same customizations to be in
  1542. effect in @emph{all} languages supported by @code{cc-mode}, use
  1543. @code{c-mode-common-hook}.
  1544. @node Horizontal scrolling
  1545. @section How can I make Emacs automatically scroll horizontally?
  1546. @cindex @code{hscroll-mode}
  1547. @cindex Horizontal scrolling
  1548. @cindex Scrolling horizontally
  1549. In Emacs 21 and later, this is on by default: if the variable
  1550. @code{truncate-lines} is non-@code{nil} in the current buffer, Emacs
  1551. automatically scrolls the display horizontally when point moves off the
  1552. left or right edge of the window.
  1553. Note that this is overridden by the variable
  1554. @code{truncate-partial-width-windows} if that variable is non-nil
  1555. and the current buffer is not full-frame width.
  1556. In Emacs 20, use @code{hscroll-mode}.
  1557. @node Overwrite mode
  1558. @section How do I make Emacs ``typeover'' or ``overwrite'' instead of inserting?
  1559. @cindex @key{Insert}
  1560. @cindex @code{overwrite-mode}
  1561. @cindex Overwriting existing text
  1562. @cindex Toggling @code{overwrite-mode}
  1563. @kbd{M-x overwrite-mode} (a minor mode). This toggles
  1564. @code{overwrite-mode} on and off, so exiting from @code{overwrite-mode}
  1565. is as easy as another @kbd{M-x overwrite-mode}.
  1566. On some systems, @key{Insert} toggles @code{overwrite-mode} on and off.
  1567. @node Turning off beeping
  1568. @section How do I stop Emacs from beeping on a terminal?
  1569. @cindex Beeping, turning off
  1570. @cindex Visible bell
  1571. @cindex Bell, visible
  1572. @email{martin@@cc.gatech.edu, Martin R. Frank} writes:
  1573. Tell Emacs to use the @dfn{visible bell} instead of the audible bell,
  1574. and set the visible bell to nothing.
  1575. That is, put the following in your @code{TERMCAP} environment variable
  1576. (assuming you have one):
  1577. @example
  1578. ... :vb=: ...
  1579. @end example
  1580. And evaluate the following Lisp form:
  1581. @example
  1582. (setq visible-bell t)
  1583. @end example
  1584. @node Turning the volume down
  1585. @section How do I turn down the bell volume in Emacs running under X?
  1586. @cindex Bell, volume of
  1587. @cindex Volume of bell
  1588. On X Window system, you can adjust the bell volume and duration for all
  1589. programs with the shell command @code{xset}.
  1590. Invoking @code{xset} without any arguments produces some basic
  1591. information, including the following:
  1592. @example
  1593. usage: xset [-display host:dpy] option ...
  1594. To turn bell off:
  1595. -b b off b 0
  1596. To set bell volume, pitch and duration:
  1597. b [vol [pitch [dur]]] b on
  1598. @end example
  1599. @node Automatic indentation
  1600. @section How do I tell Emacs to automatically indent a new line to the indentation of the previous line?
  1601. @cindex Indenting new lines
  1602. @cindex New lines, indenting of
  1603. @cindex Previous line, indenting according to
  1604. @cindex Text indentation
  1605. Such behavior is automatic (in Text mode) in Emacs 20 and later. From the
  1606. @file{etc/NEWS} file for Emacs 20.2:
  1607. @example
  1608. ** In Text mode, now only blank lines separate paragraphs. This makes
  1609. it possible to get the full benefit of Adaptive Fill mode in Text mode,
  1610. and other modes derived from it (such as Mail mode). @key{TAB} in Text
  1611. mode now runs the command @code{indent-relative}; this makes a practical
  1612. difference only when you use indented paragraphs.
  1613. If you want spaces at the beginning of a line to start a paragraph, use
  1614. the new mode, Paragraph Indent Text mode.
  1615. @end example
  1616. @cindex Prefixing lines
  1617. @cindex Fill prefix
  1618. If you have @code{auto-fill-mode} turned on (@pxref{Turning on auto-fill
  1619. by default}), you can tell Emacs to prefix every line with a certain
  1620. character sequence, the @dfn{fill prefix}. Type the prefix at the
  1621. beginning of a line, position point after it, and then type @kbd{C-x .}
  1622. (@code{set-fill-prefix}) to set the fill prefix. Thereafter,
  1623. auto-filling will automatically put the fill prefix at the beginning of
  1624. new lines, and @kbd{M-q} (@code{fill-paragraph}) will maintain any fill
  1625. prefix when refilling the paragraph.
  1626. If you have paragraphs with different levels of indentation, you will
  1627. have to set the fill prefix to the correct value each time you move to a
  1628. new paragraph. There are many packages available to deal with this
  1629. (@pxref{Packages that do not come with Emacs}). Look for ``fill'' and
  1630. ``indent'' keywords for guidance.
  1631. @node Matching parentheses
  1632. @section How do I show which parenthesis matches the one I'm looking at?
  1633. @cindex Parentheses, matching
  1634. @cindex @file{paren.el}
  1635. @cindex Highlighting matching parentheses
  1636. @cindex Pairs of parentheses, highlighting
  1637. @cindex Matching parentheses
  1638. Call @code{show-paren-mode} in your @file{.emacs} file:
  1639. @lisp
  1640. (show-paren-mode 1)
  1641. @end lisp
  1642. You can also enable this mode by selecting the @samp{Paren Match
  1643. Highlighting} option from the @samp{Options} menu of the Emacs menu bar
  1644. at the top of any Emacs frame.
  1645. Alternatives to this mode include:
  1646. @itemize @bullet
  1647. @item
  1648. If you're looking at a right parenthesis (or brace or bracket) you can
  1649. delete it and reinsert it. Emacs will momentarily move the cursor to
  1650. the matching parenthesis.
  1651. @item
  1652. @kbd{C-M-f} (@code{forward-sexp}) and @kbd{C-M-b} (@code{backward-sexp})
  1653. will skip over one set of balanced parentheses, so you can see which
  1654. parentheses match. (You can train it to skip over balanced brackets
  1655. and braces at the same time by modifying the syntax table.)
  1656. @cindex Show matching paren as in @code{vi}
  1657. @item
  1658. Here is some Emacs Lisp that will make the @key{%} key show the matching
  1659. parenthesis, like in @code{vi}. In addition, if the cursor isn't over a
  1660. parenthesis, it simply inserts a % like normal.
  1661. @lisp
  1662. ;; By an unknown contributor
  1663. (global-set-key "%" 'match-paren)
  1664. (defun match-paren (arg)
  1665. "Go to the matching paren if on a paren; otherwise insert %."
  1666. (interactive "p")
  1667. (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
  1668. ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
  1669. (t (self-insert-command (or arg 1)))))
  1670. @end lisp
  1671. @end itemize
  1672. @node Hiding #ifdef lines
  1673. @section In C mode, can I show just the lines that will be left after @code{#ifdef} commands are handled by the compiler?
  1674. @cindex @code{#ifdef}, selective display of
  1675. @cindex @code{hide-ifdef-mode}
  1676. @cindex Hiding @code{#ifdef} text
  1677. @cindex Selectively displaying @code{#ifdef} code
  1678. @kbd{M-x hide-ifdef-mode}. (This is a minor mode.) You might also want
  1679. to investigate @file{cpp.el}, which is distributed with Emacs.
  1680. @node Repeating commands
  1681. @section How do I repeat a command as many times as possible?
  1682. @cindex Repeating commands many times
  1683. @cindex Commands, repeating many times
  1684. @cindex @code{.}, equivalent to @code{vi} command
  1685. As of Emacs 20.3, there is indeed a @code{repeat} command (@kbd{C-x z})
  1686. that repeats the last command. If you preface it with a prefix
  1687. argument, the prefix arg is applied to the command.
  1688. You can also type @kbd{C-x @key{ESC} @key{ESC}}
  1689. (@code{repeat-complex-command}) to reinvoke commands that used the
  1690. minibuffer to get arguments. In @code{repeat-complex-command} you can
  1691. type @kbd{M-p} and @kbd{M-n} (and also up-arrow and down-arrow, if your
  1692. keyboard has these keys) to scan through all the different complex
  1693. commands you've typed.
  1694. To repeat a set of commands, use keyboard macros. Use @kbd{C-x (} and
  1695. @kbd{C-x )} to make a keyboard macro that invokes the command and then
  1696. type @kbd{C-x e}. @xref{Keyboard Macros,,, emacs, The GNU Emacs Manual}.
  1697. If you're really desperate for the @code{.} command in @code{vi} that
  1698. redoes the last insertion/deletion, use VIPER, a @code{vi} emulation
  1699. mode which comes with Emacs, and which appears to support it.
  1700. @node Valid X resources
  1701. @section What are the valid X resource settings (i.e., stuff in .Xdefaults)?
  1702. @cindex Resources, X
  1703. @cindex X resources
  1704. @cindex Setting X resources
  1705. @xref{X Resources,,, emacs, The GNU Emacs Manual}.
  1706. You can also use a resource editor, such as editres (for X11R5 and
  1707. onwards), to look at the resource names for the menu bar, assuming Emacs
  1708. was compiled with the X toolkit.
  1709. @node Evaluating Emacs Lisp code
  1710. @section How do I execute (``evaluate'') a piece of Emacs Lisp code?
  1711. @cindex Evaluating Lisp code
  1712. @cindex Lisp forms, evaluating
  1713. There are a number of ways to execute (@dfn{evaluate}, in Lisp lingo) an
  1714. Emacs Lisp @dfn{form}:
  1715. @itemize @bullet
  1716. @item
  1717. If you want it evaluated every time you run Emacs, put it in a file
  1718. named @file{.emacs} in your home directory. This is known as ``your
  1719. @file{.emacs} file,'' and contains all of your personal customizations.
  1720. @item
  1721. You can type the form in the @file{*scratch*} buffer, and then type
  1722. @key{LFD} (or @kbd{C-j}) after it. The result of evaluating the form
  1723. will be inserted in the buffer.
  1724. @item
  1725. In @code{emacs-lisp-mode}, typing @kbd{C-M-x} evaluates a top-level form
  1726. before or around point.
  1727. @item
  1728. Typing @kbd{C-x C-e} in any buffer evaluates the Lisp form immediately
  1729. before point and prints its value in the echo area.
  1730. @item
  1731. Typing @kbd{M-:} or @kbd{M-x eval-expression} allows you to type a Lisp
  1732. form in the minibuffer which will be evaluated once you press @key{RET}.
  1733. @item
  1734. You can use @kbd{M-x load-file} to have Emacs evaluate all the Lisp
  1735. forms in a file. (To do this from Lisp use the function @code{load}
  1736. instead.)
  1737. The functions @code{load-library}, @code{eval-region},
  1738. @code{eval-buffer}, @code{require}, and @code{autoload} are also
  1739. useful; see @ref{Emacs Lisp documentation}, if you want to learn more
  1740. about them.
  1741. @end itemize
  1742. @node Changing the length of a Tab
  1743. @section How do I change Emacs's idea of the @key{TAB} character's length?
  1744. @cindex Tab length
  1745. @cindex Length of tab character
  1746. Set the default value of the variable @code{tab-width}. For example, to set
  1747. @key{TAB} stops every 10 characters, insert the following in your
  1748. @file{.emacs} file:
  1749. @lisp
  1750. (setq-default tab-width 10)
  1751. @end lisp
  1752. Do not confuse variable @code{tab-width} with variable
  1753. @code{tab-stop-list}. The former is used for the display of literal
  1754. @key{TAB} characters. The latter controls what characters are inserted
  1755. when you press the @key{TAB} character in certain modes.
  1756. @node Inserting text at the beginning of each line
  1757. @section How do I insert <some text> at the beginning of every line?
  1758. @cindex Prefixing a region with some text
  1759. @cindex Prefix character, inserting in mail/news replies
  1760. @cindex Replies to mail/news, inserting a prefix character
  1761. @cindex @code{mail-yank-prefix}
  1762. @cindex Mail replies, inserting a prefix character
  1763. @cindex News replies, inserting a prefix character
  1764. To do this to an entire buffer, type @kbd{M-< M-x replace-regexp
  1765. @key{RET} ^ @key{RET} your text @key{RET}}.
  1766. To do this to a region, use @code{string-insert-rectangle}.
  1767. Set the mark (@kbd{C-@key{SPC}}) at the beginning of the first line you
  1768. want to prefix, move the cursor to last line to be prefixed, and type
  1769. @kbd{M-x string-insert-rectangle @key{RET}}. To do this for the whole
  1770. buffer, type @kbd{C-x h M-x string-insert-rectangle @key{RET}}.
  1771. If you are trying to prefix a yanked mail message with @samp{>}, you
  1772. might want to set the variable @code{mail-yank-prefix}. In Message
  1773. buffers, you can even use @kbd{M-;} to cite yanked messages (@kbd{M-;}
  1774. runs the function @code{comment-region}, it is a general-purpose
  1775. mechanism to comment regions) (@pxref{Changing the included text prefix}).
  1776. @node Forcing the cursor to remain in the same column
  1777. @section How do I make Emacs behave like this: when I go up or down, the cursor should stay in the same column even if the line is too short?
  1778. @cindex @code{picture-mode}
  1779. @cindex Remaining in the same column, regardless of contents
  1780. @cindex Vertical movement in empty documents
  1781. Use @kbd{M-x picture-mode}.
  1782. See also the variable @code{track-eol} and the command
  1783. @code{set-goal-column} bound to @kbd{C-x C-n}
  1784. (@pxref{Moving Point, , , emacs, The GNU Emacs Manual}).
  1785. @node Forcing Emacs to iconify itself
  1786. @section How do I tell Emacs to iconify itself?
  1787. @cindex Iconification under the X Window System
  1788. @cindex X Window System and iconification
  1789. @cindex Suspending Emacs
  1790. @kbd{C-z} iconifies Emacs when running under X and suspends Emacs
  1791. otherwise. @xref{Frame Commands,,, emacs, The GNU Emacs Manual}.
  1792. @node Using regular expressions
  1793. @section How do I use regexps (regular expressions) in Emacs?
  1794. @cindex Regexps
  1795. @cindex Regular expressions
  1796. @cindex Differences between Unix and Emacs regexps
  1797. @cindex Unix regexps, differences from Emacs
  1798. @cindex Text strings, putting regexps in
  1799. @xref{Regexp Backslash,,, emacs, The GNU Emacs Manual}.
  1800. The @code{or} operator is @samp{\|}, not @samp{|}, and the grouping operators
  1801. are @samp{\(} and @samp{\)}. Also, the string syntax for a backslash is
  1802. @samp{\\}. To specify a regular expression like @samp{xxx\(foo\|bar\)}
  1803. in a Lisp string, use @samp{xxx\\(foo\\|bar\\)}.
  1804. Note the doubled backslashes!
  1805. @itemize @bullet
  1806. @item
  1807. Unlike in Unix @file{grep}, @file{sed}, etc., a complement character set
  1808. (@samp{[^...]}) can match a newline character (@key{LFD} a.k.a.@:
  1809. @kbd{C-j} a.k.a.@: @samp{\n}), unless newline is mentioned as one of the
  1810. characters not to match.
  1811. @item
  1812. The character syntax regexps (e.g., @samp{\sw}) are not
  1813. meaningful inside character set regexps (e.g., @samp{[aeiou]}). (This
  1814. is actually typical for regexp syntax.)
  1815. @end itemize
  1816. @node Replacing text across multiple files
  1817. @section How do I perform a replace operation across more than one file?
  1818. @cindex Replacing strings across files
  1819. @cindex Multiple files, replacing across
  1820. @cindex Files, replacing strings across multiple
  1821. @cindex Recursive search/replace operations
  1822. Dired mode (@kbd{M-x dired @key{RET}}, or @kbd{C-x d}) supports the
  1823. command @code{dired-do-query-replace-regexp} (@kbd{Q}), which allows
  1824. users to replace regular expressions in multiple files.
  1825. You can use this command to perform search/replace operations on
  1826. multiple files by following the following steps:
  1827. @itemize @bullet
  1828. @item
  1829. Assemble a list of files you want to operate on with either
  1830. @code{find-dired}, @code{find-name-dired} or @code{find-grep-dired}.
  1831. @item
  1832. Mark all files in the resulting Dired buffer using @kbd{t}.
  1833. @item
  1834. Use @kbd{Q} to start a @code{query-replace-regexp} session on the marked
  1835. files.
  1836. @item
  1837. To accept all replacements in each file, hit @kbd{!}.
  1838. @end itemize
  1839. Another way to do the same thing is to use the ``tags'' feature of
  1840. Emacs: it includes the command @code{tags-query-replace} which performs
  1841. a query-replace across all the files mentioned in the @file{TAGS} file.
  1842. @xref{Tags Search,,, emacs, The GNU Emacs Manual}.
  1843. @node Documentation for etags
  1844. @section Where is the documentation for @code{etags}?
  1845. @cindex Documentation for @code{etags}
  1846. @cindex @code{etags}, documentation for
  1847. The @code{etags} man page should be in the same place as the
  1848. @code{emacs} man page.
  1849. Quick command-line switch descriptions are also available. For example,
  1850. @samp{etags -H}.
  1851. @node Disabling backups
  1852. @section How do I disable backup files?
  1853. @cindex Backups, disabling
  1854. @cindex Disabling backups
  1855. You probably don't want to do this, since backups are useful, especially
  1856. when something goes wrong.
  1857. To avoid seeing backup files (and other ``uninteresting'' files) in Dired,
  1858. load @code{dired-x} by adding the following to your @file{.emacs} file:
  1859. @lisp
  1860. (add-hook 'dired-load-hook
  1861. (lambda ()
  1862. (require 'dired-x)))
  1863. @end lisp
  1864. With @code{dired-x} loaded, @kbd{M-o} toggles omitting in each dired buffer.
  1865. You can make omitting the default for new dired buffers by putting the
  1866. following in your @file{.emacs}:
  1867. @lisp
  1868. (add-hook 'dired-mode-hook 'dired-omit-toggle)
  1869. @end lisp
  1870. If you're tired of seeing backup files whenever you do an @samp{ls} at
  1871. the Unix shell, try GNU @code{ls} with the @samp{-B} option. GNU
  1872. @code{ls} is part of the GNU Fileutils package, available from
  1873. @samp{ftp.gnu.org} and its mirrors (@pxref{Current GNU distributions}).
  1874. To disable or change the way backups are made,
  1875. @pxref{Backup Names,,, emacs, The GNU Emacs Manual}.
  1876. @cindex Backup files in a single directory
  1877. Beginning with Emacs 21.1, you can control where Emacs puts backup files
  1878. by customizing the variable @code{backup-directory-alist}. This
  1879. variable's value specifies that files whose names match specific patters
  1880. should have their backups put in certain directories. A typical use is
  1881. to add the element @code{("." . @var{dir})} to force Emacs to put
  1882. @strong{all} backup files in the directory @file{dir}.
  1883. @node Disabling auto-save-mode
  1884. @section How do I disable @code{auto-save-mode}?
  1885. @cindex Disabling @code{auto-save-mode}
  1886. @cindex Auto-saving
  1887. @cindex Saving at frequent intervals
  1888. You probably don't want to do this, since auto-saving is useful,
  1889. especially when Emacs or your computer crashes while you are editing a
  1890. document.
  1891. Instead, you might want to change the variable
  1892. @code{auto-save-interval}, which specifies how many keystrokes Emacs
  1893. waits before auto-saving. Increasing this value forces Emacs to wait
  1894. longer between auto-saves, which might annoy you less.
  1895. You might also want to look into Sebastian Kremer's @code{auto-save}
  1896. package (@pxref{Packages that do not come with Emacs}). This
  1897. package also allows you to place all auto-save files in one directory,
  1898. such as @file{/tmp}.
  1899. To disable or change how @code{auto-save-mode} works,
  1900. @pxref{Auto Save,,, emacs, The GNU Emacs Manual}.
  1901. @node Going to a line by number
  1902. @section How can I go to a certain line given its number?
  1903. @cindex Going to a line by number
  1904. @cindex Compilation error messages
  1905. @cindex Recompilation
  1906. Are you sure you indeed need to go to a line by its number? Perhaps all
  1907. you want is to display a line in your source file for which a compiler
  1908. printed an error message? If so, compiling from within Emacs using the
  1909. @kbd{M-x compile} and @kbd{M-x recompile} commands is a much more
  1910. effective way of doing that. Emacs automatically intercepts the compile
  1911. error messages, inserts them into a special buffer called
  1912. @code{*compilation*}, and lets you visit the locus of each message in
  1913. the source. Type @kbd{C-x `} to step through the offending lines one by
  1914. one (starting with Emacs 22, you can also use @kbd{M-g M-p} and
  1915. @kbd{M-g M-n} to go to the previous and next matches directly). Click
  1916. @kbd{Mouse-2} or press @key{RET} on a message text in the
  1917. @code{*compilation*} buffer to go to the line whose number is mentioned
  1918. in that message.
  1919. But if you indeed need to go to a certain text line, type @kbd{M-g M-g}
  1920. (which is the default binding of the @code{goto-line} function starting
  1921. with Emacs 22). Emacs will prompt you for the number of the line and go
  1922. to that line.
  1923. You can do this faster by invoking @code{goto-line} with a numeric
  1924. argument that is the line's number. For example, @kbd{C-u 286 M-g M-g}
  1925. will jump to line number 286 in the current buffer.
  1926. @node Modifying pull-down menus
  1927. @section How can I create or modify new pull-down menu options?
  1928. @cindex Pull-down menus, creating or modifying
  1929. @cindex Menus, creating or modifying
  1930. @cindex Creating new menu options
  1931. @cindex Modifying pull-down menus
  1932. @cindex Menus and keymaps
  1933. @cindex Keymaps and menus
  1934. Each menu title (e.g., @samp{File}, @samp{Edit}, @samp{Buffers})
  1935. represents a local or global keymap. Selecting a menu title with the
  1936. mouse displays that keymap's non-@code{nil} contents in the form of a menu.
  1937. So to add a menu option to an existing menu, all you have to do is add a
  1938. new definition to the appropriate keymap. Adding a @samp{Forward Word}
  1939. item to the @samp{Edit} menu thus requires the following Lisp code:
  1940. @lisp
  1941. (define-key global-map
  1942. [menu-bar edit forward]
  1943. '("Forward word" . forward-word))
  1944. @end lisp
  1945. @noindent
  1946. The first line adds the entry to the global keymap, which includes
  1947. global menu bar entries. Replacing the reference to @code{global-map}
  1948. with a local keymap would add this menu option only within a particular
  1949. mode.
  1950. The second line describes the path from the menu-bar to the new entry.
  1951. Placing this menu entry underneath the @samp{File} menu would mean
  1952. changing the word @code{edit} in the second line to @code{file}.
  1953. The third line is a cons cell whose first element is the title that will
  1954. be displayed, and whose second element is the function that will be
  1955. called when that menu option is invoked.
  1956. To add a new menu, rather than a new option to an existing menu, we must
  1957. define an entirely new keymap:
  1958. @lisp
  1959. (define-key global-map [menu-bar words]
  1960. (cons "Words" (make-sparse-keymap "Words")))
  1961. @end lisp
  1962. The above code creates a new sparse keymap, gives it the name
  1963. @samp{Words}, and attaches it to the global menu bar. Adding the
  1964. @samp{Forward Word} item to this new menu would thus require the
  1965. following code:
  1966. @lisp
  1967. (define-key global-map
  1968. [menu-bar words forward]
  1969. '("Forward word" . forward-word))
  1970. @end lisp
  1971. @noindent
  1972. Note that because of the way keymaps work, menu options are displayed
  1973. with the more recently defined items at the top. Thus if you were to
  1974. define menu options @samp{foo}, @samp{bar}, and @samp{baz} (in that
  1975. order), the menu option @samp{baz} would appear at the top, and
  1976. @samp{foo} would be at the bottom.
  1977. One way to avoid this problem is to use the function @code{define-key-after},
  1978. which works the same as @code{define-key}, but lets you modify where items
  1979. appear. The following Lisp code would insert the @samp{Forward Word}
  1980. item in the @samp{Edit} menu immediately following the @samp{Undo} item:
  1981. @lisp
  1982. (define-key-after
  1983. (lookup-key global-map [menu-bar edit])
  1984. [forward]
  1985. '("Forward word" . forward-word)
  1986. 'undo)
  1987. @end lisp
  1988. Note how the second and third arguments to @code{define-key-after} are
  1989. different from those of @code{define-key}, and that we have added a new
  1990. (final) argument, the function after which our new key should be
  1991. defined.
  1992. To move a menu option from one position to another, simply evaluate
  1993. @code{define-key-after} with the appropriate final argument.
  1994. More detailed information---and more examples of how to create and
  1995. modify menu options---are in the @cite{Emacs Lisp Reference Manual}, under
  1996. ``Menu Keymaps.'' (@xref{Emacs Lisp documentation}, for information on
  1997. this manual.)
  1998. @node Deleting menus and menu options
  1999. @section How do I delete menus and menu options?
  2000. @cindex Deleting menus and menu options
  2001. @cindex Menus, deleting
  2002. The simplest way to remove a menu is to set its keymap to @samp{nil}.
  2003. For example, to delete the @samp{Words} menu (@pxref{Modifying pull-down
  2004. menus}), use:
  2005. @lisp
  2006. (define-key global-map [menu-bar words] nil)
  2007. @end lisp
  2008. Similarly, removing a menu option requires redefining a keymap entry to
  2009. @code{nil}. For example, to delete the @samp{Forward word} menu option
  2010. from the @samp{Edit} menu (we added it in @ref{Modifying pull-down
  2011. menus}), use:
  2012. @lisp
  2013. (define-key global-map [menu-bar edit forward] nil)
  2014. @end lisp
  2015. @node Turning on syntax highlighting
  2016. @section How do I turn on syntax highlighting?
  2017. @cindex Syntax highlighting
  2018. @cindex @code{font-lock-mode}
  2019. @cindex Highlighting based on syntax
  2020. @cindex Colorizing text
  2021. @cindex FAQ, @code{font-lock-mode}
  2022. @code{font-lock-mode} is the standard way to have Emacs perform syntax
  2023. highlighting in the current buffer. It is enabled by default in Emacs
  2024. 22.1 and later.
  2025. With @code{font-lock-mode} turned on, different types of text will
  2026. appear in different colors. For instance, in a programming mode,
  2027. variables will appear in one face, keywords in a second, and comments in
  2028. a third.
  2029. To turn @code{font-lock-mode} off within an existing buffer, use
  2030. @kbd{M-x font-lock-mode @key{RET}}.
  2031. In Emacs 21 and earlier versions, you could use the following code in
  2032. your @file{.emacs} file to turn on @code{font-lock-mode} globally:
  2033. @lisp
  2034. (global-font-lock-mode 1)
  2035. @end lisp
  2036. Highlighting a buffer with @code{font-lock-mode} can take quite a while,
  2037. and cause an annoying delay in display, so several features exist to
  2038. work around this.
  2039. @cindex Just-In-Time syntax highlighting
  2040. In Emacs 21 and later, turning on @code{font-lock-mode} automatically
  2041. activates the new @dfn{Just-In-Time fontification} provided by
  2042. @code{jit-lock-mode}. @code{jit-lock-mode} defers the fontification of
  2043. portions of buffer until you actually need to see them, and can also
  2044. fontify while Emacs is idle. This makes display of the visible portion
  2045. of a buffer almost instantaneous. For details about customizing
  2046. @code{jit-lock-mode}, type @kbd{C-h f jit-lock-mode @key{RET}}.
  2047. @cindex Levels of syntax highlighting
  2048. @cindex Decoration level, in @code{font-lock-mode}
  2049. In versions of Emacs before 21, different levels of decoration are
  2050. available, from slight to gaudy. More decoration means you need to wait
  2051. more time for a buffer to be fontified (or a faster machine). To
  2052. control how decorated your buffers should become, set the value of
  2053. @code{font-lock-maximum-decoration} in your @file{.emacs} file, with a
  2054. @code{nil} value indicating default (usually minimum) decoration, and a
  2055. @code{t} value indicating the maximum decoration. For the gaudiest
  2056. possible look, then, include the line
  2057. @lisp
  2058. (setq font-lock-maximum-decoration t)
  2059. @end lisp
  2060. @noindent
  2061. in your @file{.emacs} file. You can also set this variable such that
  2062. different modes are highlighted in a different ways; for more
  2063. information, see the documentation for
  2064. @code{font-lock-maximum-decoration} with @kbd{C-h v} (or @kbd{M-x
  2065. describe-variable @key{RET}}).
  2066. Also see the documentation for the function @code{font-lock-mode},
  2067. available by typing @kbd{C-h f font-lock-mode} (@kbd{M-x
  2068. describe-function @key{RET} font-lock-mode @key{RET}}).
  2069. To print buffers with the faces (i.e., colors and fonts) intact, use
  2070. @kbd{M-x ps-print-buffer-with-faces} or @kbd{M-x
  2071. ps-print-region-with-faces}. You will need a way to send text to a
  2072. PostScript printer, or a PostScript interpreter such as Ghostscript;
  2073. consult the documentation of the variables @code{ps-printer-name},
  2074. @code{ps-lpr-command}, and @code{ps-lpr-switches} for more details.
  2075. @node Scrolling only one line
  2076. @section How can I force Emacs to scroll only one line when I move past the bottom of the screen?
  2077. @cindex Scrolling only one line
  2078. @cindex Reducing the increment when scrolling
  2079. Customize the @code{scroll-conservatively} variable with @kbd{M-x
  2080. customize-variable @key{RET} scroll-conservatively @key{RET}} and set it
  2081. to a large value like, say, 10000. For an explanation of what this
  2082. means, @pxref{Auto Scrolling,,, emacs, The GNU Emacs Manual}.
  2083. Alternatively, use the following Lisp form in your @file{.emacs}:
  2084. @lisp
  2085. (setq scroll-conservatively most-positive-fixnum)
  2086. @end lisp
  2087. @node Editing MS-DOS files
  2088. @section How can I edit MS-DOS files using Emacs?
  2089. @cindex Editing MS-DOS files
  2090. @cindex MS-DOS files, editing
  2091. @cindex Microsoft files, editing
  2092. @cindex Windows files, editing
  2093. As of Emacs 20, detection and handling of MS-DOS (and Windows) files is
  2094. performed transparently. You can open MS-DOS files on a Unix system,
  2095. edit it, and save it without having to worry about the file format.
  2096. When editing an MS-DOS style file, the mode line will indicate that it
  2097. is a DOS file. On Unix and GNU/Linux systems, and also on a Macintosh,
  2098. the string @samp{(DOS)} will appear near the left edge of the mode line;
  2099. on DOS and Windows, where the DOS end-of-line (EOL) format is the
  2100. default, a backslash (@samp{\}) will appear in the mode line.
  2101. @node Filling paragraphs with a single space
  2102. @section How can I tell Emacs to fill paragraphs with a single space after each period?
  2103. @cindex One space following periods
  2104. @cindex Single space following periods
  2105. @cindex Periods, one space following
  2106. Add the following line to your @file{.emacs} file:
  2107. @lisp
  2108. (setq sentence-end-double-space nil)
  2109. @end lisp
  2110. @node Escape sequences in shell output
  2111. @section Why these strange escape sequences from @code{ls} from the Shell mode?
  2112. @cindex Escape sequences in @code{ls} output
  2113. @cindex @code{ls} in Shell mode
  2114. In many systems, @code{ls} is aliased to @samp{ls --color}, which
  2115. prints using ANSI color escape sequences. Emacs version 21.1 and
  2116. later includes the @code{ansi-color} package, which lets Shell mode
  2117. recognize these escape sequences. In Emacs 23.2 and later, the
  2118. package is enabled by default; in earlier versions you can enable it
  2119. by typing @kbd{M-x ansi-color-for-comint-mode} in the Shell buffer, or
  2120. by adding @code{(add-hook 'shell-mode-hook
  2121. 'ansi-color-for-comint-mode-on)} to your init file.
  2122. In Emacs versions before 21.1, the @code{ansi-color} package is not
  2123. included. In that case, you need to unalias @code{ls} for interactive
  2124. shells running in Emacs; this can be done by checking the @code{EMACS}
  2125. variable in the environment.
  2126. @node Fullscreen mode on MS-Windows
  2127. @section How can I start Emacs in fullscreen mode on MS-Windows?
  2128. @cindex Maximize frame
  2129. @cindex Fullscreen mode
  2130. Use the function @code{w32-send-sys-command}. For example, you can
  2131. put the following in your @file{.emacs} file:
  2132. @lisp
  2133. (add-hook 'term-setup-hook
  2134. #'(lambda () (w32-send-sys-command ?\xF030)))
  2135. @end lisp
  2136. To avoid the slightly distracting visual effect of Emacs starting with
  2137. its default frame size and then growing to fullscreen, you can add an
  2138. @samp{Emacs.Geometry} entry to the Windows registry settings.
  2139. @xref{X Resources,,, emacs, The GNU Emacs Manual}.
  2140. To compute the correct values for width and height, first maximize the
  2141. Emacs frame and then evaluate @code{(frame-height)} and
  2142. @code{(frame-width)} with @kbd{M-:}.
  2143. @c ------------------------------------------------------------
  2144. @node Bugs and problems
  2145. @chapter Bugs and problems
  2146. @cindex Bugs and problems
  2147. The Emacs manual lists some common kinds of trouble users could get
  2148. into, see @ref{Lossage, , Dealing with Emacs Trouble, emacs, The GNU
  2149. Emacs Manual}, so you might look there if the problem you encounter
  2150. isn't described in this chapter. If you decide you've discovered a bug,
  2151. see @ref{Bugs, , Reporting Bugs, emacs, The GNU Emacs Manual}, for
  2152. instructions how to do that.
  2153. The file @file{etc/PROBLEMS} in the Emacs distribution lists various
  2154. known problems with building and using Emacs on specific platforms;
  2155. type @kbd{C-h C-p} to read it.
  2156. @menu
  2157. * Problems with very large files::
  2158. * ^M in the shell buffer::
  2159. * Problems with Shell Mode::
  2160. * Termcap/Terminfo entries for Emacs::
  2161. * Errors with init files::
  2162. * Emacs ignores X resources::
  2163. * Emacs ignores frame parameters::
  2164. * Editing files with $ in the name::
  2165. * Shell mode loses the current directory::
  2166. * Security risks with Emacs::
  2167. * Dired claims that no file is on this line::
  2168. @end menu
  2169. @node Problems with very large files
  2170. @section Does Emacs have problems with files larger than 8 megabytes?
  2171. @cindex Very large files, opening
  2172. @cindex Large files, opening
  2173. @cindex Opening very large files
  2174. @cindex Maximum file size
  2175. @cindex Files, maximum size
  2176. Old versions (i.e., anything before 19.29) of Emacs had problems editing
  2177. files larger than 8 megabytes. In versions 19.29 and later, the maximum
  2178. buffer size is at least 2^27-1, or 134,217,727 bytes, or 132 MBytes.
  2179. The maximum buffer size on 32-bit machines increased to 256 MBytes in
  2180. Emacs 22, and again to 512 MBytes in Emacs 23.2.
  2181. Emacs compiled on a 64-bit machine can handle much larger buffers.
  2182. @node ^M in the shell buffer
  2183. @section How do I get rid of @samp{^M} or echoed commands in my shell buffer?
  2184. @cindex Shell buffer, echoed commands and @samp{^M} in
  2185. @cindex Echoed commands in @code{shell-mode}
  2186. Try typing @kbd{M-x shell-strip-ctrl-m @key{RET}} while in @code{shell-mode} to
  2187. make them go away. If that doesn't work, you have several options:
  2188. For @code{tcsh}, put this in your @file{.cshrc} (or @file{.tcshrc})
  2189. file:
  2190. @example
  2191. if ($?EMACS) then
  2192. if ("$EMACS" =~ /*) then
  2193. if ($?tcsh) unset edit
  2194. stty nl
  2195. endif
  2196. endif
  2197. @end example
  2198. Or put this in your @file{.emacs_tcsh} or @file{~/.emacs.d/init_tcsh.sh} file:
  2199. @example
  2200. unset edit
  2201. stty nl
  2202. @end example
  2203. Alternatively, use @code{csh} in your shell buffers instead of
  2204. @code{tcsh}. One way is:
  2205. @lisp
  2206. (setq explicit-shell-file-name "/bin/csh")
  2207. @end lisp
  2208. @noindent
  2209. and another is to do this in your @file{.cshrc} (or @file{.tcshrc})
  2210. file:
  2211. @example
  2212. setenv ESHELL /bin/csh
  2213. @end example
  2214. @noindent
  2215. (You must start Emacs over again with the environment variable properly
  2216. set for this to take effect.)
  2217. You can also set the @code{ESHELL} environment variable in Emacs Lisp
  2218. with the following Lisp form,
  2219. @lisp
  2220. (setenv "ESHELL" "/bin/csh")
  2221. @end lisp
  2222. The above solutions try to prevent the shell from producing the
  2223. @samp{^M} characters in the first place. If this is not possible
  2224. (e.g., if you use a Windows shell), you can get Emacs to remove these
  2225. characters from the buffer by adding this to your @file{.emacs} init
  2226. file:
  2227. @smalllisp
  2228. (add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m)
  2229. @end smalllisp
  2230. On a related note: if your shell is echoing your input line in the shell
  2231. buffer, you might want to customize the @code{comint-process-echoes}
  2232. variable in your shell buffers, or try the following command in your
  2233. shell start-up file:
  2234. @example
  2235. stty -icrnl -onlcr -echo susp ^Z
  2236. @end example
  2237. @node Problems with Shell Mode
  2238. @section Why do I get an error message when I try to run @kbd{M-x shell}?
  2239. @cindex Shell Mode, problems
  2240. @cindex @code{explicit-shell-file-name}
  2241. This might happen because Emacs tries to look for the shell in a wrong
  2242. place. If you know where your shell executable is, set the variable
  2243. @code{explicit-shell-file-name} in your @file{.emacs} file to point to
  2244. its full file name.
  2245. @cindex Antivirus programs, and Shell Mode
  2246. Some people have trouble with Shell Mode on MS-Windows because of
  2247. intrusive antivirus software; disabling the resident antivirus program
  2248. solves the problems in those cases.
  2249. @node Termcap/Terminfo entries for Emacs
  2250. @section Where is the termcap/terminfo entry for terminal type @samp{emacs}?
  2251. @cindex Termcap
  2252. @cindex Terminfo
  2253. @cindex Emacs entries for termcap/terminfo
  2254. The termcap entry for terminal type @samp{emacs} is ordinarily put in
  2255. the @samp{TERMCAP} environment variable of subshells. It may help in
  2256. certain situations (e.g., using rlogin from shell buffer) to add an
  2257. entry for @samp{emacs} to the system-wide termcap file. Here is a
  2258. correct termcap entry for @samp{emacs}:
  2259. @example
  2260. emacs:tc=unknown:
  2261. @end example
  2262. To make a terminfo entry for @samp{emacs}, use @code{tic} or
  2263. @code{captoinfo}. You need to generate
  2264. @file{/usr/lib/terminfo/e/emacs}. It may work to simply copy
  2265. @file{/usr/lib/terminfo/d/dumb} to @file{/usr/lib/terminfo/e/emacs}.
  2266. Having a termcap/terminfo entry will not enable the use of full screen
  2267. programs in shell buffers. Use @kbd{M-x terminal-emulator} for that
  2268. instead.
  2269. A workaround to the problem of missing termcap/terminfo entries is to
  2270. change terminal type @samp{emacs} to type @samp{dumb} or @samp{unknown}
  2271. in your shell start up file. @code{csh} users could put this in their
  2272. @file{.cshrc} files:
  2273. @example
  2274. if ("$term" == emacs) set term=dumb
  2275. @end example
  2276. @node Errors with init files
  2277. @section Why does Emacs say @samp{Error in init file}?
  2278. @cindex Error in @file{.emacs}
  2279. @cindex Error in init file
  2280. @cindex Init file, errors in
  2281. @cindex @file{.emacs} file, errors in
  2282. @cindex Debugging @file{.emacs} file
  2283. An error occurred while loading either your @file{.emacs} file or the
  2284. system-wide file @file{site-lisp/default.el}. Emacs 21.1 and later pops the
  2285. @file{*Messages*} buffer, and puts there some additional information
  2286. about the error, to provide some hints for debugging.
  2287. For information on how to debug your @file{.emacs} file, see
  2288. @ref{Debugging a customization file}.
  2289. It may be the case that you need to load some package first, or use a
  2290. hook that will be evaluated after the package is loaded. A common case
  2291. of this is explained in @ref{Terminal setup code works after Emacs has
  2292. begun}.
  2293. @node Emacs ignores X resources
  2294. @section Why does Emacs ignore my X resources (my .Xdefaults file)?
  2295. @cindex X resources being ignored
  2296. @cindex Ignored X resources
  2297. @cindex @file{.Xdefaults}
  2298. As of version 19, Emacs searches for X resources in the files specified
  2299. by the following environment variables:
  2300. @itemize @bullet
  2301. @item @code{XFILESEARCHPATH}
  2302. @item @code{XUSERFILESEARCHPATH}
  2303. @item @code{XAPPLRESDIR}
  2304. @end itemize
  2305. This emulates the functionality provided by programs written using the
  2306. Xt toolkit.
  2307. @code{XFILESEARCHPATH} and @code{XUSERFILESEARCHPATH} should be a list
  2308. of file names separated by colons. @code{XAPPLRESDIR} should be a list
  2309. of directory names separated by colons.
  2310. Emacs searches for X resources:
  2311. @enumerate
  2312. @item
  2313. specified on the command line, with the @samp{-xrm RESOURCESTRING} option,
  2314. @item
  2315. then in the value of the @samp{XENVIRONMENT} environment variable,
  2316. @itemize @minus
  2317. @item
  2318. or if that is unset, in the file named
  2319. @file{~/.Xdefaults-@var{hostname}} if it exists (where @var{hostname} is
  2320. the name of the machine Emacs is running on),
  2321. @end itemize
  2322. @item
  2323. then in the screen-specific and server-wide resource properties provided
  2324. by the server,
  2325. @itemize @minus
  2326. @item
  2327. or if those properties are unset, in the file named @file{~/.Xdefaults}
  2328. if it exists,
  2329. @end itemize
  2330. @item
  2331. then in the files listed in @samp{XUSERFILESEARCHPATH},
  2332. @itemize @minus
  2333. @item
  2334. or in files named @file{@var{lang}/Emacs} in directories listed in
  2335. @samp{XAPPLRESDIR} (where @var{lang} is the value of the @code{LANG}
  2336. environment variable), if the @samp{LANG} environment variable is set,
  2337. @item
  2338. or in files named Emacs in the directories listed in @samp{XAPPLRESDIR}
  2339. @item
  2340. or in @file{~/@var{lang}/Emacs} (if the @code{LANG} environment variable
  2341. is set),
  2342. @item
  2343. or in @file{~/Emacs},
  2344. @end itemize
  2345. @item
  2346. then in the files listed in @code{XFILESEARCHPATH}.
  2347. @end enumerate
  2348. @node Emacs ignores frame parameters
  2349. @section Why don't my customizations of the frame parameters work?
  2350. @cindex Frame parameters
  2351. This probably happens because you have set the frame parameters in the
  2352. variable @code{initial-frame-alist}. That variable holds parameters
  2353. used only for the first frame created when Emacs starts. To customize
  2354. the parameters of all frames, change the variable
  2355. @code{default-frame-alist} instead.
  2356. These two variables exist because many users customize the initial frame
  2357. in a special way. For example, you could determine the position and
  2358. size of the initial frame, but would like to control the geometry of the
  2359. other frames by individually positioning each one of them.
  2360. @node Editing files with $ in the name
  2361. @section How do I edit a file with a @samp{$} in its name?
  2362. @cindex Editing files with @samp{$} in the name
  2363. @cindex @samp{$} in file names
  2364. @cindex File names containing @samp{$}, editing
  2365. When entering a file name in the minibuffer, Emacs will attempt to expand
  2366. a @samp{$} followed by a word as an environment variable. To suppress
  2367. this behavior, type @kbd{$$} instead.
  2368. @node Shell mode loses the current directory
  2369. @section Why does shell mode lose track of the shell's current directory?
  2370. @cindex Current directory and @code{shell-mode}
  2371. @cindex @code{shell-mode} and current directory
  2372. @cindex Directory, current in @code{shell-mode}
  2373. Emacs has no way of knowing when the shell actually changes its
  2374. directory. This is an intrinsic limitation of Unix. So it tries to
  2375. guess by recognizing @samp{cd} commands. If you type @kbd{cd} followed
  2376. by a directory name with a variable reference (@kbd{cd $HOME/bin}) or
  2377. with a shell metacharacter (@kbd{cd ../lib*}), Emacs will fail to
  2378. correctly guess the shell's new current directory. A huge variety of
  2379. fixes and enhancements to shell mode for this problem have been written
  2380. to handle this problem (@pxref{Finding a package with particular
  2381. functionality}).
  2382. You can tell Emacs the shell's current directory with the command
  2383. @kbd{M-x dirs}.
  2384. @node Security risks with Emacs
  2385. @section Are there any security risks in Emacs?
  2386. @cindex Security with Emacs
  2387. @cindex @samp{movemail} and security
  2388. @cindex @code{file-local-variable} and security
  2389. @cindex Synthetic X events and security
  2390. @cindex X events and security
  2391. @itemize @bullet
  2392. @item
  2393. The @file{movemail} incident. (No, this is not a risk.)
  2394. In his book @cite{The Cuckoo's Egg}, Cliff Stoll describes this in
  2395. chapter 4. The site at LBL had installed the @file{/etc/movemail}
  2396. program setuid root. (As of version 19, @file{movemail} is in your
  2397. architecture-specific directory; type @kbd{C-h v exec-directory
  2398. @key{RET}} to see what it is.) Since @code{movemail} had not been
  2399. designed for this situation, a security hole was created and users could
  2400. get root privileges.
  2401. @code{movemail} has since been changed so that this security hole will
  2402. not exist, even if it is installed setuid root. However,
  2403. @code{movemail} no longer needs to be installed setuid root, which
  2404. should eliminate this particular risk.
  2405. We have heard unverified reports that the 1988 Internet worm took
  2406. advantage of this configuration problem.
  2407. @item
  2408. The @code{file-local-variable} feature. (Yes, a risk, but easy to
  2409. change.)
  2410. There is an Emacs feature that allows the setting of local values for
  2411. variables when editing a file by including specially formatted text near
  2412. the end of the file. This feature also includes the ability to have
  2413. arbitrary Emacs Lisp code evaluated when the file is visited.
  2414. Obviously, there is a potential for Trojan horses to exploit this
  2415. feature.
  2416. As of Emacs 22, Emacs has a list of local variables that are known to
  2417. be safe to set. If a file tries to set any variable outside this
  2418. list, it asks the user to confirm whether the variables should be set.
  2419. You can also tell Emacs whether to allow the evaluation of Emacs Lisp
  2420. code found at the bottom of files by setting the variable
  2421. @code{enable-local-eval}.
  2422. @xref{File Variables,,, emacs, The GNU Emacs Manual}.
  2423. @item
  2424. Synthetic X events. (Yes, a risk; use @samp{MIT-MAGIC-COOKIE-1} or
  2425. better.)
  2426. Emacs accepts synthetic X events generated by the @code{SendEvent}
  2427. request as though they were regular events. As a result, if you are
  2428. using the trivial host-based authentication, other users who can open X
  2429. connections to your X workstation can make your Emacs process do
  2430. anything, including run other processes with your privileges.
  2431. The only fix for this is to prevent other users from being able to open
  2432. X connections. The standard way to prevent this is to use a real
  2433. authentication mechanism, such as @samp{MIT-MAGIC-COOKIE-1}. If using
  2434. the @code{xauth} program has any effect, then you are probably using
  2435. @samp{MIT-MAGIC-COOKIE-1}. Your site may be using a superior
  2436. authentication method; ask your system administrator.
  2437. If real authentication is not a possibility, you may be satisfied by
  2438. just allowing hosts access for brief intervals while you start your X
  2439. programs, then removing the access. This reduces the risk somewhat by
  2440. narrowing the time window when hostile users would have access, but
  2441. @emph{does not eliminate the risk}.
  2442. On most computers running Unix and X, you enable and disable
  2443. access using the @code{xhost} command. To allow all hosts access to
  2444. your X server, use
  2445. @example
  2446. xhost +
  2447. @end example
  2448. @noindent
  2449. at the shell prompt, which (on an HP machine, at least) produces the
  2450. following message:
  2451. @example
  2452. access control disabled, clients can connect from any host
  2453. @end example
  2454. To deny all hosts access to your X server (except those explicitly
  2455. allowed by name), use
  2456. @example
  2457. xhost -
  2458. @end example
  2459. On the test HP computer, this command generated the following message:
  2460. @example
  2461. access control enabled, only authorized clients can connect
  2462. @end example
  2463. @end itemize
  2464. @node Dired claims that no file is on this line
  2465. @section Dired says, @samp{no file on this line} when I try to do something.
  2466. @cindex Dired does not see a file
  2467. Dired uses a regular expression to find the beginning of a file name.
  2468. In a long Unix-style directory listing (@samp{ls -l}), the file name
  2469. starts after the date. The regexp has thus been written to look for the
  2470. date. By default, it should understand dates and times regardless of
  2471. the language, but if your directory listing has an unusual format, Dired
  2472. may get confused.
  2473. There are two approaches to solving this. The first one involves
  2474. setting things up so that @samp{ls -l} outputs a more standard format.
  2475. See your OS manual for more information.
  2476. The second approach involves changing the regular expression used by
  2477. dired, @code{directory-listing-before-filename-regexp}.
  2478. @c ------------------------------------------------------------
  2479. @node Compiling and installing Emacs
  2480. @chapter Compiling and installing Emacs
  2481. @cindex Compiling and installing Emacs
  2482. @menu
  2483. * Installing Emacs::
  2484. * Problems building Emacs::
  2485. @end menu
  2486. @node Installing Emacs
  2487. @section How do I install Emacs?
  2488. @cindex Installing Emacs
  2489. @cindex Unix systems, installing Emacs on
  2490. @cindex Downloading and installing Emacs
  2491. @cindex Building Emacs from source
  2492. @cindex Source code, building Emacs from
  2493. This answer is meant for users of Unix and Unix-like systems. Users of
  2494. other operating systems should see the series of questions beginning
  2495. with @ref{Emacs for MS-DOS}, which describe where to get non-Unix source
  2496. and binaries, and how to install Emacs on those systems.
  2497. Most GNU/Linux distributions provide pre-built Emacs packages.
  2498. If Emacs is not installed already, you can install it by running (as
  2499. root) a command such as @samp{yum install emacs} (Red Hat and
  2500. derivatives) or @samp{apt-get install emacs} (Debian and derivatives).
  2501. If you want to compile Emacs yourself, read the file @file{INSTALL} in
  2502. the source distribution. In brief:
  2503. @itemize @bullet
  2504. @item
  2505. First download the Emacs sources. @xref{Current GNU distributions}, for
  2506. a list of ftp sites that make them available. On @file{ftp.gnu.org},
  2507. the main GNU distribution site, sources are available as
  2508. @c Don't include VER in the file name, because pretests are not there.
  2509. @uref{ftp://ftp.gnu.org/pub/gnu/emacs/emacs-VERSION.tar.gz}
  2510. (Replace @samp{VERSION} with the relevant version number, e.g. @samp{23.1}.)
  2511. @item
  2512. Next uncompress and extract the source files. This requires
  2513. the @code{gzip} and @code{tar} programs, which are standard utilities.
  2514. If your system does not have them, these can also be downloaded from
  2515. @file{ftp.gnu.org}.
  2516. GNU @code{tar} can uncompress and extract in a single-step:
  2517. @example
  2518. tar -zxvf emacs-VERSION.tar.gz
  2519. @end example
  2520. @item
  2521. At this point, the Emacs sources should be sitting in a directory called
  2522. @file{emacs-VERSION}. On most common Unix and Unix-like systems,
  2523. you should be able to compile Emacs with the following commands:
  2524. @example
  2525. cd emacs-VERSION
  2526. ./configure # configure Emacs for your particular system
  2527. make # use Makefile to build components, then Emacs
  2528. @end example
  2529. If the @code{make} completes successfully, the odds are fairly good that
  2530. the build has gone well. (@xref{Problems building Emacs}, if you weren't
  2531. successful.)
  2532. @item
  2533. By default, Emacs is installed in @file{/usr/local}. To actually
  2534. install files, become the superuser and type
  2535. @example
  2536. make install
  2537. @end example
  2538. Note that @samp{make install} will overwrite @file{/usr/local/bin/emacs}
  2539. and any Emacs Info files that might be in @file{/usr/local/share/info/}.
  2540. @end itemize
  2541. @node Problems building Emacs
  2542. @section What should I do if I have trouble building Emacs?
  2543. @cindex Problems building Emacs
  2544. @cindex Errors when building Emacs
  2545. First look in the file @file{etc/PROBLEMS} (where you unpack the Emacs
  2546. source) to see if there is already a solution for your problem. Next,
  2547. look for other questions in this FAQ that have to do with Emacs
  2548. installation and compilation problems.
  2549. If you'd like to have someone look at your problem and help solve it,
  2550. see @ref{Help installing Emacs}.
  2551. If you cannot find a solution in the documentation, please report the
  2552. problem (@pxref{Reporting bugs}).
  2553. @c ------------------------------------------------------------
  2554. @node Finding Emacs and related packages
  2555. @chapter Finding Emacs and related packages
  2556. @cindex Finding Emacs and related packages
  2557. @menu
  2558. * Finding Emacs on the Internet::
  2559. * Finding a package with particular functionality::
  2560. * Packages that do not come with Emacs::
  2561. * Spell-checkers::
  2562. * Current GNU distributions::
  2563. * Difference between Emacs and XEmacs::
  2564. * Emacs for minimalists::
  2565. * Emacs for MS-DOS::
  2566. * Emacs for MS-Windows::
  2567. * Emacs for GNUstep::
  2568. * Emacs for Mac OS X::
  2569. @end menu
  2570. @node Finding Emacs on the Internet
  2571. @section Where can I get Emacs on the net?
  2572. @cindex Finding Emacs on the Internet
  2573. @cindex Downloading Emacs
  2574. Information on downloading Emacs is available at
  2575. @uref{http://www.gnu.org/software/emacs/, the Emacs home-page}.
  2576. @xref{Installing Emacs}, for information on how to obtain and build the latest
  2577. version of Emacs, and see @ref{Current GNU distributions}, for a list of
  2578. archive sites that make GNU software available.
  2579. @node Finding a package with particular functionality
  2580. @section How do I find a Emacs Lisp package that does XXX?
  2581. @cindex Package, finding
  2582. @cindex Finding an Emacs Lisp package
  2583. @cindex Functionality, finding a particular package
  2584. First of all, you should check to make sure that the package isn't
  2585. already available. For example, typing @kbd{M-x apropos @key{RET}
  2586. wordstar @key{RET}} lists all functions and variables containing the
  2587. string @samp{wordstar}.
  2588. It is also possible that the package is on your system, but has not been
  2589. loaded. To see which packages are available for loading, look through
  2590. your computer's lisp directory (@pxref{File-name conventions}). The Lisp
  2591. source to most packages contains a short description of how they
  2592. should be loaded, invoked, and configured---so before you use or
  2593. modify a Lisp package, see if the author has provided any hints in the
  2594. source code.
  2595. The command @kbd{C-h p} (@code{finder-by-keyword}) allows you to browse
  2596. the constituent Emacs packages.
  2597. For advice on how to find extra packages that are not part of Emacs,
  2598. see @ref{Packages that do not come with Emacs}.
  2599. @node Packages that do not come with Emacs
  2600. @section Where can I get Emacs Lisp packages that don't come with Emacs?
  2601. @cindex Unbundled packages
  2602. @cindex Finding other packages
  2603. @cindex Lisp packages that do not come with Emacs
  2604. @cindex Packages, those that do not come with Emacs
  2605. @cindex Emacs Lisp List
  2606. @cindex Emacs Lisp Archive
  2607. Your first port of call should be the @kbd{M-x list-packages} command.
  2608. This connects to the @uref{http:///elpa.gnu.org, GNU ELPA} (``Emacs
  2609. Lisp Package Archive'') server and fetches the list of additional
  2610. packages that it offers. These are GNU packages that are available
  2611. for use with Emacs, but are distributed separately. Select a package
  2612. to get more details about the features that it offers, and then if you
  2613. wish, Emacs can download and automatically install it for you.
  2614. @uref{http://www.damtp.cam.ac.uk/user/sje30/emacs/ell.html, The Emacs Lisp
  2615. List (ELL)}, maintained by @email{S.J.Eglen@@damtp.cam.ac.uk, Stephen Eglen},
  2616. aims to provide one compact list with links to all of the current Emacs
  2617. Lisp files on the Internet. The ELL can be browsed over the web, or
  2618. from Emacs with @uref{http://www.damtp.cam.ac.uk/user/sje30/emacs/ell.el,
  2619. the @file{ell} package}.
  2620. Many authors post their packages to the @uref{news:gnu.emacs.sources,
  2621. Emacs sources newsgroup}. You can search the archives of this
  2622. group with @uref{http://groups.google.com/group/gnu.emacs.sources, Google},
  2623. or @uref{http://dir.gmane.org/gmane.emacs.sources, Gmane}, for example.
  2624. Several packages are stored in
  2625. @uref{http://emacswiki.org/elisp/, the Lisp area of the Emacs Wiki}.
  2626. Read the file @file{etc/MORE.STUFF} for more information about
  2627. external packages.
  2628. @node Spell-checkers
  2629. @section Spell-checkers
  2630. @cindex Spell-checker
  2631. @cindex Checking spelling
  2632. @cindex Ispell
  2633. @cindex Aspell
  2634. @cindex Hunspell
  2635. Various spell-checkers are compatible with Emacs, including:
  2636. @table @b
  2637. @item GNU Aspell
  2638. @uref{http://aspell.net/}
  2639. @item Ispell
  2640. @uref{http://fmg-www.cs.ucla.edu/geoff/ispell.html}
  2641. @item Hunspell
  2642. @uref{http://hunspell.sourceforge.net/}
  2643. @end table
  2644. @node Current GNU distributions
  2645. @section Where can I get other up-to-date GNU stuff?
  2646. @cindex Current GNU distributions
  2647. @cindex Sources for current GNU distributions
  2648. @cindex Stuff, current GNU
  2649. @cindex Up-to-date GNU stuff
  2650. @cindex Finding current GNU software
  2651. @cindex Official GNU software sites
  2652. The most up-to-date official GNU software is normally kept at
  2653. @uref{ftp://ftp.gnu.org/pub/gnu}
  2654. A list of sites mirroring @samp{ftp.gnu.org} can be found at
  2655. @uref{http://www.gnu.org/order/ftp.html}
  2656. @node Difference between Emacs and XEmacs
  2657. @section What is the difference between Emacs and XEmacs (formerly Lucid Emacs)?
  2658. @cindex XEmacs
  2659. @cindex Difference Emacs and XEmacs
  2660. @cindex Lucid Emacs
  2661. @cindex Epoch
  2662. XEmacs is a branch version of Emacs. It was first called Lucid Emacs,
  2663. and was initially derived from a prerelease version of Emacs 19. In
  2664. this FAQ, we use the name ``Emacs'' only for the official version.
  2665. Emacs and XEmacs each come with Lisp packages that are lacking in the
  2666. other. The two versions have some significant differences at the Lisp
  2667. programming level. Their current features are roughly comparable,
  2668. though the support for some operating systems, character sets and
  2669. specific packages might be quite different.
  2670. Some XEmacs code has been contributed to Emacs, and we would like to
  2671. use other parts, but the earlier XEmacs maintainers did not always
  2672. keep track of the authors of contributed code, which makes it
  2673. impossible for the FSF to get copyright papers signed for that code.
  2674. (The FSF requires these papers for all the code included in the Emacs
  2675. release, aside from generic C support packages that retain their
  2676. separate identity and are not integrated into the code of Emacs
  2677. proper.)
  2678. If you want to talk about these two versions and distinguish them,
  2679. please call them ``Emacs'' and ``XEmacs.'' To contrast ``XEmacs''
  2680. with ``GNU Emacs'' would be misleading, since XEmacs too has its
  2681. origin in the work of the GNU Project. Terms such as ``Emacsen'' and
  2682. ``(X)Emacs'' are not wrong, but they are not very clear, so it
  2683. is better to write ``Emacs and XEmacs.''
  2684. @node Emacs for minimalists
  2685. @section I don't have enough disk space to install Emacs
  2686. @cindex Zile
  2687. @cindex Not enough disk space to install Emacs
  2688. GNU Zile is a lightweight Emacs clone. Zile is short for @samp{Zile Is
  2689. Lossy Emacs}. It has all of Emacs's basic editing features. The Zile
  2690. binary typically has a size of about 130 kbytes, so this can be useful
  2691. if you are in an extremely space-restricted environment. More
  2692. information is available from
  2693. @uref{http://www.gnu.org/software/zile/}
  2694. @node Emacs for MS-DOS
  2695. @section Where can I get Emacs for MS-DOS?
  2696. @cindex MS-DOS, Emacs for
  2697. @cindex DOS, Emacs for
  2698. @cindex Compiling Emacs for DOS
  2699. @cindex Emacs for MS-DOS
  2700. To build Emacs from source for MS-DOS, see the instructions in the file
  2701. @file{msdos/INSTALL} in the distribution. The DOS port builds and runs
  2702. on plain DOS, and also on all versions of MS-Windows from version 3.X
  2703. onwards, including Windows XP and Vista.
  2704. The file @file{etc/PROBLEMS} contains some additional information
  2705. regarding Emacs under MS-DOS.
  2706. A pre-built binary distribution of the old Emacs 20 is available, as
  2707. described at
  2708. @uref{ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/emacs.README}
  2709. For a list of other MS-DOS implementations of Emacs (and Emacs
  2710. look-alikes), consult the list of ``Emacs implementations and literature,''
  2711. available at
  2712. @uref{http://www.finseth.com/emacs.html}
  2713. Note that while many of these programs look similar to Emacs, they often
  2714. lack certain features, such as the Emacs Lisp extension language.
  2715. @node Emacs for MS-Windows
  2716. @section Where can I get Emacs for Microsoft Windows?
  2717. @cindex FAQ for Emacs on MS-Windows
  2718. @cindex Emacs for MS-Windows
  2719. @cindex Microsoft Windows, Emacs for
  2720. There is a @uref{http://www.gnu.org/software/emacs/windows/ntemacs.html,
  2721. separate FAQ} for Emacs on MS-Windows. For MS-DOS, @pxref{Emacs for MS-DOS}.
  2722. @node Emacs for GNUstep
  2723. @section Where can I get Emacs for GNUstep?
  2724. @cindex GNUstep, Emacs for
  2725. Beginning with version 23.1, Emacs supports GNUstep natively.
  2726. See the file @file{nextstep/INSTALL} in the distribution.
  2727. @node Emacs for Mac OS X
  2728. @section Where can I get Emacs for Mac OS X?
  2729. @cindex Apple computers, Emacs for
  2730. @cindex Macintosh, Emacs for
  2731. @cindex Mac OS X, Emacs for
  2732. Beginning with version 22.1, Emacs supports Mac OS X natively.
  2733. See the file @file{nextstep/INSTALL} in the distribution.
  2734. @c ------------------------------------------------------------
  2735. @node Key bindings
  2736. @chapter Key bindings
  2737. @cindex Key bindings
  2738. @menu
  2739. * Binding keys to commands::
  2740. * Invalid prefix characters::
  2741. * Terminal setup code works after Emacs has begun::
  2742. * Working with function and arrow keys::
  2743. * X key translations for Emacs::
  2744. * Backspace invokes help::
  2745. * Swapping keys::
  2746. * Producing C-XXX with the keyboard::
  2747. * No Meta key::
  2748. * No Escape key::
  2749. * Compose Character::
  2750. * Binding combinations of modifiers and function keys::
  2751. * Meta key does not work in xterm::
  2752. * ExtendChar key does not work as Meta::
  2753. * SPC no longer completes file names::
  2754. @end menu
  2755. @node Binding keys to commands
  2756. @section How do I bind keys (including function keys) to commands?
  2757. @cindex Binding keys to commands
  2758. @cindex Keys, binding to commands
  2759. @cindex Commands, binding keys to
  2760. Keys can be bound to commands either interactively or in your
  2761. @file{.emacs} file. To interactively bind keys for all modes, type
  2762. @kbd{M-x global-set-key @key{RET} @var{key} @var{cmd} @key{RET}}.
  2763. To bind a key just in the current major mode, type @kbd{M-x
  2764. local-set-key @key{RET} @var{key} @var{cmd} @key{RET}}.
  2765. @xref{Key Bindings,,, emacs, The GNU Emacs Manual}.
  2766. To make the process of binding keys interactively easier, use the
  2767. following ``trick'': First bind the key interactively, then immediately
  2768. type @kbd{C-x @key{ESC} @key{ESC} C-a C-k C-g}. Now, the command needed
  2769. to bind the key is in the kill ring, and can be yanked into your
  2770. @file{.emacs} file. If the key binding is global, no changes to the
  2771. command are required. For example,
  2772. @lisp
  2773. (global-set-key (quote [f1]) (quote help-for-help))
  2774. @end lisp
  2775. @noindent
  2776. can be placed directly into the @file{.emacs} file. If the key binding is
  2777. local, the command is used in conjunction with the @samp{add-hook} function.
  2778. For example, in TeX mode, a local binding might be
  2779. @lisp
  2780. (add-hook 'tex-mode-hook
  2781. (lambda ()
  2782. (local-set-key (quote [f1]) (quote help-for-help))))
  2783. @end lisp
  2784. @itemize @bullet
  2785. @item
  2786. Control characters in key sequences, in the form yanked from the kill
  2787. ring are given in their graphic form---i.e., @key{CTRL} is shown as
  2788. @samp{^}, @key{TAB} as a set of spaces (usually 8), etc. You may want
  2789. to convert these into their vector or string forms.
  2790. @item
  2791. If a prefix key of the character sequence to be bound is already
  2792. bound as a complete key, then you must unbind it before the new
  2793. binding. For example, if @kbd{ESC @{} is previously bound:
  2794. @lisp
  2795. (global-unset-key [?\e ?@{]) ;; or
  2796. (local-unset-key [?\e ?@{])
  2797. @end lisp
  2798. @item
  2799. Aside from commands and ``lambda lists,'' a vector or string also
  2800. can be bound to a key and thus treated as a macro. For example:
  2801. @lisp
  2802. (global-set-key [f10] [?\C-x?\e?\e?\C-a?\C-k?\C-g]) ;; or
  2803. (global-set-key [f10] "\C-x\e\e\C-a\C-k\C-g")
  2804. @end lisp
  2805. @end itemize
  2806. @node Invalid prefix characters
  2807. @section Why does Emacs say @samp{Key sequence XXX uses invalid prefix characters}?
  2808. @cindex Prefix characters, invalid
  2809. @cindex Invalid prefix characters
  2810. @cindex Misspecified key sequences
  2811. Usually, one of two things has happened. In one case, the control
  2812. character in the key sequence has been misspecified (e.g. @samp{C-f}
  2813. used instead of @samp{\C-f} within a Lisp expression). In the other
  2814. case, a @dfn{prefix key} in the keystroke sequence you were trying to bind
  2815. was already bound as a @dfn{complete key}. Historically, the @samp{ESC [}
  2816. prefix was usually the problem, in which case you should evaluate either
  2817. of these forms before attempting to bind the key sequence:
  2818. @lisp
  2819. (global-unset-key [?\e ?[]) ;; or
  2820. (global-unset-key "\e[")
  2821. @end lisp
  2822. @node Terminal setup code works after Emacs has begun
  2823. @section Why doesn't this [terminal or window-system setup] code work in my @file{.emacs} file, but it works just fine after Emacs starts up?
  2824. @cindex Terminal setup code in @file{.emacs}
  2825. During startup, Emacs initializes itself according to a given code/file
  2826. order. If some of the code executed in your @file{.emacs} file needs to
  2827. be postponed until the initial terminal or window-system setup code has
  2828. been executed but is not, then you will experience this problem (this
  2829. code/file execution order is not enforced after startup).
  2830. To postpone the execution of Emacs Lisp code until after terminal or
  2831. window-system setup, treat the code as a @dfn{lambda list} and set the
  2832. value of either the @code{term-setup-hook} or @code{window-setup-hook}
  2833. variable to this lambda function. For example,
  2834. @lisp
  2835. (add-hook 'term-setup-hook
  2836. (lambda ()
  2837. (when (string-match "\\`vt220" (or (getenv "TERM") ""))
  2838. ;; Make vt220's "Do" key behave like M-x:
  2839. (global-set-key [do] 'execute-extended-command))))
  2840. @end lisp
  2841. For information on what Emacs does every time it is started, see the
  2842. @file{lisp/startup.el} file.
  2843. @node Working with function and arrow keys
  2844. @section How do I tell what characters or symbols my function or arrow keys emit?
  2845. @cindex Working with arrow keys
  2846. @cindex Arrow keys, symbols generated by
  2847. @cindex Working with function keys
  2848. @cindex Function keys, symbols generated by
  2849. @cindex Symbols generated by function keys
  2850. Type @kbd{C-h c} then the function or arrow keys. The command will
  2851. return either a function key symbol or character sequence (see the
  2852. Emacs documentation for an explanation). This works for other
  2853. keys as well.
  2854. @node X key translations for Emacs
  2855. @section How do I set the X key ``translations'' for Emacs?
  2856. @cindex X key translations
  2857. @cindex Key translations under X
  2858. @cindex Translations for keys under X
  2859. Emacs is not written using the Xt library by default, so there are no
  2860. ``translations'' to be set. (We aren't sure how to set such translations
  2861. if you do build Emacs with Xt; please let us know if you've done this!)
  2862. The only way to affect the behavior of keys within Emacs is through
  2863. @code{xmodmap} (outside Emacs) or @code{define-key} (inside Emacs). The
  2864. @code{define-key} command should be used in conjunction with the
  2865. @code{function-key-map} map. For instance,
  2866. @lisp
  2867. (define-key function-key-map [M-@key{TAB}] [?\M-\t])
  2868. @end lisp
  2869. @noindent
  2870. defines the @kbd{M-@key{TAB}} key sequence.
  2871. @node Backspace invokes help
  2872. @section Why does the @key{Backspace} key invoke help?
  2873. @cindex Backspace key invokes help
  2874. @cindex Help invoked by Backspace
  2875. @cindex DEL key does not delete
  2876. The @key{Backspace} key (on most keyboards) generates @acronym{ASCII} code 8.
  2877. @kbd{C-h} sends the same code. In Emacs by default @kbd{C-h} invokes
  2878. help-command. This is intended to be easy to remember since the first
  2879. letter of @samp{help} is @samp{h}. The easiest solution to this problem
  2880. is to use @kbd{C-h} (and @key{Backspace}) for help and @key{DEL} (the
  2881. @key{Delete} key) for deleting the previous character.
  2882. For many people this solution may be problematic:
  2883. @itemize @bullet
  2884. @item
  2885. They normally use @key{Backspace} outside of Emacs for deleting the
  2886. previous character. This can be solved by making @key{DEL} the command
  2887. for deleting the previous character outside of Emacs. On many Unix
  2888. systems, this command will remap @key{DEL}:
  2889. @example
  2890. stty erase `^?'
  2891. @end example
  2892. @item
  2893. The user may prefer the @key{Backspace} key for deleting the
  2894. previous character because it is more conveniently located on their
  2895. keyboard or because they don't even have a separate @key{Delete} key.
  2896. In this case, the @key{Backspace} key should be made to behave like
  2897. @key{Delete}. There are several methods.
  2898. @itemize @minus
  2899. @item
  2900. Some terminals (e.g., VT3## terminals) and terminal emulators (e.g.,
  2901. TeraTerm) allow the character generated by the @key{Backspace} key to be
  2902. changed from a setup menu.
  2903. @item
  2904. You may be able to get a keyboard that is completely programmable, or a
  2905. terminal emulator that supports remapping of any key to any other key.
  2906. @item
  2907. With Emacs 21.1 and later, you can control the effect of the
  2908. @key{Backspace} and @key{Delete} keys, on both dumb terminals and a
  2909. windowed displays, by customizing the option
  2910. @code{normal-erase-is-backspace-mode}, or by invoking @kbd{M-x
  2911. normal-erase-is-backspace}. See the documentation of these symbols
  2912. (@pxref{Emacs Lisp documentation}) for more info.
  2913. @item
  2914. It is possible to swap the @key{Backspace} and @key{DEL} keys inside
  2915. Emacs:
  2916. @lisp
  2917. (keyboard-translate ?\C-h ?\C-?)
  2918. @end lisp
  2919. @noindent
  2920. This is the recommended method of forcing @key{Backspace} to act as
  2921. @key{DEL}, because it works even in modes which bind @key{DEL} to
  2922. something other than @code{delete-backward-char}.
  2923. Similarly, you could remap @key{DEL} to act as @kbd{C-d}, which by
  2924. default deletes forward:
  2925. @lisp
  2926. (keyboard-translate ?\C-? ?\C-d)
  2927. @end lisp
  2928. @xref{Swapping keys}, for further details about @code{keyboard-translate}.
  2929. @item
  2930. Another approach is to switch key bindings and put help on @kbd{C-x h}
  2931. instead:
  2932. @lisp
  2933. (global-set-key "\C-h" 'delete-backward-char)
  2934. ;; overrides mark-whole-buffer
  2935. (global-set-key "\C-xh" 'help-command)
  2936. @end lisp
  2937. @noindent
  2938. This method is not recommended, though: it only solves the problem for
  2939. those modes which bind @key{DEL} to @code{delete-backward-char}. Modes
  2940. which bind @key{DEL} to something else, such as @code{view-mode}, will
  2941. not work as you expect when you press the @key{Backspace} key. For this
  2942. reason, we recommend the @code{keyboard-translate} method, shown
  2943. above.
  2944. Other popular key bindings for help are @kbd{M-?} and @kbd{C-x ?}.
  2945. @end itemize
  2946. Don't try to bind @key{DEL} to @code{help-command}, because there are
  2947. many modes that have local bindings of @key{DEL} that will interfere.
  2948. @end itemize
  2949. When Emacs 21 or later runs on a windowed display, it binds the
  2950. @key{Delete} key to a command which deletes the character at point, to
  2951. make Emacs more consistent with keyboard operation on these systems.
  2952. For more information about troubleshooting this problem, see @ref{DEL
  2953. Does Not Delete, , If @key{DEL} Fails to Delete, emacs, The GNU Emacs
  2954. Manual}.
  2955. @node Swapping keys
  2956. @section How do I swap two keys?
  2957. @cindex Swapping keys
  2958. @cindex Keys, swapping
  2959. @cindex @code{keyboard-translate}
  2960. You can swap two keys (or key sequences) by using the
  2961. @code{keyboard-translate} function. For example, to turn @kbd{C-h}
  2962. into @key{DEL} and @key{DEL} to @kbd{C-h}, use
  2963. @lisp
  2964. (keyboard-translate ?\C-h ?\C-?) ; translate `C-h' to DEL
  2965. (keyboard-translate ?\C-? ?\C-h) ; translate DEL to `C-h'.
  2966. @end lisp
  2967. @noindent
  2968. The first key sequence of the pair after the function identifies what is
  2969. produced by the keyboard; the second, what is matched for in the
  2970. keymaps.
  2971. However, in the specific case of @kbd{C-h} and @key{DEL}, you should
  2972. toggle @code{normal-erase-is-backspace-mode} instead of calling
  2973. @code{keyboard-translate}.
  2974. @xref{DEL Does Not Delete,,, emacs, The GNU Emacs Manual}.
  2975. Keyboard translations are not the same as key bindings in keymaps.
  2976. Emacs contains numerous keymaps that apply in different situations, but
  2977. there is only one set of keyboard translations, and it applies to every
  2978. character that Emacs reads from the terminal. Keyboard translations
  2979. take place at the lowest level of input processing; the keys that are
  2980. looked up in keymaps contain the characters that result from keyboard
  2981. translation.
  2982. @node Producing C-XXX with the keyboard
  2983. @section How do I produce C-XXX with my keyboard?
  2984. @cindex Producing control characters
  2985. @cindex Generating control characters
  2986. @cindex Control characters, generating
  2987. On terminals (but not under X), some common ``aliases'' are:
  2988. @table @asis
  2989. @item @kbd{C-2} or @kbd{C-@key{SPC}}
  2990. @kbd{C-@@}
  2991. @item @kbd{C-6}
  2992. @kbd{C-^}
  2993. @item @kbd{C-7} or @kbd{C-S--}
  2994. @kbd{C-_}
  2995. @item @kbd{C-4}
  2996. @kbd{C-\}
  2997. @item @kbd{C-5}
  2998. @kbd{C-]}
  2999. @item @kbd{C-/}
  3000. @kbd{C-?}
  3001. @end table
  3002. Often other aliases exist; use the @kbd{C-h c} command and try
  3003. @key{CTRL} with all of the digits on your keyboard to see what gets
  3004. generated. You can also try the @kbd{C-h w} command if you know the
  3005. name of the command.
  3006. @node No Meta key
  3007. @section What if I don't have a @key{Meta} key?
  3008. @cindex No @key{Meta} key
  3009. @cindex @key{Meta} key, what to do if you lack it
  3010. On many keyboards, the @key{Alt} key acts as @key{Meta}, so try it.
  3011. Instead of typing @kbd{M-a}, you can type @kbd{@key{ESC} a}. In fact,
  3012. Emacs converts @kbd{M-a} internally into @kbd{@key{ESC} a} anyway
  3013. (depending on the value of @code{meta-prefix-char}). Note that you
  3014. press @key{Meta} and @key{a} together, but with @key{ESC}, you press
  3015. @key{ESC}, release it, and then press @key{a}.
  3016. @node No Escape key
  3017. @section What if I don't have an @key{Escape} key?
  3018. @cindex No Escape key
  3019. @cindex Lacking an Escape key
  3020. @cindex Escape key, lacking
  3021. Type @kbd{C-[} instead. This should send @acronym{ASCII} code 27 just like an
  3022. Escape key would. @kbd{C-3} may also work on some terminal (but not
  3023. under X). For many terminals (notably DEC terminals) @key{F11}
  3024. generates @key{ESC}. If not, the following form can be used to bind it:
  3025. @lisp
  3026. ;; F11 is the documented ESC replacement on DEC terminals.
  3027. (define-key function-key-map [f11] [?\e])
  3028. @end lisp
  3029. @node Compose Character
  3030. @section Can I make my @key{Compose Character} key behave like a @key{Meta} key?
  3031. @cindex @key{Compose Character} key, using as @key{Meta}
  3032. @cindex @key{Meta}, using @key{Compose Character} for
  3033. On a dumb terminal such as a VT220, no. It is rumored that certain
  3034. VT220 clones could have their @key{Compose} key configured this way. If
  3035. you're using X, you might be able to do this with the @code{xmodmap}
  3036. command.
  3037. @node Binding combinations of modifiers and function keys
  3038. @section How do I bind a combination of modifier key and function key?
  3039. @cindex Modifiers and function keys
  3040. @cindex Function keys and modifiers
  3041. @cindex Binding modifiers and function keys
  3042. You can represent modified function keys in vector format by adding
  3043. prefixes to the function key symbol. For example (from the Emacs
  3044. documentation):
  3045. @lisp
  3046. (global-set-key [?\C-x right] 'forward-page)
  3047. @end lisp
  3048. @noindent
  3049. where @samp{?\C-x} is the Lisp character constant for the character @kbd{C-x}.
  3050. You can use the modifier keys @key{Control}, @key{Meta}, @key{Hyper},
  3051. @key{Super}, @key{Alt}, and @key{Shift} with function keys. To
  3052. represent these modifiers, prepend the strings @samp{C-}, @samp{M-},
  3053. @samp{H-}, @samp{s-}, @samp{A-}, and @samp{S-} to the symbol name. Here
  3054. is how to make @kbd{H-M-RIGHT} move forward a word:
  3055. @lisp
  3056. (global-set-key [H-M-right] 'forward-word)
  3057. @end lisp
  3058. @itemize @bullet
  3059. @item
  3060. Not all modifiers are permitted in all situations. @key{Hyper},
  3061. @key{Super}, and @key{Alt} are not available on Unix character
  3062. terminals. Non-@acronym{ASCII} keys and mouse events (e.g. @kbd{C-=} and
  3063. @kbd{Mouse-1}) also fall under this category.
  3064. @end itemize
  3065. @xref{Binding keys to commands}, for general key binding instructions.
  3066. @node Meta key does not work in xterm
  3067. @section Why doesn't my @key{Meta} key work in an @code{xterm} window?
  3068. @cindex @key{Meta} key and @code{xterm}
  3069. @cindex Xterm and @key{Meta} key
  3070. @xref{Unibyte Mode,, Single-Byte Character Set Support, emacs, The GNU Emacs Manual}.
  3071. If the advice in the Emacs manual fails, try all of these methods before
  3072. asking for further help:
  3073. @itemize @bullet
  3074. @item
  3075. You may have big problems using @code{mwm} as your window manager.
  3076. (Does anyone know a good generic solution to allow the use of the
  3077. @key{Meta} key in Emacs with @file{mwm}?)
  3078. @item
  3079. For X11: Make sure it really is a @key{Meta} key. Use @code{xev} to
  3080. find out what keysym your @key{Meta} key generates. It should be either
  3081. @code{Meta_L} or @code{Meta_R}. If it isn't, use @file{xmodmap} to fix
  3082. the situation. If @key{Meta} does generate @code{Meta_L} or
  3083. @code{Meta_R}, but @kbd{M-x} produces a non-@acronym{ASCII} character, put this in
  3084. your @file{~/.Xdefaults} file:
  3085. @example
  3086. XTerm*eightBitInput: false
  3087. XTerm*eightBitOutput: true
  3088. @end example
  3089. @item
  3090. Make sure the @code{pty} the @code{xterm} is using is passing 8 bit
  3091. characters. @samp{stty -a} (or @samp{stty everything}) should show
  3092. @samp{cs8} somewhere. If it shows @samp{cs7} instead, use @samp{stty
  3093. cs8 -istrip} (or @samp{stty pass8}) to fix it.
  3094. @item
  3095. If there is an @code{rlogin} connection between @code{xterm} and Emacs, the
  3096. @samp{-8} argument may need to be given to rlogin to make it pass all 8 bits
  3097. of every character.
  3098. @item
  3099. If Emacs is running on Ultrix, it is reported that evaluating
  3100. @code{(set-input-mode t nil)} helps.
  3101. @item
  3102. If all else fails, you can make @code{xterm} generate @kbd{@key{ESC} W} when
  3103. you type @kbd{M-W}, which is the same conversion Emacs would make if it
  3104. got the @kbd{M-W} anyway. In X11R4, the following resource
  3105. specification will do this:
  3106. @example
  3107. XTerm.VT100.EightBitInput: false
  3108. @end example
  3109. @noindent
  3110. (This changes the behavior of the @code{insert-eight-bit} action.)
  3111. With older @code{xterm}s, you can specify this behavior with a translation:
  3112. @example
  3113. XTerm.VT100.Translations: #override \
  3114. Meta<KeyPress>: string(0x1b) insert()
  3115. @end example
  3116. @noindent
  3117. You might have to replace @samp{Meta} with @samp{Alt}.
  3118. @end itemize
  3119. @node ExtendChar key does not work as Meta
  3120. @section Why doesn't my @key{ExtendChar} key work as a @key{Meta} key under HP-UX 8.0 and 9.x?
  3121. @cindex @key{ExtendChar} key as @key{Meta}
  3122. @cindex @key{Meta}, using @key{ExtendChar} for
  3123. @cindex HP-UX, the @key{ExtendChar} key
  3124. This is a result of an internationalization extension in X11R4 and the
  3125. fact that HP is now using this extension. Emacs assumes that the
  3126. @code{XLookupString} function returns the same result regardless of the
  3127. @key{Meta} key state which is no longer necessarily true. Until Emacs
  3128. is fixed, the temporary kludge is to run this command after each time
  3129. the X server is started but preferably before any xterm clients are:
  3130. @example
  3131. xmodmap -e 'remove mod1 = Mode_switch'
  3132. @end example
  3133. @c FIXME: Emacs 21 supports I18N in X11; does that mean that this bug is
  3134. @c solved?
  3135. This will disable the use of the extra keysyms systemwide, which may be
  3136. undesirable if you actually intend to use them.
  3137. @node SPC no longer completes file names
  3138. @section Why doesn't SPC complete file names anymore?
  3139. @cindex @kbd{SPC} file name completion
  3140. Starting with Emacs 22.1, @kbd{SPC} no longer completes file names in
  3141. the minibuffer, so that file names with embedded spaces could be typed
  3142. without the need to quote the spaces.
  3143. You can get the old behavior by binding @kbd{SPC} to
  3144. @code{minibuffer-complete-word} in the minibuffer, as follows:
  3145. @lisp
  3146. (define-key minibuffer-local-filename-completion-map (kbd "SPC")
  3147. 'minibuffer-complete-word)
  3148. (define-key minibuffer-local-must-match-filename-map (kbd "SPC")
  3149. 'minibuffer-complete-word)
  3150. @end lisp
  3151. @c ------------------------------------------------------------
  3152. @node Alternate character sets
  3153. @chapter Alternate character sets
  3154. @cindex Alternate character sets
  3155. @menu
  3156. * Emacs does not display 8-bit characters::
  3157. * Inputting eight-bit characters::
  3158. * Right-to-left alphabets::
  3159. * How to add fonts::
  3160. @end menu
  3161. @node Emacs does not display 8-bit characters
  3162. @section How do I make Emacs display 8-bit characters?
  3163. @cindex Displaying eight-bit characters
  3164. @cindex Eight-bit characters, displaying
  3165. @xref{Unibyte Mode,, Single-byte Character Set Support, emacs, The GNU
  3166. Emacs Manual}. On a Unix, when Emacs runs on a text-only terminal
  3167. display or is invoked with @samp{emacs -nw}, you typically need to use
  3168. @code{set-terminal-coding-system} to tell Emacs what the terminal can
  3169. display, even after setting the language environment; otherwise
  3170. non-@acronym{ASCII} characters will display as @samp{?}. On other operating
  3171. systems, such as MS-DOS and MS-Windows, Emacs queries the OS about the
  3172. character set supported by the display, and sets up the required
  3173. terminal coding system automatically.
  3174. @node Inputting eight-bit characters
  3175. @section How do I input eight-bit characters?
  3176. @cindex Entering eight-bit characters
  3177. @cindex Eight-bit characters, entering
  3178. @cindex Input, 8-bit characters
  3179. Various methods are available for input of eight-bit characters.
  3180. @xref{Unibyte Mode,, Single-byte Character Set Support, emacs, The GNU
  3181. Emacs Manual}. For more sophisticated methods,
  3182. @pxref{Input Methods,,, emacs, The GNU Emacs Manual}.
  3183. @node Right-to-left alphabets
  3184. @section Where is an Emacs that can handle Semitic (right-to-left) alphabets?
  3185. @cindex Right-to-left alphabets
  3186. @cindex Hebrew, handling with Emacs
  3187. @cindex Semitic alphabets
  3188. @cindex Arabic
  3189. @cindex Farsi
  3190. @cindex bidirectional scripts
  3191. Emacs supports display and editing of bidirectional scripts, such as
  3192. Arabic, Farsi, and Hebrew, since version 24.1.
  3193. @xref{New in Emacs 24, bidirectional display}.
  3194. @node How to add fonts
  3195. @section How do I add fonts for use with Emacs?
  3196. @cindex add fonts for use with Emacs
  3197. @cindex intlfonts
  3198. First, download and install the BDF font files and any auxiliary
  3199. packages they need. The GNU Intlfonts distribution can be found on
  3200. @uref{http://directory.fsf.org/localization/intlfonts.html, the GNU
  3201. Software Directory Web site}.
  3202. Next, if you are on X Window system, issue the following two commands
  3203. from the shell's prompt:
  3204. @example
  3205. xset +fp /usr/local/share/emacs/fonts
  3206. xset fp rehash
  3207. @end example
  3208. @noindent
  3209. (Modify the first command if you installed the fonts in a directory
  3210. that is not @file{/usr/local/share/emacs/fonts}.) You also need to
  3211. arrange for these two commands to run whenever you log in, e.g., by
  3212. adding them to your window-system startup file, such as
  3213. @file{~/.xsessionrc} or @file{~/.gnomerc}.
  3214. Now, add the following line to your @file{~/.emacs} init file:
  3215. @lisp
  3216. (add-to-list 'bdf-directory-list "/usr/share/emacs/fonts/bdf")
  3217. @end lisp
  3218. @noindent
  3219. (Again, modify the file name if you installed the fonts elsewhere.)
  3220. Finally, if you wish to use the installed fonts with @code{ps-print},
  3221. add the following line to your @file{~/.emacs}:
  3222. @lisp
  3223. (setq ps-multibyte-buffer 'bdf-font-except-latin)
  3224. @end lisp
  3225. A few additional steps are necessary for MS-Windows; they are listed
  3226. below.
  3227. First, make sure @emph{all} the directories with BDF font files are
  3228. mentioned in @code{bdf-directory-list}. On Unix and GNU/Linux
  3229. systems, one normally runs @kbd{make install} to install the BDF fonts
  3230. in the same directory. By contrast, Windows users typically don't run
  3231. the Intlfonts installation command, but unpack the distribution in
  3232. some directory, which leaves the BDF fonts in its subdirectories. For
  3233. example, assume that you unpacked Intlfonts in @file{C:/Intlfonts};
  3234. then you should set @code{bdf-directory-list} as follows:
  3235. @lisp
  3236. (setq bdf-directory-list
  3237. '("C:/Intlfonts/Asian"
  3238. "C:/Intlfonts/Chinese" "C:/Intlfonts/Chinese.X"
  3239. "C:/Intlfonts/Chinese.BIG" "C:/Intlfonts/Ethiopic"
  3240. "C:/Intlfonts/European" "C:/Intlfonts/European.BIG"
  3241. "C:/Intlfonts/Japanese" "C:/Intlfonts/Japanese.X"
  3242. "C:/Intlfonts/Japanese.BIG" "C:/Intlfonts/Korean.X"
  3243. "C:/Intlfonts/Misc"))
  3244. @end lisp
  3245. @cindex @code{w32-bdf-filename-alist}
  3246. @cindex @code{w32-find-bdf-fonts}
  3247. Next, you need to set up the variable @code{w32-bdf-filename-alist} to
  3248. an alist of the BDF fonts and their corresponding file names.
  3249. Assuming you have set @code{bdf-directory-list} to name all the
  3250. directories with the BDF font files, the following Lisp snippet will
  3251. set up @code{w32-bdf-filename-alist}:
  3252. @lisp
  3253. (setq w32-bdf-filename-alist
  3254. (w32-find-bdf-fonts bdf-directory-list))
  3255. @end lisp
  3256. Now, create fontsets for the BDF fonts:
  3257. @smallexample
  3258. (create-fontset-from-fontset-spec
  3259. "-*-fixed-medium-r-normal-*-16-*-*-*-c-*-fontset-bdf,
  3260. japanese-jisx0208:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0208.1983-*,
  3261. katakana-jisx0201:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0201*-*,
  3262. latin-jisx0201:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0201*-*,
  3263. japanese-jisx0208-1978:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0208.1978-*,
  3264. thai-tis620:-misc-fixed-medium-r-normal--16-160-72-72-m-80-tis620.2529-1,
  3265. lao:-misc-fixed-medium-r-normal--16-160-72-72-m-80-MuleLao-1,
  3266. tibetan-1-column:-TibMdXA-fixed-medium-r-normal--16-160-72-72-m-80-MuleTibetan-1,
  3267. ethiopic:-Admas-Ethiomx16f-Medium-R-Normal--16-150-100-100-M-160-Ethiopic-Unicode,
  3268. tibetan:-TibMdXA-fixed-medium-r-normal--16-160-72-72-m-160-MuleTibetan-0")
  3269. @end smallexample
  3270. Many of the international bdf fonts from Intlfonts are type 0, and
  3271. therefore need to be added to font-encoding-alist:
  3272. @lisp
  3273. (setq font-encoding-alist
  3274. (append '(("MuleTibetan-0" (tibetan . 0))
  3275. ("GB2312" (chinese-gb2312 . 0))
  3276. ("JISX0208" (japanese-jisx0208 . 0))
  3277. ("JISX0212" (japanese-jisx0212 . 0))
  3278. ("VISCII" (vietnamese-viscii-lower . 0))
  3279. ("KSC5601" (korean-ksc5601 . 0))
  3280. ("MuleArabic-0" (arabic-digit . 0))
  3281. ("MuleArabic-1" (arabic-1-column . 0))
  3282. ("MuleArabic-2" (arabic-2-column . 0)))
  3283. font-encoding-alist))
  3284. @end lisp
  3285. You can now use the Emacs font menu to select the @samp{bdf: 16-dot medium}
  3286. fontset, or you can select it by setting the default font in your
  3287. @file{~/.emacs}:
  3288. @lisp
  3289. (set-default-font "fontset-bdf")
  3290. @end lisp
  3291. @c ------------------------------------------------------------
  3292. @node Mail and news
  3293. @chapter Mail and news
  3294. @cindex Mail and news
  3295. @menu
  3296. * Changing the included text prefix::
  3297. * Saving a copy of outgoing mail::
  3298. * Expanding aliases when sending mail::
  3299. * Sorting the messages in an Rmail folder::
  3300. * Rmail writes to /var/spool/mail::
  3301. * Replying to the sender of a message::
  3302. * Automatically starting a mail or news reader::
  3303. * Reading news with Emacs::
  3304. * Gnus does not work with NNTP::
  3305. * Making Gnus faster::
  3306. * Catching up in all newsgroups::
  3307. @end menu
  3308. @node Changing the included text prefix
  3309. @section How do I change the included text prefix in mail/news followups?
  3310. @cindex Prefix in mail/news followups, changing
  3311. @cindex Included text prefix, changing
  3312. @cindex Setting the included text character
  3313. @cindex Quoting in mail messages
  3314. If you read mail with Rmail, set the variable @code{mail-yank-prefix}.
  3315. For Gnus, set @code{message-yank-prefix}. For VM, set
  3316. @code{vm-included-text-prefix}. For mh-e, set @code{mh-ins-buf-prefix}.
  3317. For fancier control of citations, use Supercite (@pxref{Top,, the Supercite
  3318. Manual, sc, The Supercite Manual}).
  3319. To prevent Emacs from including various headers of the replied-to
  3320. message, set the value of @code{mail-yank-ignored-headers} to an
  3321. appropriate regexp.
  3322. @node Saving a copy of outgoing mail
  3323. @section How do I save a copy of outgoing mail?
  3324. @cindex Saving a copy of outgoing mail
  3325. @cindex Copying outgoing mail to a file
  3326. @cindex Filing outgoing mail
  3327. @cindex Automatic filing of outgoing mail
  3328. @cindex Mail, saving outgoing automatically
  3329. You can either mail yourself a copy by including a @samp{BCC} header in the
  3330. mail message, or store a copy of the message directly to a file by
  3331. including an @samp{FCC} header.
  3332. If you use standard mail, you can automatically create a @samp{BCC} to
  3333. yourself by putting
  3334. @lisp
  3335. (setq mail-self-blind t)
  3336. @end lisp
  3337. @noindent
  3338. in your @file{.emacs} file. You can automatically include an @samp{FCC}
  3339. field by putting something like the following in your @file{.emacs}
  3340. file:
  3341. @lisp
  3342. (setq mail-archive-file-name (expand-file-name "~/outgoing"))
  3343. @end lisp
  3344. The output file will be in Unix mail format.
  3345. If you use @code{mh-e}, add an @samp{FCC} or @samp{BCC} field to your
  3346. components file.
  3347. It does not work to put @samp{set record filename} in the @file{.mailrc}
  3348. file.
  3349. @node Expanding aliases when sending mail
  3350. @section Why doesn't Emacs expand my aliases when sending mail?
  3351. @cindex Expanding aliases when sending mail
  3352. @cindex Mail alias expansion
  3353. @cindex Sending mail with aliases
  3354. @xref{Mail Aliases,, The Emacs Manual, emacs, The Emacs Manual}.
  3355. @itemize @bullet
  3356. @item
  3357. Normally, Emacs expands aliases when you send the message.
  3358. To expand them before this, use @kbd{M-x expand-mail-aliases}.
  3359. @item
  3360. Emacs normally only reads the @file{.mailrc} file once per session, when
  3361. you start to compose your first mail message. If you edit the file
  3362. after this, you can use @kbd{M-x build-mail-aliases} to make Emacs
  3363. reread it. Prior to Emacs 24.1, this is not an interactive command, so
  3364. you must instead type @kbd{M-: (build-mail-aliases) @key{RET}}.
  3365. @item
  3366. If you like, you can expand mail aliases as abbrevs, as soon as you
  3367. type them in. To enable this feature, execute the following:
  3368. @lisp
  3369. (add-hook 'mail-mode-hook 'mail-abbrevs-setup)
  3370. @end lisp
  3371. Note that the aliases are expanded automatically only after you type
  3372. a word-separator character (e.g. @key{RET} or @kbd{,}). You can force their
  3373. expansion by moving point to the end of the alias and typing @kbd{C-x a e}
  3374. (@kbd{M-x expand-abbrev}).
  3375. @end itemize
  3376. @node Sorting the messages in an Rmail folder
  3377. @section How can I sort the messages in my Rmail folder?
  3378. @cindex Rmail, sorting messages in
  3379. @cindex Folder, sorting messages in an Rmail
  3380. @cindex Sorting messages in an Rmail folder
  3381. In Rmail, type @kbd{C-c C-s C-h} to get a list of sorting functions
  3382. and their key bindings.
  3383. @node Rmail writes to /var/spool/mail
  3384. @section Why does Rmail need to write to @file{/var/spool/mail}?
  3385. @cindex Rmail and @file{/var/spool/mail}
  3386. @cindex @file{/var/spool/mail} and Rmail
  3387. This is the behavior of the @code{movemail} program which Rmail uses.
  3388. This indicates that @code{movemail} is configured to use lock files.
  3389. RMS writes:
  3390. @quotation
  3391. Certain systems require lock files to interlock access to mail files.
  3392. On these systems, @code{movemail} must write lock files, or you risk losing
  3393. mail. You simply must arrange to let @code{movemail} write them.
  3394. Other systems use the @code{flock} system call to interlock access. On
  3395. these systems, you should configure @code{movemail} to use @code{flock}.
  3396. @end quotation
  3397. @node Replying to the sender of a message
  3398. @section How can I force Rmail to reply to the sender of a message, but not the other recipients?
  3399. @cindex Replying only to the sender of a message
  3400. @cindex Sender, replying only to
  3401. @cindex Rmail, replying to the sender of a message in
  3402. @email{isaacson@@seas.upenn.edu, Ron Isaacson} says: When you hit
  3403. @key{r} to reply in Rmail, by default it CCs all of the original
  3404. recipients (everyone on the original @samp{To} and @samp{CC}
  3405. lists). With a prefix argument (i.e., typing @kbd{C-u} before @key{r}),
  3406. it replies only to the sender. However, going through the whole
  3407. @kbd{C-u} business every time you want to reply is a pain. This is the
  3408. best fix I've been able to come up with:
  3409. @lisp
  3410. (defun rmail-reply-t ()
  3411. "Reply only to the sender of the current message. (See rmail-reply.)"
  3412. (interactive)
  3413. (rmail-reply t))
  3414. (add-hook 'rmail-mode-hook
  3415. (lambda ()
  3416. (define-key rmail-mode-map "r" 'rmail-reply-t)
  3417. (define-key rmail-mode-map "R" 'rmail-reply)))
  3418. @end lisp
  3419. @node Automatically starting a mail or news reader
  3420. @section How do I make Emacs automatically start my mail/news reader?
  3421. @cindex Mail reader, starting automatically
  3422. @cindex News reader, starting automatically
  3423. @cindex Starting mail/news reader automatically
  3424. To start Emacs in Gnus:
  3425. @example
  3426. emacs -f gnus
  3427. @end example
  3428. @noindent
  3429. in Rmail:
  3430. @example
  3431. emacs -f rmail
  3432. @end example
  3433. A more convenient way to start with Gnus:
  3434. @example
  3435. alias gnus 'emacs -f gnus'
  3436. gnus
  3437. @end example
  3438. It is probably unwise to automatically start your mail or news reader
  3439. from your @file{.emacs} file. This would cause problems if you needed to run
  3440. two copies of Emacs at the same time. Also, this would make it difficult for
  3441. you to start Emacs quickly when you needed to.
  3442. @node Reading news with Emacs
  3443. @section How do I read news under Emacs?
  3444. @cindex Reading news under Emacs
  3445. @cindex Usenet reader in Emacs
  3446. @cindex Gnus newsreader
  3447. @cindex FAQ for Gnus
  3448. @cindex Gnus FAQ
  3449. @cindex Learning more about Gnus
  3450. Use @kbd{M-x gnus}. For more information on Gnus, @pxref{Top,, the Gnus
  3451. Manual, gnus, The Gnus Manual}, which includes @ref{Frequently Asked
  3452. Questions,, the Gnus FAQ, gnus, The Gnus Manual}.
  3453. @node Gnus does not work with NNTP
  3454. @section Why doesn't Gnus work via NNTP?
  3455. @cindex Gnus and NNTP
  3456. @cindex NNTP, Gnus fails to work with
  3457. There is a bug in NNTP version 1.5.10, such that when multiple requests
  3458. are sent to the NNTP server, the server only handles the first one
  3459. before blocking waiting for more input which never comes. NNTP version
  3460. 1.5.11 claims to fix this.
  3461. You can work around the bug inside Emacs like this:
  3462. @lisp
  3463. (setq nntp-maximum-request 1)
  3464. @end lisp
  3465. You can find out what version of NNTP your news server is running by
  3466. telnetting to the NNTP port (usually 119) on the news server machine
  3467. (i.e., @kbd{telnet server-machine 119}). The server should give its
  3468. version number in the welcome message. Type @kbd{quit} to get out.
  3469. @node Making Gnus faster
  3470. @section How do I make Gnus faster?
  3471. @cindex Faster, starting Gnus
  3472. @cindex Starting Gnus faster
  3473. @cindex Gnus, starting faster
  3474. @cindex Slow catch up in Gnus
  3475. @cindex Gnus is slow when catching up
  3476. @cindex Crosspostings make Gnus catching up slow
  3477. From the Gnus FAQ (@pxref{Reading news with Emacs}):
  3478. @quotation
  3479. If you have a slow machine, or are just really impatient, there are a
  3480. few things you can do to make Gnus run faster.
  3481. Set @code{gnus-check-new-newsgroups} and
  3482. @code{gnus-check-bogus-newsgroups} to @code{nil} to make startup faster.
  3483. Set @code{gnus-show-threads}, @code{gnus-use-cross-reference} and
  3484. @code{gnus-nov-is-evil} to @code{nil} to make entering and exiting the
  3485. summary buffer faster.
  3486. @end quotation
  3487. @node Catching up in all newsgroups
  3488. @section How do I catch up all newsgroups in Gnus?
  3489. @cindex Catching up all newsgroups in Gnus
  3490. @cindex Gnus, Catching up all newsgroups in
  3491. In the @file{*Newsgroup*} buffer, type @kbd{M-< C-x ( c y C-x ) M-0 C-x e}
  3492. Leave off the initial @kbd{M-<} if you only want to catch up from point
  3493. to the end of the @file{*Newsgroup*} buffer.
  3494. @node Concept index
  3495. @unnumbered Concept Index
  3496. @printindex cp
  3497. @bye