text.texi 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894
  1. @c -*- coding: utf-8 -*-
  2. @c This is part of the Emacs manual.
  3. @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2017 Free Software
  4. @c Foundation, Inc.
  5. @c See file emacs.texi for copying conditions.
  6. @node Text
  7. @chapter Commands for Human Languages
  8. @cindex text
  9. @cindex manipulating text
  10. This chapter describes Emacs commands that act on @dfn{text}, by
  11. which we mean sequences of characters in a human language (as opposed
  12. to, say, a computer programming language). These commands act in ways
  13. that take into account the syntactic and stylistic conventions of
  14. human languages: conventions involving words, sentences, paragraphs,
  15. and capital letters. There are also commands for @dfn{filling}, which
  16. means rearranging the lines of a paragraph to be approximately equal
  17. in length. These commands, while intended primarily for editing text,
  18. are also often useful for editing programs.
  19. Emacs has several major modes for editing human-language text. If
  20. the file contains ordinary text, use Text mode, which customizes Emacs
  21. in small ways for the syntactic conventions of text. Outline mode
  22. provides special commands for operating on text with an outline
  23. structure. Org mode extends Outline mode and turn Emacs into a
  24. full-fledged organizer: you can manage TODO lists, store notes and
  25. publish them in many formats.
  26. @iftex
  27. @xref{Outline Mode}.
  28. @end iftex
  29. @cindex nXML mode
  30. @cindex mode, XML
  31. @cindex mode, nXML
  32. @findex nxml-mode
  33. Emacs has other major modes for text which contains embedded
  34. commands, such as @TeX{} and @LaTeX{} (@pxref{TeX Mode}); HTML and
  35. SGML (@pxref{HTML Mode}); XML
  36. @ifinfo
  37. (@pxref{Top,The nXML Mode Manual,,nxml-mode, nXML Mode});
  38. @end ifinfo
  39. @ifnotinfo
  40. (see the nXML mode Info manual, which is distributed with Emacs);
  41. @end ifnotinfo
  42. and Groff and Nroff (@pxref{Nroff Mode}).
  43. @cindex ASCII art
  44. If you need to edit ASCII art pictures made out of text characters,
  45. use Picture mode, a special major mode for editing such pictures.
  46. @iftex
  47. @xref{Picture Mode,,, emacs-xtra, Specialized Emacs Features}.
  48. @end iftex
  49. @ifnottex
  50. @xref{Picture Mode}.
  51. @end ifnottex
  52. @ifinfo
  53. @cindex skeletons
  54. @cindex templates
  55. @cindex autotyping
  56. @cindex automatic typing
  57. The automatic typing features may be useful when writing text.
  58. @inforef{Top,The Autotype Manual,autotype}.
  59. @end ifinfo
  60. @menu
  61. * Words:: Moving over and killing words.
  62. * Sentences:: Moving over and killing sentences.
  63. * Paragraphs:: Moving over paragraphs.
  64. * Pages:: Moving over pages.
  65. * Quotation Marks:: Inserting quotation marks.
  66. * Filling:: Filling or justifying text.
  67. * Case:: Changing the case of text.
  68. * Text Mode:: The major modes for editing text files.
  69. * Outline Mode:: Editing outlines.
  70. * Org Mode:: The Emacs organizer.
  71. * TeX Mode:: Editing TeX and LaTeX files.
  72. * HTML Mode:: Editing HTML and SGML files.
  73. * Nroff Mode:: Editing input to the nroff formatter.
  74. * Enriched Text:: Editing text enriched with fonts, colors, etc.
  75. * Text Based Tables:: Commands for editing text-based tables.
  76. * Two-Column:: Splitting text columns into separate windows.
  77. @end menu
  78. @node Words
  79. @section Words
  80. @cindex words
  81. @cindex Meta commands and words
  82. Emacs defines several commands for moving over or operating on
  83. words:
  84. @table @kbd
  85. @item M-f
  86. Move forward over a word (@code{forward-word}).
  87. @item M-b
  88. Move backward over a word (@code{backward-word}).
  89. @item M-d
  90. Kill up to the end of a word (@code{kill-word}).
  91. @item M-@key{DEL}
  92. Kill back to the beginning of a word (@code{backward-kill-word}).
  93. @item M-@@
  94. Mark the end of the next word (@code{mark-word}).
  95. @item M-t
  96. Transpose two words or drag a word across others
  97. (@code{transpose-words}).
  98. @end table
  99. Notice how these keys form a series that parallels the character-based
  100. @kbd{C-f}, @kbd{C-b}, @kbd{C-d}, @key{DEL} and @kbd{C-t}. @kbd{M-@@} is
  101. cognate to @kbd{C-@@}, which is an alias for @kbd{C-@key{SPC}}.
  102. @kindex M-f
  103. @kindex M-b
  104. @findex forward-word
  105. @findex backward-word
  106. The commands @kbd{M-f} (@code{forward-word}) and @kbd{M-b}
  107. (@code{backward-word}) move forward and backward over words. These
  108. @key{META}-based key sequences are analogous to the key sequences
  109. @kbd{C-f} and @kbd{C-b}, which move over single characters. The
  110. analogy extends to numeric arguments, which serve as repeat counts.
  111. @kbd{M-f} with a negative argument moves backward, and @kbd{M-b} with
  112. a negative argument moves forward. Forward motion stops right after
  113. the last letter of the word, while backward motion stops right before
  114. the first letter.
  115. @kindex M-d
  116. @findex kill-word
  117. @kbd{M-d} (@code{kill-word}) kills the word after point. To be
  118. precise, it kills everything from point to the place @kbd{M-f} would
  119. move to. Thus, if point is in the middle of a word, @kbd{M-d} kills
  120. just the part after point. If some punctuation comes between point
  121. and the next word, it is killed along with the word. (If you wish to
  122. kill only the next word but not the punctuation before it, simply do
  123. @kbd{M-f} to get the end, and kill the word backwards with
  124. @kbd{M-@key{DEL}}.) @kbd{M-d} takes arguments just like @kbd{M-f}.
  125. @findex backward-kill-word
  126. @kindex M-DEL
  127. @kbd{M-@key{DEL}} (@code{backward-kill-word}) kills the word before
  128. point. It kills everything from point back to where @kbd{M-b} would
  129. move to. For instance, if point is after the space in @w{@samp{FOO,
  130. BAR}}, it kills @w{@samp{FOO, }}. If you wish to kill just
  131. @samp{FOO}, and not the comma and the space, use @kbd{M-b M-d} instead
  132. of @kbd{M-@key{DEL}}.
  133. @c Don't index M-t and transpose-words here, they are indexed in
  134. @c fixit.texi, in the node "Transpose".
  135. @c @kindex M-t
  136. @c @findex transpose-words
  137. @kbd{M-t} (@code{transpose-words}) exchanges the word before or
  138. containing point with the following word. The delimiter characters between
  139. the words do not move. For example, @w{@samp{FOO, BAR}} transposes into
  140. @w{@samp{BAR, FOO}} rather than @samp{@w{BAR FOO,}}. @xref{Transpose}, for
  141. more on transposition.
  142. @kindex M-@@
  143. @findex mark-word
  144. To operate on words with an operation which acts on the region, use
  145. the command @kbd{M-@@} (@code{mark-word}). This command sets the mark
  146. where @kbd{M-f} would move to. @xref{Marking Objects}, for more
  147. information about this command.
  148. The word commands' understanding of word boundaries is controlled by
  149. the syntax table. Any character can, for example, be declared to be a
  150. word delimiter. @xref{Syntax Tables,, Syntax Tables, elisp, The Emacs
  151. Lisp Reference Manual}.
  152. In addition, see @ref{Position Info} for the @kbd{M-=}
  153. (@code{count-words-region}) and @kbd{M-x count-words} commands, which
  154. count and report the number of words in the region or buffer.
  155. @node Sentences
  156. @section Sentences
  157. @cindex sentences
  158. @cindex manipulating sentences
  159. The Emacs commands for manipulating sentences and paragraphs are
  160. mostly on Meta keys, like the word-handling commands.
  161. @table @kbd
  162. @item M-a
  163. Move back to the beginning of the sentence (@code{backward-sentence}).
  164. @item M-e
  165. Move forward to the end of the sentence (@code{forward-sentence}).
  166. @item M-k
  167. Kill forward to the end of the sentence (@code{kill-sentence}).
  168. @item C-x @key{DEL}
  169. Kill back to the beginning of the sentence (@code{backward-kill-sentence}).
  170. @end table
  171. @kindex M-a
  172. @kindex M-e
  173. @findex backward-sentence
  174. @findex forward-sentence
  175. The commands @kbd{M-a} (@code{backward-sentence}) and @kbd{M-e}
  176. (@code{forward-sentence}) move to the beginning and end of the current
  177. sentence, respectively. Their bindings were chosen to resemble
  178. @kbd{C-a} and @kbd{C-e}, which move to the beginning and end of a
  179. line. Unlike them, @kbd{M-a} and @kbd{M-e} move over successive
  180. sentences if repeated.
  181. Moving backward over a sentence places point just before the first
  182. character of the sentence; moving forward places point right after the
  183. punctuation that ends the sentence. Neither one moves over the
  184. whitespace at the sentence boundary.
  185. @kindex M-k
  186. @findex kill-sentence
  187. Just as @kbd{C-a} and @kbd{C-e} have a kill command, @kbd{C-k}, to
  188. go with them, @kbd{M-a} and @kbd{M-e} have a corresponding kill
  189. command: @kbd{M-k} (@code{kill-sentence}) kills from point to the end
  190. of the sentence. With a positive numeric argument @var{n}, it kills
  191. the next @var{n} sentences; with a negative argument @minus{}@var{n},
  192. it kills back to the beginning of the @var{n}th preceding sentence.
  193. @kindex C-x DEL
  194. @findex backward-kill-sentence
  195. The @kbd{C-x @key{DEL}} (@code{backward-kill-sentence}) kills back
  196. to the beginning of a sentence.
  197. The sentence commands assume that you follow the American typist's
  198. convention of putting two spaces at the end of a sentence. That is, a
  199. sentence ends wherever there is a @samp{.}, @samp{?} or @samp{!}
  200. followed by the end of a line or two spaces, with any number of
  201. @samp{)}, @samp{]}, @samp{'}, or @samp{"} characters allowed in
  202. between. A sentence also begins or ends wherever a paragraph begins
  203. or ends. It is useful to follow this convention, because it allows
  204. the Emacs sentence commands to distinguish between periods that end a
  205. sentence and periods that indicate abbreviations.
  206. @vindex sentence-end-double-space
  207. If you want to use just one space between sentences, you can set the
  208. variable @code{sentence-end-double-space} to @code{nil} to make the
  209. sentence commands stop for single spaces. However, this has a
  210. drawback: there is no way to distinguish between periods that end
  211. sentences and those that indicate abbreviations. For convenient and
  212. reliable editing, we therefore recommend you follow the two-space
  213. convention. The variable @code{sentence-end-double-space} also
  214. affects filling (@pxref{Fill Commands}).
  215. @vindex sentence-end
  216. The variable @code{sentence-end} controls how to recognize the end
  217. of a sentence. If non-@code{nil}, its value should be a regular
  218. expression, which is used to match the last few characters of a
  219. sentence, together with the whitespace following the sentence
  220. (@pxref{Regexps}). If the value is @code{nil}, the default, then
  221. Emacs computes sentence ends according to various criteria such as the
  222. value of @code{sentence-end-double-space}.
  223. @vindex sentence-end-without-period
  224. Some languages, such as Thai, do not use periods to indicate the end
  225. of a sentence. Set the variable @code{sentence-end-without-period} to
  226. @code{t} in such cases.
  227. @node Paragraphs
  228. @section Paragraphs
  229. @cindex paragraphs
  230. @cindex manipulating paragraphs
  231. The Emacs commands for manipulating paragraphs are also on Meta keys.
  232. @table @kbd
  233. @item M-@{
  234. Move back to previous paragraph beginning (@code{backward-paragraph}).
  235. @item M-@}
  236. Move forward to next paragraph end (@code{forward-paragraph}).
  237. @item M-h
  238. Put point and mark around this or next paragraph (@code{mark-paragraph}).
  239. @end table
  240. @kindex M-@{
  241. @kindex M-@}
  242. @findex backward-paragraph
  243. @findex forward-paragraph
  244. @kbd{M-@{} (@code{backward-paragraph}) moves to the beginning of the
  245. current or previous paragraph (see below for the definition of a
  246. paragraph). @kbd{M-@}} (@code{forward-paragraph}) moves to the end of
  247. the current or next paragraph. If there is a blank line before the
  248. paragraph, @kbd{M-@{} moves to the blank line.
  249. @kindex M-h
  250. @findex mark-paragraph
  251. When you wish to operate on a paragraph, type @kbd{M-h}
  252. (@code{mark-paragraph}) to set the region around it. For example,
  253. @kbd{M-h C-w} kills the paragraph around or after point. @kbd{M-h}
  254. puts point at the beginning and mark at the end of the paragraph point
  255. was in. If point is between paragraphs (in a run of blank lines, or
  256. at a boundary), @kbd{M-h} sets the region around the paragraph
  257. following point. If there are blank lines preceding the first line of
  258. the paragraph, one of these blank lines is included in the region. If
  259. the region is already active, the command sets the mark without
  260. changing point, and each subsequent @kbd{M-h} further advances the
  261. mark by one paragraph.
  262. The definition of a paragraph depends on the major mode. In
  263. Fundamental mode, as well as Text mode and related modes, a paragraph
  264. is separated from neighboring paragraphs by one or more
  265. @dfn{blank lines}---lines that are either empty, or consist solely of
  266. space, tab and/or formfeed characters. In programming language modes,
  267. paragraphs are usually defined in a similar way, so that you can use
  268. the paragraph commands even though there are no paragraphs as such in
  269. a program.
  270. Note that an indented line is @emph{not} itself a paragraph break in
  271. Text mode. If you want indented lines to separate paragraphs, use
  272. Paragraph-Indent Text mode instead. @xref{Text Mode}.
  273. If you set a fill prefix, then paragraphs are delimited by all lines
  274. which don't start with the fill prefix. @xref{Filling}.
  275. @vindex paragraph-start
  276. @vindex paragraph-separate
  277. The precise definition of a paragraph boundary is controlled by the
  278. variables @code{paragraph-separate} and @code{paragraph-start}. The
  279. value of @code{paragraph-start} is a regular expression that should
  280. match lines that either start or separate paragraphs
  281. (@pxref{Regexps}). The value of @code{paragraph-separate} is another
  282. regular expression that should match lines that separate paragraphs
  283. without being part of any paragraph (for example, blank lines). Lines
  284. that start a new paragraph and are contained in it must match only
  285. @code{paragraph-start}, not @code{paragraph-separate}. For example,
  286. in Fundamental mode, @code{paragraph-start} is @w{@code{"\f\\|[
  287. \t]*$"}}, and @code{paragraph-separate} is @w{@code{"[ \t\f]*$"}}.
  288. @node Pages
  289. @section Pages
  290. @cindex pages
  291. @cindex formfeed character
  292. Within some text files, text is divided into @dfn{pages} delimited
  293. by the @dfn{formfeed character} (@acronym{ASCII} code 12, also denoted
  294. as @samp{control-L}), which is displayed in Emacs as the escape
  295. sequence @samp{^L} (@pxref{Text Display}). Traditionally, when such
  296. text files are printed to hardcopy, each formfeed character forces a
  297. page break. Most Emacs commands treat it just like any other
  298. character, so you can insert it with @kbd{C-q C-l}, delete it with
  299. @key{DEL}, etc. In addition, Emacs provides commands to move over
  300. pages and operate on them.
  301. @table @kbd
  302. @item M-x what-page
  303. Display the page number of point, and the line number within that page.
  304. @item C-x [
  305. Move point to previous page boundary (@code{backward-page}).
  306. @item C-x ]
  307. Move point to next page boundary (@code{forward-page}).
  308. @item C-x C-p
  309. Put point and mark around this page (or another page) (@code{mark-page}).
  310. @item C-x l
  311. Count the lines in this page (@code{count-lines-page}).
  312. @end table
  313. @findex what-page
  314. @kbd{M-x what-page} counts pages from the beginning of the file, and
  315. counts lines within the page, showing both numbers in the echo area.
  316. @kindex C-x [
  317. @kindex C-x ]
  318. @findex forward-page
  319. @findex backward-page
  320. The @kbd{C-x [} (@code{backward-page}) command moves point to immediately
  321. after the previous page delimiter. If point is already right after a page
  322. delimiter, it skips that one and stops at the previous one. A numeric
  323. argument serves as a repeat count. The @kbd{C-x ]} (@code{forward-page})
  324. command moves forward past the next page delimiter.
  325. @kindex C-x C-p
  326. @findex mark-page
  327. The @kbd{C-x C-p} command (@code{mark-page}) puts point at the
  328. beginning of the current page (after that page delimiter at the
  329. front), and the mark at the end of the page (after the page delimiter
  330. at the end).
  331. @kbd{C-x C-p C-w} is a handy way to kill a page to move it
  332. elsewhere. If you move to another page delimiter with @kbd{C-x [} and
  333. @kbd{C-x ]}, then yank the killed page, all the pages will be properly
  334. delimited once again. The reason @kbd{C-x C-p} includes only the
  335. following page delimiter in the region is to ensure that.
  336. A numeric argument to @kbd{C-x C-p} specifies which page to go to,
  337. relative to the current one. Zero means the current page, one
  338. the next page, and @minus{}1 the previous one.
  339. @kindex C-x l
  340. @findex count-lines-page
  341. The @kbd{C-x l} command (@code{count-lines-page}) is good for deciding
  342. where to break a page in two. It displays in the echo area the total number
  343. of lines in the current page, and then divides it up into those preceding
  344. the current line and those following, as in
  345. @example
  346. Page has 96 (72+25) lines
  347. @end example
  348. @noindent
  349. Notice that the sum is off by one; this is correct if point is not at the
  350. beginning of a line.
  351. @vindex page-delimiter
  352. The variable @code{page-delimiter} controls where pages begin. Its
  353. value is a regular expression that matches the beginning of a line
  354. that separates pages (@pxref{Regexps}). The normal value of this
  355. variable is @code{"^\f"}, which matches a formfeed character at the
  356. beginning of a line.
  357. @node Quotation Marks
  358. @section Quotation Marks
  359. @cindex Quotation marks
  360. @cindex Electric Quote mode
  361. @cindex mode, Electric Quote
  362. @cindex curly quotes
  363. @cindex curved quotes
  364. @cindex guillemets
  365. @findex electric-quote-mode
  366. One common way to quote is the typewriter convention, which quotes
  367. using straight apostrophes @t{'like this'} or double-quotes @t{"like
  368. this"}. Another common way is the curved quote convention, which uses
  369. left and right single or double quotation marks @t{‘like this’} or
  370. @t{“like this”}. In text files, typewriter quotes are simple and
  371. portable; curved quotes are less ambiguous and typically look nicer.
  372. @vindex electric-quote-chars
  373. Electric Quote mode makes it easier to type curved quotes. As you
  374. type characters it optionally converts @t{`} to @t{‘}, @t{'} to @t{’},
  375. @t{``} to @t{“}, and @t{''} to @t{”}. It's possible to change the
  376. default quotes listed above, by customizing the variable
  377. @code{electric-quote-chars}, a list of four characters, where the
  378. items correspond to the left single quote, the right single quote, the
  379. left double quote and the right double quote, respectively, whose
  380. default value is @code{'(?‘ ?’ ?“ ?”)}.
  381. @vindex electric-quote-paragraph
  382. @vindex electric-quote-comment
  383. @vindex electric-quote-string
  384. You can customize the behavior of Electric Quote mode by customizing
  385. variables that control where it is active. It is active in text
  386. paragraphs if @code{electric-quote-paragraph} is non-@code{nil}, in
  387. programming-language comments if @code{electric-quote-comment} is
  388. non-@code{nil}, and in programming-language strings if
  389. @code{electric-quote-string} is non-@code{nil}. The default is
  390. @code{nil} for @code{electric-quote-string} and @code{t} for the other
  391. variables.
  392. Electric Quote mode is disabled by default. To toggle it, type
  393. @kbd{M-x electric-quote-mode}. To toggle it in a single buffer, use
  394. @kbd{M-x electric-quote-local-mode}. To suppress it for a single use,
  395. type @kbd{C-q `} or @kbd{C-q '} instead of @kbd{`} or @kbd{'}. To
  396. insert a curved quote even when Electric Quote is disabled or
  397. inactive, you can type @kbd{C-x 8 [} for @t{‘}, @kbd{C-x 8 ]} for
  398. @t{’}, @kbd{C-x 8 @{} for @t{“}, and @kbd{C-x 8 @}} for @t{”}.
  399. @xref{Inserting Text}. Note that the value of
  400. @code{electric-quote-chars} does not affect these keybindings, they
  401. are not keybindings of @code{electric-quote-mode} but bound in
  402. @code{global-map}.
  403. @node Filling
  404. @section Filling Text
  405. @cindex filling text
  406. @dfn{Filling} text means breaking it up into lines that fit a
  407. specified width. Emacs does filling in two ways. In Auto Fill mode,
  408. inserting text with self-inserting characters also automatically fills
  409. it. There are also explicit fill commands that you can use when editing
  410. text.
  411. @menu
  412. * Auto Fill:: Auto Fill mode breaks long lines automatically.
  413. * Fill Commands:: Commands to refill paragraphs and center lines.
  414. * Fill Prefix:: Filling paragraphs that are indented or in a comment, etc.
  415. * Adaptive Fill:: How Emacs can determine the fill prefix automatically.
  416. @end menu
  417. @node Auto Fill
  418. @subsection Auto Fill Mode
  419. @cindex Auto Fill mode
  420. @cindex mode, Auto Fill
  421. @dfn{Auto Fill} mode is a buffer-local minor mode (@pxref{Minor
  422. Modes}) in which lines are broken automatically when they become too
  423. wide. Breaking happens only when you type a @key{SPC} or @key{RET}.
  424. @table @kbd
  425. @item M-x auto-fill-mode
  426. Enable or disable Auto Fill mode.
  427. @item @key{SPC}
  428. @itemx @key{RET}
  429. In Auto Fill mode, break lines when appropriate.
  430. @end table
  431. @findex auto-fill-mode
  432. The mode command @kbd{M-x auto-fill-mode} toggles Auto Fill mode in
  433. the current buffer. With a positive numeric argument, it enables Auto
  434. Fill mode, and with a negative argument it disables it. If
  435. @code{auto-fill-mode} is called from Lisp with an omitted or
  436. @code{nil} argument, it enables Auto Fill mode. To enable Auto Fill
  437. mode automatically in certain major modes, add @code{auto-fill-mode}
  438. to the mode hooks (@pxref{Major Modes}). When Auto Fill mode is
  439. enabled, the mode indicator @samp{Fill} appears in the mode line
  440. (@pxref{Mode Line}).
  441. Auto Fill mode breaks lines automatically at spaces whenever they
  442. get longer than the desired width. This line breaking occurs only
  443. when you type @key{SPC} or @key{RET}. If you wish to insert a space
  444. or newline without permitting line-breaking, type @kbd{C-q @key{SPC}}
  445. or @kbd{C-q C-j} respectively. Also, @kbd{C-o} inserts a newline
  446. without line breaking.
  447. When Auto Fill mode breaks a line, it tries to obey the
  448. @dfn{adaptive fill prefix}: if a fill prefix can be deduced from the
  449. first and/or second line of the current paragraph, it is inserted into
  450. the new line (@pxref{Adaptive Fill}). Otherwise the new line is
  451. indented, as though you had typed @key{TAB} on it
  452. (@pxref{Indentation}). In a programming language mode, if a line is
  453. broken in the middle of a comment, the comment is split by inserting
  454. new comment delimiters as appropriate.
  455. Auto Fill mode does not refill entire paragraphs; it breaks lines
  456. but does not merge lines. Therefore, editing in the middle of a
  457. paragraph can result in a paragraph that is not correctly filled. To
  458. fill it, call the explicit fill commands
  459. @iftex
  460. described in the next section.
  461. @end iftex
  462. @ifnottex
  463. (@pxref{Fill Commands}).
  464. @end ifnottex
  465. @node Fill Commands
  466. @subsection Explicit Fill Commands
  467. @table @kbd
  468. @item M-q
  469. Fill current paragraph (@code{fill-paragraph}).
  470. @item C-x f
  471. Set the fill column (@code{set-fill-column}).
  472. @item M-x fill-region
  473. Fill each paragraph in the region (@code{fill-region}).
  474. @item M-x fill-region-as-paragraph
  475. Fill the region, considering it as one paragraph.
  476. @item M-o M-s
  477. Center a line.
  478. @end table
  479. @kindex M-q
  480. @findex fill-paragraph
  481. The command @kbd{M-q} (@code{fill-paragraph}) @dfn{fills} the
  482. current paragraph. It redistributes the line breaks within the
  483. paragraph, and deletes any excess space and tab characters occurring
  484. within the paragraph, in such a way that the lines end up fitting
  485. within a certain maximum width.
  486. @findex fill-region
  487. Normally, @kbd{M-q} acts on the paragraph where point is, but if
  488. point is between paragraphs, it acts on the paragraph after point. If
  489. the region is active, it acts instead on the text in the region. You
  490. can also call @kbd{M-x fill-region} to specifically fill the text in
  491. the region.
  492. @findex fill-region-as-paragraph
  493. @kbd{M-q} and @code{fill-region} use the usual Emacs criteria for
  494. finding paragraph boundaries (@pxref{Paragraphs}). For more control,
  495. you can use @kbd{M-x fill-region-as-paragraph}, which refills
  496. everything between point and mark as a single paragraph. This command
  497. deletes any blank lines within the region, so separate blocks of text
  498. end up combined into one block.
  499. @cindex justification
  500. A numeric argument to @kbd{M-q} tells it to @dfn{justify} the text
  501. as well as filling it. This means that extra spaces are inserted to
  502. make the right margin line up exactly at the fill column. To remove
  503. the extra spaces, use @kbd{M-q} with no argument. (Likewise for
  504. @code{fill-region}.)
  505. @vindex fill-column
  506. @kindex C-x f
  507. @findex set-fill-column
  508. The maximum line width for filling is specified by the buffer-local
  509. variable @code{fill-column}. The default value (@pxref{Locals}) is
  510. 70. The easiest way to set @code{fill-column} in the current buffer
  511. is to use the command @kbd{C-x f} (@code{set-fill-column}). With a
  512. numeric argument, it uses that as the new fill column. With just
  513. @kbd{C-u} as argument, it sets @code{fill-column} to the current
  514. horizontal position of point.
  515. @kindex M-o M-s @r{(Text mode)}
  516. @cindex centering
  517. @findex center-line
  518. The command @kbd{M-o M-s} (@code{center-line}) centers the current line
  519. within the current fill column. With an argument @var{n}, it centers
  520. @var{n} lines individually and moves past them. This binding is
  521. made by Text mode and is available only in that and related modes
  522. (@pxref{Text Mode}).
  523. By default, Emacs considers a period followed by two spaces or by a
  524. newline as the end of a sentence; a period followed by just one space
  525. indicates an abbreviation, not the end of a sentence. Accordingly,
  526. the fill commands will not break a line after a period followed by
  527. just one space. If you set the variable
  528. @code{sentence-end-double-space} to @code{nil}, the fill commands will
  529. break a line after a period followed by one space, and put just one
  530. space after each period. @xref{Sentences}, for other effects and
  531. possible drawbacks of this.
  532. @vindex colon-double-space
  533. If the variable @code{colon-double-space} is non-@code{nil}, the
  534. fill commands put two spaces after a colon.
  535. @vindex fill-nobreak-predicate
  536. To specify additional conditions where line-breaking is not allowed,
  537. customize the abnormal hook variable @code{fill-nobreak-predicate}
  538. (@pxref{Hooks}). Each function in this hook is called with no
  539. arguments, with point positioned where Emacs is considering breaking a
  540. line. If a function returns a non-@code{nil} value, Emacs will not
  541. break the line there. Functions you can use there include:
  542. @code{fill-single-word-nobreak-p} (don't break after the first word of
  543. a sentence or before the last); @code{fill-single-char-nobreak-p}
  544. (don't break after a one-letter word); and @code{fill-french-nobreak-p}
  545. (don't break after @samp{(} or before @samp{)}, @samp{:} or @samp{?}).
  546. @node Fill Prefix
  547. @subsection The Fill Prefix
  548. @cindex fill prefix
  549. The @dfn{fill prefix} feature allows paragraphs to be filled so that
  550. each line starts with a special string of characters (such as a
  551. sequence of spaces, giving an indented paragraph). You can specify a
  552. fill prefix explicitly; otherwise, Emacs tries to deduce one
  553. automatically (@pxref{Adaptive Fill}).
  554. @table @kbd
  555. @item C-x .
  556. Set the fill prefix (@code{set-fill-prefix}).
  557. @item M-q
  558. Fill a paragraph using current fill prefix (@code{fill-paragraph}).
  559. @item M-x fill-individual-paragraphs
  560. Fill the region, considering each change of indentation as starting a
  561. new paragraph.
  562. @item M-x fill-nonuniform-paragraphs
  563. Fill the region, considering only paragraph-separator lines as starting
  564. a new paragraph.
  565. @end table
  566. @kindex C-x .
  567. @findex set-fill-prefix
  568. To specify a fill prefix for the current buffer, move to a line that
  569. starts with the desired prefix, put point at the end of the prefix,
  570. and type @w{@kbd{C-x .}}@: (@code{set-fill-prefix}). (That's a period
  571. after the @kbd{C-x}.) To turn off the fill prefix, specify an empty
  572. prefix: type @w{@kbd{C-x .}}@: with point at the beginning of a line.
  573. When a fill prefix is in effect, the fill commands remove the fill
  574. prefix from each line of the paragraph before filling, and insert it
  575. on each line after filling. (The beginning of the first line of the
  576. paragraph is left unchanged, since often that is intentionally
  577. different.) Auto Fill mode also inserts the fill prefix automatically
  578. when it makes a new line (@pxref{Auto Fill}). The @kbd{C-o} command
  579. inserts the fill prefix on new lines it creates, when you use it at
  580. the beginning of a line (@pxref{Blank Lines}). Conversely, the
  581. command @kbd{M-^} deletes the prefix (if it occurs) after the newline
  582. that it deletes (@pxref{Indentation}).
  583. For example, if @code{fill-column} is 40 and you set the fill prefix
  584. to @samp{;; }, then @kbd{M-q} in the following text
  585. @example
  586. ;; This is an
  587. ;; example of a paragraph
  588. ;; inside a Lisp-style comment.
  589. @end example
  590. @noindent
  591. produces this:
  592. @example
  593. ;; This is an example of a paragraph
  594. ;; inside a Lisp-style comment.
  595. @end example
  596. Lines that do not start with the fill prefix are considered to start
  597. paragraphs, both in @kbd{M-q} and the paragraph commands; this gives
  598. good results for paragraphs with hanging indentation (every line
  599. indented except the first one). Lines which are blank or indented once
  600. the prefix is removed also separate or start paragraphs; this is what
  601. you want if you are writing multi-paragraph comments with a comment
  602. delimiter on each line.
  603. @findex fill-individual-paragraphs
  604. You can use @kbd{M-x fill-individual-paragraphs} to set the fill
  605. prefix for each paragraph automatically. This command divides the
  606. region into paragraphs, treating every change in the amount of
  607. indentation as the start of a new paragraph, and fills each of these
  608. paragraphs. Thus, all the lines in one paragraph have the same
  609. amount of indentation. That indentation serves as the fill prefix for
  610. that paragraph.
  611. @findex fill-nonuniform-paragraphs
  612. @kbd{M-x fill-nonuniform-paragraphs} is a similar command that divides
  613. the region into paragraphs in a different way. It considers only
  614. paragraph-separating lines (as defined by @code{paragraph-separate}) as
  615. starting a new paragraph. Since this means that the lines of one
  616. paragraph may have different amounts of indentation, the fill prefix
  617. used is the smallest amount of indentation of any of the lines of the
  618. paragraph. This gives good results with styles that indent a paragraph's
  619. first line more or less that the rest of the paragraph.
  620. @vindex fill-prefix
  621. The fill prefix is stored in the variable @code{fill-prefix}. Its value
  622. is a string, or @code{nil} when there is no fill prefix. This is a
  623. per-buffer variable; altering the variable affects only the current buffer,
  624. but there is a default value which you can change as well. @xref{Locals}.
  625. The @code{indentation} text property provides another way to control
  626. the amount of indentation paragraphs receive. @xref{Enriched
  627. Indentation}.
  628. @node Adaptive Fill
  629. @subsection Adaptive Filling
  630. @cindex adaptive filling
  631. The fill commands can deduce the proper fill prefix for a paragraph
  632. automatically in certain cases: either whitespace or certain punctuation
  633. characters at the beginning of a line are propagated to all lines of the
  634. paragraph.
  635. If the paragraph has two or more lines, the fill prefix is taken from
  636. the paragraph's second line, but only if it appears on the first line as
  637. well.
  638. If a paragraph has just one line, fill commands @emph{may} take a
  639. prefix from that line. The decision is complicated because there are
  640. three reasonable things to do in such a case:
  641. @itemize @bullet
  642. @item
  643. Use the first line's prefix on all the lines of the paragraph.
  644. @item
  645. Indent subsequent lines with whitespace, so that they line up under the
  646. text that follows the prefix on the first line, but don't actually copy
  647. the prefix from the first line.
  648. @item
  649. Don't do anything special with the second and following lines.
  650. @end itemize
  651. All three of these styles of formatting are commonly used. So the
  652. fill commands try to determine what you would like, based on the prefix
  653. that appears and on the major mode. Here is how.
  654. @vindex adaptive-fill-first-line-regexp
  655. If the prefix found on the first line matches
  656. @code{adaptive-fill-first-line-regexp}, or if it appears to be a
  657. comment-starting sequence (this depends on the major mode), then the
  658. prefix found is used for filling the paragraph, provided it would not
  659. act as a paragraph starter on subsequent lines.
  660. Otherwise, the prefix found is converted to an equivalent number of
  661. spaces, and those spaces are used as the fill prefix for the rest of the
  662. lines, provided they would not act as a paragraph starter on subsequent
  663. lines.
  664. In Text mode, and other modes where only blank lines and page
  665. delimiters separate paragraphs, the prefix chosen by adaptive filling
  666. never acts as a paragraph starter, so it can always be used for filling.
  667. @vindex adaptive-fill-mode
  668. @vindex adaptive-fill-regexp
  669. The variable @code{adaptive-fill-regexp} determines what kinds of line
  670. beginnings can serve as a fill prefix: any characters at the start of
  671. the line that match this regular expression are used. If you set the
  672. variable @code{adaptive-fill-mode} to @code{nil}, the fill prefix is
  673. never chosen automatically.
  674. @vindex adaptive-fill-function
  675. You can specify more complex ways of choosing a fill prefix
  676. automatically by setting the variable @code{adaptive-fill-function} to a
  677. function. This function is called with point after the left margin of a
  678. line, and it should return the appropriate fill prefix based on that
  679. line. If it returns @code{nil}, @code{adaptive-fill-regexp} gets
  680. a chance to find a prefix.
  681. @node Case
  682. @section Case Conversion Commands
  683. @cindex case conversion
  684. Emacs has commands for converting either a single word or any arbitrary
  685. range of text to upper case or to lower case.
  686. @table @kbd
  687. @item M-l
  688. Convert following word to lower case (@code{downcase-word}).
  689. @item M-u
  690. Convert following word to upper case (@code{upcase-word}).
  691. @item M-c
  692. Capitalize the following word (@code{capitalize-word}).
  693. @item C-x C-l
  694. Convert region to lower case (@code{downcase-region}).
  695. @item C-x C-u
  696. Convert region to upper case (@code{upcase-region}).
  697. @end table
  698. @kindex M-l
  699. @kindex M-u
  700. @kindex M-c
  701. @cindex words, case conversion
  702. @cindex converting text to upper or lower case
  703. @cindex capitalizing words
  704. @findex downcase-word
  705. @findex upcase-word
  706. @findex capitalize-word
  707. @kbd{M-l} (@code{downcase-word}) converts the word after point to
  708. lower case, moving past it. Thus, repeating @kbd{M-l} converts
  709. successive words. @kbd{M-u} (@code{upcase-word}) converts to all
  710. capitals instead, while @kbd{M-c} (@code{capitalize-word}) puts the
  711. first letter of the word into upper case and the rest into lower case.
  712. All these commands convert several words at once if given an argument.
  713. They are especially convenient for converting a large amount of text
  714. from all upper case to mixed case, because you can move through the
  715. text using @kbd{M-l}, @kbd{M-u} or @kbd{M-c} on each word as
  716. appropriate, occasionally using @kbd{M-f} instead to skip a word.
  717. When given a negative argument, the word case conversion commands apply
  718. to the appropriate number of words before point, but do not move point.
  719. This is convenient when you have just typed a word in the wrong case: you
  720. can give the case conversion command and continue typing.
  721. If a word case conversion command is given in the middle of a word,
  722. it applies only to the part of the word which follows point. (This is
  723. comparable to what @kbd{M-d} (@code{kill-word}) does.) With a
  724. negative argument, case conversion applies only to the part of the
  725. word before point.
  726. @kindex C-x C-l
  727. @kindex C-x C-u
  728. @findex downcase-region
  729. @findex upcase-region
  730. The other case conversion commands are @kbd{C-x C-u}
  731. (@code{upcase-region}) and @kbd{C-x C-l} (@code{downcase-region}), which
  732. convert everything between point and mark to the specified case. Point and
  733. mark do not move.
  734. The region case conversion commands @code{upcase-region} and
  735. @code{downcase-region} are normally disabled. This means that they ask
  736. for confirmation if you try to use them. When you confirm, you may
  737. enable the command, which means it will not ask for confirmation again.
  738. @xref{Disabling}.
  739. @node Text Mode
  740. @section Text Mode
  741. @cindex Text mode
  742. @cindex mode, Text
  743. @findex text-mode
  744. Text mode is a major mode for editing files of text in a human
  745. language. Files which have names ending in the extension @file{.txt}
  746. are usually opened in Text mode (@pxref{Choosing Modes}). To
  747. explicitly switch to Text mode, type @kbd{M-x text-mode}.
  748. In Text mode, only blank lines and page delimiters separate
  749. paragraphs. As a result, paragraphs can be indented, and adaptive
  750. filling determines what indentation to use when filling a paragraph.
  751. @xref{Adaptive Fill}.
  752. @kindex TAB @r{(Text mode)}
  753. In Text mode, the @key{TAB} (@code{indent-for-tab-command}) command
  754. usually inserts whitespace up to the next tab stop, instead of
  755. indenting the current line. @xref{Indentation}, for details.
  756. Text mode turns off the features concerned with comments except when
  757. you explicitly invoke them. It changes the syntax table so that
  758. apostrophes are considered part of words (e.g., @samp{don't} is
  759. considered one word). However, if a word starts with an apostrophe,
  760. it is treated as a prefix for the purposes of capitalization
  761. (e.g., @kbd{M-c} converts @samp{'hello'} into @samp{'Hello'}, as
  762. expected).
  763. @cindex Paragraph-Indent Text mode
  764. @cindex mode, Paragraph-Indent Text
  765. @findex paragraph-indent-text-mode
  766. @findex paragraph-indent-minor-mode
  767. If you indent the first lines of paragraphs, then you should use
  768. Paragraph-Indent Text mode (@kbd{M-x paragraph-indent-text-mode})
  769. rather than Text mode. In that mode, you do not need to have blank
  770. lines between paragraphs, because the first-line indentation is
  771. sufficient to start a paragraph; however paragraphs in which every
  772. line is indented are not supported. Use @kbd{M-x
  773. paragraph-indent-minor-mode} to enable an equivalent minor mode for
  774. situations where you shouldn't change the major mode---in mail
  775. composition, for instance.
  776. @kindex M-TAB @r{(Text mode)}
  777. Text mode binds @kbd{M-@key{TAB}} to @code{ispell-complete-word}.
  778. This command performs completion of the partial word in the buffer
  779. before point, using the spelling dictionary as the space of possible
  780. words. @xref{Spelling}. If your window manager defines
  781. @kbd{M-@key{TAB}} to switch windows, you can type @kbd{@key{ESC}
  782. @key{TAB}} or @kbd{C-M-i} instead.
  783. @vindex text-mode-hook
  784. Entering Text mode runs the mode hook @code{text-mode-hook}
  785. (@pxref{Major Modes}).
  786. The following sections describe several major modes that are
  787. @dfn{derived} from Text mode. These derivatives share most of the
  788. features of Text mode described above. In particular, derivatives of
  789. Text mode run @code{text-mode-hook} prior to running their own mode
  790. hooks.
  791. @node Outline Mode
  792. @section Outline Mode
  793. @cindex Outline mode
  794. @cindex mode, Outline
  795. @cindex invisible lines
  796. @findex outline-mode
  797. @findex outline-minor-mode
  798. @vindex outline-minor-mode-prefix
  799. @vindex outline-mode-hook
  800. Outline mode is a major mode derived from Text mode, which is
  801. specialized for editing outlines. It provides commands to navigate
  802. between entries in the outline structure, and commands to make parts
  803. of a buffer temporarily invisible, so that the outline structure may
  804. be more easily viewed. Type @kbd{M-x outline-mode} to switch to
  805. Outline mode. Entering Outline mode runs the hook
  806. @code{text-mode-hook} followed by the hook @code{outline-mode-hook}
  807. (@pxref{Hooks}).
  808. When you use an Outline mode command to make a line invisible
  809. (@pxref{Outline Visibility}), the line disappears from the screen. An
  810. ellipsis (three periods in a row) is displayed at the end of the
  811. previous visible line, to indicate the hidden text. Multiple
  812. consecutive invisible lines produce just one ellipsis.
  813. Editing commands that operate on lines, such as @kbd{C-n} and
  814. @kbd{C-p}, treat the text of the invisible line as part of the
  815. previous visible line. Killing the ellipsis at the end of a visible
  816. line really kills all the following invisible text associated with the
  817. ellipsis.
  818. Outline minor mode is a buffer-local minor mode which provides the
  819. same commands as the major mode, Outline mode, but can be used in
  820. conjunction with other major modes. You can type @kbd{M-x
  821. outline-minor-mode} to toggle Outline minor mode in the current
  822. buffer, or use a file-local variable setting to enable it in a
  823. specific file (@pxref{File Variables}).
  824. @kindex C-c @@ @r{(Outline minor mode)}
  825. The major mode, Outline mode, provides special key bindings on the
  826. @kbd{C-c} prefix. Outline minor mode provides similar bindings with
  827. @kbd{C-c @@} as the prefix; this is to reduce the conflicts with the
  828. major mode's special commands. (The variable
  829. @code{outline-minor-mode-prefix} controls the prefix used.)
  830. @menu
  831. * Outline Format:: What the text of an outline looks like.
  832. * Outline Motion:: Special commands for moving through outlines.
  833. * Outline Visibility:: Commands to control what is visible.
  834. * Outline Views:: Outlines and multiple views.
  835. * Foldout:: Folding means zooming in on outlines.
  836. @end menu
  837. @node Outline Format
  838. @subsection Format of Outlines
  839. @cindex heading lines (Outline mode)
  840. @cindex body lines (Outline mode)
  841. Outline mode assumes that the lines in the buffer are of two types:
  842. @dfn{heading lines} and @dfn{body lines}. A heading line represents a
  843. topic in the outline. Heading lines start with one or more asterisk
  844. (@samp{*}) characters; the number of asterisks determines the depth of
  845. the heading in the outline structure. Thus, a heading line with one
  846. @samp{*} is a major topic; all the heading lines with two @samp{*}s
  847. between it and the next one-@samp{*} heading are its subtopics; and so
  848. on. Any line that is not a heading line is a body line. Body lines
  849. belong with the preceding heading line. Here is an example:
  850. @example
  851. * Food
  852. This is the body,
  853. which says something about the topic of food.
  854. ** Delicious Food
  855. This is the body of the second-level header.
  856. ** Distasteful Food
  857. This could have
  858. a body too, with
  859. several lines.
  860. *** Dormitory Food
  861. * Shelter
  862. Another first-level topic with its header line.
  863. @end example
  864. A heading line together with all following body lines is called
  865. collectively an @dfn{entry}. A heading line together with all following
  866. deeper heading lines and their body lines is called a @dfn{subtree}.
  867. @vindex outline-regexp
  868. You can customize the criterion for distinguishing heading lines by
  869. setting the variable @code{outline-regexp}. (The recommended ways to
  870. do this are in a major mode function or with a file local variable.)
  871. Any line whose beginning has a match for this regexp is considered a
  872. heading line. Matches that start within a line (not at the left
  873. margin) do not count.
  874. The length of the matching text determines the level of the heading;
  875. longer matches make a more deeply nested level. Thus, for example, if
  876. a text formatter has commands @samp{@@chapter}, @samp{@@section} and
  877. @samp{@@subsection} to divide the document into chapters and sections,
  878. you could make those lines count as heading lines by setting
  879. @code{outline-regexp} to @samp{"@@chap\\|@@\\(sub\\)*section"}. Note
  880. the trick: the two words @samp{chapter} and @samp{section} are equally
  881. long, but by defining the regexp to match only @samp{chap} we ensure
  882. that the length of the text matched on a chapter heading is shorter,
  883. so that Outline mode will know that sections are contained in
  884. chapters. This works as long as no other command starts with
  885. @samp{@@chap}.
  886. @vindex outline-level
  887. You can explicitly specify a rule for calculating the level of a
  888. heading line by setting the variable @code{outline-level}. The value
  889. of @code{outline-level} should be a function that takes no arguments
  890. and returns the level of the current heading. The recommended ways to
  891. set this variable are in a major mode command or with a file local
  892. variable.
  893. @node Outline Motion
  894. @subsection Outline Motion Commands
  895. Outline mode provides special motion commands that move backward and
  896. forward to heading lines.
  897. @table @kbd
  898. @item C-c C-n
  899. Move point to the next visible heading line
  900. (@code{outline-next-visible-heading}).
  901. @item C-c C-p
  902. Move point to the previous visible heading line
  903. (@code{outline-previous-visible-heading}).
  904. @item C-c C-f
  905. Move point to the next visible heading line at the same level
  906. as the one point is on (@code{outline-forward-same-level}).
  907. @item C-c C-b
  908. Move point to the previous visible heading line at the same level
  909. (@code{outline-backward-same-level}).
  910. @item C-c C-u
  911. Move point up to a lower-level (more inclusive) visible heading line
  912. (@code{outline-up-heading}).
  913. @end table
  914. @findex outline-next-visible-heading
  915. @findex outline-previous-visible-heading
  916. @kindex C-c C-n @r{(Outline mode)}
  917. @kindex C-c C-p @r{(Outline mode)}
  918. @kbd{C-c C-n} (@code{outline-next-visible-heading}) moves down to
  919. the next heading line. @kbd{C-c C-p}
  920. (@code{outline-previous-visible-heading}) moves similarly backward.
  921. Both accept numeric arguments as repeat counts.
  922. @findex outline-up-heading
  923. @findex outline-forward-same-level
  924. @findex outline-backward-same-level
  925. @kindex C-c C-f @r{(Outline mode)}
  926. @kindex C-c C-b @r{(Outline mode)}
  927. @kindex C-c C-u @r{(Outline mode)}
  928. @kbd{C-c C-f} (@code{outline-forward-same-level}) and @kbd{C-c C-b}
  929. (@code{outline-backward-same-level}) move from one heading line to
  930. another visible heading at the same depth in the outline. @kbd{C-c
  931. C-u} (@code{outline-up-heading}) moves backward to another heading
  932. that is less deeply nested.
  933. @node Outline Visibility
  934. @subsection Outline Visibility Commands
  935. Outline mode provides several commands for temporarily hiding or
  936. revealing parts of the buffer, based on the outline structure. These
  937. commands are not undoable; their effects are simply not recorded by
  938. the undo mechanism, so you can undo right past them (@pxref{Undo}).
  939. Many of these commands act on the current heading line. If
  940. point is on a heading line, that is the current heading line; if point
  941. is on a body line, the current heading line is the nearest preceding
  942. header line.
  943. @table @kbd
  944. @item C-c C-c
  945. Make the current heading line's body invisible
  946. (@code{outline-hide-entry}).
  947. @item C-c C-e
  948. Make the current heading line's body visible
  949. (@code{outline-show-entry}).
  950. @item C-c C-d
  951. Make everything under the current heading invisible, not including the
  952. heading itself (@code{outline-hide-subtree}).
  953. @item C-c C-s
  954. Make everything under the current heading visible, including body,
  955. subheadings, and their bodies (@code{outline-show-subtree}).
  956. @item C-c C-l
  957. Make the body of the current heading line, and of all its subheadings,
  958. invisible (@code{outline-hide-leaves}).
  959. @item C-c C-k
  960. Make all subheadings of the current heading line, at all levels,
  961. visible (@code{outline-show-branches}).
  962. @item C-c C-i
  963. Make immediate subheadings (one level down) of the current heading
  964. line visible (@code{outline-show-children}).
  965. @item C-c C-t
  966. Make all body lines in the buffer invisible
  967. (@code{outline-hide-body}).
  968. @item C-c C-a
  969. Make all lines in the buffer visible (@code{outline-show-all}).
  970. @item C-c C-q
  971. Hide everything except the top @var{n} levels of heading lines
  972. (@code{outline-hide-sublevels}).
  973. @item C-c C-o
  974. Hide everything except for the heading or body that point is in, plus
  975. the headings leading up from there to the top level of the outline
  976. (@code{outline-hide-other}).
  977. @end table
  978. @findex outline-hide-entry
  979. @findex outline-show-entry
  980. @kindex C-c C-c @r{(Outline mode)}
  981. @kindex C-c C-e @r{(Outline mode)}
  982. The simplest of these commands are @kbd{C-c C-c}
  983. (@code{outline-hide-entry}), which hides the body lines directly
  984. following the current heading line, and @kbd{C-c C-e}
  985. (@code{outline-show-entry}), which reveals them. Subheadings and
  986. their bodies are not affected.
  987. @findex outline-hide-subtree
  988. @findex outline-show-subtree
  989. @kindex C-c C-s @r{(Outline mode)}
  990. @kindex C-c C-d @r{(Outline mode)}
  991. @cindex subtree (Outline mode)
  992. The commands @kbd{C-c C-d} (@code{outline-hide-subtree}) and
  993. @kbd{C-c C-s} (@code{outline-show-subtree}) are more powerful. They
  994. apply to the current heading line's @dfn{subtree}: its body, all of
  995. its subheadings, both direct and indirect, and all of their bodies.
  996. @findex outline-hide-leaves
  997. @findex outline-show-branches
  998. @findex outline-show-children
  999. @kindex C-c C-l @r{(Outline mode)}
  1000. @kindex C-c C-k @r{(Outline mode)}
  1001. @kindex C-c C-i @r{(Outline mode)}
  1002. The command @kbd{C-c C-l} (@code{outline-hide-leaves}) hides the
  1003. body of the current heading line as well as all the bodies in its
  1004. subtree; the subheadings themselves are left visible. The command
  1005. @kbd{C-c C-k} (@code{outline-show-branches}) reveals the subheadings,
  1006. if they had previously been hidden (e.g., by @kbd{C-c C-d}). The
  1007. command @kbd{C-c C-i} (@code{outline-show-children}) is a weaker
  1008. version of this; it reveals just the direct subheadings, i.e., those
  1009. one level down.
  1010. @findex outline-hide-other
  1011. @kindex C-c C-o @r{(Outline mode)}
  1012. The command @kbd{C-c C-o} (@code{outline-hide-other}) hides
  1013. everything except the entry that point is in, plus its parents (the
  1014. headers leading up from there to top level in the outline) and the top
  1015. level headings. It also reveals body lines preceding the first
  1016. heading in the buffer.
  1017. @findex outline-hide-body
  1018. @findex outline-show-all
  1019. @kindex C-c C-t @r{(Outline mode)}
  1020. @kindex C-c C-a @r{(Outline mode)}
  1021. @findex hide-sublevels
  1022. @kindex C-c C-q @r{(Outline mode)}
  1023. The remaining commands affect the whole buffer. @kbd{C-c C-t}
  1024. (@code{outline-hide-body}) makes all body lines invisible, so that you
  1025. see just the outline structure (as a special exception, it will not
  1026. hide lines at the top of the file, preceding the first header line,
  1027. even though these are technically body lines). @kbd{C-c C-a}
  1028. (@code{outline-show-all}) makes all lines visible. @kbd{C-c C-q}
  1029. (@code{outline-hide-sublevels}) hides all but the top level headings
  1030. at and above the level of the current heading line (defaulting to 1 if
  1031. point is not on a heading); with a numeric argument @var{n}, it hides
  1032. everything except the top @var{n} levels of heading lines. Note that
  1033. it completely reveals all the @var{n} top levels and the body lines
  1034. before the first heading.
  1035. @anchor{Outline Search}
  1036. @findex reveal-mode
  1037. @vindex search-invisible
  1038. When incremental search finds text that is hidden by Outline mode,
  1039. it makes that part of the buffer visible. If you exit the search at
  1040. that position, the text remains visible. To toggle whether or not
  1041. an active incremental search can match hidden text, type @kbd{M-s i}.
  1042. To change the default for future searches, customize the option
  1043. @code{search-invisible}. (This option also affects how @code{query-replace}
  1044. and related functions treat hidden text, @pxref{Query Replace}.)
  1045. You can also automatically make text visible as you navigate in it by
  1046. using Reveal mode (@kbd{M-x reveal-mode}), a buffer-local minor mode.
  1047. @node Outline Views
  1048. @subsection Viewing One Outline in Multiple Views
  1049. @cindex multiple views of outline
  1050. @cindex views of an outline
  1051. @cindex outline with multiple views
  1052. @cindex indirect buffers and outlines
  1053. You can display two views of a single outline at the same time, in
  1054. different windows. To do this, you must create an indirect buffer using
  1055. @kbd{M-x make-indirect-buffer}. The first argument of this command is
  1056. the existing outline buffer name, and its second argument is the name to
  1057. use for the new indirect buffer. @xref{Indirect Buffers}.
  1058. Once the indirect buffer exists, you can display it in a window in the
  1059. normal fashion, with @kbd{C-x 4 b} or other Emacs commands. The Outline
  1060. mode commands to show and hide parts of the text operate on each buffer
  1061. independently; as a result, each buffer can have its own view. If you
  1062. want more than two views on the same outline, create additional indirect
  1063. buffers.
  1064. @node Foldout
  1065. @subsection Folding Editing
  1066. @cindex folding editing
  1067. The Foldout package extends Outline mode and Outline minor mode with
  1068. folding commands. The idea of folding is that you zoom in on a
  1069. nested portion of the outline, while hiding its relatives at higher
  1070. levels.
  1071. Consider an Outline mode buffer with all the text and subheadings under
  1072. level-1 headings hidden. To look at what is hidden under one of these
  1073. headings, you could use @kbd{C-c C-e} (@kbd{M-x outline-show-entry})
  1074. to expose the body, or @kbd{C-c C-i} to expose the child (level-2)
  1075. headings.
  1076. @kindex C-c C-z
  1077. @findex foldout-zoom-subtree
  1078. With Foldout, you use @kbd{C-c C-z} (@kbd{M-x foldout-zoom-subtree}).
  1079. This exposes the body and child subheadings, and narrows the buffer so
  1080. that only the @w{level-1} heading, the body and the level-2 headings are
  1081. visible. Now to look under one of the level-2 headings, position the
  1082. cursor on it and use @kbd{C-c C-z} again. This exposes the level-2 body
  1083. and its level-3 child subheadings and narrows the buffer again. Zooming
  1084. in on successive subheadings can be done as much as you like. A string
  1085. in the mode line shows how deep you've gone.
  1086. When zooming in on a heading, to see only the child subheadings specify
  1087. a numeric argument: @kbd{C-u C-c C-z}. The number of levels of children
  1088. can be specified too (compare @kbd{M-x outline-show-children}), e.g.,
  1089. @w{@kbd{M-2 C-c C-z}} exposes two levels of child subheadings.
  1090. Alternatively, the body can be specified with a negative argument:
  1091. @w{@kbd{M-- C-c C-z}}. The whole subtree can be expanded, similarly to
  1092. @kbd{C-c C-s} (@kbd{M-x outline-show-subtree}), by specifying a zero
  1093. argument: @w{@kbd{M-0 C-c C-z}}.
  1094. While you're zoomed in, you can still use Outline mode's exposure and
  1095. hiding functions without disturbing Foldout. Also, since the buffer is
  1096. narrowed, global editing actions will only affect text under the
  1097. zoomed-in heading. This is useful for restricting changes to a
  1098. particular chapter or section of your document.
  1099. @kindex C-c C-x
  1100. @findex foldout-exit-fold
  1101. To unzoom (exit) a fold, use @kbd{C-c C-x} (@kbd{M-x foldout-exit-fold}).
  1102. This hides all the text and subheadings under the top-level heading and
  1103. returns you to the previous view of the buffer. Specifying a numeric
  1104. argument exits that many levels of folds. Specifying a zero argument
  1105. exits all folds.
  1106. To cancel the narrowing of a fold without hiding the text and
  1107. subheadings, specify a negative argument. For example, @w{@kbd{M--2 C-c
  1108. C-x}} exits two folds and leaves the text and subheadings exposed.
  1109. Foldout mode also provides mouse commands for entering and exiting
  1110. folds, and for showing and hiding text:
  1111. @table @asis
  1112. @item @kbd{C-M-mouse-1} zooms in on the heading clicked on
  1113. @itemize @w{}
  1114. @item
  1115. single click: expose body.
  1116. @item
  1117. double click: expose subheadings.
  1118. @item
  1119. triple click: expose body and subheadings.
  1120. @item
  1121. quad click: expose entire subtree.
  1122. @end itemize
  1123. @item @kbd{C-M-mouse-2} exposes text under the heading clicked on
  1124. @itemize @w{}
  1125. @item
  1126. single click: expose body.
  1127. @item
  1128. double click: expose subheadings.
  1129. @item
  1130. triple click: expose body and subheadings.
  1131. @item
  1132. quad click: expose entire subtree.
  1133. @end itemize
  1134. @item @kbd{C-M-mouse-3} hides text under the heading clicked on or exits fold
  1135. @itemize @w{}
  1136. @item
  1137. single click: hide subtree.
  1138. @item
  1139. double click: exit fold and hide text.
  1140. @item
  1141. triple click: exit fold without hiding text.
  1142. @item
  1143. quad click: exit all folds and hide text.
  1144. @end itemize
  1145. @end table
  1146. @c FIXME not marked as a user variable
  1147. @vindex foldout-mouse-modifiers
  1148. You can specify different modifier keys (instead of
  1149. @kbd{@key{Ctrl}-@key{META}-}) by setting @code{foldout-mouse-modifiers}; but if
  1150. you have already loaded the @file{foldout.el} library, you must reload
  1151. it in order for this to take effect.
  1152. To use the Foldout package, you can type @kbd{M-x load-library
  1153. @key{RET} foldout @key{RET}}; or you can arrange for to do that
  1154. automatically by putting the following in your init file:
  1155. @example
  1156. (with-eval-after-load "outline"
  1157. (require 'foldout))
  1158. @end example
  1159. @node Org Mode
  1160. @section Org Mode
  1161. @cindex organizer
  1162. @cindex planner
  1163. @findex Org mode
  1164. @findex mode, Org
  1165. @findex org-mode
  1166. Org mode is a variant of Outline mode for using Emacs as an
  1167. organizer and/or authoring system. Files with names ending in the
  1168. extension @file{.org} are opened in Org mode (@pxref{Choosing Modes}).
  1169. To explicitly switch to Org mode, type @kbd{M-x org-mode}.
  1170. In Org mode, as in Outline mode, each entry has a heading line that
  1171. starts with one or more @samp{*} characters. @xref{Outline Format}.
  1172. In addition, any line that begins with the @samp{#} character is
  1173. treated as a comment.
  1174. @kindex TAB @r{(Org Mode)}
  1175. @findex org-cycle
  1176. Org mode provides commands for easily viewing and manipulating the
  1177. outline structure. The simplest of these commands is @key{TAB}
  1178. (@code{org-cycle}). If invoked on a heading line, it cycles through
  1179. the different visibility states of the subtree: (i) showing only that
  1180. heading line, (ii) showing only the heading line and the heading lines
  1181. of its direct children, if any, and (iii) showing the entire subtree.
  1182. If invoked in a body line, the global binding for @key{TAB} is
  1183. executed.
  1184. @kindex S-TAB @r{(Org Mode)}
  1185. @findex org-shifttab
  1186. Typing @kbd{S-@key{TAB}} (@code{org-shifttab}) anywhere in an Org mode
  1187. buffer cycles the visibility of the entire outline structure, between
  1188. (i) showing only top-level heading lines, (ii) showing all heading
  1189. lines but no body lines, and (iii) showing everything.
  1190. @kindex M-<up> @r{(Org Mode)}
  1191. @kindex M-<down> @r{(Org Mode)}
  1192. @kindex M-<left> @r{(Org Mode)}
  1193. @kindex M-<right> @r{(Org Mode)}
  1194. @findex org-metaup
  1195. @findex org-metadown
  1196. @findex org-metaleft
  1197. @findex org-metaright
  1198. You can move an entire entry up or down in the buffer, including its
  1199. body lines and subtree (if any), by typing @kbd{M-<up>}
  1200. (@code{org-metaup}) or @kbd{M-<down>} (@code{org-metadown}) on the
  1201. heading line. Similarly, you can promote or demote a heading line
  1202. with @kbd{M-<left>} (@code{org-metaleft}) and @kbd{M-<right>}
  1203. (@code{org-metaright}). These commands execute their global bindings
  1204. if invoked on a body line.
  1205. The following subsections give basic instructions for using Org mode
  1206. as an organizer and as an authoring system. For details, @pxref{Top,
  1207. The Org Mode Manual, Introduction, org, The Org Manual}.
  1208. @menu
  1209. * Org Organizer:: Managing TODO lists and agendas.
  1210. * Org Authoring:: Exporting Org buffers to various formats.
  1211. @end menu
  1212. @node Org Organizer
  1213. @subsection Org as an organizer
  1214. @cindex TODO item
  1215. @cindex Org agenda
  1216. @kindex C-c C-t @r{(Org Mode)}
  1217. @findex org-todo
  1218. @vindex org-todo-keywords
  1219. You can tag an Org entry as a @dfn{TODO} item by typing @kbd{C-c
  1220. C-t} (@code{org-todo}) anywhere in the entry. This adds the keyword
  1221. @samp{TODO} to the heading line. Typing @kbd{C-c C-t} again switches
  1222. the keyword to @samp{DONE}; another @kbd{C-c C-t} removes the keyword
  1223. entirely, and so forth. You can customize the keywords used by
  1224. @kbd{C-c C-t} via the variable @code{org-todo-keywords}.
  1225. @kindex C-c C-s @r{(Org Mode)}
  1226. @kindex C-c C-d @r{(Org Mode)}
  1227. @findex org-schedule
  1228. @findex org-deadline
  1229. Apart from marking an entry as TODO, you can attach a date to it, by
  1230. typing @kbd{C-c C-s} (@code{org-schedule}) in the entry. This prompts
  1231. for a date by popping up the Emacs Calendar (@pxref{Calendar/Diary}),
  1232. and then adds the tag @samp{SCHEDULED}, together with the selected
  1233. date, beneath the heading line. The command @kbd{C-c C-d}
  1234. (@code{org-deadline}) has the same effect, except that it uses the tag
  1235. @code{DEADLINE}.
  1236. @kindex C-c [ @r{(Org Mode)}
  1237. @findex org-agenda-file-to-front
  1238. @vindex org-agenda-files
  1239. Once you have some TODO items planned in an Org file, you can add
  1240. that file to the list of @dfn{agenda files} by typing @kbd{C-c [}
  1241. (@code{org-agenda-file-to-front}). Org mode is designed to let you
  1242. easily maintain multiple agenda files, e.g., for organizing different
  1243. aspects of your life. The list of agenda files is stored in the
  1244. variable @code{org-agenda-files}.
  1245. @findex org-agenda
  1246. To view items coming from your agenda files, type @kbd{M-x
  1247. org-agenda}. This command prompts for what you want to see: a list of
  1248. things to do this week, a list of TODO items with specific keywords,
  1249. etc.
  1250. @ifnottex
  1251. @xref{Agenda Views,,,org, The Org Manual}, for details.
  1252. @end ifnottex
  1253. @node Org Authoring
  1254. @subsection Org as an authoring system
  1255. @cindex Org exporting
  1256. @findex org-export
  1257. @kindex C-c C-e @r{(Org mode)}
  1258. You may want to format your Org notes nicely and to prepare them for
  1259. export and publication. To export the current buffer, type @kbd{C-c
  1260. C-e} (@code{org-export}) anywhere in an Org buffer. This command
  1261. prompts for an export format; currently supported formats include
  1262. HTML, @LaTeX{}, OpenDocument (@file{.odt}), and PDF@. Some formats,
  1263. such as PDF, require certain system tools to be installed.
  1264. @vindex org-publish-project-alist
  1265. To export several files at once to a specific directory, either
  1266. locally or over the network, you must define a list of projects
  1267. through the variable @code{org-publish-project-alist}. See its
  1268. documentation for details.
  1269. Org supports a simple markup scheme for applying text formatting to
  1270. exported documents:
  1271. @example
  1272. - This text is /emphasized/
  1273. - This text is *in bold*
  1274. - This text is _underlined_
  1275. - This text uses =a teletype font=
  1276. #+begin_quote
  1277. ``This is a quote.''
  1278. #+end_quote
  1279. #+begin_example
  1280. This is an example.
  1281. #+end_example
  1282. @end example
  1283. For further details, @ref{Exporting,,,org, The Org Manual}, and
  1284. @ref{Publishing,,,org, The Org Manual}.
  1285. @node TeX Mode
  1286. @section @TeX{} Mode
  1287. @cindex @TeX{} mode
  1288. @cindex @LaTeX{} mode
  1289. @cindex Sli@TeX{} mode
  1290. @cindex Doc@TeX{} mode
  1291. @cindex mode, @TeX{}
  1292. @cindex mode, @LaTeX{}
  1293. @cindex mode, Sli@TeX{}
  1294. @cindex mode, Doc@TeX{}
  1295. @findex tex-mode
  1296. @findex plain-tex-mode
  1297. @findex latex-mode
  1298. @findex slitex-mode
  1299. @findex doctex-mode
  1300. @findex bibtex-mode
  1301. Emacs provides special major modes for editing files written in
  1302. @TeX{} and its related formats. @TeX{} is a powerful text formatter
  1303. written by Donald Knuth; like GNU Emacs, it is free software.
  1304. @LaTeX{} is a simplified input format for @TeX{}, implemented using
  1305. @TeX{} macros. Doc@TeX{} is a special file format in which the
  1306. @LaTeX{} sources are written, combining sources with documentation.
  1307. Sli@TeX{} is an obsolete special form of @LaTeX{}.@footnote{It has
  1308. been replaced by the @samp{slides} document class, which comes with
  1309. @LaTeX{}.}
  1310. @vindex tex-default-mode
  1311. @TeX{} mode has four variants: Plain @TeX{} mode, @LaTeX{} mode,
  1312. Doc@TeX{} mode, and Sli@TeX{} mode. These distinct major modes differ
  1313. only slightly, and are designed for editing the four different
  1314. formats. Emacs selects the appropriate mode by looking at the
  1315. contents of the buffer. (This is done by the @code{tex-mode} command,
  1316. which is normally called automatically when you visit a @TeX{}-like
  1317. file. @xref{Choosing Modes}.) If the contents are insufficient to
  1318. determine this, Emacs chooses the mode specified by the variable
  1319. @code{tex-default-mode}; its default value is @code{latex-mode}. If
  1320. Emacs does not guess right, you can select the correct variant of
  1321. @TeX{} mode using the command @kbd{M-x plain-tex-mode}, @kbd{M-x
  1322. latex-mode}, @kbd{M-x slitex-mode}, or @kbd{doctex-mode}.
  1323. The following sections document the features of @TeX{} mode and its
  1324. variants. There are several other @TeX{}-related Emacs packages,
  1325. which are not documented in this manual:
  1326. @itemize @bullet
  1327. @item
  1328. Bib@TeX{} mode is a major mode for Bib@TeX{} files, which are commonly
  1329. used for keeping bibliographic references for @LaTeX{} documents. For
  1330. more information, see the documentation string for the command
  1331. @code{bibtex-mode}.
  1332. @item
  1333. The Ref@TeX{} package provides a minor mode which can be used with
  1334. @LaTeX{} mode to manage bibliographic references.
  1335. @ifinfo
  1336. @xref{Top,The Ref@TeX{} Manual,,reftex}.
  1337. @end ifinfo
  1338. @ifnotinfo
  1339. For more information, see the Ref@TeX{} Info manual, which is
  1340. distributed with Emacs.
  1341. @end ifnotinfo
  1342. @item
  1343. The AUC@TeX{} package provides more advanced features for editing
  1344. @TeX{} and its related formats, including the ability to preview
  1345. @TeX{} equations within Emacs buffers. Unlike Bib@TeX{} mode and the
  1346. Ref@TeX{} package, AUC@TeX{} is not distributed with Emacs by default.
  1347. It can be downloaded via the Package Menu (@pxref{Packages}); once
  1348. installed, see
  1349. @ifinfo
  1350. @ref{Top,The AUC@TeX{} Manual,,auctex}.
  1351. @end ifinfo
  1352. @ifnotinfo
  1353. the AUC@TeX{} manual, which is included with the package.
  1354. @end ifnotinfo
  1355. @end itemize
  1356. @menu
  1357. * TeX Editing:: Special commands for editing in TeX mode.
  1358. * LaTeX Editing:: Additional commands for LaTeX input files.
  1359. * TeX Print:: Commands for printing part of a file with TeX.
  1360. * TeX Misc:: Customization of TeX mode, and related features.
  1361. @end menu
  1362. @node TeX Editing
  1363. @subsection @TeX{} Editing Commands
  1364. @table @kbd
  1365. @item "
  1366. Insert, according to context, either @samp{``} or @samp{"} or
  1367. @samp{''} (@code{tex-insert-quote}).
  1368. @item C-j
  1369. Insert a paragraph break (two newlines) and check the previous
  1370. paragraph for unbalanced braces or dollar signs
  1371. (@code{tex-terminate-paragraph}).
  1372. @item M-x tex-validate-region
  1373. Check each paragraph in the region for unbalanced braces or dollar signs.
  1374. @item C-c @{
  1375. Insert @samp{@{@}} and position point between them (@code{tex-insert-braces}).
  1376. @item C-c @}
  1377. Move forward past the next unmatched close brace (@code{up-list}).
  1378. @end table
  1379. @findex tex-insert-quote
  1380. @kindex " @r{(@TeX{} mode)}
  1381. In @TeX{}, the character @samp{"} is not normally used; instead,
  1382. quotations begin with @samp{``} and end with @samp{''}. @TeX{} mode
  1383. therefore binds the @kbd{"} key to the @code{tex-insert-quote}
  1384. command. This inserts @samp{``} after whitespace or an open brace,
  1385. @samp{"} after a backslash, and @samp{''} after any other character.
  1386. As a special exception, if you type @kbd{"} when the text before
  1387. point is either @samp{``} or @samp{''}, Emacs replaces that preceding
  1388. text with a single @samp{"} character. You can therefore type
  1389. @kbd{""} to insert @samp{"}, should you ever need to do so. (You can
  1390. also use @kbd{C-q "} to insert this character.)
  1391. In @TeX{} mode, @samp{$} has a special syntax code which attempts to
  1392. understand the way @TeX{} math mode delimiters match. When you insert a
  1393. @samp{$} that is meant to exit math mode, the position of the matching
  1394. @samp{$} that entered math mode is displayed for a second. This is the
  1395. same feature that displays the open brace that matches a close brace that
  1396. is inserted. However, there is no way to tell whether a @samp{$} enters
  1397. math mode or leaves it; so when you insert a @samp{$} that enters math
  1398. mode, the previous @samp{$} position is shown as if it were a match, even
  1399. though they are actually unrelated.
  1400. @findex tex-insert-braces
  1401. @kindex C-c @{ @r{(@TeX{} mode)}
  1402. @findex up-list
  1403. @kindex C-c @} @r{(@TeX{} mode)}
  1404. @TeX{} uses braces as delimiters that must match. Some users prefer
  1405. to keep braces balanced at all times, rather than inserting them
  1406. singly. Use @kbd{C-c @{} (@code{tex-insert-braces}) to insert a pair of
  1407. braces. It leaves point between the two braces so you can insert the
  1408. text that belongs inside. Afterward, use the command @kbd{C-c @}}
  1409. (@code{up-list}) to move forward past the close brace.
  1410. @findex tex-validate-region
  1411. @findex tex-terminate-paragraph
  1412. @kindex C-j @r{(@TeX{} mode)}
  1413. There are two commands for checking the matching of braces.
  1414. @kbd{C-j} (@code{tex-terminate-paragraph}) checks the paragraph before
  1415. point, and inserts two newlines to start a new paragraph. It outputs
  1416. a message in the echo area if any mismatch is found. @kbd{M-x
  1417. tex-validate-region} checks a region, paragraph by paragraph. The
  1418. errors are listed in an @file{*Occur*} buffer; you can use the usual
  1419. Occur mode commands in that buffer, such as @kbd{C-c C-c}, to visit a
  1420. particular mismatch (@pxref{Other Repeating Search}).
  1421. Note that Emacs commands count square brackets and parentheses in
  1422. @TeX{} mode, not just braces. This is not strictly correct for the
  1423. purpose of checking @TeX{} syntax. However, parentheses and square
  1424. brackets are likely to be used in text as matching delimiters, and it
  1425. is useful for the various motion commands and automatic match display
  1426. to work with them.
  1427. @node LaTeX Editing
  1428. @subsection @LaTeX{} Editing Commands
  1429. @LaTeX{} mode provides a few extra features not applicable to plain
  1430. @TeX{}:
  1431. @table @kbd
  1432. @item C-c C-o
  1433. Insert @samp{\begin} and @samp{\end} for @LaTeX{} block and position
  1434. point on a line between them (@code{tex-latex-block}).
  1435. @item C-c C-e
  1436. Close the innermost @LaTeX{} block not yet closed
  1437. (@code{tex-close-latex-block}).
  1438. @end table
  1439. @findex tex-latex-block
  1440. @kindex C-c C-o @r{(@LaTeX{} mode)}
  1441. In @LaTeX{} input, @samp{\begin} and @samp{\end} tags are used to
  1442. group blocks of text. To insert a block, type @kbd{C-c C-o}
  1443. (@code{tex-latex-block}). This prompts for a block type, and inserts
  1444. the appropriate matching @samp{\begin} and @samp{\end} tags, leaving a
  1445. blank line between the two and moving point there.
  1446. @vindex latex-block-names
  1447. When entering the block type argument to @kbd{C-c C-o}, you can use
  1448. the usual completion commands (@pxref{Completion}). The default
  1449. completion list contains the standard @LaTeX{} block types. If you
  1450. want additional block types for completion, customize the list
  1451. variable @code{latex-block-names}.
  1452. @findex tex-close-latex-block
  1453. @kindex C-c C-e @r{(@LaTeX{} mode)}
  1454. @findex latex-electric-env-pair-mode
  1455. In @LaTeX{} input, @samp{\begin} and @samp{\end} tags must balance.
  1456. You can use @kbd{C-c C-e} (@code{tex-close-latex-block}) to insert an
  1457. @samp{\end} tag which matches the last unmatched @samp{\begin}. It
  1458. also indents the @samp{\end} to match the corresponding @samp{\begin},
  1459. and inserts a newline after the @samp{\end} tag if point is at the
  1460. beginning of a line. The minor mode @code{latex-electric-env-pair-mode}
  1461. automatically inserts an @samp{\end} or @samp{\begin} tag for you
  1462. when you type the corresponding one.
  1463. @node TeX Print
  1464. @subsection @TeX{} Printing Commands
  1465. You can invoke @TeX{} as an subprocess of Emacs, supplying either
  1466. the entire contents of the buffer or just part of it (e.g., one
  1467. chapter of a larger document).
  1468. @table @kbd
  1469. @item C-c C-b
  1470. Invoke @TeX{} on the entire current buffer (@code{tex-buffer}).
  1471. @item C-c C-r
  1472. Invoke @TeX{} on the current region, together with the buffer's header
  1473. (@code{tex-region}).
  1474. @item C-c C-f
  1475. Invoke @TeX{} on the current file (@code{tex-file}).
  1476. @item C-c C-v
  1477. Preview the output from the last @kbd{C-c C-r}, @kbd{C-c C-b}, or @kbd{C-c
  1478. C-f} command (@code{tex-view}).
  1479. @item C-c C-p
  1480. Print the output from the last @kbd{C-c C-b}, @kbd{C-c C-r}, or
  1481. @kbd{C-c C-f} command (@code{tex-print}).
  1482. @item C-c @key{TAB}
  1483. Invoke Bib@TeX{} on the current file (@code{tex-bibtex-file}).
  1484. @item C-c C-l
  1485. Recenter the window showing output from @TeX{} so that the last line
  1486. can be seen (@code{tex-recenter-output-buffer}).
  1487. @item C-c C-k
  1488. Kill the @TeX{} subprocess (@code{tex-kill-job}).
  1489. @item C-c C-c
  1490. Invoke some other compilation command on the entire current buffer
  1491. (@code{tex-compile}).
  1492. @end table
  1493. @findex tex-buffer
  1494. @kindex C-c C-b @r{(@TeX{} mode)}
  1495. @findex tex-view
  1496. @kindex C-c C-v @r{(@TeX{} mode)}
  1497. @findex tex-print
  1498. @kindex C-c C-p @r{(@TeX{} mode)}
  1499. To pass the current buffer through @TeX{}, type @kbd{C-c C-b}
  1500. (@code{tex-buffer}). The formatted output goes in a temporary file,
  1501. normally a @file{.dvi} file. Afterwards, you can type @kbd{C-c C-v}
  1502. (@code{tex-view}) to launch an external program, such as
  1503. @command{xdvi}, to view this output file. You can also type @kbd{C-c
  1504. C-p} (@code{tex-print}) to print a hardcopy of the output file.
  1505. @cindex @env{TEXINPUTS} environment variable
  1506. @vindex tex-directory
  1507. By default, @kbd{C-c C-b} runs @TeX{} in the current directory. The
  1508. output of @TeX{} also goes in this directory. To run @TeX{} in a
  1509. different directory, change the variable @code{tex-directory} to the
  1510. desired directory name. If your environment variable @env{TEXINPUTS}
  1511. contains relative directory names, or if your files contains
  1512. @samp{\input} commands with relative file names, then
  1513. @code{tex-directory} @emph{must} be @code{"."} or you will get the
  1514. wrong results. Otherwise, it is safe to specify some other directory,
  1515. such as @code{"/tmp"}.
  1516. @vindex tex-run-command
  1517. @vindex latex-run-command
  1518. @vindex tex-dvi-view-command
  1519. @vindex tex-dvi-print-command
  1520. @vindex tex-print-file-extension
  1521. The buffer's @TeX{} variant determines what shell command @kbd{C-c
  1522. C-b} actually runs. In Plain @TeX{} mode, it is specified by the
  1523. variable @code{tex-run-command}, which defaults to @code{"tex"}. In
  1524. @LaTeX{} mode, it is specified by @code{latex-run-command}, which
  1525. defaults to @code{"latex"}. The shell command that @kbd{C-c C-v} runs
  1526. to view the @file{.dvi} output is determined by the variable
  1527. @code{tex-dvi-view-command}, regardless of the @TeX{} variant. The
  1528. shell command that @kbd{C-c C-p} runs to print the output is
  1529. determined by the variable @code{tex-dvi-print-command}. The variable
  1530. @code{tex-print-file-extension} can be set to the required file
  1531. extension for viewing and printing @TeX{}-compiled files. For
  1532. example, you can set it to @file{.pdf}, and update
  1533. @code{tex-dvi-view-command} and @code{tex-dvi-print-command}
  1534. accordingly.
  1535. Normally, Emacs automatically appends the output file name to the
  1536. shell command strings described in the preceding paragraph. For
  1537. example, if @code{tex-dvi-view-command} is @code{"xdvi"}, @kbd{C-c
  1538. C-v} runs @command{xdvi @var{output-file-name}}. In some cases,
  1539. however, the file name needs to be embedded in the command, e.g., if
  1540. you need to provide the file name as an argument to one command whose
  1541. output is piped to another. You can specify where to put the file
  1542. name with @samp{*} in the command string. For example,
  1543. @example
  1544. (setq tex-dvi-print-command "dvips -f * | lpr")
  1545. @end example
  1546. @findex tex-kill-job
  1547. @kindex C-c C-k @r{(@TeX{} mode)}
  1548. @findex tex-recenter-output-buffer
  1549. @kindex C-c C-l @r{(@TeX{} mode)}
  1550. The terminal output from @TeX{}, including any error messages,
  1551. appears in a buffer called @file{*tex-shell*}. If @TeX{} gets an
  1552. error, you can switch to this buffer and feed it input (this works as
  1553. in Shell mode; @pxref{Interactive Shell}). Without switching to this
  1554. buffer you can scroll it so that its last line is visible by typing
  1555. @kbd{C-c C-l}.
  1556. Type @kbd{C-c C-k} (@code{tex-kill-job}) to kill the @TeX{} process if
  1557. you see that its output is no longer useful. Using @kbd{C-c C-b} or
  1558. @kbd{C-c C-r} also kills any @TeX{} process still running.
  1559. @findex tex-region
  1560. @kindex C-c C-r @r{(@TeX{} mode)}
  1561. You can also pass an arbitrary region through @TeX{} by typing
  1562. @kbd{C-c C-r} (@code{tex-region}). This is tricky, however, because
  1563. most files of @TeX{} input contain commands at the beginning to set
  1564. parameters and define macros, without which no later part of the file
  1565. will format correctly. To solve this problem, @kbd{C-c C-r} allows
  1566. you to designate a part of the file as containing essential commands;
  1567. it is included before the specified region as part of the input to
  1568. @TeX{}. The designated part of the file is called the @dfn{header}.
  1569. @cindex header (@TeX{} mode)
  1570. To indicate the bounds of the header in Plain @TeX{} mode, you insert two
  1571. special strings in the file. Insert @samp{%**start of header} before the
  1572. header, and @samp{%**end of header} after it. Each string must appear
  1573. entirely on one line, but there may be other text on the line before or
  1574. after. The lines containing the two strings are included in the header.
  1575. If @samp{%**start of header} does not appear within the first 100 lines of
  1576. the buffer, @kbd{C-c C-r} assumes that there is no header.
  1577. In @LaTeX{} mode, the header begins with @samp{\documentclass} or
  1578. @samp{\documentstyle} and ends with @samp{\begin@{document@}}. These
  1579. are commands that @LaTeX{} requires you to use in any case, so nothing
  1580. special needs to be done to identify the header.
  1581. @findex tex-file
  1582. @kindex C-c C-f @r{(@TeX{} mode)}
  1583. The commands (@code{tex-buffer}) and (@code{tex-region}) do all of their
  1584. work in a temporary directory, and do not have available any of the auxiliary
  1585. files needed by @TeX{} for cross-references; these commands are generally
  1586. not suitable for running the final copy in which all of the cross-references
  1587. need to be correct.
  1588. When you want the auxiliary files for cross references, use @kbd{C-c
  1589. C-f} (@code{tex-file}) which runs @TeX{} on the current buffer's file,
  1590. in that file's directory. Before running @TeX{}, it offers to save any
  1591. modified buffers. Generally, you need to use (@code{tex-file}) twice to
  1592. get the cross-references right.
  1593. @vindex tex-start-options
  1594. The value of the variable @code{tex-start-options} specifies
  1595. options for the @TeX{} run.
  1596. @vindex tex-start-commands
  1597. The value of the variable @code{tex-start-commands} specifies @TeX{}
  1598. commands for starting @TeX{}. The default value causes @TeX{} to run
  1599. in nonstop mode. To run @TeX{} interactively, set the variable to
  1600. @code{""}.
  1601. @vindex tex-main-file
  1602. Large @TeX{} documents are often split into several files---one main
  1603. file, plus subfiles. Running @TeX{} on a subfile typically does not
  1604. work; you have to run it on the main file. In order to make
  1605. @code{tex-file} useful when you are editing a subfile, you can set the
  1606. variable @code{tex-main-file} to the name of the main file. Then
  1607. @code{tex-file} runs @TeX{} on that file.
  1608. The most convenient way to use @code{tex-main-file} is to specify it
  1609. in a local variable list in each of the subfiles. @xref{File
  1610. Variables}.
  1611. @findex tex-bibtex-file
  1612. @kindex C-c TAB @r{(@TeX{} mode)}
  1613. @vindex tex-bibtex-command
  1614. For @LaTeX{} files, you can use Bib@TeX{} to process the auxiliary
  1615. file for the current buffer's file. Bib@TeX{} looks up bibliographic
  1616. citations in a data base and prepares the cited references for the
  1617. bibliography section. The command @kbd{C-c @key{TAB}}
  1618. (@code{tex-bibtex-file}) runs the shell command
  1619. (@code{tex-bibtex-command}) to produce a @samp{.bbl} file for the
  1620. current buffer's file. Generally, you need to do @kbd{C-c C-f}
  1621. (@code{tex-file}) once to generate the @samp{.aux} file, then do
  1622. @kbd{C-c @key{TAB}} (@code{tex-bibtex-file}), and then repeat @kbd{C-c C-f}
  1623. (@code{tex-file}) twice more to get the cross-references correct.
  1624. @findex tex-compile
  1625. @kindex C-c C-c @r{(@TeX{} mode)}
  1626. To invoke some other compilation program on the current @TeX{}
  1627. buffer, type @kbd{C-c C-c} (@code{tex-compile}). This command knows
  1628. how to pass arguments to many common programs, including
  1629. @file{pdflatex}, @file{yap}, @file{xdvi}, and @file{dvips}. You can
  1630. select your desired compilation program using the standard completion
  1631. keys (@pxref{Completion}).
  1632. @node TeX Misc
  1633. @subsection @TeX{} Mode Miscellany
  1634. @vindex tex-shell-hook
  1635. @vindex tex-mode-hook
  1636. @vindex latex-mode-hook
  1637. @vindex slitex-mode-hook
  1638. @vindex plain-tex-mode-hook
  1639. Entering any variant of @TeX{} mode runs the hooks
  1640. @code{text-mode-hook} and @code{tex-mode-hook}. Then it runs either
  1641. @code{plain-tex-mode-hook}, @code{latex-mode-hook}, or
  1642. @code{slitex-mode-hook}, whichever is appropriate. Starting the
  1643. @TeX{} shell runs the hook @code{tex-shell-hook}. @xref{Hooks}.
  1644. @findex iso-iso2tex
  1645. @findex iso-tex2iso
  1646. @findex iso-iso2gtex
  1647. @findex iso-gtex2iso
  1648. @cindex Latin-1 @TeX{} encoding
  1649. @cindex @TeX{} encoding
  1650. The commands @kbd{M-x iso-iso2tex}, @kbd{M-x iso-tex2iso}, @kbd{M-x
  1651. iso-iso2gtex} and @kbd{M-x iso-gtex2iso} can be used to convert
  1652. between Latin-1 encoded files and @TeX{}-encoded equivalents.
  1653. @node HTML Mode
  1654. @section SGML and HTML Modes
  1655. @cindex SGML mode
  1656. @cindex HTML mode
  1657. @cindex mode, SGML
  1658. @cindex mode, HTML
  1659. @findex sgml-mode
  1660. @findex html-mode
  1661. The major modes for SGML and HTML provide indentation support and
  1662. commands for operating on tags.
  1663. HTML consists of two modes---one, a basic mode called
  1664. @code{html-mode} is a slightly customized variant of SGML mode. The
  1665. other, which is used by default for HTML files, is called
  1666. @code{mhtml-mode}, and attempts to properly handle Javascript enclosed
  1667. in a @code{<script>} element and CSS embedded in a @code{<style>}
  1668. element.
  1669. @table @kbd
  1670. @item C-c C-n
  1671. @kindex C-c C-n @r{(SGML mode)}
  1672. @findex sgml-name-char
  1673. Interactively specify a special character and insert the SGML
  1674. @samp{&}-command for that character (@code{sgml-name-char}).
  1675. @item C-c C-t
  1676. @kindex C-c C-t @r{(SGML mode)}
  1677. @findex sgml-tag
  1678. Interactively specify a tag and its attributes (@code{sgml-tag}).
  1679. This command asks you for a tag name and for the attribute values,
  1680. then inserts both the opening tag and the closing tag, leaving point
  1681. between them.
  1682. With a prefix argument @var{n}, the command puts the tag around the
  1683. @var{n} words already present in the buffer after point. Whenever a
  1684. region is active, it puts the tag around the region (when Transient
  1685. Mark mode is off, it does this when a numeric argument of @minus{}1 is
  1686. supplied.)
  1687. @item C-c C-a
  1688. @kindex C-c C-a @r{(SGML mode)}
  1689. @findex sgml-attributes
  1690. Interactively insert attribute values for the current tag
  1691. (@code{sgml-attributes}).
  1692. @item C-c C-f
  1693. @kindex C-c C-f @r{(SGML mode)}
  1694. @findex sgml-skip-tag-forward
  1695. Skip across a balanced tag group (which extends from an opening tag
  1696. through its corresponding closing tag) (@code{sgml-skip-tag-forward}).
  1697. A numeric argument acts as a repeat count.
  1698. @item C-c C-b
  1699. @kindex C-c C-b @r{(SGML mode)}
  1700. @findex sgml-skip-tag-backward
  1701. Skip backward across a balanced tag group (which extends from an
  1702. opening tag through its corresponding closing tag)
  1703. (@code{sgml-skip-tag-backward}). A numeric argument acts as a repeat
  1704. count.
  1705. @item C-c C-d
  1706. @kindex C-c C-d @r{(SGML mode)}
  1707. @findex sgml-delete-tag
  1708. Delete the tag at or after point, and delete the matching tag too
  1709. (@code{sgml-delete-tag}). If the tag at or after point is an opening
  1710. tag, delete the closing tag too; if it is a closing tag, delete the
  1711. opening tag too.
  1712. @item C-c ? @var{tag} @key{RET}
  1713. @kindex C-c ? @r{(SGML mode)}
  1714. @findex sgml-tag-help
  1715. Display a description of the meaning of tag @var{tag}
  1716. (@code{sgml-tag-help}). If the argument @var{tag} is empty, describe
  1717. the tag at point.
  1718. @item C-c /
  1719. @kindex C-c / @r{(SGML mode)}
  1720. @findex sgml-close-tag
  1721. Insert a close tag for the innermost unterminated tag
  1722. (@code{sgml-close-tag}). If called within a tag or a comment,
  1723. close it instead of inserting a close tag.
  1724. @item C-c 8
  1725. @kindex C-c 8 @r{(SGML mode)}
  1726. @findex sgml-name-8bit-mode
  1727. Toggle a minor mode in which Latin-1 characters insert the
  1728. corresponding SGML commands that stand for them, instead of the
  1729. characters themselves (@code{sgml-name-8bit-mode}).
  1730. @item C-c C-v
  1731. @kindex C-c C-v @r{(SGML mode)}
  1732. @findex sgml-validate
  1733. Run a shell command (which you must specify) to validate the current
  1734. buffer as SGML (@code{sgml-validate}).
  1735. @item C-c @key{TAB}
  1736. @kindex C-c TAB @r{(SGML mode)}
  1737. @findex sgml-tags-invisible
  1738. Toggle the visibility of existing tags in the buffer. This can be
  1739. used as a cheap preview (@code{sgml-tags-invisible}).
  1740. @end table
  1741. @cindex nXML mode
  1742. @cindex mode, nXML
  1743. @findex nxml-mode
  1744. @cindex XML schema
  1745. The major mode for editing XML documents is called nXML mode. This
  1746. is a powerful major mode that can recognize many existing XML schema
  1747. and use them to provide completion of XML elements via
  1748. @kbd{M-@key{TAB}}, as well as on-the-fly XML
  1749. validation with error highlighting. To enable nXML mode in an
  1750. existing buffer, type @kbd{M-x nxml-mode}, or, equivalently, @kbd{M-x
  1751. xml-mode}. Emacs uses nXML mode for files which have the extension
  1752. @file{.xml}. For XHTML files, which have the extension @file{.xhtml},
  1753. Emacs uses HTML mode by default; you can make it use nXML mode by
  1754. customizing the variable @code{auto-mode-alist} (@pxref{Choosing
  1755. Modes}).
  1756. @ifinfo
  1757. nXML mode is described in its own manual: @xref{Top, nXML
  1758. Mode,,nxml-mode, nXML Mode}.
  1759. @end ifinfo
  1760. @ifnotinfo
  1761. nXML mode is described in an Info manual, which is distributed with
  1762. Emacs.
  1763. @end ifnotinfo
  1764. @vindex sgml-xml-mode
  1765. You may choose to use the less powerful SGML mode for editing XML,
  1766. since XML is a strict subset of SGML@. To enable SGML mode in an
  1767. existing buffer, type @kbd{M-x sgml-mode}. On enabling SGML mode,
  1768. Emacs examines the buffer to determine whether it is XML; if so, it
  1769. sets the variable @code{sgml-xml-mode} to a non-@code{nil} value.
  1770. This causes SGML mode's tag insertion commands, described above, to
  1771. always insert explicit closing tags as well.
  1772. @node Nroff Mode
  1773. @section Nroff Mode
  1774. @cindex nroff
  1775. @findex nroff-mode
  1776. @vindex nroff-mode-hook
  1777. Nroff mode, a major mode derived from Text mode, is
  1778. specialized for editing nroff files (e.g., Unix man pages). Type
  1779. @kbd{M-x nroff-mode} to enter this mode. Entering Nroff mode runs the
  1780. hook @code{text-mode-hook}, then @code{nroff-mode-hook}
  1781. (@pxref{Hooks}).
  1782. In Nroff mode, nroff command lines are treated as paragraph
  1783. separators, pages are separated by @samp{.bp} commands, and comments
  1784. start with backslash-doublequote. It also defines these commands:
  1785. @findex forward-text-line
  1786. @findex backward-text-line
  1787. @findex count-text-lines
  1788. @kindex M-n @r{(Nroff mode)}
  1789. @kindex M-p @r{(Nroff mode)}
  1790. @kindex M-? @r{(Nroff mode)}
  1791. @table @kbd
  1792. @item M-n
  1793. Move to the beginning of the next line that isn't an nroff command
  1794. (@code{forward-text-line}). An argument is a repeat count.
  1795. @item M-p
  1796. Like @kbd{M-n} but move up (@code{backward-text-line}).
  1797. @item M-?
  1798. Displays in the echo area the number of text lines (lines that are not
  1799. nroff commands) in the region (@code{count-text-lines}).
  1800. @end table
  1801. @findex electric-nroff-mode
  1802. Electric Nroff mode is a buffer-local minor mode that can be used
  1803. with Nroff mode. To toggle this minor mode, type @kbd{M-x
  1804. electric-nroff-mode} (@pxref{Minor Modes}). When the mode is on, each
  1805. time you type @key{RET} to end a line containing an nroff command that
  1806. opens a kind of grouping, the nroff command to close that grouping is
  1807. automatically inserted on the following line.
  1808. If you use Outline minor mode with Nroff mode (@pxref{Outline
  1809. Mode}), heading lines are lines of the form @samp{.H} followed by a
  1810. number (the header level).
  1811. @node Enriched Text
  1812. @section Enriched Text
  1813. @cindex Enriched mode
  1814. @cindex mode, Enriched
  1815. @cindex enriched text
  1816. @cindex WYSIWYG
  1817. @cindex word processing
  1818. @cindex text/enriched MIME format
  1819. Enriched mode is a minor mode for editing formatted text files in a
  1820. WYSIWYG (What You See Is What You Get) fashion. When Enriched
  1821. mode is enabled, you can apply various formatting properties to the
  1822. text in the buffer, such as fonts and colors; upon saving the buffer,
  1823. those properties are saved together with the text, using the MIME
  1824. @samp{text/enriched} file format.
  1825. Enriched mode is typically used with Text mode (@pxref{Text Mode}).
  1826. It is @emph{not} compatible with Font Lock mode, which is used by many
  1827. major modes, including most programming language modes, for syntax
  1828. highlighting (@pxref{Font Lock}). Unlike Enriched mode, Font Lock
  1829. mode assigns text properties automatically, based on the current
  1830. buffer contents; those properties are not saved to disk.
  1831. The file @file{enriched.txt} in Emacs's @code{data-directory}
  1832. serves as an example of the features of Enriched mode.
  1833. @menu
  1834. * Enriched Mode:: Entering and exiting Enriched mode.
  1835. * Hard and Soft Newlines:: There are two different kinds of newlines.
  1836. * Editing Format Info:: How to edit text properties.
  1837. * Enriched Faces:: Bold, italic, underline, etc.
  1838. * Enriched Indentation:: Changing the left and right margins.
  1839. * Enriched Justification:: Centering, setting text flush with the
  1840. left or right margin, etc.
  1841. * Enriched Properties:: The ``special text properties'' submenu.
  1842. @end menu
  1843. @node Enriched Mode
  1844. @subsection Enriched Mode
  1845. Enriched mode is a buffer-local minor mode (@pxref{Minor Modes}).
  1846. When you visit a file that has been saved in the @samp{text/enriched}
  1847. format, Emacs automatically enables Enriched mode, and applies the
  1848. formatting information in the file to the buffer text. When you save
  1849. a buffer with Enriched mode enabled, it is saved using the
  1850. @samp{text/enriched} format, including the formatting information.
  1851. @findex enriched-mode
  1852. To create a new file of formatted text, visit the nonexistent file
  1853. and type @kbd{M-x enriched-mode}. This command actually toggles
  1854. Enriched mode. With a prefix argument, it enables Enriched mode if
  1855. the argument is positive, and disables Enriched mode otherwise. If
  1856. you disable Enriched mode, Emacs no longer saves the buffer using the
  1857. @samp{text/enriched} format; any formatting properties that have been
  1858. added to the buffer remain in the buffer, but they are not saved to
  1859. disk.
  1860. @vindex enriched-translations
  1861. Enriched mode does not save all Emacs text properties, only those
  1862. specified in the variable @code{enriched-translations}. These include
  1863. properties for fonts, colors, indentation, and justification.
  1864. @findex format-decode-buffer
  1865. If you visit a file and Emacs fails to recognize that it is in the
  1866. @samp{text/enriched} format, type @kbd{M-x format-decode-buffer}.
  1867. This command prompts for a file format, and re-reads the file in that
  1868. format. Specifying the @samp{text/enriched} format automatically
  1869. enables Enriched mode.
  1870. To view a @samp{text/enriched} file in raw form (as plain text with
  1871. markup tags rather than formatted text), use @kbd{M-x
  1872. find-file-literally} (@pxref{Visiting}).
  1873. @xref{Format Conversion,, Format Conversion, elisp, the Emacs Lisp
  1874. Reference Manual}, for details of how Emacs recognizes and converts
  1875. file formats like @samp{text/enriched}. @xref{Text Properties,,,
  1876. elisp, the Emacs Lisp Reference Manual}, for more information about
  1877. text properties.
  1878. @node Hard and Soft Newlines
  1879. @subsection Hard and Soft Newlines
  1880. @cindex hard newline
  1881. @cindex soft newline
  1882. @cindex newlines, hard and soft
  1883. @cindex use-hard-newlines
  1884. In Enriched mode, Emacs distinguishes between two different kinds of
  1885. newlines, @dfn{hard} newlines and @dfn{soft} newlines. You can also
  1886. enable or disable this feature in other buffers, by typing @kbd{M-x
  1887. use-hard-newlines}.
  1888. Hard newlines are used to separate paragraphs, or anywhere there
  1889. needs to be a line break regardless of how the text is filled; soft
  1890. newlines are used for filling. The @key{RET} (@code{newline}) and
  1891. @kbd{C-o} (@code{open-line}) commands insert hard newlines. The fill
  1892. commands, including Auto Fill (@pxref{Auto Fill}), insert only soft
  1893. newlines and delete only soft newlines, leaving hard newlines alone.
  1894. @c FIXME: I don't see 'unfilled' in that node. --xfq
  1895. Thus, when editing with Enriched mode, you should not use @key{RET}
  1896. or @kbd{C-o} to break lines in the middle of filled paragraphs. Use
  1897. Auto Fill mode or explicit fill commands (@pxref{Fill Commands})
  1898. instead. Use @key{RET} or @kbd{C-o} where line breaks should always
  1899. remain, such as in tables and lists. For such lines, you may also
  1900. want to set the justification style to @code{unfilled}
  1901. (@pxref{Enriched Justification}).
  1902. @node Editing Format Info
  1903. @subsection Editing Format Information
  1904. The easiest way to alter properties is with the @samp{Text
  1905. Properties} menu. You can get to this menu from the @samp{Edit} menu
  1906. in the menu bar (@pxref{Menu Bar}), or with @kbd{C-mouse-2}
  1907. (@pxref{Menu Mouse Clicks}). Some of the commands in the @samp{Text
  1908. Properties} menu are listed below (you can also invoke them with
  1909. @kbd{M-x}):
  1910. @table @code
  1911. @findex facemenu-remove-face-props
  1912. @item Remove Face Properties
  1913. Remove face properties from the region
  1914. (@code{facemenu-remove-face-props}).
  1915. @findex facemenu-remove-all
  1916. @item Remove Text Properties
  1917. Remove all text properties from the region, including face properties
  1918. (@code{facemenu-remove-all}).
  1919. @findex describe-text-properties
  1920. @cindex text properties of characters
  1921. @cindex overlays at character position
  1922. @cindex widgets at buffer position
  1923. @cindex buttons at buffer position
  1924. @item Describe Properties
  1925. List all text properties and other information about the character
  1926. following point (@code{describe-text-properties}).
  1927. @item Display Faces
  1928. Display a list of defined faces (@code{list-faces-display}).
  1929. @xref{Faces}.
  1930. @item Display Colors
  1931. Display a list of defined colors (@code{list-colors-display}).
  1932. @xref{Colors}.
  1933. @end table
  1934. @noindent
  1935. The other menu entries are described in the following sections.
  1936. @node Enriched Faces
  1937. @subsection Faces in Enriched Text
  1938. The following commands can be used to add or remove faces
  1939. (@pxref{Faces}). Each applies to the text in the region if the mark
  1940. is active, and to the next self-inserting character if the mark is
  1941. inactive. With a prefix argument, each command applies to the next
  1942. self-inserting character even if the region is active.
  1943. @table @kbd
  1944. @kindex M-o d @r{(Enriched mode)}
  1945. @findex facemenu-set-default
  1946. @item M-o d
  1947. Remove all @code{face} properties (@code{facemenu-set-default}).
  1948. @kindex M-o b @r{(Enriched mode)}
  1949. @findex facemenu-set-bold
  1950. @item M-o b
  1951. Apply the @code{bold} face (@code{facemenu-set-bold}).
  1952. @kindex M-o i @r{(Enriched mode)}
  1953. @findex facemenu-set-italic
  1954. @item M-o i
  1955. Apply the @code{italic} face (@code{facemenu-set-italic}).
  1956. @kindex M-o l @r{(Enriched mode)}
  1957. @findex facemenu-set-bold-italic
  1958. @item M-o l
  1959. Apply the @code{bold-italic} face (@code{facemenu-set-bold-italic}).
  1960. @kindex M-o u @r{(Enriched mode)}
  1961. @findex facemenu-set-underline
  1962. @item M-o u
  1963. Apply the @code{underline} face (@code{facemenu-set-underline}).
  1964. @kindex M-o o @r{(Enriched mode)}
  1965. @findex facemenu-set-face
  1966. @item M-o o @var{face} @key{RET}
  1967. Apply the face @var{face} (@code{facemenu-set-face}).
  1968. @findex facemenu-set-foreground
  1969. @item M-x facemenu-set-foreground
  1970. Prompt for a color (@pxref{Colors}), and apply it as a foreground
  1971. color.
  1972. @findex facemenu-set-background
  1973. @item M-x facemenu-set-background
  1974. Prompt for a color, and apply it as a background color.
  1975. @end table
  1976. @noindent
  1977. These command are also available via the Text Properties menu.
  1978. A self-inserting character normally inherits the face properties
  1979. (and most other text properties) from the preceding character in the
  1980. buffer. If you use one of the above commands to specify the face for
  1981. the next self-inserting character, that character will not inherit the
  1982. faces properties from the preceding character, but it will still
  1983. inherit other text properties.
  1984. Enriched mode defines two additional faces: @code{excerpt} and
  1985. @code{fixed}. These correspond to codes used in the text/enriched
  1986. file format. The @code{excerpt} face is intended for quotations; by
  1987. default, it appears the same as @code{italic}. The @code{fixed} face
  1988. specifies fixed-width text; by default, it appears the same as
  1989. @code{bold}.
  1990. @node Enriched Indentation
  1991. @subsection Indentation in Enriched Text
  1992. In Enriched mode, you can specify different amounts of indentation
  1993. for the right or left margin of a paragraph or a part of a paragraph.
  1994. These margins also affect fill commands such as @kbd{M-q}
  1995. (@pxref{Filling}).
  1996. The Indentation submenu of Text Properties offers commands
  1997. for specifying indentation:
  1998. @table @code
  1999. @kindex C-x TAB @r{(Enriched mode)}
  2000. @findex increase-left-margin
  2001. @item Indent More
  2002. Indent the region by 4 columns (@code{increase-left-margin}). In
  2003. Enriched mode, this command is also available on @kbd{C-x @key{TAB}}; if
  2004. you supply a numeric argument, that says how many columns to add to the
  2005. margin (a negative argument reduces the number of columns).
  2006. @item Indent Less
  2007. Remove 4 columns of indentation from the region.
  2008. @item Indent Right More
  2009. Make the text narrower by indenting 4 columns at the right margin.
  2010. @item Indent Right Less
  2011. Remove 4 columns of indentation from the right margin.
  2012. @end table
  2013. @vindex standard-indent
  2014. The variable @code{standard-indent} specifies how many columns these
  2015. commands should add to or subtract from the indentation. The default
  2016. value is 4. The default right margin for Enriched mode is controlled
  2017. by the variable @code{fill-column}, as usual.
  2018. @kindex C-c [ @r{(Enriched mode)}
  2019. @kindex C-c ] @r{(Enriched mode)}
  2020. @findex set-left-margin
  2021. @findex set-right-margin
  2022. You can also type @kbd{C-c [} (@code{set-left-margin}) and @kbd{C-c
  2023. ]} (@code{set-right-margin}) to set the left and right margins. You
  2024. can specify the margin width with a numeric argument; otherwise these
  2025. commands prompt for a value via the minibuffer.
  2026. The fill prefix, if any, works in addition to the specified paragraph
  2027. indentation: @kbd{C-x .} does not include the specified indentation's
  2028. whitespace in the new value for the fill prefix, and the fill commands
  2029. look for the fill prefix after the indentation on each line. @xref{Fill
  2030. Prefix}.
  2031. @node Enriched Justification
  2032. @subsection Justification in Enriched Text
  2033. @cindex justification style
  2034. In Enriched mode, you can use the following commands to specify
  2035. various @dfn{justification styles} for filling. These commands apply
  2036. to the paragraph containing point, or, if the region is active, to all
  2037. paragraphs overlapping the region.
  2038. @table @kbd
  2039. @kindex M-j l @r{(Enriched mode)}
  2040. @findex set-justification-left
  2041. @item M-j l
  2042. Align lines to the left margin (@code{set-justification-left}).
  2043. @kindex M-j r @r{(Enriched mode)}
  2044. @findex set-justification-right
  2045. @item M-j r
  2046. Align lines to the right margin (@code{set-justification-right}).
  2047. @kindex M-j b @r{(Enriched mode)}
  2048. @findex set-justification-full
  2049. @item M-j b
  2050. Align lines to both margins, inserting spaces in the middle of the
  2051. line to achieve this (@code{set-justification-full}).
  2052. @kindex M-j c @r{(Enriched mode)}
  2053. @kindex M-S @r{(Enriched mode)}
  2054. @findex set-justification-center
  2055. @item M-j c
  2056. @itemx M-S
  2057. Center lines between the margins (@code{set-justification-center}).
  2058. @kindex M-j u @r{(Enriched mode)}
  2059. @findex set-justification-none
  2060. @item M-j u
  2061. Turn off filling entirely (@code{set-justification-none}). The fill
  2062. commands do nothing on text with this setting. You can, however,
  2063. still indent the left margin.
  2064. @end table
  2065. @vindex default-justification
  2066. You can also specify justification styles using the Justification
  2067. submenu in the Text Properties menu. The default justification style
  2068. is specified by the per-buffer variable @code{default-justification}.
  2069. Its value should be one of the symbols @code{left}, @code{right},
  2070. @code{full}, @code{center}, or @code{none}; their meanings correspond
  2071. to the commands above.
  2072. @node Enriched Properties
  2073. @subsection Setting Other Text Properties
  2074. The Special Properties submenu of Text Properties has entries for
  2075. adding or removing three other text properties: @code{read-only},
  2076. (which disallows alteration of the text), @code{invisible} (which
  2077. hides text), and @code{intangible} (which disallows moving point
  2078. within the text). The @samp{Remove Special} menu item removes all of
  2079. these special properties from the text in the region.
  2080. The @code{invisible} and @code{intangible} properties are not saved.
  2081. @node Text Based Tables
  2082. @section Editing Text-based Tables
  2083. @cindex table mode
  2084. @cindex text-based tables
  2085. The @code{table} package provides commands to easily edit text-based
  2086. tables. Here is an example of what such a table looks like:
  2087. @smallexample
  2088. @group
  2089. +-----------------+--------------------------------+-----------------+
  2090. | Command | Description | Key Binding |
  2091. +-----------------+--------------------------------+-----------------+
  2092. | forward-char |Move point right N characters | C-f |
  2093. | |(left if N is negative). | |
  2094. | | | |
  2095. +-----------------+--------------------------------+-----------------+
  2096. | backward-char |Move point left N characters | C-b |
  2097. | |(right if N is negative). | |
  2098. | | | |
  2099. +-----------------+--------------------------------+-----------------+
  2100. @end group
  2101. @end smallexample
  2102. When Emacs recognizes such a stretch of text as a table
  2103. (@pxref{Table Recognition}), editing the contents of each table cell
  2104. will automatically resize the table, whenever the contents become too
  2105. large to fit in the cell. You can use the commands defined in the
  2106. following sections for navigating and editing the table layout.
  2107. @findex table-fixed-width-mode
  2108. Type @kbd{M-x table-fixed-width-mode} to toggle the automatic table
  2109. resizing feature.
  2110. @menu
  2111. * Table Definition:: What is a text based table.
  2112. * Table Creation:: How to create a table.
  2113. * Table Recognition:: How to activate and deactivate tables.
  2114. * Cell Commands:: Cell-oriented commands in a table.
  2115. * Cell Justification:: Justifying cell contents.
  2116. * Table Rows and Columns:: Inserting and deleting rows and columns.
  2117. * Table Conversion:: Converting between plain text and tables.
  2118. * Table Misc:: Table miscellany.
  2119. @end menu
  2120. @node Table Definition
  2121. @subsection What is a Text-based Table?
  2122. @cindex cells, for text-based tables
  2123. A @dfn{table} consists of a rectangular text area which is divided
  2124. into @dfn{cells}. Each cell must be at least one character wide and
  2125. one character high, not counting its border lines. A cell can be
  2126. subdivided into more cells, but they cannot overlap.
  2127. Cell border lines are drawn with three special characters, specified
  2128. by the following variables:
  2129. @table @code
  2130. @vindex table-cell-vertical-char
  2131. @item table-cell-vertical-char
  2132. The character used for vertical lines. The default is @samp{|}.
  2133. @vindex table-cell-horizontal-chars
  2134. @item table-cell-horizontal-chars
  2135. The characters used for horizontal lines. The default is @samp{"-="}.
  2136. @vindex table-cell-intersection-char
  2137. @item table-cell-intersection-char
  2138. The character used for the intersection of horizontal and vertical
  2139. lines. The default is @samp{+}.
  2140. @end table
  2141. @noindent
  2142. The following are examples of @emph{invalid} tables:
  2143. @example
  2144. +-----+ +--+ +-++--+
  2145. | | | | | || |
  2146. | | | | | || |
  2147. +--+ | +--+--+ +-++--+
  2148. | | | | | | +-++--+
  2149. | | | | | | | || |
  2150. +--+--+ +--+--+ +-++--+
  2151. a b c
  2152. @end example
  2153. @noindent
  2154. From left to right:
  2155. @enumerate a
  2156. @item
  2157. Overlapped cells or non-rectangular cells are not allowed.
  2158. @item
  2159. The border must be rectangular.
  2160. @item
  2161. Cells must have a minimum width/height of one character.
  2162. @end enumerate
  2163. @node Table Creation
  2164. @subsection Creating a Table
  2165. @cindex create a text-based table
  2166. @cindex table creation
  2167. @findex table-insert
  2168. To create a text-based table from scratch, type @kbd{M-x
  2169. table-insert}. This command prompts for the number of table columns,
  2170. the number of table rows, cell width and cell height. The cell width
  2171. and cell height do not include the cell borders; each can be specified
  2172. as a single integer (which means each cell is given the same
  2173. width/height), or as a sequence of integers separated by spaces or
  2174. commas (which specify the width/height of the individual table
  2175. columns/rows, counting from left to right for table columns and from
  2176. top to bottom for table rows). The specified table is then inserted
  2177. at point.
  2178. The table inserted by @kbd{M-x table-insert} contains special text
  2179. properties, which tell Emacs to treat it specially as a text-based
  2180. table. If you save the buffer to a file and visit it again later,
  2181. those properties are lost, and the table appears to Emacs as an
  2182. ordinary piece of text. See the next section, for how to convert it
  2183. back into a table.
  2184. @node Table Recognition
  2185. @subsection Table Recognition
  2186. @cindex table recognition
  2187. @findex table-recognize
  2188. @findex table-unrecognize
  2189. Existing text-based tables in a buffer, which lack the special text
  2190. properties applied by @kbd{M-x table-insert}, are not treated
  2191. specially as tables. To apply those text properties, type @kbd{M-x
  2192. table-recognize}. This command scans the current buffer,
  2193. @dfn{recognizes} valid table cells, and applies the relevant text
  2194. properties. Conversely, type @kbd{M-x table-unrecognize} to
  2195. @dfn{unrecognize} all tables in the current buffer, removing the
  2196. special text properties and converting tables back to plain text.
  2197. You can also use the following commands to selectively recognize or
  2198. unrecognize tables:
  2199. @table @kbd
  2200. @findex table-recognize-region
  2201. @item M-x table-recognize-region
  2202. Recognize tables within the current region.
  2203. @findex table-unrecognize-region
  2204. @item M-x table-unrecognize-region
  2205. Unrecognize tables within the current region.
  2206. @findex table-recognize-table
  2207. @item M-x table-recognize-table
  2208. Recognize the table at point and activate it.
  2209. @findex table-unrecognize-table
  2210. @item M-x table-unrecognize-table
  2211. Deactivate the table at point.
  2212. @findex table-recognize-cell
  2213. @item M-x table-recognize-cell
  2214. Recognize the cell at point and activate it.
  2215. @findex table-unrecognize-cell
  2216. @item M-x table-unrecognize-cell
  2217. Deactivate the cell at point.
  2218. @end table
  2219. @xref{Table Conversion}, for another way to recognize a table.
  2220. @node Cell Commands
  2221. @subsection Commands for Table Cells
  2222. @findex table-forward-cell
  2223. @findex table-backward-cell
  2224. The commands @kbd{M-x table-forward-cell} and @kbd{M-x
  2225. table-backward-cell} move point from the current cell to an adjacent
  2226. cell. The order is cyclic: when point is in the last cell of a table,
  2227. @kbd{M-x table-forward-cell} moves to the first cell. Likewise, when
  2228. point is on the first cell, @kbd{M-x table-backward-cell} moves to the
  2229. last cell.
  2230. @findex table-span-cell
  2231. @kbd{M-x table-span-cell} prompts for a direction---right, left,
  2232. above, or below---and merges the current cell with the adjacent cell
  2233. in that direction. This command signals an error if the merge would
  2234. result in an illegitimate cell layout.
  2235. @findex table-split-cell
  2236. @findex table-split-cell-vertically
  2237. @findex table-split-cell-horizontally
  2238. @cindex text-based tables, splitting cells
  2239. @cindex splitting table cells
  2240. @kbd{M-x table-split-cell} splits the current cell vertically or
  2241. horizontally, prompting for the direction with the minibuffer. To
  2242. split in a specific direction, use @kbd{M-x
  2243. table-split-cell-vertically} and @kbd{M-x
  2244. table-split-cell-horizontally}. When splitting vertically, the old
  2245. cell contents are automatically split between the two new cells. When
  2246. splitting horizontally, you are prompted for how to divide the cell
  2247. contents, if the cell is non-empty; the options are @samp{split}
  2248. (divide the contents at point), @samp{left} (put all the contents in
  2249. the left cell), and @samp{right} (put all the contents in the right
  2250. cell).
  2251. The following commands enlarge or shrink a cell. By default, they
  2252. resize by one row or column; if a numeric argument is supplied, that
  2253. specifies the number of rows or columns to resize by.
  2254. @table @kbd
  2255. @findex table-heighten-cell
  2256. @item M-x table-heighten-cell
  2257. Enlarge the current cell vertically.
  2258. @findex table-shorten-cell
  2259. @item M-x table-shorten-cell
  2260. Shrink the current cell vertically.
  2261. @findex table-widen-cell
  2262. @item M-x table-widen-cell
  2263. Enlarge the current cell horizontally.
  2264. @findex table-narrow-cell
  2265. @item M-x table-narrow-cell
  2266. Shrink the current cell horizontally.
  2267. @end table
  2268. @node Cell Justification
  2269. @subsection Cell Justification
  2270. @cindex justification in text-based tables
  2271. The command @kbd{M-x table-justify} imposes @dfn{justification} on
  2272. one or more cells in a text-based table. Justification determines how
  2273. the text in the cell is aligned, relative to the edges of the cell.
  2274. Each cell in a table can be separately justified.
  2275. @findex table-justify
  2276. @kbd{M-x table-justify} first prompts for what to justify; the
  2277. options are @samp{cell} (just the current cell), @samp{column} (all
  2278. cells in the current table column) and @samp{row} (all cells in the
  2279. current table row). The command then prompts for the justification
  2280. style; the options are @code{left}, @code{center}, @code{right},
  2281. @code{top}, @code{middle}, @code{bottom}, or @code{none} (meaning no
  2282. vertical justification).
  2283. Horizontal and vertical justification styles are specified
  2284. independently, and both types can be in effect simultaneously; for
  2285. instance, you can call @kbd{M-x table-justify} twice, once to specify
  2286. @code{right} justification and once to specify @code{bottom}
  2287. justification, to align the contents of a cell to the bottom right.
  2288. @vindex table-detect-cell-alignment
  2289. The justification style is stored in the buffer as a text property,
  2290. and is lost when you kill the buffer or exit Emacs. However, the
  2291. table recognition commands, such as @kbd{M-x table-recognize}
  2292. (@pxref{Table Recognition}), attempt to determine and re-apply each
  2293. cell's justification style, by examining its contents. To disable
  2294. this feature, change the variable @code{table-detect-cell-alignment}
  2295. to @code{nil}.
  2296. @node Table Rows and Columns
  2297. @subsection Table Rows and Columns
  2298. @cindex inserting rows and columns in text-based tables
  2299. @findex table-insert-row
  2300. @kbd{M-x table-insert-row} inserts a row of cells before the current
  2301. table row. The current row, together with point, is pushed down past
  2302. the new row. To insert a row after the last row at the bottom of a
  2303. table, invoke this command with point below the table, just below the
  2304. bottom edge. You can insert more than one row at a time by using a
  2305. numeric prefix argument.
  2306. @c A numeric prefix argument specifies the number of rows to insert.
  2307. @findex table-insert-column
  2308. Similarly, @kbd{M-x table-insert-column} inserts a column of cells
  2309. to the left of the current table column. To insert a column to the
  2310. right side of the rightmost column, invoke this command with point to
  2311. the right of the rightmost column, outside the table. A numeric
  2312. prefix argument specifies the number of columns to insert.
  2313. @cindex deleting rows and column in text-based tables
  2314. @kbd{M-x table-delete-column} deletes the column of cells at point.
  2315. Similarly, @kbd{M-x table-delete-row} deletes the row of cells at
  2316. point. A numeric prefix argument to either command specifies the
  2317. number of columns or rows to delete.
  2318. @node Table Conversion
  2319. @subsection Converting Between Plain Text and Tables
  2320. @cindex text to table
  2321. @cindex table to text
  2322. @findex table-capture
  2323. The command @kbd{M-x table-capture} captures plain text in a region
  2324. and turns it into a table. Unlike @kbd{M-x table-recognize}
  2325. (@pxref{Table Recognition}), the original text does not need to have a
  2326. table appearance; it only needs to have a logical table-like
  2327. structure.
  2328. For example, suppose we have the following numbers, which are
  2329. divided into three lines and separated horizontally by commas:
  2330. @example
  2331. 1, 2, 3, 4
  2332. 5, 6, 7, 8
  2333. , 9, 10
  2334. @end example
  2335. @noindent
  2336. Invoking @kbd{M-x table-capture} on that text produces this table:
  2337. @example
  2338. +-----+-----+-----+-----+
  2339. |1 |2 |3 |4 |
  2340. +-----+-----+-----+-----+
  2341. |5 |6 |7 |8 |
  2342. +-----+-----+-----+-----+
  2343. | |9 |10 | |
  2344. +-----+-----+-----+-----+
  2345. @end example
  2346. @findex table-release
  2347. @kbd{M-x table-release} does the opposite: it converts a table back
  2348. to plain text, removing its cell borders.
  2349. One application of this pair of commands is to edit a text in
  2350. layout. Look at the following three paragraphs (the latter two are
  2351. indented with header lines):
  2352. @example
  2353. table-capture is a powerful command.
  2354. Here are some things it can do:
  2355. Parse Cell Items Using row and column delimiter regexps,
  2356. it parses the specified text area and
  2357. extracts cell items into a table.
  2358. @end example
  2359. @noindent
  2360. Applying @code{table-capture} to a region containing the above text,
  2361. with empty strings for the column and row delimiter regexps, creates a
  2362. table with a single cell like the following one.
  2363. @smallexample
  2364. @group
  2365. +----------------------------------------------------------+
  2366. |table-capture is a powerful command. |
  2367. |Here are some things it can do: |
  2368. | |
  2369. |Parse Cell Items Using row and column delimiter regexps,|
  2370. | it parses the specified text area and |
  2371. | extracts cell items into a table. |
  2372. +----------------------------------------------------------+
  2373. @end group
  2374. @end smallexample
  2375. @noindent
  2376. We can then use the cell splitting commands (@pxref{Cell Commands}) to
  2377. subdivide the table so that each paragraph occupies a cell:
  2378. @smallexample
  2379. +----------------------------------------------------------+
  2380. |table-capture is a powerful command. |
  2381. |Here are some things it can do: |
  2382. +-----------------+----------------------------------------+
  2383. |Parse Cell Items | Using row and column delimiter regexps,|
  2384. | | it parses the specified text area and |
  2385. | | extracts cell items into a table. |
  2386. +-----------------+----------------------------------------+
  2387. @end smallexample
  2388. @noindent
  2389. Each cell can now be edited independently without affecting the layout
  2390. of other cells. When finished, we can invoke @kbd{M-x table-release}
  2391. to convert the table back to plain text.
  2392. @node Table Misc
  2393. @subsection Table Miscellany
  2394. @cindex table dimensions
  2395. @findex table-query-dimension
  2396. The command @code{table-query-dimension} reports the layout of the
  2397. table and table cell at point. Here is an example of its output:
  2398. @smallexample
  2399. Cell: (21w, 6h), Table: (67w, 16h), Dim: (2c, 3r), Total Cells: 5
  2400. @end smallexample
  2401. @noindent
  2402. This indicates that the current cell is 21 characters wide and 6 lines
  2403. high, the table is 67 characters wide and 16 lines high with 2 columns
  2404. and 3 rows, and a total of 5 cells.
  2405. @findex table-insert-sequence
  2406. @kbd{M-x table-insert-sequence} inserts a string into each cell.
  2407. Each string is a part of a sequence i.e., a series of increasing
  2408. integer numbers.
  2409. @cindex table for HTML and LaTeX
  2410. @findex table-generate-source
  2411. @kbd{M-x table-generate-source} generates a table formatted for a
  2412. specific markup language. It asks for a language (which must be one
  2413. of @code{html}, @code{latex}, or @code{cals}), a destination buffer in
  2414. which to put the result, and a table caption, and then inserts the
  2415. generated table into the specified buffer. The default destination
  2416. buffer is @code{table.@var{lang}}, where @var{lang} is the language
  2417. you specified.
  2418. @node Two-Column
  2419. @section Two-Column Editing
  2420. @cindex two-column editing
  2421. @cindex splitting columns
  2422. @cindex columns, splitting
  2423. Two-column mode lets you conveniently edit two side-by-side columns
  2424. of text. It uses two side-by-side windows, each showing its own
  2425. buffer. There are three ways to enter two-column mode:
  2426. @table @asis
  2427. @item @kbd{@key{F2} 2} or @kbd{C-x 6 2}
  2428. @kindex F2 2
  2429. @kindex C-x 6 2
  2430. @findex 2C-two-columns
  2431. Enter two-column mode with the current buffer on the left, and on the
  2432. right, a buffer whose name is based on the current buffer's name
  2433. (@code{2C-two-columns}). If the right-hand buffer doesn't already
  2434. exist, it starts out empty; the current buffer's contents are not
  2435. changed.
  2436. This command is appropriate when the current buffer is empty or contains
  2437. just one column and you want to add another column.
  2438. @item @kbd{@key{F2} s} or @kbd{C-x 6 s}
  2439. @kindex F2 s
  2440. @kindex C-x 6 s
  2441. @findex 2C-split
  2442. Split the current buffer, which contains two-column text, into two
  2443. buffers, and display them side by side (@code{2C-split}). The current
  2444. buffer becomes the left-hand buffer, but the text in the right-hand
  2445. column is moved into the right-hand buffer. The current column
  2446. specifies the split point. Splitting starts with the current line and
  2447. continues to the end of the buffer.
  2448. This command is appropriate when you have a buffer that already contains
  2449. two-column text, and you wish to separate the columns temporarily.
  2450. @item @kbd{@key{F2} b @var{buffer} @key{RET}}
  2451. @itemx @kbd{C-x 6 b @var{buffer} @key{RET}}
  2452. @kindex F2 b
  2453. @kindex C-x 6 b
  2454. @findex 2C-associate-buffer
  2455. Enter two-column mode using the current buffer as the left-hand buffer,
  2456. and using buffer @var{buffer} as the right-hand buffer
  2457. (@code{2C-associate-buffer}).
  2458. @end table
  2459. @kbd{@key{F2} s} or @kbd{C-x 6 s} looks for a column separator, which
  2460. is a string that appears on each line between the two columns. You can
  2461. specify the width of the separator with a numeric argument to
  2462. @kbd{@key{F2} s}; that many characters, before point, constitute the
  2463. separator string. By default, the width is 1, so the column separator
  2464. is the character before point.
  2465. When a line has the separator at the proper place, @kbd{@key{F2} s}
  2466. puts the text after the separator into the right-hand buffer, and
  2467. deletes the separator. Lines that don't have the column separator at
  2468. the proper place remain unsplit; they stay in the left-hand buffer, and
  2469. the right-hand buffer gets an empty line to correspond. (This is the
  2470. way to write a line that spans both columns while in two-column
  2471. mode: write it in the left-hand buffer, and put an empty line in the
  2472. right-hand buffer.)
  2473. @kindex F2 RET
  2474. @kindex C-x 6 RET
  2475. @findex 2C-newline
  2476. The command @kbd{C-x 6 @key{RET}} or @kbd{@key{F2} @key{RET}}
  2477. (@code{2C-newline}) inserts a newline in each of the two buffers at
  2478. corresponding positions. This is the easiest way to add a new line to
  2479. the two-column text while editing it in split buffers.
  2480. @kindex F2 1
  2481. @kindex C-x 6 1
  2482. @findex 2C-merge
  2483. When you have edited both buffers as you wish, merge them with
  2484. @kbd{@key{F2} 1} or @kbd{C-x 6 1} (@code{2C-merge}). This copies the
  2485. text from the right-hand buffer as a second column in the other buffer.
  2486. To go back to two-column editing, use @kbd{@key{F2} s}.
  2487. @kindex F2 d
  2488. @kindex C-x 6 d
  2489. @findex 2C-dissociate
  2490. Use @kbd{@key{F2} d} or @kbd{C-x 6 d} to dissociate the two buffers,
  2491. leaving each as it stands (@code{2C-dissociate}). If the other buffer,
  2492. the one not current when you type @kbd{@key{F2} d}, is empty,
  2493. @kbd{@key{F2} d} kills it.