meta-mode.el 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  1. ;;; meta-mode.el --- major mode for editing Metafont or MetaPost sources -*- lexical-binding:t -*-
  2. ;; Copyright (C) 1997, 2001-2012 Free Software Foundation, Inc.
  3. ;; Author: Ulrik Vieth <vieth@thphy.uni-duesseldorf.de>
  4. ;; Version: 1.0
  5. ;; Keywords: Metafont, MetaPost, tex, languages
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;; Description:
  19. ;;
  20. ;; This Emacs Lisp package provides a major mode for editing Metafont
  21. ;; or MetaPost sources. It includes all the necessary code to set up
  22. ;; a major mode including an appropriate syntax table, keymap, and a
  23. ;; mode-specific pull-down menu. It also provides a sophisticated set
  24. ;; of font-lock patterns, a fancy indentation function adapted from
  25. ;; AUCTeX's latex.el, and some basic mode-specific editing functions
  26. ;; such as functions to move to the beginning or end of the enclosing
  27. ;; environment, or to mark, re-indent, or comment-out environments.
  28. ;; On the other hand, it doesn't yet provide any functionality for
  29. ;; running Metafont or MetaPost in a shell buffer from within Emacs,
  30. ;; but such functionality might be added later, either as part of this
  31. ;; package or as a separate Emacs Lisp package.
  32. ;; Customization:
  33. ;;
  34. ;; Following the usual Emacs Lisp coding conventions, the major modes
  35. ;; defined in this package provide several hook variables to allow for
  36. ;; local customization when entering the modes. In particular, there
  37. ;; is a `meta-common-mode-hook' which applies to both modes as well as
  38. ;; `metafont-mode-hook' and `metapost-mode-hook' which apply to the
  39. ;; individual modes. In addition, there are several variables and
  40. ;; regexps controlling e.g. the behavior of the indentation function,
  41. ;; which may be customized via `edit-options'. Please refer to the
  42. ;; docstrings in the code below for details.
  43. ;; Availability:
  44. ;;
  45. ;; As of this version 1.0, this package will be uploaded to CTAN
  46. ;; archives, where it shall find a permanent home, presumably in
  47. ;; tex-archive/support/emacs-modes. It will also be submitted for
  48. ;; integration into the GNU Emacs distribution at that time.
  49. ;;
  50. ;; History:
  51. ;;
  52. ;; v 0.0 -- 1997/02/01 UV Started writing meta-mode.el.
  53. ;; v 0.1 -- 1997/02/02 UV Added preliminary set of font-lock patterns.
  54. ;; v 0.2 -- 1997/02/03 UV Improved and debugged font-lock patterns.
  55. ;; Added indent-line-function for TAB.
  56. ;; v 0.3 -- 1997/02/17 UV Improved font-lock patterns and syntax table.
  57. ;; Improved and debugged indentation function.
  58. ;; v 0.4 -- 1997/02/18 UV Added functions to indent regions for M-C-q,
  59. ;; also added a preliminary mode-specific menu.
  60. ;; v 0.5 -- 1997/02/19 UV Added functions to skip to next or previous
  61. ;; defun and to re-indent or comment-out defuns.
  62. ;; v 0.6 -- 1997/02/20 UV More debugging, testing and clean-up.
  63. ;; v 0.7 -- 1997/02/22 UV Use easymenu to define mode-specific menu.
  64. ;; v 0.8 -- 1997/02/24 UV Added completion function for M-TAB.
  65. ;; v 0.9 -- 1997/03/08 UV Added fill-paragraph function for comments.
  66. ;; Also fixed a few remaining font-lock problems.
  67. ;; Added meta-mode-load-hook to load meta-buf.el.
  68. ;; v 1.0 -- 1997/04/07 UV Cleanup for official public release.
  69. ;;
  70. ;; Historical Footnote:
  71. ;;
  72. ;; This package was begun on February 1, 1997, exactly 20 years after
  73. ;; the genesis of TeX took place according to Don Knuth's own account
  74. ;; (cf. ``The Errors of TeX'', reprinted in ``Literate Programming'',
  75. ;; Chapter 10, p. 249). What better date could there be to choose?
  76. ;;
  77. ;;; Code:
  78. (require 'easymenu)
  79. (defgroup meta-font nil
  80. "Major mode for editing Metafont or MetaPost sources."
  81. :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
  82. :group 'languages)
  83. ;;; Fontification.
  84. (defvar meta-font-lock-keywords
  85. (let ((input-keywords
  86. "\\(input\\|generate\\)")
  87. (begin-keywords
  88. (concat "\\(begin\\(char\\|fig\\|graph\\|logochar\\)\\|"
  89. "\\cmchar\\|dcchar\\|ecchar\\)"))
  90. (end-keywords
  91. "\\(end\\(char\\|fig\\|graph\\)\\)")
  92. (macro-keywords-1
  93. "\\(def\\|let\\|mode_def\\|vardef\\)")
  94. (macro-keywords-2
  95. "\\(primarydef\\|secondarydef\\|tertiarydef\\)")
  96. ;(make-regexp
  97. ; '("expr" "suffix" "text" "primary" "secondary" "tertiary") t)
  98. (args-keywords
  99. (concat "\\(expr\\|primary\\|s\\(econdary\\|uffix\\)\\|"
  100. "te\\(rtiary\\|xt\\)\\)"))
  101. ;(make-regexp
  102. ; '("boolean" "color" "numeric" "pair" "path" "pen" "picture"
  103. ; "string" "transform" "newinternal") t)
  104. (type-keywords
  105. (concat "\\(boolean\\|color\\|n\\(ewinternal\\|umeric\\)\\|"
  106. "p\\(a\\(ir\\|th\\)\\|en\\|icture\\)\\|string\\|"
  107. "transform\\)"))
  108. ;(make-regexp
  109. ; '("for" "forever" "forsuffixes" "endfor"
  110. ; "step" "until" "upto" "downto" "thru" "within"
  111. ; "iff" "if" "elseif" "else" "fi" "exitif" "exitunless"
  112. ; "let" "def" "vardef" "enddef" "mode_def"
  113. ; "true" "false" "known" "unknown" "and" "or" "not"
  114. ; "save" "interim" "inner" "outer" "relax"
  115. ; "begingroup" "endgroup" "expandafter" "scantokens"
  116. ; "generate" "input" "endinput" "end" "bye"
  117. ; "message" "errmessage" "errhelp" "special" "numspecial"
  118. ; "readstring" "readfrom" "write") t)
  119. (syntactic-keywords
  120. (concat "\\(and\\|b\\(egingroup\\|ye\\)\\|"
  121. "d\\(ef\\|ownto\\)\\|e\\(lse\\(\\|if\\)"
  122. "\\|nd\\(\\|def\\|for\\|group\\|input\\)"
  123. "\\|rr\\(help\\|message\\)"
  124. "\\|x\\(it\\(if\\|unless\\)\\|pandafter\\)\\)\\|"
  125. "f\\(alse\\|i\\|or\\(\\|ever\\|suffixes\\)\\)\\|"
  126. "generate\\|i\\(ff?\\|n\\(ner\\|put\\|terim\\)\\)\\|"
  127. "known\\|let\\|m\\(essage\\|ode_def\\)\\|"
  128. "n\\(ot\\|umspecial\\)\\|o\\(r\\|uter\\)\\|"
  129. "re\\(ad\\(from\\|string\\)\\|lax\\)\\|"
  130. "s\\(ave\\|cantokens\\|pecial\\|tep\\)\\|"
  131. "t\\(hru\\|rue\\)\\|"
  132. "u\\(n\\(known\\|til\\)\\|pto\\)\\|"
  133. "vardef\\|w\\(ithin\\|rite\\)\\)"))
  134. )
  135. (list
  136. ;; embedded TeX code in btex ... etex
  137. (cons (concat "\\(btex\\|verbatimtex\\)"
  138. "[ \t\f]+\\(.*\\)[ \t\f]+"
  139. "\\(etex\\)")
  140. '((1 font-lock-keyword-face)
  141. (2 font-lock-string-face)
  142. (3 font-lock-keyword-face)))
  143. ;; unary macro definitions: def, vardef, let
  144. (cons (concat "\\<" macro-keywords-1 "\\>"
  145. "[ \t\f]+\\(\\sw+\\|\\s_+\\|\\s.+\\)")
  146. '((1 font-lock-keyword-face)
  147. (2 font-lock-function-name-face)))
  148. ;; binary macro definitions: <leveldef> x operator y
  149. (cons (concat "\\<" macro-keywords-2 "\\>"
  150. "[ \t\f]+\\(\\sw+\\)"
  151. "[ \t\f]*\\(\\sw+\\|\\s.+\\)"
  152. "[ \t\f]*\\(\\sw+\\)")
  153. '((1 font-lock-keyword-face)
  154. (2 font-lock-variable-name-face nil t)
  155. (3 font-lock-function-name-face nil t)
  156. (4 font-lock-variable-name-face nil t)))
  157. ;; variable declarations: numeric, pair, color, ...
  158. (cons (concat "\\<" type-keywords "\\>"
  159. "\\([ \t\f]+\\(\\sw+\\)\\)*")
  160. '((1 font-lock-type-face)
  161. (font-lock-match-meta-declaration-item-and-skip-to-next
  162. (goto-char (match-end 1)) nil
  163. (1 font-lock-variable-name-face nil t))))
  164. ;; argument declarations: expr, suffix, text, ...
  165. (cons (concat "\\<" args-keywords "\\>"
  166. "\\([ \t\f]+\\(\\sw+\\|\\s_+\\)\\)*")
  167. '((1 font-lock-type-face)
  168. (font-lock-match-meta-declaration-item-and-skip-to-next
  169. (goto-char (match-end 1)) nil
  170. (1 font-lock-variable-name-face nil t))))
  171. ;; special case of arguments: expr x of y
  172. (cons (concat "\\(expr\\)[ \t\f]+\\(\\sw+\\)"
  173. "[ \t\f]+\\(of\\)[ \t\f]+\\(\\sw+\\)")
  174. '((1 font-lock-type-face)
  175. (2 font-lock-variable-name-face)
  176. (3 font-lock-keyword-face nil t)
  177. (4 font-lock-variable-name-face nil t)))
  178. ;; syntactic keywords
  179. (cons (concat "\\<" syntactic-keywords "\\>")
  180. 'font-lock-keyword-face)
  181. ;; beginchar, beginfig
  182. (cons (concat "\\<" begin-keywords "\\>")
  183. 'font-lock-keyword-face)
  184. ;; endchar, endfig
  185. (cons (concat "\\<" end-keywords "\\>")
  186. 'font-lock-keyword-face)
  187. ;; input, generate
  188. (cons (concat "\\<" input-keywords "\\>"
  189. "[ \t\f]+\\(\\sw+\\)")
  190. '((1 font-lock-keyword-face)
  191. (2 font-lock-constant-face)))
  192. ;; embedded Metafont/MetaPost code in comments
  193. (cons "|\\([^|]+\\)|"
  194. '(1 font-lock-constant-face t))
  195. ))
  196. "Default expressions to highlight in Metafont or MetaPost mode.")
  197. (defun font-lock-match-meta-declaration-item-and-skip-to-next (limit)
  198. ;; Match and move over Metafont/MetaPost declaration item after point.
  199. ;;
  200. ;; The expected syntax of an item is either "word" or "symbol",
  201. ;; possibly ending with optional whitespace. Everything following
  202. ;; the item (but belonging to it) is expected to by skipable by
  203. ;; `forward-sexp'. The list of items is expected to be separated
  204. ;; by commas and terminated by semicolons or equals signs.
  205. ;;
  206. (if (looking-at "[ \t\f]*\\(\\sw+\\|\\s_+\\)")
  207. (save-match-data
  208. (condition-case nil
  209. (save-restriction
  210. ;; Restrict to end of line, currently guaranteed to be LIMIT.
  211. (narrow-to-region (point-min) limit)
  212. (goto-char (match-end 1))
  213. ;; Move over any item value, etc., to the next item.
  214. (while (not (looking-at "[ \t\f]*\\(\\(,\\)\\|;\\|=\\|$\\)"))
  215. (goto-char (or (scan-sexps (point) 1) (point-max))))
  216. (goto-char (match-end 2)))
  217. (error t)))))
  218. ;;; Completion.
  219. ;; The data used to prepare the following lists of primitives and
  220. ;; standard macros available in Metafont or MetaPost was extracted
  221. ;; from the original sources like this:
  222. ;;
  223. ;; grep '^primitive' texk-7.0/web2c/{mf,mp}.web |\
  224. ;; sed 's/primitive(\("[a-zA-Z]*"\).*/\1/' > {mf,mp}_prim.list
  225. ;;
  226. ;; grep '\(let\|def\|vardef\|primarydef\|secondarydef\|tertiarydef\)'
  227. ;; texmf/meta{font,post}/plain.{mf,mp} > {mf,mp}_plain.list
  228. (defconst meta-common-primitives-list
  229. '("ASCII" "addto" "also" "and" "angle" "atleast" "batchmode"
  230. "begingroup" "boolean" "boundarychar" "char" "charcode" "chardp"
  231. "charexists" "charext" "charht" "charic" "charlist" "charwd"
  232. "contour" "controls" "cosd" "curl" "cycle" "day" "decimal" "def"
  233. "delimiters" "designsize" "directiontime" "doublepath" "dump" "else"
  234. "elseif" "end" "enddef" "endfor" "endgroup" "endinput" "errhelp"
  235. "errmessage" "errorstopmode" "everyjob" "exitif" "expandafter"
  236. "expr" "extensible" "false" "fi" "floor" "fontdimen" "fontmaking"
  237. "for" "forever" "forsuffixes" "headerbyte" "hex" "if" "inner"
  238. "input" "interim" "intersectiontimes" "jobname" "kern" "known"
  239. "length" "let" "ligtable" "makepath" "makepen" "message" "mexp"
  240. "mlog" "month" "newinternal" "nonstopmode" "normaldeviate" "not"
  241. "nullpen" "nullpicture" "numeric" "oct" "odd" "of" "or" "outer"
  242. "pair" "path" "pausing" "pen" "pencircle" "penoffset" "picture"
  243. "point" "postcontrol" "precontrol" "primary" "primarydef" "quote"
  244. "randomseed" "readstring" "reverse" "rotated" "save" "scaled"
  245. "scantokens" "scrollmode" "secondary" "secondarydef" "shifted"
  246. "shipout" "show" "showdependencies" "showstats" "showstopping"
  247. "showtoken" "showvariable" "sind" "skipto" "slanted" "special"
  248. "sqrt" "step" "str" "string" "subpath" "substring" "suffix"
  249. "tension" "tertiary" "tertiarydef" "text" "time" "to"
  250. "tracingcapsules" "tracingchoices" "tracingcommands"
  251. "tracingequations" "tracingmacros" "tracingonline" "tracingoutput"
  252. "tracingrestores" "tracingspecs" "tracingstats" "tracingtitles"
  253. "transform" "transformed" "true" "turningnumber" "uniformdeviate"
  254. "unknown" "until" "vardef" "warningcheck" "withpen" "xpart"
  255. "xscaled" "xxpart" "xypart" "year" "ypart" "yscaled" "yxpart"
  256. "yypart" "zscaled")
  257. "List of primitives common to Metafont and MetaPost.")
  258. (defconst metafont-primitives-list
  259. '("at" "autorounding" "chardx" "chardy" "cull" "display"
  260. "dropping" "fillin" "from" "granularity" "hppp" "inwindow"
  261. "keeping" "numspecial" "openwindow" "proofing" "smoothing"
  262. "totalweight" "tracingedges" "tracingpens" "turningcheck" "vppp"
  263. "withweight" "xoffset" "yoffset")
  264. "List of primitives only defined in Metafont.")
  265. (defconst metapost-primitives-list
  266. '("arclength" "arctime" "bluepart" "bounded" "btex" "clip"
  267. "clipped" "color" "dashed" "dashpart" "etex" "filled" "fontpart"
  268. "fontsize" "greenpart" "infont" "linecap" "linejoin" "llcorner"
  269. "lrcorner" "miterlimit" "mpxbreak" "pathpart" "penpart"
  270. "prologues" "readfrom" "redpart" "setbounds" "stroked" "textpart"
  271. "textual" "tracinglostchars" "truecorners" "ulcorner" "urcorner"
  272. "verbatimtex" "withcolor" "within" "write")
  273. "List of primitives only defined in MetaPost.")
  274. (defconst meta-common-plain-macros-list
  275. '( "abs" "bot" "bye" "byte" "ceiling" "clear_pen_memory"
  276. "clearit" "clearpen" "clearxy" "counterclockwise" "cutdraw" "decr"
  277. "dir" "direction" "directionpoint" "div" "dotprod" "downto" "draw"
  278. "drawdot" "erase" "exitunless" "fill" "filldraw" "flex" "gobble"
  279. "hide" "incr" "interact" "interpath" "intersectionpoint" "inverse"
  280. "label" "labels" "lft" "loggingall" "magstep" "makelabel" "max"
  281. "min" "mod" "numtok" "penlabels" "penpos" "penstroke" "pickup"
  282. "range" "reflectedabout" "relax" "rotatedabout" "rotatedaround"
  283. "round" "rt" "savepen" "shipit" "softjoin" "solve" "stop"
  284. "superellipse" "takepower" "tensepath" "thru" "top" "tracingall"
  285. "tracingnone" "undraw" "undrawdot" "unfill" "unfilldraw"
  286. "unitvector" "upto" "whatever")
  287. "List of macros common to plain Metafont and MetaPost.")
  288. (defconst metafont-plain-macros-list
  289. '("beginchar" "change_width" "culldraw" "cullit" "cutoff"
  290. "define_blacker_pixels" "define_corrected_pixels"
  291. "define_good_x_pixels" "define_good_y_pixels"
  292. "define_horizontal_corrected_pixels" "define_pixels"
  293. "define_whole_blacker_pixels" "define_whole_pixels"
  294. "define_whole_vertical_blacker_pixels"
  295. "define_whole_vertical_pixels" "endchar" "fix_units"
  296. "font_coding_scheme" "font_extra_space" "font_identifier"
  297. "font_normal_shrink" "font_normal_space" "font_normal_stretch"
  298. "font_quad" "font_size" "font_slant" "font_x_height" "gfcorners"
  299. "good.bot" "good.lft" "good.rt" "good.top" "good.x" "good.y"
  300. "grayfont" "hround" "imagerules" "italcorr" "labelfont"
  301. "lowres_fix" "makebox" "makegrid" "maketicks" "mode_lowres"
  302. "mode_proof" "mode_setup" "mode_smoke" "nodisplays" "notransforms"
  303. "openit" "penrazor" "pensquare" "proofoffset" "proofrule"
  304. "proofrulethickness" "screenchars" "screenrule" "screenstrokes"
  305. "showit" "slantfont" "smode" "titlefont" "vround")
  306. "List of macros only defined in plain Metafont.")
  307. (defconst metapost-plain-macros-list
  308. '("arrowhead" "bbox" "beginfig" "buildcycle" "center" "cutafter"
  309. "cutbefore" "dashpattern" "dotlabel" "dotlabels" "drawarrow"
  310. "drawdblarrow" "drawoptions" "endfig" "image" "label" "off" "on"
  311. "thelabel")
  312. "List of macros only defined in plain MetaPost.")
  313. (defconst metapost-graph-macros-list
  314. '("augment" "auto.x" "auto.y" "autogrid" "begingraph" "endgraph"
  315. "format" "frame" "gdata" "gdotlabel" "gdraw" "gdrawarrow"
  316. "gdrawdblarrow" "gfill" "glabel" "grid" "itick" "otick" "plot"
  317. "setcoords" "setrange")
  318. "List of macros only defined in MetaPost \"graph\" package.")
  319. (defconst metapost-boxes-macros-list
  320. '("boxit" "boxjoin" "bpath" "circleit" "drawboxed" "drawboxes"
  321. "drawunboxed" "fixpos" "fixsize" "pic" "rboxit")
  322. "List of macros only defined in MetaPost \"boxes\" package.")
  323. (defvar metafont-symbol-list
  324. (append meta-common-primitives-list
  325. metafont-primitives-list
  326. meta-common-plain-macros-list
  327. metafont-plain-macros-list)
  328. "List of known symbols to complete in Metafont mode.")
  329. (defvar metapost-symbol-list
  330. (append meta-common-primitives-list
  331. metapost-primitives-list
  332. meta-common-plain-macros-list
  333. metapost-plain-macros-list
  334. metapost-graph-macros-list
  335. metapost-boxes-macros-list)
  336. "List of known symbols to complete in MetaPost mode.")
  337. (defvar meta-symbol-list nil
  338. "List of known symbols to complete in Metafont or MetaPost mode.")
  339. (defvar meta-symbol-changed nil
  340. "Flag indicating whether `meta-symbol-list' has been initialized.")
  341. (defvar meta-complete-list nil
  342. ; (list (list "\\<\\(\\sw+\\)" 1 'meta-symbol-list)
  343. ; (list "" 'ispell-complete-word))
  344. "List of ways to perform completion in Metafont or MetaPost mode.
  345. Each entry is a list with the following elements:
  346. 1. Regexp matching the preceding text.
  347. 2. A number indicating the subgroup in the regexp containing the text.
  348. 3. A function returning an alist of possible completions.
  349. 4. Text to append after a successful completion (if any).
  350. Or alternatively:
  351. 1. Regexp matching the preceding text.
  352. 2. Function to do the actual completion.")
  353. (defun meta-add-symbols (&rest entries)
  354. "Add entries to list of known symbols in Metafont or MetaPost mode."
  355. (if meta-symbol-changed
  356. (setq meta-symbol-list (cons entries meta-symbol-list))
  357. (setq meta-symbol-changed t)
  358. (setq meta-symbol-list (cons entries meta-symbol-list))))
  359. (defun meta-symbol-list ()
  360. "Return value of list of known symbols in Metafont or MetaPost mode.
  361. If the list was changed, sort the list and remove duplicates first."
  362. (if (not meta-symbol-changed)
  363. ()
  364. (setq meta-symbol-changed nil)
  365. (message "Preparing completion list...")
  366. ;; sort list of symbols
  367. (setq meta-symbol-list
  368. (sort (mapcar 'meta-listify (apply 'append meta-symbol-list))
  369. 'meta-car-string-lessp))
  370. ;; remove duplicates
  371. (let ((entry meta-symbol-list))
  372. (while (and entry (cdr entry))
  373. (let ((this (car entry))
  374. (next (car (cdr entry))))
  375. (if (not (string-equal (car this) (car next)))
  376. (setq entry (cdr entry))
  377. (if (> (length next) (length this))
  378. (setcdr this (cdr next)))
  379. (setcdr entry (cdr (cdr entry)))))))
  380. (message "Preparing completion list... done"))
  381. meta-symbol-list)
  382. (defun meta-listify (a)
  383. ;; utility function used in `meta-add-symbols'
  384. (if (listp a) a (list a)))
  385. (defun meta-car-string-lessp (a b)
  386. ;; utility function used in `meta-add-symbols'
  387. (string-lessp (car a) (car b)))
  388. (defun meta-completions-at-point ()
  389. (let ((list meta-complete-list)
  390. entry)
  391. (while list
  392. (setq entry (car list)
  393. list (cdr list))
  394. (if (looking-back (car entry) (max (point-min) (- (point) 200)))
  395. (setq list nil)))
  396. (if (numberp (nth 1 entry))
  397. (let* ((sub (nth 1 entry))
  398. (close (nth 3 entry))
  399. (begin (match-beginning sub))
  400. (end (match-end sub))
  401. (list (funcall (nth 2 entry))))
  402. (list
  403. begin end list
  404. :exit-function
  405. (unless (zerop (length close))
  406. (lambda (_s finished)
  407. (when (memq finished '(sole finished))
  408. (if (looking-at (regexp-quote close))
  409. (goto-char (match-end 0))
  410. (insert close)))))))
  411. (nth 1 entry))))
  412. (define-obsolete-function-alias 'meta-complete-symbol
  413. 'completion-at-point "24.1")
  414. ;;; Indentation.
  415. (defcustom meta-indent-level 2
  416. "Indentation of begin-end blocks in Metafont or MetaPost mode."
  417. :type 'integer
  418. :group 'meta-font)
  419. (defcustom meta-left-comment-regexp "%%+"
  420. "Regexp matching comments that should be placed on the left margin."
  421. :type 'regexp
  422. :group 'meta-font)
  423. (defcustom meta-right-comment-regexp nil
  424. "Regexp matching comments that should be placed on the right margin."
  425. :type '(choice regexp
  426. (const :tag "None" nil))
  427. :group 'meta-font)
  428. (defcustom meta-ignore-comment-regexp "%[^%]"
  429. "Regexp matching comments whose indentation should not be touched."
  430. :type 'regexp
  431. :group 'meta-font)
  432. (defcustom meta-begin-environment-regexp
  433. (concat "\\(begin\\(char\\|fig\\|gr\\(aph\\|oup\\)\\|logochar\\)\\|"
  434. "def\\|for\\(\\|ever\\|suffixes\\)\\|if\\|mode_def\\|"
  435. "primarydef\\|secondarydef\\|tertiarydef\\|vardef\\)")
  436. "Regexp matching the beginning of environments to be indented."
  437. :type 'regexp
  438. :group 'meta-font)
  439. (defcustom meta-end-environment-regexp
  440. (concat "\\(end\\(char\\|def\\|f\\(ig\\|or\\)\\|gr\\(aph\\|oup\\)\\)"
  441. "\\|fi\\)")
  442. "Regexp matching the end of environments to be indented."
  443. :type 'regexp
  444. :group 'meta-font)
  445. (defcustom meta-within-environment-regexp
  446. ; (concat "\\(e\\(lse\\(\\|if\\)\\|xit\\(if\\|unless\\)\\)\\)")
  447. (concat "\\(else\\(\\|if\\)\\)")
  448. "Regexp matching keywords within environments not to be indented."
  449. :type 'regexp
  450. :group 'meta-font)
  451. (defun meta-comment-indent ()
  452. "Return the indentation for a comment in Metafont or MetaPost mode."
  453. (if (and meta-left-comment-regexp
  454. (looking-at meta-left-comment-regexp))
  455. (current-column)
  456. (skip-chars-backward "\t\f ")
  457. (max (if (bolp) 0 (1+ (current-column)))
  458. comment-column)))
  459. (defun meta-indent-line ()
  460. "Indent the line containing point as Metafont or MetaPost source."
  461. (interactive)
  462. (let ((indent (meta-indent-calculate)))
  463. (if (/= (current-indentation) indent)
  464. (save-excursion
  465. (delete-region (line-beginning-position)
  466. (progn (back-to-indentation) (point)))
  467. (indent-to indent)))
  468. (if (< (current-column) indent)
  469. (back-to-indentation))))
  470. (defun meta-indent-calculate ()
  471. "Return the indentation of current line of Metafont or MetaPost source."
  472. ;; Indentation within strings is not considered as Meta* don't allow multi
  473. ;; line strings.
  474. (save-excursion
  475. (back-to-indentation)
  476. (cond
  477. ;; Comments to the left margin.
  478. ((and meta-left-comment-regexp
  479. (looking-at meta-left-comment-regexp))
  480. 0)
  481. ;; Comments to the right margin.
  482. ((and meta-right-comment-regexp
  483. (looking-at meta-right-comment-regexp))
  484. comment-column)
  485. ;; Comments best left alone.
  486. ((and meta-ignore-comment-regexp
  487. (looking-at meta-ignore-comment-regexp))
  488. (current-indentation))
  489. ;; Beginning of buffer.
  490. ((eq (point-at-bol) (point-min))
  491. 0)
  492. ;; Backindent at end of environments.
  493. ((meta-indent-looking-at-code
  494. (concat "\\<" meta-end-environment-regexp "\\>"))
  495. (- (meta-indent-current-indentation) meta-indent-level))
  496. ;; Backindent at keywords within environments.
  497. ((meta-indent-looking-at-code
  498. (concat "\\<" meta-within-environment-regexp "\\>"))
  499. (- (meta-indent-current-indentation) meta-indent-level))
  500. (t (meta-indent-current-indentation)))))
  501. (defun meta-indent-in-string-p ()
  502. "Tell if the point is in a string."
  503. (or (nth 3 (syntax-ppss))
  504. (eq (get-text-property (point) 'face) font-lock-string-face)))
  505. (defun meta-indent-looking-at-code (regexp)
  506. "Same as `looking-at' but checks that the point is not in a string."
  507. (unless (meta-indent-in-string-p)
  508. (looking-at regexp)))
  509. (defun meta-indent-previous-line ()
  510. "Go to the previous line of code, skipping comments."
  511. (skip-chars-backward "\n\t\f ")
  512. (move-to-column (current-indentation))
  513. ;; Ignore comments.
  514. (while (and (looking-at comment-start) (not (bobp)))
  515. (skip-chars-backward "\n\t\f ")
  516. (when (not (bobp))
  517. (move-to-column (current-indentation)))))
  518. (defun meta-indent-unfinished-line ()
  519. "Tell if the current line of code ends with an unfinished expression."
  520. (save-excursion
  521. (end-of-line)
  522. ;; Skip backward the comments.
  523. (let ((point-not-in-string (point)))
  524. (while (search-backward comment-start (point-at-bol) t)
  525. (unless (meta-indent-in-string-p)
  526. (setq point-not-in-string (point))))
  527. (goto-char point-not-in-string))
  528. ;; Search for the end of the previous expression.
  529. (if (search-backward ";" (point-at-bol) t)
  530. (progn (while (and (meta-indent-in-string-p)
  531. (search-backward ";" (point-at-bol) t)))
  532. (if (= (char-after) ?\;)
  533. (forward-char)
  534. (beginning-of-line)))
  535. (beginning-of-line))
  536. ;; See if the last statement of the line is environment-related,
  537. ;; or exists at all.
  538. (if (meta-indent-looking-at-code
  539. (concat "[ \t\f]*\\($\\|" (regexp-quote comment-start)
  540. "\\|\\<" meta-end-environment-regexp "\\>"
  541. "\\|\\<" meta-begin-environment-regexp "\\>"
  542. "\\|\\<" meta-within-environment-regexp "\\>\\)"))
  543. nil
  544. t)))
  545. (defun meta-indent-current-indentation ()
  546. "Return the indentation wanted for the current line of code."
  547. (+ (meta-indent-current-nesting)
  548. (if (save-excursion
  549. (back-to-indentation)
  550. (and (not (looking-at (concat "\\<" meta-end-environment-regexp "\\>"
  551. "\\|\\<" meta-within-environment-regexp "\\>")))
  552. (progn (meta-indent-previous-line)
  553. (meta-indent-unfinished-line))))
  554. meta-indent-level
  555. 0)))
  556. (defun meta-indent-current-nesting ()
  557. "Return the indentation according to the nearest environment keyword."
  558. (save-excursion
  559. (save-restriction
  560. (widen)
  561. (back-to-indentation)
  562. (let ((to-add 0))
  563. ;; If we found some environment marker backward...
  564. (if (catch 'found
  565. (while (re-search-backward
  566. (concat "(\\|)\\|\\<" meta-end-environment-regexp "\\>"
  567. "\\|\\<" meta-begin-environment-regexp "\\>"
  568. "\\|\\<" meta-within-environment-regexp "\\>")
  569. nil t)
  570. ;; If we aren't in a string or in a comment, we've found something.
  571. (unless (or (meta-indent-in-string-p)
  572. (nth 4 (syntax-ppss)))
  573. (cond ((= (char-after) ?\()
  574. (setq to-add (+ to-add meta-indent-level)))
  575. ((= (char-after) ?\))
  576. (setq to-add (- to-add meta-indent-level)))
  577. (t (throw 'found t))))))
  578. (progn
  579. ;; ... then use it to compute the current indentation.
  580. (back-to-indentation)
  581. (+ to-add (current-indentation) (meta-indent-level-count)
  582. ;; Compensate for backindent of end and within keywords.
  583. (if (meta-indent-looking-at-code
  584. (concat "\\<" meta-end-environment-regexp "\\>\\|"
  585. "\\<" meta-within-environment-regexp "\\>"))
  586. meta-indent-level
  587. ;; Compensate for unfinished line.
  588. (if (save-excursion
  589. (meta-indent-previous-line)
  590. (meta-indent-unfinished-line))
  591. (- meta-indent-level)
  592. 0))))
  593. 0)))))
  594. (defun meta-indent-level-count ()
  595. "Count indentation change for begin-end commands in the current line."
  596. (save-excursion
  597. (save-restriction
  598. (let ((count 0))
  599. (narrow-to-region
  600. (point) (save-excursion
  601. (re-search-forward "[^\\\\\"]%\\|\n\\|\\'" nil t)
  602. (backward-char) (point)))
  603. (while (re-search-forward "\\<\\sw+\\>\\|(\\|)" nil t)
  604. (save-excursion
  605. (goto-char (match-beginning 0))
  606. (cond
  607. ;; Count number of begin-end keywords within line.
  608. ((meta-indent-looking-at-code
  609. (concat "\\<" meta-begin-environment-regexp "\\>"))
  610. (setq count (+ count meta-indent-level)))
  611. ((meta-indent-looking-at-code
  612. (concat "\\<" meta-end-environment-regexp "\\>"))
  613. (setq count (- count meta-indent-level))))))
  614. count))))
  615. ;;; Editing commands.
  616. (defcustom meta-begin-defun-regexp
  617. (concat "\\(begin\\(char\\|fig\\|logochar\\)\\|def\\|mode_def\\|"
  618. "primarydef\\|secondarydef\\|tertiarydef\\|vardef\\)")
  619. "Regexp matching beginning of defuns in Metafont or MetaPost mode."
  620. :type 'regexp
  621. :group 'meta-font)
  622. (defcustom meta-end-defun-regexp
  623. (concat "\\(end\\(char\\|def\\|fig\\)\\)")
  624. "Regexp matching the end of defuns in Metafont or MetaPost mode."
  625. :type 'regexp
  626. :group 'meta-font)
  627. (defun meta-beginning-of-defun (&optional arg)
  628. "Move backward to beginning of a defun in Metafont or MetaPost code.
  629. With numeric argument, do it that many times.
  630. Negative arg -N means move forward to Nth following beginning of defun.
  631. Returns t unless search stops due to beginning or end of buffer."
  632. (interactive "p")
  633. (if (or (null arg) (= 0 arg)) (setq arg 1))
  634. (and arg (< arg 0) (not (eobp)) (forward-char 1))
  635. (and (re-search-backward
  636. (concat "\\<" meta-begin-defun-regexp "\\>") nil t arg)
  637. (progn (goto-char (match-beginning 0))
  638. (skip-chars-backward "%")
  639. (skip-chars-backward " \t\f") t)))
  640. (defun meta-end-of-defun (&optional arg)
  641. "Move forward to end of a defun in Metafont or MetaPost code.
  642. With numeric argument, do it that many times.
  643. Negative argument -N means move back to Nth preceding end of defun.
  644. Returns t unless search stops due to beginning or end of buffer."
  645. (interactive "p")
  646. (if (or (null arg) (= 0 arg)) (setq arg 1))
  647. (and (< arg 0) (not (bobp)) (forward-line -1))
  648. (and (re-search-forward
  649. (concat "\\<" meta-end-defun-regexp "\\>") nil t arg)
  650. (progn (goto-char (match-end 0))
  651. (skip-chars-forward ";")
  652. (skip-chars-forward " \t\f")
  653. (if (looking-at "\n") (forward-line 1)) t)))
  654. (defun meta-comment-region (beg end &optional arg)
  655. "Comment out active region as Metafont or MetaPost source."
  656. (interactive "r")
  657. (comment-region beg end arg))
  658. (defun meta-uncomment-region (beg end)
  659. "Uncomment active region as Metafont or MetaPost source."
  660. (interactive "r")
  661. (comment-region beg end -1))
  662. (defun meta-comment-defun (&optional arg)
  663. "Comment out current environment as Metafont or MetaPost source.
  664. With prefix argument, uncomment the environment.
  665. The environment used is the one that contains point or follows point."
  666. (interactive "P")
  667. (save-excursion
  668. (let* ((end (if (meta-end-of-defun) (point) (point-max)))
  669. (beg (if (meta-beginning-of-defun) (point) (point-min))))
  670. (comment-region beg end arg))))
  671. (defun meta-uncomment-defun ()
  672. "Uncomment current environment as Metafont or MetaPost source."
  673. (interactive)
  674. (meta-comment-defun -1))
  675. (defun meta-indent-region (beg end)
  676. "Indent the active region as Metafont or MetaPost source."
  677. (interactive "r")
  678. (indent-region beg end nil))
  679. (defun meta-indent-buffer ()
  680. "Indent the whole buffer contents as Metafont or MetaPost source."
  681. (interactive)
  682. (save-excursion
  683. (indent-region (point-min) (point-max) nil)))
  684. (defun meta-indent-defun ()
  685. "Indent the current environment as Metafont or MetaPost source.
  686. The environment indented is the one that contains point or follows point."
  687. (interactive)
  688. (save-excursion
  689. (let* ((end (if (meta-end-of-defun) (point) (point-max)))
  690. (beg (if (meta-beginning-of-defun) (point) (point-min))))
  691. (indent-region beg end nil))))
  692. (defun meta-mark-defun ()
  693. "Put mark at end of the environment, point at the beginning.
  694. The environment marked is the one that contains point or follows point."
  695. (interactive)
  696. (push-mark (point))
  697. (meta-end-of-defun)
  698. (push-mark (point) nil t)
  699. (meta-beginning-of-defun))
  700. ;;; Syntax table, keymap and menu.
  701. (define-abbrev-table 'meta-mode-abbrev-table ()
  702. "Abbrev table used in Metafont or MetaPost mode.")
  703. (defvar meta-common-mode-syntax-table
  704. (let ((st (make-syntax-table)))
  705. ;; underscores are word constituents
  706. (modify-syntax-entry ?_ "w" st)
  707. ;; miscellaneous non-word symbols
  708. (modify-syntax-entry ?# "_" st)
  709. (modify-syntax-entry ?@ "_" st)
  710. (modify-syntax-entry ?$ "_" st)
  711. (modify-syntax-entry ?? "_" st)
  712. (modify-syntax-entry ?! "_" st)
  713. ;; binary operators
  714. (modify-syntax-entry ?& "." st)
  715. (modify-syntax-entry ?+ "." st)
  716. (modify-syntax-entry ?- "." st)
  717. (modify-syntax-entry ?/ "." st)
  718. (modify-syntax-entry ?* "." st)
  719. (modify-syntax-entry ?. "." st)
  720. (modify-syntax-entry ?: "." st)
  721. (modify-syntax-entry ?= "." st)
  722. (modify-syntax-entry ?< "." st)
  723. (modify-syntax-entry ?> "." st)
  724. (modify-syntax-entry ?| "." st)
  725. ;; opening and closing delimiters
  726. (modify-syntax-entry ?\( "()" st)
  727. (modify-syntax-entry ?\) ")(" st)
  728. (modify-syntax-entry ?\[ "(]" st)
  729. (modify-syntax-entry ?\] ")[" st)
  730. (modify-syntax-entry ?\{ "(}" st)
  731. (modify-syntax-entry ?\} "){" st)
  732. ;; comment character
  733. (modify-syntax-entry ?% "<" st)
  734. (modify-syntax-entry ?\n ">" st)
  735. ;; escape character, needed for embedded TeX code
  736. (modify-syntax-entry ?\\ "\\" st)
  737. st)
  738. "Syntax table used in Metafont or MetaPost mode.")
  739. (defvar meta-common-mode-map
  740. (let ((map (make-sparse-keymap)))
  741. ;; Comment Paragraphs:
  742. ;; (define-key map "\M-a" 'backward-sentence)
  743. ;; (define-key map "\M-e" 'forward-sentence)
  744. ;; (define-key map "\M-h" 'mark-paragraph)
  745. ;; (define-key map "\M-q" 'fill-paragraph)
  746. ;; Navigation:
  747. (define-key map "\M-\C-a" 'meta-beginning-of-defun)
  748. (define-key map "\M-\C-e" 'meta-end-of-defun)
  749. (define-key map "\M-\C-h" 'meta-mark-defun)
  750. ;; Indentation:
  751. (define-key map "\M-\C-q" 'meta-indent-defun)
  752. (define-key map "\C-c\C-qe" 'meta-indent-defun)
  753. (define-key map "\C-c\C-qr" 'meta-indent-region)
  754. (define-key map "\C-c\C-qb" 'meta-indent-buffer)
  755. ;; Commenting Out:
  756. (define-key map "\C-c%" 'meta-comment-defun)
  757. ;; (define-key map "\C-uC-c%" 'meta-uncomment-defun)
  758. (define-key map "\C-c;" 'meta-comment-region)
  759. (define-key map "\C-c:" 'meta-uncomment-region)
  760. ;; Symbol Completion:
  761. (define-key map "\M-\t" 'completion-at-point)
  762. ;; Shell Commands:
  763. ;; (define-key map "\C-c\C-c" 'meta-command-file)
  764. ;; (define-key map "\C-c\C-k" 'meta-kill-job)
  765. ;; (define-key map "\C-c\C-l" 'meta-recenter-output)
  766. map)
  767. "Keymap used in Metafont or MetaPost mode.")
  768. (define-obsolete-variable-alias 'meta-mode-map 'meta-common-mode-map "24.1")
  769. (easy-menu-define
  770. meta-mode-menu meta-common-mode-map
  771. "Menu used in Metafont or MetaPost mode."
  772. (list "Meta"
  773. ["Forward Environment" meta-beginning-of-defun t]
  774. ["Backward Environment" meta-end-of-defun t]
  775. "--"
  776. ["Indent Line" meta-indent-line t]
  777. ["Indent Environment" meta-indent-defun t]
  778. ["Indent Region" meta-indent-region
  779. :active (meta-mark-active)]
  780. ["Indent Buffer" meta-indent-buffer t]
  781. "--"
  782. ["Comment Out Environment" meta-comment-defun t]
  783. ["Uncomment Environment" meta-uncomment-defun t]
  784. ["Comment Out Region" meta-comment-region
  785. :active (meta-mark-active)]
  786. ["Uncomment Region" meta-uncomment-region
  787. :active (meta-mark-active)]
  788. "--"
  789. ["Complete Symbol" completion-at-point t]
  790. ; "--"
  791. ; ["Command on Buffer" meta-command-file t]
  792. ; ["Kill Job" meta-kill-job t]
  793. ; ["Recenter Output Buffer" meta-recenter-output-buffer t]
  794. ))
  795. ;; Compatibility: XEmacs doesn't have the `mark-active' variable.
  796. (defun meta-mark-active ()
  797. "Return whether the mark and region are currently active in this buffer."
  798. (if (boundp 'mark-active) mark-active (mark)))
  799. ;;; Hook variables.
  800. (defcustom meta-mode-load-hook nil
  801. "Hook evaluated when first loading Metafont or MetaPost mode."
  802. :type 'hook
  803. :group 'meta-font)
  804. (defcustom meta-common-mode-hook nil
  805. "Hook evaluated by both `metafont-mode' and `metapost-mode'."
  806. :type 'hook
  807. :group 'meta-font)
  808. (defcustom metafont-mode-hook nil
  809. "Hook evaluated by `metafont-mode' after `meta-common-mode-hook'."
  810. :type 'hook
  811. :group 'meta-font)
  812. (defcustom metapost-mode-hook nil
  813. "Hook evaluated by `metapost-mode' after `meta-common-mode-hook'."
  814. :type 'hook
  815. :group 'meta-font)
  816. ;;; Initialization.
  817. (define-derived-mode meta-common-mode prog-mode "-Meta-common-"
  818. "Common initialization for Metafont or MetaPost mode."
  819. :abbrev-table meta-mode-abbrev-table
  820. (set (make-local-variable 'paragraph-start)
  821. (concat page-delimiter "\\|$"))
  822. (set (make-local-variable 'paragraph-separate)
  823. (concat page-delimiter "\\|$"))
  824. (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
  825. (set (make-local-variable 'comment-start-skip) "%+[ \t\f]*")
  826. (set (make-local-variable 'comment-start) "%")
  827. (set (make-local-variable 'comment-end) "")
  828. (set (make-local-variable 'comment-multi-line) nil)
  829. ;; We use `back-to-indentation' but \f is no indentation sign.
  830. (modify-syntax-entry ?\f "_ ")
  831. (set (make-local-variable 'parse-sexp-ignore-comments) t)
  832. (add-hook 'completion-at-point-functions #'meta-completions-at-point nil t)
  833. (set (make-local-variable 'comment-indent-function) #'meta-comment-indent)
  834. (set (make-local-variable 'indent-line-function) #'meta-indent-line)
  835. ;; No need to define a mode-specific 'indent-region-function.
  836. ;; Simply use the generic 'indent-region and 'comment-region.
  837. ;; Set defaults for font-lock mode.
  838. (set (make-local-variable 'font-lock-defaults)
  839. '(meta-font-lock-keywords
  840. nil nil ((?_ . "w")) nil
  841. (font-lock-comment-start-regexp . "%")))
  842. ;; Activate syntax table, keymap and menu.
  843. (easy-menu-add meta-mode-menu))
  844. ;;;###autoload
  845. (define-derived-mode metafont-mode meta-common-mode "Metafont"
  846. "Major mode for editing Metafont sources."
  847. ;; Set defaults for completion function.
  848. (set (make-local-variable 'meta-symbol-list) nil)
  849. (set (make-local-variable 'meta-symbol-changed) nil)
  850. (apply 'meta-add-symbols metafont-symbol-list)
  851. (set (make-local-variable 'meta-complete-list)
  852. (list (list "\\<\\(\\sw+\\)" 1 'meta-symbol-list)
  853. (list "" 'ispell-complete-word))))
  854. ;;;###autoload
  855. (define-derived-mode metapost-mode meta-common-mode "MetaPost"
  856. "Major mode for editing MetaPost sources."
  857. ;; Set defaults for completion function.
  858. (set (make-local-variable 'meta-symbol-list) nil)
  859. (set (make-local-variable 'meta-symbol-changed) nil)
  860. (apply 'meta-add-symbols metapost-symbol-list)
  861. (set (make-local-variable 'meta-complete-list)
  862. (list (list "\\<\\(\\sw+\\)" 1 'meta-symbol-list)
  863. (list "" 'ispell-complete-word))))
  864. ;;; Just in case ...
  865. (provide 'meta-mode)
  866. (run-hooks 'meta-mode-load-hook)
  867. ;;; meta-mode.el ends here