renpy.el 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541
  1. ; WARNING: This file is automatically generated.
  2. ;WARNING: Edit renpy.el.tmpl instead, then run make_renpy_el.py
  3. ; -*- emacs-lisp -*-
  4. ;;; renpy.el --- silly walks for Renpy -*- coding: iso-8859-1 -*-
  5. ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
  6. ;; Free Software Foundation, Inc.
  7. ;; Author: PyTom <pytom@bishoujo.us>
  8. ;; Based on python.el, which has the following maintainership:
  9. ;; Author: Dave Love <fx@gnu.org>
  10. ;; Maintainer: FSF
  11. ;; Created: Nov 2003
  12. ;; Keywords: languages
  13. ;; This file is part of GNU Emacs.
  14. ;; GNU Emacs is free software: you can redistribute it and/or modify
  15. ;; it under the terms of the GNU General Public License as published by
  16. ;; the Free Software Foundation, either version 3 of the License, or
  17. ;; (at your option) any later version.
  18. ;; GNU Emacs is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;; You should have received a copy of the GNU General Public License
  23. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  24. ;;; Code:
  25. (setq renpy-generic-imenu
  26. '( ( nil "\\b\\(label\\|menu\\)\\s-+\\(\\w+\\):" 2)
  27. ( nil "\\b\\(screen\\)\\s-+\\(\\w+\\):" 2)
  28. ( nil "\\b\\(transform\\)\\s-+\\(\\w+\\):" 2)
  29. ; ( nil "\\bcall\\s-+\\w+\\s-+from\\s-+\\(\\w+\\)" 1)
  30. ( nil "\\b\\(def\\|class\\)\\s-+\\(\\w+\\)" 2)
  31. ))
  32. (require 'comint)
  33. (eval-when-compile
  34. (require 'compile)
  35. (require 'hippie-exp))
  36. (require 'sym-comp)
  37. (autoload 'comint-mode "comint")
  38. (defgroup renpy nil
  39. "Silly walks in the Renpy language."
  40. :group 'languages
  41. :version "22.1"
  42. :link '(emacs-commentary-link "renpy"))
  43. ;;;###autoload
  44. (add-to-list 'auto-mode-alist '("\\.rpy\\'" . renpy-mode))
  45. (add-to-list 'auto-mode-alist '("\\.rpym\\'" . renpy-mode))
  46. (add-to-list 'same-window-buffer-names "*Renpy*")
  47. ;;;; Font lock
  48. (defvar renpy-font-lock-keywords
  49. `(,(rx symbol-start
  50. ;; From v 2.5 reference, § keywords.
  51. ;; def and class dealt with separately below
  52. (or "and" "as" "assert" "break" "continue" "del" "elif" "else"
  53. "except" "exec" "finally" "for" "from" "global" "if"
  54. "import" "in" "is" "lambda" "not" "or" "pass" "print"
  55. "raise" "return" "try" "while" "with" "yield"
  56. ;; Not real keywords, but close enough to be fontified as such
  57. "self" "True" "False"
  58. "$"
  59. "add"
  60. "and"
  61. "animation"
  62. "as"
  63. "as"
  64. "assert"
  65. "at"
  66. "bar"
  67. "behind"
  68. "block"
  69. "break"
  70. "button"
  71. "call"
  72. "choice"
  73. "circles"
  74. "class"
  75. "clockwise"
  76. "contains"
  77. "continue"
  78. "counterclockwise"
  79. "def"
  80. "define"
  81. "del"
  82. "elif"
  83. "else"
  84. "event"
  85. "except"
  86. "exec"
  87. "expression"
  88. "finally"
  89. "fixed"
  90. "for"
  91. "frame"
  92. "from"
  93. "function"
  94. "global"
  95. "grid"
  96. "has"
  97. "hbox"
  98. "hide"
  99. "hotbar"
  100. "hotspot"
  101. "if"
  102. "if"
  103. "image"
  104. "imagebutton"
  105. "imagemap"
  106. "import"
  107. "in"
  108. "in"
  109. "init"
  110. "input"
  111. "is"
  112. "jump"
  113. "key"
  114. "knot"
  115. "label"
  116. "lambda"
  117. "menu"
  118. "not"
  119. "null"
  120. "nvl"
  121. "on"
  122. "onlayer"
  123. "or"
  124. "parallel"
  125. "pass"
  126. "pause"
  127. "play"
  128. "print"
  129. "python"
  130. "queue"
  131. "raise"
  132. "repeat"
  133. "return"
  134. "return"
  135. "scene"
  136. "screen"
  137. "set"
  138. "show"
  139. "side"
  140. "stop"
  141. "text"
  142. "textbutton"
  143. "time"
  144. "timer"
  145. "transform"
  146. "transform"
  147. "try"
  148. "use"
  149. "vbar"
  150. "vbox"
  151. "viewport"
  152. "while"
  153. "while"
  154. "window"
  155. "with"
  156. "with"
  157. "yield"
  158. "zorder"
  159. )
  160. symbol-end)
  161. (,(rx symbol-start "None" symbol-end) ; see § Keywords in 2.5 manual
  162. . font-lock-constant-face)
  163. ;; Definitions
  164. (,(rx symbol-start (group "class") (1+ space) (group (1+ (or word ?_))))
  165. (1 font-lock-keyword-face) (2 font-lock-type-face))
  166. (,(rx symbol-start (group "label") (1+ space) (group (1+ (or word ?_))))
  167. (1 font-lock-keyword-face) (2 font-lock-type-face))
  168. (,(rx symbol-start (group "screen") (1+ space) (group (1+ (or word ?_))))
  169. (1 font-lock-keyword-face) (2 font-lock-type-face))
  170. (,(rx symbol-start (group "transform") (1+ space) (group (1+ (or word ?_))))
  171. (1 font-lock-keyword-face) (2 font-lock-type-face))
  172. (,(rx symbol-start (group "def") (1+ space) (group (1+ (or word ?_))))
  173. (1 font-lock-keyword-face) (2 font-lock-function-name-face))
  174. ;; Top-level assignments are worth highlighting.
  175. (,(rx line-start (group (1+ (or word ?_))) (0+ space) "=")
  176. (1 font-lock-variable-name-face))
  177. (,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_)))) ; decorators
  178. (1 font-lock-type-face))
  179. ;; Built-ins. (The next three blocks are from
  180. ;; `__builtin__.__dict__.keys()' in Renpy 2.5.1.) These patterns
  181. ;; are debateable, but they at least help to spot possible
  182. ;; shadowing of builtins.
  183. (,(rx symbol-start (or
  184. ;; exceptions
  185. "ArithmeticError" "AssertionError" "AttributeError"
  186. "BaseException" "DeprecationWarning" "EOFError"
  187. "EnvironmentError" "Exception" "FloatingPointError"
  188. "FutureWarning" "GeneratorExit" "IOError" "ImportError"
  189. "ImportWarning" "IndentationError" "IndexError" "KeyError"
  190. "KeyboardInterrupt" "LookupError" "MemoryError" "NameError"
  191. "NotImplemented" "NotImplementedError" "OSError"
  192. "OverflowError" "PendingDeprecationWarning" "ReferenceError"
  193. "RuntimeError" "RuntimeWarning" "StandardError"
  194. "StopIteration" "SyntaxError" "SyntaxWarning" "SystemError"
  195. "SystemExit" "TabError" "TypeError" "UnboundLocalError"
  196. "UnicodeDecodeError" "UnicodeEncodeError" "UnicodeError"
  197. "UnicodeTranslateError" "UnicodeWarning" "UserWarning"
  198. "ValueError" "Warning" "ZeroDivisionError") symbol-end)
  199. . font-lock-type-face)
  200. (,(rx (or line-start (not (any ". \t"))) (* (any " \t")) symbol-start
  201. (group (or
  202. ;; callable built-ins, fontified when not appearing as
  203. ;; object attributes
  204. "abs" "all" "any" "apply" "basestring" "bool" "buffer" "callable"
  205. "chr" "classmethod" "cmp" "coerce" "compile" "complex"
  206. "copyright" "credits" "delattr" "dict" "dir" "divmod"
  207. "enumerate" "eval" "execfile" "exit" "file" "filter" "float"
  208. "frozenset" "getattr" "globals" "hasattr" "hash" "help"
  209. "hex" "id" "input" "int" "intern" "isinstance" "issubclass"
  210. "iter" "len" "license" "list" "locals" "long" "map" "max"
  211. "min" "object" "oct" "open" "ord" "pow" "property" "quit"
  212. "range" "raw_input" "reduce" "reload" "repr" "reversed"
  213. "round" "set" "setattr" "slice" "sorted" "staticmethod"
  214. "str" "sum" "super" "tuple" "type" "unichr" "unicode" "vars"
  215. "xrange" "zip"
  216. "action"
  217. "activate_align"
  218. "activate_alignaround"
  219. "activate_alpha"
  220. "activate_anchor"
  221. "activate_angle"
  222. "activate_antialias"
  223. "activate_area"
  224. "activate_around"
  225. "activate_background"
  226. "activate_bar_invert"
  227. "activate_bar_resizing"
  228. "activate_bar_vertical"
  229. "activate_black_color"
  230. "activate_bold"
  231. "activate_bottom_bar"
  232. "activate_bottom_gutter"
  233. "activate_bottom_margin"
  234. "activate_bottom_padding"
  235. "activate_box_layout"
  236. "activate_clipping"
  237. "activate_color"
  238. "activate_corner1"
  239. "activate_corner2"
  240. "activate_crop"
  241. "activate_delay"
  242. "activate_drop_shadow"
  243. "activate_drop_shadow_color"
  244. "activate_first_indent"
  245. "activate_first_spacing"
  246. "activate_fit_first"
  247. "activate_font"
  248. "activate_foreground"
  249. "activate_italic"
  250. "activate_justify"
  251. "activate_language"
  252. "activate_layout"
  253. "activate_left_bar"
  254. "activate_left_gutter"
  255. "activate_left_margin"
  256. "activate_left_padding"
  257. "activate_line_spacing"
  258. "activate_min_width"
  259. "activate_minwidth"
  260. "activate_mouse"
  261. "activate_offset"
  262. "activate_outlines"
  263. "activate_pos"
  264. "activate_radius"
  265. "activate_rest_indent"
  266. "activate_right_bar"
  267. "activate_right_gutter"
  268. "activate_right_margin"
  269. "activate_right_padding"
  270. "activate_rotate"
  271. "activate_rotate_pad"
  272. "activate_size"
  273. "activate_size_group"
  274. "activate_slow_abortable"
  275. "activate_slow_cps"
  276. "activate_slow_cps_multiplier"
  277. "activate_sound"
  278. "activate_spacing"
  279. "activate_subpixel"
  280. "activate_text_align"
  281. "activate_text_y_fudge"
  282. "activate_thumb"
  283. "activate_thumb_offset"
  284. "activate_thumb_shadow"
  285. "activate_top_bar"
  286. "activate_top_gutter"
  287. "activate_top_margin"
  288. "activate_top_padding"
  289. "activate_underline"
  290. "activate_unscrollable"
  291. "activate_xalign"
  292. "activate_xanchor"
  293. "activate_xanchoraround"
  294. "activate_xaround"
  295. "activate_xfill"
  296. "activate_xmargin"
  297. "activate_xmaximum"
  298. "activate_xminimum"
  299. "activate_xoffset"
  300. "activate_xpadding"
  301. "activate_xpos"
  302. "activate_xzoom"
  303. "activate_yalign"
  304. "activate_yanchor"
  305. "activate_yanchoraround"
  306. "activate_yaround"
  307. "activate_yfill"
  308. "activate_ymargin"
  309. "activate_ymaximum"
  310. "activate_yminimum"
  311. "activate_yoffset"
  312. "activate_ypadding"
  313. "activate_ypos"
  314. "activate_yzoom"
  315. "activate_zoom"
  316. "adjustment"
  317. "align"
  318. "alignaround"
  319. "allow"
  320. "alpha"
  321. "anchor"
  322. "angle"
  323. "antialias"
  324. "area"
  325. "around"
  326. "auto"
  327. "background"
  328. "bar_invert"
  329. "bar_resizing"
  330. "bar_vertical"
  331. "black_color"
  332. "bold"
  333. "bottom_bar"
  334. "bottom_gutter"
  335. "bottom_margin"
  336. "bottom_padding"
  337. "box_layout"
  338. "changed"
  339. "child_size"
  340. "clicked"
  341. "clipping"
  342. "color"
  343. "corner1"
  344. "corner2"
  345. "crop"
  346. "default"
  347. "delay"
  348. "draggable"
  349. "drop_shadow"
  350. "drop_shadow_color"
  351. "exclude"
  352. "first_indent"
  353. "first_spacing"
  354. "fit_first"
  355. "focus"
  356. "font"
  357. "foreground"
  358. "ground"
  359. "height"
  360. "hover"
  361. "hover_align"
  362. "hover_alignaround"
  363. "hover_alpha"
  364. "hover_anchor"
  365. "hover_angle"
  366. "hover_antialias"
  367. "hover_area"
  368. "hover_around"
  369. "hover_background"
  370. "hover_bar_invert"
  371. "hover_bar_resizing"
  372. "hover_bar_vertical"
  373. "hover_black_color"
  374. "hover_bold"
  375. "hover_bottom_bar"
  376. "hover_bottom_gutter"
  377. "hover_bottom_margin"
  378. "hover_bottom_padding"
  379. "hover_box_layout"
  380. "hover_clipping"
  381. "hover_color"
  382. "hover_corner1"
  383. "hover_corner2"
  384. "hover_crop"
  385. "hover_delay"
  386. "hover_drop_shadow"
  387. "hover_drop_shadow_color"
  388. "hover_first_indent"
  389. "hover_first_spacing"
  390. "hover_fit_first"
  391. "hover_font"
  392. "hover_foreground"
  393. "hover_italic"
  394. "hover_justify"
  395. "hover_language"
  396. "hover_layout"
  397. "hover_left_bar"
  398. "hover_left_gutter"
  399. "hover_left_margin"
  400. "hover_left_padding"
  401. "hover_line_spacing"
  402. "hover_min_width"
  403. "hover_minwidth"
  404. "hover_mouse"
  405. "hover_offset"
  406. "hover_outlines"
  407. "hover_pos"
  408. "hover_radius"
  409. "hover_rest_indent"
  410. "hover_right_bar"
  411. "hover_right_gutter"
  412. "hover_right_margin"
  413. "hover_right_padding"
  414. "hover_rotate"
  415. "hover_rotate_pad"
  416. "hover_size"
  417. "hover_size_group"
  418. "hover_slow_abortable"
  419. "hover_slow_cps"
  420. "hover_slow_cps_multiplier"
  421. "hover_sound"
  422. "hover_spacing"
  423. "hover_subpixel"
  424. "hover_text_align"
  425. "hover_text_y_fudge"
  426. "hover_thumb"
  427. "hover_thumb_offset"
  428. "hover_thumb_shadow"
  429. "hover_top_bar"
  430. "hover_top_gutter"
  431. "hover_top_margin"
  432. "hover_top_padding"
  433. "hover_underline"
  434. "hover_unscrollable"
  435. "hover_xalign"
  436. "hover_xanchor"
  437. "hover_xanchoraround"
  438. "hover_xaround"
  439. "hover_xfill"
  440. "hover_xmargin"
  441. "hover_xmaximum"
  442. "hover_xminimum"
  443. "hover_xoffset"
  444. "hover_xpadding"
  445. "hover_xpos"
  446. "hover_xzoom"
  447. "hover_yalign"
  448. "hover_yanchor"
  449. "hover_yanchoraround"
  450. "hover_yaround"
  451. "hover_yfill"
  452. "hover_ymargin"
  453. "hover_ymaximum"
  454. "hover_yminimum"
  455. "hover_yoffset"
  456. "hover_ypadding"
  457. "hover_ypos"
  458. "hover_yzoom"
  459. "hover_zoom"
  460. "hovered"
  461. "id"
  462. "idle"
  463. "idle_align"
  464. "idle_alignaround"
  465. "idle_alpha"
  466. "idle_anchor"
  467. "idle_angle"
  468. "idle_antialias"
  469. "idle_area"
  470. "idle_around"
  471. "idle_background"
  472. "idle_bar_invert"
  473. "idle_bar_resizing"
  474. "idle_bar_vertical"
  475. "idle_black_color"
  476. "idle_bold"
  477. "idle_bottom_bar"
  478. "idle_bottom_gutter"
  479. "idle_bottom_margin"
  480. "idle_bottom_padding"
  481. "idle_box_layout"
  482. "idle_clipping"
  483. "idle_color"
  484. "idle_corner1"
  485. "idle_corner2"
  486. "idle_crop"
  487. "idle_delay"
  488. "idle_drop_shadow"
  489. "idle_drop_shadow_color"
  490. "idle_first_indent"
  491. "idle_first_spacing"
  492. "idle_fit_first"
  493. "idle_font"
  494. "idle_foreground"
  495. "idle_italic"
  496. "idle_justify"
  497. "idle_language"
  498. "idle_layout"
  499. "idle_left_bar"
  500. "idle_left_gutter"
  501. "idle_left_margin"
  502. "idle_left_padding"
  503. "idle_line_spacing"
  504. "idle_min_width"
  505. "idle_minwidth"
  506. "idle_mouse"
  507. "idle_offset"
  508. "idle_outlines"
  509. "idle_pos"
  510. "idle_radius"
  511. "idle_rest_indent"
  512. "idle_right_bar"
  513. "idle_right_gutter"
  514. "idle_right_margin"
  515. "idle_right_padding"
  516. "idle_rotate"
  517. "idle_rotate_pad"
  518. "idle_size"
  519. "idle_size_group"
  520. "idle_slow_abortable"
  521. "idle_slow_cps"
  522. "idle_slow_cps_multiplier"
  523. "idle_sound"
  524. "idle_spacing"
  525. "idle_subpixel"
  526. "idle_text_align"
  527. "idle_text_y_fudge"
  528. "idle_thumb"
  529. "idle_thumb_offset"
  530. "idle_thumb_shadow"
  531. "idle_top_bar"
  532. "idle_top_gutter"
  533. "idle_top_margin"
  534. "idle_top_padding"
  535. "idle_underline"
  536. "idle_unscrollable"
  537. "idle_xalign"
  538. "idle_xanchor"
  539. "idle_xanchoraround"
  540. "idle_xaround"
  541. "idle_xfill"
  542. "idle_xmargin"
  543. "idle_xmaximum"
  544. "idle_xminimum"
  545. "idle_xoffset"
  546. "idle_xpadding"
  547. "idle_xpos"
  548. "idle_xzoom"
  549. "idle_yalign"
  550. "idle_yanchor"
  551. "idle_yanchoraround"
  552. "idle_yaround"
  553. "idle_yfill"
  554. "idle_ymargin"
  555. "idle_ymaximum"
  556. "idle_yminimum"
  557. "idle_yoffset"
  558. "idle_ypadding"
  559. "idle_ypos"
  560. "idle_yzoom"
  561. "idle_zoom"
  562. "image_style"
  563. "insensitive"
  564. "insensitive_align"
  565. "insensitive_alignaround"
  566. "insensitive_alpha"
  567. "insensitive_anchor"
  568. "insensitive_angle"
  569. "insensitive_antialias"
  570. "insensitive_area"
  571. "insensitive_around"
  572. "insensitive_background"
  573. "insensitive_bar_invert"
  574. "insensitive_bar_resizing"
  575. "insensitive_bar_vertical"
  576. "insensitive_black_color"
  577. "insensitive_bold"
  578. "insensitive_bottom_bar"
  579. "insensitive_bottom_gutter"
  580. "insensitive_bottom_margin"
  581. "insensitive_bottom_padding"
  582. "insensitive_box_layout"
  583. "insensitive_clipping"
  584. "insensitive_color"
  585. "insensitive_corner1"
  586. "insensitive_corner2"
  587. "insensitive_crop"
  588. "insensitive_delay"
  589. "insensitive_drop_shadow"
  590. "insensitive_drop_shadow_color"
  591. "insensitive_first_indent"
  592. "insensitive_first_spacing"
  593. "insensitive_fit_first"
  594. "insensitive_font"
  595. "insensitive_foreground"
  596. "insensitive_italic"
  597. "insensitive_justify"
  598. "insensitive_language"
  599. "insensitive_layout"
  600. "insensitive_left_bar"
  601. "insensitive_left_gutter"
  602. "insensitive_left_margin"
  603. "insensitive_left_padding"
  604. "insensitive_line_spacing"
  605. "insensitive_min_width"
  606. "insensitive_minwidth"
  607. "insensitive_mouse"
  608. "insensitive_offset"
  609. "insensitive_outlines"
  610. "insensitive_pos"
  611. "insensitive_radius"
  612. "insensitive_rest_indent"
  613. "insensitive_right_bar"
  614. "insensitive_right_gutter"
  615. "insensitive_right_margin"
  616. "insensitive_right_padding"
  617. "insensitive_rotate"
  618. "insensitive_rotate_pad"
  619. "insensitive_size"
  620. "insensitive_size_group"
  621. "insensitive_slow_abortable"
  622. "insensitive_slow_cps"
  623. "insensitive_slow_cps_multiplier"
  624. "insensitive_sound"
  625. "insensitive_spacing"
  626. "insensitive_subpixel"
  627. "insensitive_text_align"
  628. "insensitive_text_y_fudge"
  629. "insensitive_thumb"
  630. "insensitive_thumb_offset"
  631. "insensitive_thumb_shadow"
  632. "insensitive_top_bar"
  633. "insensitive_top_gutter"
  634. "insensitive_top_margin"
  635. "insensitive_top_padding"
  636. "insensitive_underline"
  637. "insensitive_unscrollable"
  638. "insensitive_xalign"
  639. "insensitive_xanchor"
  640. "insensitive_xanchoraround"
  641. "insensitive_xaround"
  642. "insensitive_xfill"
  643. "insensitive_xmargin"
  644. "insensitive_xmaximum"
  645. "insensitive_xminimum"
  646. "insensitive_xoffset"
  647. "insensitive_xpadding"
  648. "insensitive_xpos"
  649. "insensitive_xzoom"
  650. "insensitive_yalign"
  651. "insensitive_yanchor"
  652. "insensitive_yanchoraround"
  653. "insensitive_yaround"
  654. "insensitive_yfill"
  655. "insensitive_ymargin"
  656. "insensitive_ymaximum"
  657. "insensitive_yminimum"
  658. "insensitive_yoffset"
  659. "insensitive_ypadding"
  660. "insensitive_ypos"
  661. "insensitive_yzoom"
  662. "insensitive_zoom"
  663. "italic"
  664. "justify"
  665. "language"
  666. "layout"
  667. "left_bar"
  668. "left_gutter"
  669. "left_margin"
  670. "left_padding"
  671. "length"
  672. "line_spacing"
  673. "min_width"
  674. "minwidth"
  675. "mouse"
  676. "mousewheel"
  677. "offset"
  678. "outlines"
  679. "pos"
  680. "prefix"
  681. "radius"
  682. "range"
  683. "rest_indent"
  684. "right_bar"
  685. "right_gutter"
  686. "right_margin"
  687. "right_padding"
  688. "rotate"
  689. "rotate_pad"
  690. "selected_activate_align"
  691. "selected_activate_alignaround"
  692. "selected_activate_alpha"
  693. "selected_activate_anchor"
  694. "selected_activate_angle"
  695. "selected_activate_antialias"
  696. "selected_activate_area"
  697. "selected_activate_around"
  698. "selected_activate_background"
  699. "selected_activate_bar_invert"
  700. "selected_activate_bar_resizing"
  701. "selected_activate_bar_vertical"
  702. "selected_activate_black_color"
  703. "selected_activate_bold"
  704. "selected_activate_bottom_bar"
  705. "selected_activate_bottom_gutter"
  706. "selected_activate_bottom_margin"
  707. "selected_activate_bottom_padding"
  708. "selected_activate_box_layout"
  709. "selected_activate_clipping"
  710. "selected_activate_color"
  711. "selected_activate_corner1"
  712. "selected_activate_corner2"
  713. "selected_activate_crop"
  714. "selected_activate_delay"
  715. "selected_activate_drop_shadow"
  716. "selected_activate_drop_shadow_color"
  717. "selected_activate_first_indent"
  718. "selected_activate_first_spacing"
  719. "selected_activate_fit_first"
  720. "selected_activate_font"
  721. "selected_activate_foreground"
  722. "selected_activate_italic"
  723. "selected_activate_justify"
  724. "selected_activate_language"
  725. "selected_activate_layout"
  726. "selected_activate_left_bar"
  727. "selected_activate_left_gutter"
  728. "selected_activate_left_margin"
  729. "selected_activate_left_padding"
  730. "selected_activate_line_spacing"
  731. "selected_activate_min_width"
  732. "selected_activate_minwidth"
  733. "selected_activate_mouse"
  734. "selected_activate_offset"
  735. "selected_activate_outlines"
  736. "selected_activate_pos"
  737. "selected_activate_radius"
  738. "selected_activate_rest_indent"
  739. "selected_activate_right_bar"
  740. "selected_activate_right_gutter"
  741. "selected_activate_right_margin"
  742. "selected_activate_right_padding"
  743. "selected_activate_rotate"
  744. "selected_activate_rotate_pad"
  745. "selected_activate_size"
  746. "selected_activate_size_group"
  747. "selected_activate_slow_abortable"
  748. "selected_activate_slow_cps"
  749. "selected_activate_slow_cps_multiplier"
  750. "selected_activate_sound"
  751. "selected_activate_spacing"
  752. "selected_activate_subpixel"
  753. "selected_activate_text_align"
  754. "selected_activate_text_y_fudge"
  755. "selected_activate_thumb"
  756. "selected_activate_thumb_offset"
  757. "selected_activate_thumb_shadow"
  758. "selected_activate_top_bar"
  759. "selected_activate_top_gutter"
  760. "selected_activate_top_margin"
  761. "selected_activate_top_padding"
  762. "selected_activate_underline"
  763. "selected_activate_unscrollable"
  764. "selected_activate_xalign"
  765. "selected_activate_xanchor"
  766. "selected_activate_xanchoraround"
  767. "selected_activate_xaround"
  768. "selected_activate_xfill"
  769. "selected_activate_xmargin"
  770. "selected_activate_xmaximum"
  771. "selected_activate_xminimum"
  772. "selected_activate_xoffset"
  773. "selected_activate_xpadding"
  774. "selected_activate_xpos"
  775. "selected_activate_xzoom"
  776. "selected_activate_yalign"
  777. "selected_activate_yanchor"
  778. "selected_activate_yanchoraround"
  779. "selected_activate_yaround"
  780. "selected_activate_yfill"
  781. "selected_activate_ymargin"
  782. "selected_activate_ymaximum"
  783. "selected_activate_yminimum"
  784. "selected_activate_yoffset"
  785. "selected_activate_ypadding"
  786. "selected_activate_ypos"
  787. "selected_activate_yzoom"
  788. "selected_activate_zoom"
  789. "selected_align"
  790. "selected_alignaround"
  791. "selected_alpha"
  792. "selected_anchor"
  793. "selected_angle"
  794. "selected_antialias"
  795. "selected_area"
  796. "selected_around"
  797. "selected_background"
  798. "selected_bar_invert"
  799. "selected_bar_resizing"
  800. "selected_bar_vertical"
  801. "selected_black_color"
  802. "selected_bold"
  803. "selected_bottom_bar"
  804. "selected_bottom_gutter"
  805. "selected_bottom_margin"
  806. "selected_bottom_padding"
  807. "selected_box_layout"
  808. "selected_clipping"
  809. "selected_color"
  810. "selected_corner1"
  811. "selected_corner2"
  812. "selected_crop"
  813. "selected_delay"
  814. "selected_drop_shadow"
  815. "selected_drop_shadow_color"
  816. "selected_first_indent"
  817. "selected_first_spacing"
  818. "selected_fit_first"
  819. "selected_font"
  820. "selected_foreground"
  821. "selected_hover"
  822. "selected_hover_align"
  823. "selected_hover_alignaround"
  824. "selected_hover_alpha"
  825. "selected_hover_anchor"
  826. "selected_hover_angle"
  827. "selected_hover_antialias"
  828. "selected_hover_area"
  829. "selected_hover_around"
  830. "selected_hover_background"
  831. "selected_hover_bar_invert"
  832. "selected_hover_bar_resizing"
  833. "selected_hover_bar_vertical"
  834. "selected_hover_black_color"
  835. "selected_hover_bold"
  836. "selected_hover_bottom_bar"
  837. "selected_hover_bottom_gutter"
  838. "selected_hover_bottom_margin"
  839. "selected_hover_bottom_padding"
  840. "selected_hover_box_layout"
  841. "selected_hover_clipping"
  842. "selected_hover_color"
  843. "selected_hover_corner1"
  844. "selected_hover_corner2"
  845. "selected_hover_crop"
  846. "selected_hover_delay"
  847. "selected_hover_drop_shadow"
  848. "selected_hover_drop_shadow_color"
  849. "selected_hover_first_indent"
  850. "selected_hover_first_spacing"
  851. "selected_hover_fit_first"
  852. "selected_hover_font"
  853. "selected_hover_foreground"
  854. "selected_hover_italic"
  855. "selected_hover_justify"
  856. "selected_hover_language"
  857. "selected_hover_layout"
  858. "selected_hover_left_bar"
  859. "selected_hover_left_gutter"
  860. "selected_hover_left_margin"
  861. "selected_hover_left_padding"
  862. "selected_hover_line_spacing"
  863. "selected_hover_min_width"
  864. "selected_hover_minwidth"
  865. "selected_hover_mouse"
  866. "selected_hover_offset"
  867. "selected_hover_outlines"
  868. "selected_hover_pos"
  869. "selected_hover_radius"
  870. "selected_hover_rest_indent"
  871. "selected_hover_right_bar"
  872. "selected_hover_right_gutter"
  873. "selected_hover_right_margin"
  874. "selected_hover_right_padding"
  875. "selected_hover_rotate"
  876. "selected_hover_rotate_pad"
  877. "selected_hover_size"
  878. "selected_hover_size_group"
  879. "selected_hover_slow_abortable"
  880. "selected_hover_slow_cps"
  881. "selected_hover_slow_cps_multiplier"
  882. "selected_hover_sound"
  883. "selected_hover_spacing"
  884. "selected_hover_subpixel"
  885. "selected_hover_text_align"
  886. "selected_hover_text_y_fudge"
  887. "selected_hover_thumb"
  888. "selected_hover_thumb_offset"
  889. "selected_hover_thumb_shadow"
  890. "selected_hover_top_bar"
  891. "selected_hover_top_gutter"
  892. "selected_hover_top_margin"
  893. "selected_hover_top_padding"
  894. "selected_hover_underline"
  895. "selected_hover_unscrollable"
  896. "selected_hover_xalign"
  897. "selected_hover_xanchor"
  898. "selected_hover_xanchoraround"
  899. "selected_hover_xaround"
  900. "selected_hover_xfill"
  901. "selected_hover_xmargin"
  902. "selected_hover_xmaximum"
  903. "selected_hover_xminimum"
  904. "selected_hover_xoffset"
  905. "selected_hover_xpadding"
  906. "selected_hover_xpos"
  907. "selected_hover_xzoom"
  908. "selected_hover_yalign"
  909. "selected_hover_yanchor"
  910. "selected_hover_yanchoraround"
  911. "selected_hover_yaround"
  912. "selected_hover_yfill"
  913. "selected_hover_ymargin"
  914. "selected_hover_ymaximum"
  915. "selected_hover_yminimum"
  916. "selected_hover_yoffset"
  917. "selected_hover_ypadding"
  918. "selected_hover_ypos"
  919. "selected_hover_yzoom"
  920. "selected_hover_zoom"
  921. "selected_idle"
  922. "selected_idle_align"
  923. "selected_idle_alignaround"
  924. "selected_idle_alpha"
  925. "selected_idle_anchor"
  926. "selected_idle_angle"
  927. "selected_idle_antialias"
  928. "selected_idle_area"
  929. "selected_idle_around"
  930. "selected_idle_background"
  931. "selected_idle_bar_invert"
  932. "selected_idle_bar_resizing"
  933. "selected_idle_bar_vertical"
  934. "selected_idle_black_color"
  935. "selected_idle_bold"
  936. "selected_idle_bottom_bar"
  937. "selected_idle_bottom_gutter"
  938. "selected_idle_bottom_margin"
  939. "selected_idle_bottom_padding"
  940. "selected_idle_box_layout"
  941. "selected_idle_clipping"
  942. "selected_idle_color"
  943. "selected_idle_corner1"
  944. "selected_idle_corner2"
  945. "selected_idle_crop"
  946. "selected_idle_delay"
  947. "selected_idle_drop_shadow"
  948. "selected_idle_drop_shadow_color"
  949. "selected_idle_first_indent"
  950. "selected_idle_first_spacing"
  951. "selected_idle_fit_first"
  952. "selected_idle_font"
  953. "selected_idle_foreground"
  954. "selected_idle_italic"
  955. "selected_idle_justify"
  956. "selected_idle_language"
  957. "selected_idle_layout"
  958. "selected_idle_left_bar"
  959. "selected_idle_left_gutter"
  960. "selected_idle_left_margin"
  961. "selected_idle_left_padding"
  962. "selected_idle_line_spacing"
  963. "selected_idle_min_width"
  964. "selected_idle_minwidth"
  965. "selected_idle_mouse"
  966. "selected_idle_offset"
  967. "selected_idle_outlines"
  968. "selected_idle_pos"
  969. "selected_idle_radius"
  970. "selected_idle_rest_indent"
  971. "selected_idle_right_bar"
  972. "selected_idle_right_gutter"
  973. "selected_idle_right_margin"
  974. "selected_idle_right_padding"
  975. "selected_idle_rotate"
  976. "selected_idle_rotate_pad"
  977. "selected_idle_size"
  978. "selected_idle_size_group"
  979. "selected_idle_slow_abortable"
  980. "selected_idle_slow_cps"
  981. "selected_idle_slow_cps_multiplier"
  982. "selected_idle_sound"
  983. "selected_idle_spacing"
  984. "selected_idle_subpixel"
  985. "selected_idle_text_align"
  986. "selected_idle_text_y_fudge"
  987. "selected_idle_thumb"
  988. "selected_idle_thumb_offset"
  989. "selected_idle_thumb_shadow"
  990. "selected_idle_top_bar"
  991. "selected_idle_top_gutter"
  992. "selected_idle_top_margin"
  993. "selected_idle_top_padding"
  994. "selected_idle_underline"
  995. "selected_idle_unscrollable"
  996. "selected_idle_xalign"
  997. "selected_idle_xanchor"
  998. "selected_idle_xanchoraround"
  999. "selected_idle_xaround"
  1000. "selected_idle_xfill"
  1001. "selected_idle_xmargin"
  1002. "selected_idle_xmaximum"
  1003. "selected_idle_xminimum"
  1004. "selected_idle_xoffset"
  1005. "selected_idle_xpadding"
  1006. "selected_idle_xpos"
  1007. "selected_idle_xzoom"
  1008. "selected_idle_yalign"
  1009. "selected_idle_yanchor"
  1010. "selected_idle_yanchoraround"
  1011. "selected_idle_yaround"
  1012. "selected_idle_yfill"
  1013. "selected_idle_ymargin"
  1014. "selected_idle_ymaximum"
  1015. "selected_idle_yminimum"
  1016. "selected_idle_yoffset"
  1017. "selected_idle_ypadding"
  1018. "selected_idle_ypos"
  1019. "selected_idle_yzoom"
  1020. "selected_idle_zoom"
  1021. "selected_insensitive_align"
  1022. "selected_insensitive_alignaround"
  1023. "selected_insensitive_alpha"
  1024. "selected_insensitive_anchor"
  1025. "selected_insensitive_angle"
  1026. "selected_insensitive_antialias"
  1027. "selected_insensitive_area"
  1028. "selected_insensitive_around"
  1029. "selected_insensitive_background"
  1030. "selected_insensitive_bar_invert"
  1031. "selected_insensitive_bar_resizing"
  1032. "selected_insensitive_bar_vertical"
  1033. "selected_insensitive_black_color"
  1034. "selected_insensitive_bold"
  1035. "selected_insensitive_bottom_bar"
  1036. "selected_insensitive_bottom_gutter"
  1037. "selected_insensitive_bottom_margin"
  1038. "selected_insensitive_bottom_padding"
  1039. "selected_insensitive_box_layout"
  1040. "selected_insensitive_clipping"
  1041. "selected_insensitive_color"
  1042. "selected_insensitive_corner1"
  1043. "selected_insensitive_corner2"
  1044. "selected_insensitive_crop"
  1045. "selected_insensitive_delay"
  1046. "selected_insensitive_drop_shadow"
  1047. "selected_insensitive_drop_shadow_color"
  1048. "selected_insensitive_first_indent"
  1049. "selected_insensitive_first_spacing"
  1050. "selected_insensitive_fit_first"
  1051. "selected_insensitive_font"
  1052. "selected_insensitive_foreground"
  1053. "selected_insensitive_italic"
  1054. "selected_insensitive_justify"
  1055. "selected_insensitive_language"
  1056. "selected_insensitive_layout"
  1057. "selected_insensitive_left_bar"
  1058. "selected_insensitive_left_gutter"
  1059. "selected_insensitive_left_margin"
  1060. "selected_insensitive_left_padding"
  1061. "selected_insensitive_line_spacing"
  1062. "selected_insensitive_min_width"
  1063. "selected_insensitive_minwidth"
  1064. "selected_insensitive_mouse"
  1065. "selected_insensitive_offset"
  1066. "selected_insensitive_outlines"
  1067. "selected_insensitive_pos"
  1068. "selected_insensitive_radius"
  1069. "selected_insensitive_rest_indent"
  1070. "selected_insensitive_right_bar"
  1071. "selected_insensitive_right_gutter"
  1072. "selected_insensitive_right_margin"
  1073. "selected_insensitive_right_padding"
  1074. "selected_insensitive_rotate"
  1075. "selected_insensitive_rotate_pad"
  1076. "selected_insensitive_size"
  1077. "selected_insensitive_size_group"
  1078. "selected_insensitive_slow_abortable"
  1079. "selected_insensitive_slow_cps"
  1080. "selected_insensitive_slow_cps_multiplier"
  1081. "selected_insensitive_sound"
  1082. "selected_insensitive_spacing"
  1083. "selected_insensitive_subpixel"
  1084. "selected_insensitive_text_align"
  1085. "selected_insensitive_text_y_fudge"
  1086. "selected_insensitive_thumb"
  1087. "selected_insensitive_thumb_offset"
  1088. "selected_insensitive_thumb_shadow"
  1089. "selected_insensitive_top_bar"
  1090. "selected_insensitive_top_gutter"
  1091. "selected_insensitive_top_margin"
  1092. "selected_insensitive_top_padding"
  1093. "selected_insensitive_underline"
  1094. "selected_insensitive_unscrollable"
  1095. "selected_insensitive_xalign"
  1096. "selected_insensitive_xanchor"
  1097. "selected_insensitive_xanchoraround"
  1098. "selected_insensitive_xaround"
  1099. "selected_insensitive_xfill"
  1100. "selected_insensitive_xmargin"
  1101. "selected_insensitive_xmaximum"
  1102. "selected_insensitive_xminimum"
  1103. "selected_insensitive_xoffset"
  1104. "selected_insensitive_xpadding"
  1105. "selected_insensitive_xpos"
  1106. "selected_insensitive_xzoom"
  1107. "selected_insensitive_yalign"
  1108. "selected_insensitive_yanchor"
  1109. "selected_insensitive_yanchoraround"
  1110. "selected_insensitive_yaround"
  1111. "selected_insensitive_yfill"
  1112. "selected_insensitive_ymargin"
  1113. "selected_insensitive_ymaximum"
  1114. "selected_insensitive_yminimum"
  1115. "selected_insensitive_yoffset"
  1116. "selected_insensitive_ypadding"
  1117. "selected_insensitive_ypos"
  1118. "selected_insensitive_yzoom"
  1119. "selected_insensitive_zoom"
  1120. "selected_italic"
  1121. "selected_justify"
  1122. "selected_language"
  1123. "selected_layout"
  1124. "selected_left_bar"
  1125. "selected_left_gutter"
  1126. "selected_left_margin"
  1127. "selected_left_padding"
  1128. "selected_line_spacing"
  1129. "selected_min_width"
  1130. "selected_minwidth"
  1131. "selected_mouse"
  1132. "selected_offset"
  1133. "selected_outlines"
  1134. "selected_pos"
  1135. "selected_radius"
  1136. "selected_rest_indent"
  1137. "selected_right_bar"
  1138. "selected_right_gutter"
  1139. "selected_right_margin"
  1140. "selected_right_padding"
  1141. "selected_rotate"
  1142. "selected_rotate_pad"
  1143. "selected_size"
  1144. "selected_size_group"
  1145. "selected_slow_abortable"
  1146. "selected_slow_cps"
  1147. "selected_slow_cps_multiplier"
  1148. "selected_sound"
  1149. "selected_spacing"
  1150. "selected_subpixel"
  1151. "selected_text_align"
  1152. "selected_text_y_fudge"
  1153. "selected_thumb"
  1154. "selected_thumb_offset"
  1155. "selected_thumb_shadow"
  1156. "selected_top_bar"
  1157. "selected_top_gutter"
  1158. "selected_top_margin"
  1159. "selected_top_padding"
  1160. "selected_underline"
  1161. "selected_unscrollable"
  1162. "selected_xalign"
  1163. "selected_xanchor"
  1164. "selected_xanchoraround"
  1165. "selected_xaround"
  1166. "selected_xfill"
  1167. "selected_xmargin"
  1168. "selected_xmaximum"
  1169. "selected_xminimum"
  1170. "selected_xoffset"
  1171. "selected_xpadding"
  1172. "selected_xpos"
  1173. "selected_xzoom"
  1174. "selected_yalign"
  1175. "selected_yanchor"
  1176. "selected_yanchoraround"
  1177. "selected_yaround"
  1178. "selected_yfill"
  1179. "selected_ymargin"
  1180. "selected_ymaximum"
  1181. "selected_yminimum"
  1182. "selected_yoffset"
  1183. "selected_ypadding"
  1184. "selected_ypos"
  1185. "selected_yzoom"
  1186. "selected_zoom"
  1187. "size"
  1188. "size_group"
  1189. "slow"
  1190. "slow_abortable"
  1191. "slow_cps"
  1192. "slow_cps_multiplier"
  1193. "sound"
  1194. "spacing"
  1195. "style"
  1196. "style_group"
  1197. "subpixel"
  1198. "suffix"
  1199. "text_align"
  1200. "text_style"
  1201. "text_y_fudge"
  1202. "thumb"
  1203. "thumb_offset"
  1204. "thumb_shadow"
  1205. "top_bar"
  1206. "top_gutter"
  1207. "top_margin"
  1208. "top_padding"
  1209. "transpose"
  1210. "underline"
  1211. "unhovered"
  1212. "unscrollable"
  1213. "value"
  1214. "width"
  1215. "xadjustment"
  1216. "xalign"
  1217. "xanchor"
  1218. "xanchoraround"
  1219. "xaround"
  1220. "xfill"
  1221. "xmargin"
  1222. "xmaximum"
  1223. "xminimum"
  1224. "xoffset"
  1225. "xpadding"
  1226. "xpos"
  1227. "xzoom"
  1228. "yadjustment"
  1229. "yalign"
  1230. "yanchor"
  1231. "yanchoraround"
  1232. "yaround"
  1233. "yfill"
  1234. "ymargin"
  1235. "ymaximum"
  1236. "yminimum"
  1237. "yoffset"
  1238. "ypadding"
  1239. "ypos"
  1240. "yzoom"
  1241. "zoom"
  1242. )) symbol-end)
  1243. (1 font-lock-builtin-face))
  1244. (,(rx symbol-start (or
  1245. ;; other built-ins
  1246. "True" "False" "None" "Ellipsis"
  1247. "_" "__debug__" "__doc__" "__import__" "__name__") symbol-end)
  1248. . font-lock-builtin-face)))
  1249. (defconst renpy-font-lock-syntactic-keywords
  1250. ;; Make outer chars of matching triple-quote sequences into generic
  1251. ;; string delimiters. Fixme: Is there a better way?
  1252. ;; First avoid a sequence preceded by an odd number of backslashes.
  1253. `((,(rx (not (any ?\\))
  1254. ?\\ (* (and ?\\ ?\\))
  1255. (group (syntax string-quote))
  1256. (backref 1)
  1257. (group (backref 1)))
  1258. (2 ,(string-to-syntax "\""))) ; dummy
  1259. (,(rx (group (optional (any "uUrR"))) ; prefix gets syntax property
  1260. (optional (any "rR")) ; possible second prefix
  1261. (group (syntax string-quote)) ; maybe gets property
  1262. (backref 2) ; per first quote
  1263. (group (backref 2))) ; maybe gets property
  1264. (1 (renpy-quote-syntax 1))
  1265. (2 (renpy-quote-syntax 2))
  1266. (3 (renpy-quote-syntax 3)))
  1267. ;; This doesn't really help.
  1268. ;;; (,(rx (and ?\\ (group ?\n))) (1 " "))
  1269. ))
  1270. (defun renpy-quote-syntax (n)
  1271. "Put `syntax-table' property correctly on triple quote.
  1272. Used for syntactic keywords. N is the match number (1, 2 or 3)."
  1273. ;; Given a triple quote, we have to check the context to know
  1274. ;; whether this is an opening or closing triple or whether it's
  1275. ;; quoted anyhow, and should be ignored. (For that we need to do
  1276. ;; the same job as `syntax-ppss' to be correct and it seems to be OK
  1277. ;; to use it here despite initial worries.) We also have to sort
  1278. ;; out a possible prefix -- well, we don't _have_ to, but I think it
  1279. ;; should be treated as part of the string.
  1280. ;; Test cases:
  1281. ;; ur"""ar""" x='"' # """
  1282. ;; x = ''' """ ' a
  1283. ;; '''
  1284. ;; x '"""' x """ \"""" x
  1285. (save-excursion
  1286. (goto-char (match-beginning 0))
  1287. (cond
  1288. ;; Consider property for the last char if in a fenced string.
  1289. ((= n 3)
  1290. (let* ((font-lock-syntactic-keywords nil)
  1291. (syntax (syntax-ppss)))
  1292. (when (eq t (nth 3 syntax)) ; after unclosed fence
  1293. (goto-char (nth 8 syntax)) ; fence position
  1294. (skip-chars-forward "uUrR") ; skip any prefix
  1295. ;; Is it a matching sequence?
  1296. (if (eq (char-after) (char-after (match-beginning 2)))
  1297. (eval-when-compile (string-to-syntax "|"))))))
  1298. ;; Consider property for initial char, accounting for prefixes.
  1299. ((or (and (= n 2) ; leading quote (not prefix)
  1300. (= (match-beginning 1) (match-end 1))) ; prefix is null
  1301. (and (= n 1) ; prefix
  1302. (/= (match-beginning 1) (match-end 1)))) ; non-empty
  1303. (let ((font-lock-syntactic-keywords nil))
  1304. (unless (eq 'string (syntax-ppss-context (syntax-ppss)))
  1305. (eval-when-compile (string-to-syntax "|")))))
  1306. ;; Otherwise (we're in a non-matching string) the property is
  1307. ;; nil, which is OK.
  1308. )))
  1309. ;; This isn't currently in `font-lock-defaults' as probably not worth
  1310. ;; it -- we basically only mess with a few normally-symbol characters.
  1311. ;; (defun renpy-font-lock-syntactic-face-function (state)
  1312. ;; "`font-lock-syntactic-face-function' for Renpy mode.
  1313. ;; Returns the string or comment face as usual, with side effect of putting
  1314. ;; a `syntax-table' property on the inside of the string or comment which is
  1315. ;; the standard syntax table."
  1316. ;; (if (nth 3 state)
  1317. ;; (save-excursion
  1318. ;; (goto-char (nth 8 state))
  1319. ;; (condition-case nil
  1320. ;; (forward-sexp)
  1321. ;; (error nil))
  1322. ;; (put-text-property (1+ (nth 8 state)) (1- (point))
  1323. ;; 'syntax-table (standard-syntax-table))
  1324. ;; 'font-lock-string-face)
  1325. ;; (put-text-property (1+ (nth 8 state)) (line-end-position)
  1326. ;; 'syntax-table (standard-syntax-table))
  1327. ;; 'font-lock-comment-face))
  1328. ;;;; Keymap and syntax
  1329. (defvar renpy-mode-map
  1330. (let ((map (make-sparse-keymap)))
  1331. ;; Mostly taken from renpy-mode.el.
  1332. (define-key map ":" 'renpy-electric-colon)
  1333. (define-key map "\177" 'renpy-backspace)
  1334. (define-key map "\C-c<" 'renpy-shift-left)
  1335. (define-key map "\C-c>" 'renpy-shift-right)
  1336. (define-key map "\C-c\C-k" 'renpy-mark-block)
  1337. (define-key map "\C-c\C-n" 'renpy-next-statement)
  1338. (define-key map "\C-c\C-p" 'renpy-previous-statement)
  1339. (define-key map "\C-c\C-u" 'renpy-beginning-of-block)
  1340. (define-key map "\C-c\C-f" 'renpy-describe-symbol)
  1341. (define-key map "\C-c\C-w" 'renpy-check)
  1342. (define-key map "\C-c\C-v" 'renpy-check) ; a la sgml-mode
  1343. (substitute-key-definition 'complete-symbol 'symbol-complete
  1344. map global-map)
  1345. (easy-menu-define renpy-menu map "Ren'Py Mode menu"
  1346. `("Ren'Py"
  1347. :help "Ren'Py-specific Features"
  1348. ["Shift region left" renpy-shift-left :active mark-active
  1349. :help "Shift by a single indentation step"]
  1350. ["Shift region right" renpy-shift-right :active mark-active
  1351. :help "Shift by a single indentation step"]
  1352. "-"
  1353. ["Mark block" renpy-mark-block
  1354. :help "Mark innermost block around point"]
  1355. ["Start of block" renpy-beginning-of-block
  1356. :help "Go to start of innermost definition around point"]
  1357. ["End of block" renpy-end-of-block
  1358. :help "Go to end of innermost definition around point"]
  1359. ))
  1360. map))
  1361. ;; Fixme: add toolbar stuff for useful things like symbol help, send
  1362. ;; region, at least. (Shouldn't be specific to Renpy, obviously.)
  1363. ;; eric has items including: (un)indent, (un)comment, restart script,
  1364. ;; run script, debug script; also things for profiling, unit testing.
  1365. (defvar renpy-mode-syntax-table
  1366. (let ((table (make-syntax-table)))
  1367. ;; Give punctuation syntax to ASCII that normally has symbol
  1368. ;; syntax or has word syntax and isn't a letter.
  1369. (let ((symbol (string-to-syntax "_"))
  1370. (sst (standard-syntax-table)))
  1371. (dotimes (i 128)
  1372. (unless (= i ?_)
  1373. (if (equal symbol (aref sst i))
  1374. (modify-syntax-entry i "." table)))))
  1375. (modify-syntax-entry ?$ "." table)
  1376. (modify-syntax-entry ?% "." table)
  1377. ;; exceptions
  1378. (modify-syntax-entry ?# "<" table)
  1379. (modify-syntax-entry ?\n ">" table)
  1380. (modify-syntax-entry ?' "\"" table)
  1381. (modify-syntax-entry ?` "$" table)
  1382. table))
  1383. ;;;; Utility stuff
  1384. (defsubst renpy-in-string/comment ()
  1385. "Return non-nil if point is in a Renpy literal (a comment or string)."
  1386. ;; We don't need to save the match data.
  1387. (nth 8 (syntax-ppss)))
  1388. (defconst renpy-space-backslash-table
  1389. (let ((table (copy-syntax-table renpy-mode-syntax-table)))
  1390. (modify-syntax-entry ?\\ " " table)
  1391. table)
  1392. "`renpy-mode-syntax-table' with backslash given whitespace syntax.")
  1393. (defun renpy-skip-comments/blanks (&optional backward)
  1394. "Skip comments and blank lines.
  1395. BACKWARD non-nil means go backwards, otherwise go forwards.
  1396. Backslash is treated as whitespace so that continued blank lines
  1397. are skipped. Doesn't move out of comments -- should be outside
  1398. or at end of line."
  1399. (let ((arg (if backward
  1400. ;; If we're in a comment (including on the trailing
  1401. ;; newline), forward-comment doesn't move backwards out
  1402. ;; of it. Don't set the syntax table round this bit!
  1403. (let ((syntax (syntax-ppss)))
  1404. (if (nth 4 syntax)
  1405. (goto-char (nth 8 syntax)))
  1406. (- (point-max)))
  1407. (point-max))))
  1408. (with-syntax-table renpy-space-backslash-table
  1409. (forward-comment arg))))
  1410. (defun renpy-backslash-continuation-line-p ()
  1411. "Non-nil if preceding line ends with backslash that is not in a comment."
  1412. (and (eq ?\\ (char-before (line-end-position 0)))
  1413. (not (syntax-ppss-context (syntax-ppss)))))
  1414. (defun renpy-continuation-line-p ()
  1415. "Return non-nil if current line continues a previous one.
  1416. The criteria are that the previous line ends in a backslash outside
  1417. comments and strings, or that point is within brackets/parens."
  1418. (or (renpy-backslash-continuation-line-p)
  1419. (let ((depth (syntax-ppss-depth
  1420. (save-excursion ; syntax-ppss with arg changes point
  1421. (syntax-ppss (line-beginning-position))))))
  1422. (or (> depth 0)
  1423. (if (< depth 0) ; Unbalanced brackets -- act locally
  1424. (save-excursion
  1425. (condition-case ()
  1426. (progn (backward-up-list) t) ; actually within brackets
  1427. (error nil))))))))
  1428. (defun renpy-comment-line-p ()
  1429. "Return non-nil if and only if current line has only a comment."
  1430. (save-excursion
  1431. (end-of-line)
  1432. (when (eq 'comment (syntax-ppss-context (syntax-ppss)))
  1433. (back-to-indentation)
  1434. (looking-at (rx (or (syntax comment-start) line-end))))))
  1435. (defun renpy-blank-line-p ()
  1436. "Return non-nil if and only if current line is blank."
  1437. (save-excursion
  1438. (beginning-of-line)
  1439. (looking-at "\\s-*$")))
  1440. (defun renpy-beginning-of-string ()
  1441. "Go to beginning of string around point.
  1442. Do nothing if not in string."
  1443. (let ((state (syntax-ppss)))
  1444. (when (eq 'string (syntax-ppss-context state))
  1445. (goto-char (nth 8 state)))))
  1446. (defun renpy-open-block-statement-p (&optional bos)
  1447. "Return non-nil if statement at point opens a block.
  1448. BOS non-nil means point is known to be at beginning of statement."
  1449. (save-excursion
  1450. (unless bos (renpy-beginning-of-statement))
  1451. ; A statement opens a block if it ends with :.
  1452. (renpy-end-of-statement)
  1453. (equal (char-before) 58)))
  1454. ;; (looking-at (rx (and (or "if" "else" "elif" "while" "for" "def"
  1455. ;; "class" "try" "except" "finally" "with")
  1456. ;; symbol-end)))))
  1457. (defun renpy-close-block-statement-p (&optional bos)
  1458. "Return non-nil if current line is a statement closing a block.
  1459. BOS non-nil means point is at beginning of statement.
  1460. The criteria are that the line isn't a comment or in string and
  1461. starts with keyword `raise', `break', `continue' or `pass'."
  1462. (save-excursion
  1463. (unless bos (renpy-beginning-of-statement))
  1464. (back-to-indentation)
  1465. (looking-at (rx (or "return" "raise" "break" "continue" "pass")
  1466. symbol-end))))
  1467. (defun renpy-outdent-p ()
  1468. "Return non-nil if current line should outdent a level."
  1469. (save-excursion
  1470. (back-to-indentation)
  1471. (and (looking-at (rx (and (or "else" "finally" "except" "elif")
  1472. symbol-end)))
  1473. (not (renpy-in-string/comment))
  1474. ;; Ensure there's a previous statement and move to it.
  1475. (zerop (renpy-previous-statement))
  1476. (not (renpy-close-block-statement-p t))
  1477. ;; Fixme: check this
  1478. (not (renpy-open-block-statement-p)))))
  1479. ;;;; Indentation.
  1480. (defcustom renpy-indent 4
  1481. "Number of columns for a unit of indentation in Renpy mode.
  1482. See also `\\[renpy-guess-indent]'"
  1483. :group 'renpy
  1484. :type 'integer)
  1485. (put 'renpy-indent 'safe-local-variable 'integerp)
  1486. (defcustom renpy-guess-indent nil
  1487. "Non-nil means Renpy mode guesses `renpy-indent' for the buffer."
  1488. :type 'boolean
  1489. :group 'renpy)
  1490. (defcustom renpy-indent-string-contents t
  1491. "Non-nil means indent contents of multi-line strings together.
  1492. This means indent them the same as the preceding non-blank line.
  1493. Otherwise preserve their indentation.
  1494. This only applies to `doc' strings, i.e. those that form statements;
  1495. the indentation is preserved in others."
  1496. :type '(choice (const :tag "Align with preceding" t)
  1497. (const :tag "Preserve indentation" nil))
  1498. :group 'renpy)
  1499. (defcustom renpy-honour-comment-indentation nil
  1500. "Non-nil means indent relative to preceding comment line.
  1501. Only do this for comments where the leading comment character is
  1502. followed by space. This doesn't apply to comment lines, which
  1503. are always indented in lines with preceding comments."
  1504. :type 'boolean
  1505. :group 'renpy)
  1506. (defcustom renpy-continuation-offset 4
  1507. "Number of columns of additional indentation for continuation lines.
  1508. Continuation lines follow a backslash-terminated line starting a
  1509. statement."
  1510. :group 'renpy
  1511. :type 'integer)
  1512. (defun renpy-guess-indent ()
  1513. "Guess step for indentation of current buffer.
  1514. Set `renpy-indent' locally to the value guessed."
  1515. (interactive)
  1516. (save-excursion
  1517. (save-restriction
  1518. (widen)
  1519. (goto-char (point-min))
  1520. (let (done indent)
  1521. (while (and (not done) (not (eobp)))
  1522. (when (and (re-search-forward (rx ?: (0+ space)
  1523. (or (syntax comment-start)
  1524. line-end))
  1525. nil 'move)
  1526. (renpy-open-block-statement-p))
  1527. (save-excursion
  1528. (renpy-beginning-of-statement)
  1529. (let ((initial (current-indentation)))
  1530. (if (zerop (renpy-next-statement))
  1531. (setq indent (- (current-indentation) initial)))
  1532. (if (and indent (>= indent 2) (<= indent 8)) ; sanity check
  1533. (setq done t))))))
  1534. (when done
  1535. (when (/= indent (default-value 'renpy-indent))
  1536. (set (make-local-variable 'renpy-indent) indent)
  1537. (unless (= tab-width renpy-indent)
  1538. (setq indent-tabs-mode nil)))
  1539. indent)))))
  1540. ;; Alist of possible indentations and start of statement they would
  1541. ;; close. Used in indentation cycling (below).
  1542. (defvar renpy-indent-list nil
  1543. "Internal use.")
  1544. ;; Length of the above
  1545. (defvar renpy-indent-list-length nil
  1546. "Internal use.")
  1547. ;; Current index into the alist.
  1548. (defvar renpy-indent-index nil
  1549. "Internal use.")
  1550. (defun renpy-calculate-indentation ()
  1551. "Calculate Renpy indentation for line at point."
  1552. (setq renpy-indent-list nil
  1553. renpy-indent-list-length 1)
  1554. (save-excursion
  1555. (beginning-of-line)
  1556. (let ((syntax (syntax-ppss))
  1557. start)
  1558. (cond
  1559. ((eq 'string (syntax-ppss-context syntax)) ; multi-line string
  1560. (if (not renpy-indent-string-contents)
  1561. (current-indentation)
  1562. ;; Only respect `renpy-indent-string-contents' in doc
  1563. ;; strings (defined as those which form statements).
  1564. (if (not (save-excursion
  1565. (renpy-beginning-of-statement)
  1566. (looking-at (rx (or (syntax string-delimiter)
  1567. (syntax string-quote))))))
  1568. (current-indentation)
  1569. ;; Find indentation of preceding non-blank line within string.
  1570. (setq start (nth 8 syntax))
  1571. (forward-line -1)
  1572. (while (and (< start (point)) (looking-at "\\s-*$"))
  1573. (forward-line -1))
  1574. (current-indentation))))
  1575. ((renpy-continuation-line-p) ; after backslash, or bracketed
  1576. (let ((point (point))
  1577. (open-start (cadr syntax))
  1578. (backslash (renpy-backslash-continuation-line-p))
  1579. (colon (eq ?: (char-before (1- (line-beginning-position))))))
  1580. (if open-start
  1581. ;; Inside bracketed expression.
  1582. (progn
  1583. (goto-char (1+ open-start))
  1584. ;; Look for first item in list (preceding point) and
  1585. ;; align with it, if found.
  1586. (if (with-syntax-table renpy-space-backslash-table
  1587. (let ((parse-sexp-ignore-comments t))
  1588. (condition-case ()
  1589. (progn (forward-sexp)
  1590. (backward-sexp)
  1591. (< (point) point))
  1592. (error nil))))
  1593. ;; Extra level if we're backslash-continued or
  1594. ;; following a key.
  1595. (if (or backslash colon)
  1596. (+ renpy-indent (current-column))
  1597. (current-column))
  1598. ;; Otherwise indent relative to statement start, one
  1599. ;; level per bracketing level.
  1600. (goto-char (1+ open-start))
  1601. (renpy-beginning-of-statement)
  1602. (+ (current-indentation) (* (car syntax) renpy-indent))))
  1603. ;; Otherwise backslash-continued.
  1604. (forward-line -1)
  1605. (if (renpy-continuation-line-p)
  1606. ;; We're past first continuation line. Align with
  1607. ;; previous line.
  1608. (current-indentation)
  1609. ;; First continuation line. Indent one step, with an
  1610. ;; extra one if statement opens a block.
  1611. (renpy-beginning-of-statement)
  1612. (+ (current-indentation) renpy-continuation-offset
  1613. (if (renpy-open-block-statement-p t)
  1614. renpy-indent
  1615. 0))))))
  1616. ((bobp) 0)
  1617. ;; Fixme: Like renpy-mode.el; not convinced by this.
  1618. ((looking-at (rx (0+ space) (syntax comment-start)
  1619. (not (any " \t\n")))) ; non-indentable comment
  1620. (current-indentation))
  1621. ((and renpy-honour-comment-indentation
  1622. ;; Back over whitespace, newlines, non-indentable comments.
  1623. (catch 'done
  1624. (while (cond ((bobp) nil)
  1625. ((not (forward-comment -1))
  1626. nil) ; not at comment start
  1627. ;; Now at start of comment -- trailing one?
  1628. ((/= (current-column) (current-indentation))
  1629. nil)
  1630. ;; Indentable comment, like renpy-mode.el?
  1631. ((and (looking-at (rx (syntax comment-start)
  1632. (or space line-end)))
  1633. (/= 0 (current-column)))
  1634. (throw 'done (current-column)))
  1635. ;; Else skip it (loop).
  1636. (t))))))
  1637. (t
  1638. (renpy-indentation-levels)
  1639. ;; Prefer to indent comments with an immediately-following
  1640. ;; statement, e.g.
  1641. ;; ...
  1642. ;; # ...
  1643. ;; def ...
  1644. (when (and (> renpy-indent-list-length 1)
  1645. (renpy-comment-line-p))
  1646. (forward-line)
  1647. (unless (renpy-comment-line-p)
  1648. (let ((elt (assq (current-indentation) renpy-indent-list)))
  1649. (setq renpy-indent-list
  1650. (nconc (delete elt renpy-indent-list)
  1651. (list elt))))))
  1652. (caar (last renpy-indent-list)))))))
  1653. ;;;; Cycling through the possible indentations with successive TABs.
  1654. ;; These don't need to be buffer-local since they're only relevant
  1655. ;; during a cycle.
  1656. (defun renpy-initial-text ()
  1657. "Text of line following indentation and ignoring any trailing comment."
  1658. (save-excursion
  1659. (buffer-substring (progn
  1660. (back-to-indentation)
  1661. (point))
  1662. (progn
  1663. (end-of-line)
  1664. (forward-comment -1)
  1665. (point)))))
  1666. (defconst renpy-block-pairs
  1667. '(("else" "if" "elif" "while" "for" "try" "except")
  1668. ("elif" "if" "elif")
  1669. ("except" "try" "except")
  1670. ("finally" "try" "except"))
  1671. "Alist of keyword matches.
  1672. The car of an element is a keyword introducing a statement which
  1673. can close a block opened by a keyword in the cdr.")
  1674. (defun renpy-first-word ()
  1675. "Return first word (actually symbol) on the line."
  1676. (save-excursion
  1677. (back-to-indentation)
  1678. (current-word t)))
  1679. (defun renpy-indentation-levels ()
  1680. "Return a list of possible indentations for this line.
  1681. It is assumed not to be a continuation line or in a multi-line string.
  1682. Includes the default indentation and those which would close all
  1683. enclosing blocks. Elements of the list are actually pairs:
  1684. \(INDENTATION . TEXT), where TEXT is the initial text of the
  1685. corresponding block opening (or nil)."
  1686. (save-excursion
  1687. (let ((initial "")
  1688. levels indent)
  1689. ;; Only one possibility immediately following a block open
  1690. ;; statement, assuming it doesn't have a `suite' on the same line.
  1691. (cond
  1692. ((save-excursion (and (renpy-previous-statement)
  1693. (renpy-open-block-statement-p t)
  1694. (setq indent (current-indentation))
  1695. ;; Check we don't have something like:
  1696. ;; if ...: ...
  1697. (if (progn (renpy-end-of-statement)
  1698. (renpy-skip-comments/blanks t)
  1699. (eq ?: (char-before)))
  1700. (setq indent (+ renpy-indent indent)))))
  1701. (push (cons indent initial) levels))
  1702. ;; Only one possibility for comment line immediately following
  1703. ;; another.
  1704. ((save-excursion
  1705. (when (renpy-comment-line-p)
  1706. (forward-line -1)
  1707. (if (renpy-comment-line-p)
  1708. (push (cons (current-indentation) initial) levels)))))
  1709. ;; Fixme: Maybe have a case here which indents (only) first
  1710. ;; line after a lambda.
  1711. (t
  1712. (let ((start (car (assoc (renpy-first-word) renpy-block-pairs))))
  1713. (renpy-previous-statement)
  1714. ;; Is this a valid indentation for the line of interest?
  1715. (unless (or (if start ; potentially only outdentable
  1716. ;; Check for things like:
  1717. ;; if ...: ...
  1718. ;; else ...:
  1719. ;; where the second line need not be outdented.
  1720. (not (member (renpy-first-word)
  1721. (cdr (assoc start
  1722. renpy-block-pairs)))))
  1723. ;; Not sensible to indent to the same level as
  1724. ;; previous `return' &c.
  1725. (renpy-close-block-statement-p))
  1726. (push (cons (current-indentation) (renpy-initial-text))
  1727. levels))
  1728. (while (renpy-beginning-of-block)
  1729. (when (or (not start)
  1730. (member (renpy-first-word)
  1731. (cdr (assoc start renpy-block-pairs))))
  1732. (push (cons (current-indentation) (renpy-initial-text))
  1733. levels))))))
  1734. (prog1 (or levels (setq levels '((0 . ""))))
  1735. (setq renpy-indent-list levels
  1736. renpy-indent-list-length (length renpy-indent-list))))))
  1737. ;; This is basically what `renpy-indent-line' would be if we didn't
  1738. ;; do the cycling.
  1739. (defun renpy-indent-line-1 (&optional leave)
  1740. "Subroutine of `renpy-indent-line'.
  1741. Does non-repeated indentation. LEAVE non-nil means leave
  1742. indentation if it is valid, i.e. one of the positions returned by
  1743. `renpy-calculate-indentation'."
  1744. (let ((target (renpy-calculate-indentation))
  1745. (pos (- (point-max) (point))))
  1746. (if (or (= target (current-indentation))
  1747. ;; Maybe keep a valid indentation.
  1748. (and leave renpy-indent-list
  1749. (assq (current-indentation) renpy-indent-list)))
  1750. (if (< (current-column) (current-indentation))
  1751. (back-to-indentation))
  1752. (beginning-of-line)
  1753. (delete-horizontal-space)
  1754. (indent-to target)
  1755. (if (> (- (point-max) pos) (point))
  1756. (goto-char (- (point-max) pos))))))
  1757. (defun renpy-indent-line-2 ()
  1758. "Indent current line as Renpy code.
  1759. When invoked via `indent-for-tab-command', cycle through possible
  1760. indentations for current line. The cycle is broken by a command
  1761. different from `indent-for-tab-command', i.e. successive TABs do
  1762. the cycling."
  1763. (interactive)
  1764. (if (and (eq this-command 'indent-for-tab-command)
  1765. (eq last-command this-command))
  1766. (if (= 1 renpy-indent-list-length)
  1767. (message "Sole indentation")
  1768. (progn (setq renpy-indent-index
  1769. (% (1+ renpy-indent-index) renpy-indent-list-length))
  1770. (beginning-of-line)
  1771. (delete-horizontal-space)
  1772. (indent-to (car (nth renpy-indent-index renpy-indent-list)))
  1773. (if (renpy-block-end-p)
  1774. (let ((text (cdr (nth renpy-indent-index
  1775. renpy-indent-list))))
  1776. (if text
  1777. (message "Closes: %s" text))))))
  1778. (renpy-indent-line-1)
  1779. (setq renpy-indent-index (1- renpy-indent-list-length))))
  1780. (defun renpy-indent-region (start end)
  1781. "`indent-region-function' for Renpy.
  1782. Leaves validly-indented lines alone, i.e. doesn't indent to
  1783. another valid position."
  1784. (save-excursion
  1785. (goto-char end)
  1786. (setq end (point-marker))
  1787. (goto-char start)
  1788. (or (bolp) (forward-line 1))
  1789. (while (< (point) end)
  1790. (or (and (bolp) (eolp))
  1791. (renpy-indent-line-1 t))
  1792. (forward-line 1))
  1793. (move-marker end nil)))
  1794. (defun renpy-block-end-p ()
  1795. "Non-nil if this is a line in a statement closing a block,
  1796. or a blank line indented to where it would close a block."
  1797. (and (not (renpy-comment-line-p))
  1798. (or (renpy-close-block-statement-p t)
  1799. (< (current-indentation)
  1800. (save-excursion
  1801. (renpy-previous-statement)
  1802. (current-indentation))))))
  1803. ;;;; Movement.
  1804. ;; Fixme: Define {for,back}ward-sexp-function? Maybe skip units like
  1805. ;; block, statement, depending on context.
  1806. (defun renpy-beginning-of-defun ()
  1807. "`beginning-of-defun-function' for Renpy.
  1808. Finds beginning of innermost nested class or method definition.
  1809. Returns the name of the definition found at the end, or nil if
  1810. reached start of buffer."
  1811. (let ((ci (current-indentation))
  1812. (def-re (rx line-start (0+ space) (or "def" "class") (1+ space)
  1813. (group (1+ (or word (syntax symbol))))))
  1814. found lep) ;; def-line
  1815. (if (renpy-comment-line-p)
  1816. (setq ci most-positive-fixnum))
  1817. (while (and (not (bobp)) (not found))
  1818. ;; Treat bol at beginning of function as outside function so
  1819. ;; that successive C-M-a makes progress backwards.
  1820. ;;(setq def-line (looking-at def-re))
  1821. (unless (bolp) (end-of-line))
  1822. (setq lep (line-end-position))
  1823. (if (and (re-search-backward def-re nil 'move)
  1824. ;; Must be less indented or matching top level, or
  1825. ;; equally indented if we started on a definition line.
  1826. (let ((in (current-indentation)))
  1827. (or (and (zerop ci) (zerop in))
  1828. (= lep (line-end-position)) ; on initial line
  1829. ;; Not sure why it was like this -- fails in case of
  1830. ;; last internal function followed by first
  1831. ;; non-def statement of the main body.
  1832. ;; (and def-line (= in ci))
  1833. (= in ci)
  1834. (< in ci)))
  1835. (not (renpy-in-string/comment)))
  1836. (setq found t)))
  1837. found))
  1838. (defun renpy-end-of-defun ()
  1839. "`end-of-defun-function' for Renpy.
  1840. Finds end of innermost nested class or method definition."
  1841. (let ((orig (point))
  1842. (pattern (rx line-start (0+ space) (or "def" "class") space)))
  1843. ;; Go to start of current block and check whether it's at top
  1844. ;; level. If it is, and not a block start, look forward for
  1845. ;; definition statement.
  1846. (when (renpy-comment-line-p)
  1847. (end-of-line)
  1848. (forward-comment most-positive-fixnum))
  1849. (if (not (renpy-open-block-statement-p))
  1850. (renpy-beginning-of-block))
  1851. (if (zerop (current-indentation))
  1852. (unless (renpy-open-block-statement-p)
  1853. (while (and (re-search-forward pattern nil 'move)
  1854. (renpy-in-string/comment))) ; just loop
  1855. (unless (eobp)
  1856. (beginning-of-line)))
  1857. ;; Don't move before top-level statement that would end defun.
  1858. (end-of-line)
  1859. (renpy-beginning-of-defun))
  1860. ;; If we got to the start of buffer, look forward for
  1861. ;; definition statement.
  1862. (if (and (bobp) (not (looking-at "def\\|class")))
  1863. (while (and (not (eobp))
  1864. (re-search-forward pattern nil 'move)
  1865. (renpy-in-string/comment)))) ; just loop
  1866. ;; We're at a definition statement (or end-of-buffer).
  1867. (unless (eobp)
  1868. (renpy-end-of-block)
  1869. ;; Count trailing space in defun (but not trailing comments).
  1870. (skip-syntax-forward " >")
  1871. (unless (eobp) ; e.g. missing final newline
  1872. (beginning-of-line)))
  1873. ;; Catch pathological cases like this, where the beginning-of-defun
  1874. ;; skips to a definition we're not in:
  1875. ;; if ...:
  1876. ;; ...
  1877. ;; else:
  1878. ;; ... # point here
  1879. ;; ...
  1880. ;; def ...
  1881. (if (< (point) orig)
  1882. (goto-char (point-max)))))
  1883. (defun renpy-beginning-of-statement ()
  1884. "Go to start of current statement.
  1885. Accounts for continuation lines, multi-line strings, and
  1886. multi-line bracketed expressions."
  1887. (beginning-of-line)
  1888. (renpy-beginning-of-string)
  1889. (let (point)
  1890. (while (and (renpy-continuation-line-p)
  1891. (if point
  1892. (< (point) point)
  1893. t))
  1894. (beginning-of-line)
  1895. (if (renpy-backslash-continuation-line-p)
  1896. (progn
  1897. (forward-line -1)
  1898. (while (renpy-backslash-continuation-line-p)
  1899. (forward-line -1)))
  1900. (renpy-beginning-of-string)
  1901. (renpy-skip-out))
  1902. (setq point (point))))
  1903. (back-to-indentation))
  1904. (defun renpy-skip-out (&optional forward syntax)
  1905. "Skip out of any nested brackets.
  1906. Skip forward if FORWARD is non-nil, else backward.
  1907. If SYNTAX is non-nil it is the state returned by `syntax-ppss' at point.
  1908. Return non-nil if and only if skipping was done."
  1909. (let ((depth (syntax-ppss-depth (or syntax (syntax-ppss))))
  1910. (forward (if forward -1 1)))
  1911. (unless (zerop depth)
  1912. (if (> depth 0)
  1913. ;; Skip forward out of nested brackets.
  1914. (condition-case () ; beware invalid syntax
  1915. (progn (backward-up-list (* forward depth)) t)
  1916. (error nil))
  1917. ;; Invalid syntax (too many closed brackets).
  1918. ;; Skip out of as many as possible.
  1919. (let (done)
  1920. (while (condition-case ()
  1921. (progn (backward-up-list forward)
  1922. (setq done t))
  1923. (error nil)))
  1924. done)))))
  1925. (defun renpy-end-of-statement ()
  1926. "Go to the end of the current statement and return point.
  1927. Usually this is the start of the next line, but if this is a
  1928. multi-line statement we need to skip over the continuation lines.
  1929. On a comment line, go to end of line."
  1930. (end-of-line)
  1931. (while (let (comment)
  1932. ;; Move past any enclosing strings and sexps, or stop if
  1933. ;; we're in a comment.
  1934. (while (let ((s (syntax-ppss)))
  1935. (cond ((eq 'comment (syntax-ppss-context s))
  1936. (setq comment t)
  1937. nil)
  1938. ((eq 'string (syntax-ppss-context s))
  1939. ;; Go to start of string and skip it.
  1940. (let ((pos (point)))
  1941. (goto-char (nth 8 s))
  1942. (condition-case () ; beware invalid syntax
  1943. (progn (forward-sexp) t)
  1944. ;; If there's a mismatched string, make sure
  1945. ;; we still overall move *forward*.
  1946. (error (goto-char pos) (end-of-line)))))
  1947. ((renpy-skip-out t s))))
  1948. (end-of-line))
  1949. (unless comment
  1950. (eq ?\\ (char-before)))) ; Line continued?
  1951. (end-of-line 2)) ; Try next line.
  1952. (point))
  1953. (defun renpy-previous-statement (&optional count)
  1954. "Go to start of previous statement.
  1955. With argument COUNT, do it COUNT times. Stop at beginning of buffer.
  1956. Return count of statements left to move."
  1957. (interactive "p")
  1958. (unless count (setq count 1))
  1959. (if (< count 0)
  1960. (renpy-next-statement (- count))
  1961. (renpy-beginning-of-statement)
  1962. (while (and (> count 0) (not (bobp)))
  1963. (renpy-skip-comments/blanks t)
  1964. (renpy-beginning-of-statement)
  1965. (unless (bobp) (setq count (1- count))))
  1966. count))
  1967. (defun renpy-next-statement (&optional count)
  1968. "Go to start of next statement.
  1969. With argument COUNT, do it COUNT times. Stop at end of buffer.
  1970. Return count of statements left to move."
  1971. (interactive "p")
  1972. (unless count (setq count 1))
  1973. (if (< count 0)
  1974. (renpy-previous-statement (- count))
  1975. (beginning-of-line)
  1976. (let (bogus)
  1977. (while (and (> count 0) (not (eobp)) (not bogus))
  1978. (renpy-end-of-statement)
  1979. (renpy-skip-comments/blanks)
  1980. (if (eq 'string (syntax-ppss-context (syntax-ppss)))
  1981. (setq bogus t)
  1982. (unless (eobp)
  1983. (setq count (1- count))))))
  1984. count))
  1985. (defun renpy-beginning-of-block (&optional arg)
  1986. "Go to start of current block.
  1987. With numeric arg, do it that many times. If ARG is negative, call
  1988. `renpy-end-of-block' instead.
  1989. If point is on the first line of a block, use its outer block.
  1990. If current statement is in column zero, don't move and return nil.
  1991. Otherwise return non-nil."
  1992. (interactive "p")
  1993. (unless arg (setq arg 1))
  1994. (cond
  1995. ((zerop arg))
  1996. ((< arg 0) (renpy-end-of-block (- arg)))
  1997. (t
  1998. (let ((point (point)))
  1999. (if (or (renpy-comment-line-p)
  2000. (renpy-blank-line-p))
  2001. (renpy-skip-comments/blanks t))
  2002. (renpy-beginning-of-statement)
  2003. (let ((ci (current-indentation)))
  2004. (if (zerop ci)
  2005. (not (goto-char point)) ; return nil
  2006. ;; Look upwards for less indented statement.
  2007. (if (catch 'done
  2008. ;;; This is slower than the below.
  2009. ;;; (while (zerop (renpy-previous-statement))
  2010. ;;; (when (and (< (current-indentation) ci)
  2011. ;;; (renpy-open-block-statement-p t))
  2012. ;;; (beginning-of-line)
  2013. ;;; (throw 'done t)))
  2014. (while (and (zerop (forward-line -1)))
  2015. (when (and (< (current-indentation) ci)
  2016. (not (renpy-comment-line-p))
  2017. ;; Move to beginning to save effort in case
  2018. ;; this is in string.
  2019. (progn (renpy-beginning-of-statement) t)
  2020. (renpy-open-block-statement-p t))
  2021. (beginning-of-line)
  2022. (throw 'done t)))
  2023. (not (goto-char point))) ; Failed -- return nil
  2024. (renpy-beginning-of-block (1- arg)))))))))
  2025. (defun renpy-end-of-block (&optional arg)
  2026. "Go to end of current block.
  2027. With numeric arg, do it that many times. If ARG is negative,
  2028. call `renpy-beginning-of-block' instead.
  2029. If current statement is in column zero and doesn't open a block,
  2030. don't move and return nil. Otherwise return t."
  2031. (interactive "p")
  2032. (unless arg (setq arg 1))
  2033. (if (< arg 0)
  2034. (renpy-beginning-of-block (- arg))
  2035. (while (and (> arg 0)
  2036. (let* ((point (point))
  2037. (_ (if (renpy-comment-line-p)
  2038. (renpy-skip-comments/blanks t)))
  2039. (ci (current-indentation))
  2040. (open (renpy-open-block-statement-p)))
  2041. (if (and (zerop ci) (not open))
  2042. (not (goto-char point))
  2043. (catch 'done
  2044. (while (zerop (renpy-next-statement))
  2045. (when (or (and open (<= (current-indentation) ci))
  2046. (< (current-indentation) ci))
  2047. (renpy-skip-comments/blanks t)
  2048. (beginning-of-line 2)
  2049. (throw 'done t)))))))
  2050. (setq arg (1- arg)))
  2051. (zerop arg)))
  2052. (defvar renpy-which-func-length-limit 40
  2053. "Non-strict length limit for `renpy-which-func' output.")
  2054. (defun renpy-which-func ()
  2055. (let ((function-name (renpy-current-defun renpy-which-func-length-limit)))
  2056. (set-text-properties 0 (length function-name) nil function-name)
  2057. function-name))
  2058. ;;;; Imenu.
  2059. ;; For possibily speeding this up, here's the top of the ELP profile
  2060. ;; for rescanning pydoc.py (2.2k lines, 90kb):
  2061. ;; Function Name Call Count Elapsed Time Average Time
  2062. ;; ==================================== ========== ============= ============
  2063. ;; renpy-imenu-create-index 156 2.430906 0.0155827307
  2064. ;; renpy-end-of-defun 155 1.2718260000 0.0082053290
  2065. ;; renpy-end-of-block 155 1.1898689999 0.0076765741
  2066. ;; renpy-next-statement 2970 1.024717 0.0003450225
  2067. ;; renpy-end-of-statement 2970 0.4332190000 0.0001458649
  2068. ;; renpy-beginning-of-defun 265 0.0918479999 0.0003465962
  2069. ;; renpy-skip-comments/blanks 3125 0.0753319999 2.410...e-05
  2070. (defvar renpy-recursing)
  2071. ;;;; `Electric' commands.
  2072. (defun renpy-electric-colon (arg)
  2073. "Insert a colon and maybe outdent the line if it is a statement like `else'.
  2074. With numeric ARG, just insert that many colons. With \\[universal-argument],
  2075. just insert a single colon."
  2076. (interactive "*P")
  2077. (self-insert-command (if (not (integerp arg)) 1 arg))
  2078. (and (not arg)
  2079. (eolp)
  2080. (renpy-outdent-p)
  2081. (not (renpy-in-string/comment))
  2082. (> (current-indentation) (renpy-calculate-indentation))
  2083. (renpy-indent-line))) ; OK, do it
  2084. (put 'renpy-electric-colon 'delete-selection t)
  2085. (defun renpy-backspace (arg)
  2086. "Maybe delete a level of indentation on the current line.
  2087. Do so if point is at the end of the line's indentation outside
  2088. strings and comments.
  2089. Otherwise just call `backward-delete-char-untabify'.
  2090. Repeat ARG times."
  2091. (interactive "*p")
  2092. (if (or (/= (current-indentation) (current-column))
  2093. (bolp)
  2094. (renpy-continuation-line-p)
  2095. (renpy-in-string/comment))
  2096. (backward-delete-char-untabify arg)
  2097. ;; Look for the largest valid indentation which is smaller than
  2098. ;; the current indentation.
  2099. (let ((indent 0)
  2100. (ci (current-indentation))
  2101. (indents (renpy-indentation-levels))
  2102. initial)
  2103. (dolist (x indents)
  2104. (if (< (car x) ci)
  2105. (setq indent (max indent (car x)))))
  2106. (setq initial (cdr (assq indent indents)))
  2107. (if (> (length initial) 0)
  2108. (message "Closes %s" initial))
  2109. (delete-horizontal-space)
  2110. (indent-to indent))))
  2111. (put 'renpy-backspace 'delete-selection 'supersede)
  2112. (defun renpy-fill-paragraph-2 (&optional justify)
  2113. "`fill-paragraph-function' handling multi-line strings and possibly comments.
  2114. If any of the current line is in or at the end of a multi-line string,
  2115. fill the string or the paragraph of it that point is in, preserving
  2116. the string's indentation."
  2117. (interactive "P")
  2118. (or (fill-comment-paragraph justify)
  2119. (save-excursion
  2120. (end-of-line)
  2121. (let* ((syntax (syntax-ppss))
  2122. (orig (point))
  2123. start end)
  2124. (cond ((nth 4 syntax) ; comment. fixme: loses with trailing one
  2125. (let (fill-paragraph-function)
  2126. (fill-paragraph justify)))
  2127. ;; The `paragraph-start' and `paragraph-separate'
  2128. ;; variables don't allow us to delimit the last
  2129. ;; paragraph in a multi-line string properly, so narrow
  2130. ;; to the string and then fill around (the end of) the
  2131. ;; current line.
  2132. ((eq t (nth 3 syntax)) ; in fenced string
  2133. (goto-char (nth 8 syntax)) ; string start
  2134. (setq start (line-beginning-position))
  2135. (setq end (condition-case () ; for unbalanced quotes
  2136. (progn (forward-sexp)
  2137. (- (point) 3))
  2138. (error (point-max)))))
  2139. ((re-search-backward "\\s|\\s-*\\=" nil t) ; end of fenced string
  2140. (forward-char)
  2141. (setq end (point))
  2142. (condition-case ()
  2143. (progn (backward-sexp)
  2144. (setq start (line-beginning-position)))
  2145. (error nil))))
  2146. (when end
  2147. (save-restriction
  2148. (narrow-to-region start end)
  2149. (goto-char orig)
  2150. ;; Avoid losing leading and trailing newlines in doc
  2151. ;; strings written like:
  2152. ;; """
  2153. ;; ...
  2154. ;; """
  2155. (let ((paragraph-separate
  2156. ;; Note that the string could be part of an
  2157. ;; expression, so it can have preceding and
  2158. ;; trailing non-whitespace.
  2159. (concat
  2160. (rx (or
  2161. ;; Opening triple quote without following text.
  2162. (and (* nonl)
  2163. (group (syntax string-delimiter))
  2164. (repeat 2 (backref 1))
  2165. ;; Fixme: Not sure about including
  2166. ;; trailing whitespace.
  2167. (* (any " \t"))
  2168. eol)
  2169. ;; Closing trailing quote without preceding text.
  2170. (and (group (any ?\" ?')) (backref 2)
  2171. (syntax string-delimiter))))
  2172. "\\(?:" paragraph-separate "\\)"))
  2173. fill-paragraph-function)
  2174. (fill-paragraph justify))))))) t)
  2175. (defun renpy-shift-left (start end &optional count)
  2176. "Shift lines in region COUNT (the prefix arg) columns to the left.
  2177. COUNT defaults to `renpy-indent'. If region isn't active, just shift
  2178. current line. The region shifted includes the lines in which START and
  2179. END lie. It is an error if any lines in the region are indented less than
  2180. COUNT columns."
  2181. (interactive
  2182. (if mark-active
  2183. (list (region-beginning) (region-end) current-prefix-arg)
  2184. (list (line-beginning-position) (line-end-position) current-prefix-arg)))
  2185. (if count
  2186. (setq count (prefix-numeric-value count))
  2187. (setq count renpy-indent))
  2188. (when (> count 0)
  2189. (save-excursion
  2190. (goto-char start)
  2191. (while (< (point) end)
  2192. (if (and (< (current-indentation) count)
  2193. (not (looking-at "[ \t]*$")))
  2194. (error "Can't shift all lines enough"))
  2195. (forward-line))
  2196. (indent-rigidly start end (- count)))))
  2197. (add-to-list 'debug-ignored-errors "^Can't shift all lines enough")
  2198. (defun renpy-shift-right (start end &optional count)
  2199. "Shift lines in region COUNT (the prefix arg) columns to the right.
  2200. COUNT defaults to `renpy-indent'. If region isn't active, just shift
  2201. current line. The region shifted includes the lines in which START and
  2202. END lie."
  2203. (interactive
  2204. (if mark-active
  2205. (list (region-beginning) (region-end) current-prefix-arg)
  2206. (list (line-beginning-position) (line-end-position) current-prefix-arg)))
  2207. (if count
  2208. (setq count (prefix-numeric-value count))
  2209. (setq count renpy-indent))
  2210. (indent-rigidly start end count))
  2211. (defun renpy-outline-level ()
  2212. "`outline-level' function for Renpy mode.
  2213. The level is the number of `renpy-indent' steps of indentation
  2214. of current line."
  2215. (1+ (/ (current-indentation) renpy-indent)))
  2216. ;; Fixme: Consider top-level assignments, imports, &c.
  2217. (defun renpy-current-defun (&optional length-limit)
  2218. "`add-log-current-defun-function' for Renpy."
  2219. (save-excursion
  2220. ;; Move up the tree of nested `class' and `def' blocks until we
  2221. ;; get to zero indentation, accumulating the defined names.
  2222. (let ((accum)
  2223. (length -1))
  2224. (catch 'done
  2225. (while (or (null length-limit)
  2226. (null (cdr accum))
  2227. (< length length-limit))
  2228. (let ((started-from (point)))
  2229. (renpy-beginning-of-block)
  2230. (end-of-line)
  2231. (beginning-of-defun)
  2232. (when (= (point) started-from)
  2233. (throw 'done nil)))
  2234. (when (looking-at (rx (0+ space) (or "def" "class") (1+ space)
  2235. (group (1+ (or word (syntax symbol))))))
  2236. (push (match-string 1) accum)
  2237. (setq length (+ length 1 (length (car accum)))))
  2238. (when (= (current-indentation) 0)
  2239. (throw 'done nil))))
  2240. (when accum
  2241. (when (and length-limit (> length length-limit))
  2242. (setcar accum ".."))
  2243. (mapconcat 'identity accum ".")))))
  2244. (defun renpy-mark-block ()
  2245. "Mark the block around point.
  2246. Uses `renpy-beginning-of-block', `renpy-end-of-block'."
  2247. (interactive)
  2248. (push-mark)
  2249. (renpy-beginning-of-block)
  2250. (push-mark (point) nil t)
  2251. (renpy-end-of-block)
  2252. (exchange-point-and-mark))
  2253. ;;;; Modes.
  2254. ;; pdb tracking is alert once this file is loaded, but takes no action if
  2255. ;; `renpy-pdbtrack-do-tracking-p' is nil.
  2256. (defvar outline-heading-end-regexp)
  2257. (defvar eldoc-documentation-function)
  2258. (defvar renpy-mode-running) ;Dynamically scoped var.
  2259. ;;;###autoload
  2260. (define-derived-mode renpy-mode fundamental-mode "Ren'Py"
  2261. "Major mode for editing Renpy files.
  2262. Turns on Font Lock mode unconditionally since it is currently required
  2263. for correct parsing of the source.
  2264. See also `jython-mode', which is actually invoked if the buffer appears to
  2265. contain Jython code. See also `run-renpy' and associated Renpy mode
  2266. commands for running Renpy under Emacs.
  2267. The Emacs commands which work with `defun's, e.g. \\[beginning-of-defun], deal
  2268. with nested `def' and `class' blocks. They take the innermost one as
  2269. current without distinguishing method and class definitions. Used multiple
  2270. times, they move over others at the same indentation level until they reach
  2271. the end of definitions at that level, when they move up a level.
  2272. \\<renpy-mode-map>
  2273. Colon is electric: it outdents the line if appropriate, e.g. for
  2274. an else statement. \\[renpy-backspace] at the beginning of an indented statement
  2275. deletes a level of indentation to close the current block; otherwise it
  2276. deletes a character backward. TAB indents the current line relative to
  2277. the preceding code. Successive TABs, with no intervening command, cycle
  2278. through the possibilities for indentation on the basis of enclosing blocks.
  2279. \\[fill-paragraph] fills comments and multi-line strings appropriately, but has no
  2280. effect outside them.
  2281. Supports Eldoc mode (only for functions, using a Renpy process),
  2282. Info-Look and Imenu. In Outline minor mode, `class' and `def'
  2283. lines count as headers. Symbol completion is available in the
  2284. same way as in the Renpy shell using the `rlcompleter' module
  2285. and this is added to the Hippie Expand functions locally if
  2286. Hippie Expand mode is turned on. Completion of symbols of the
  2287. form x.y only works if the components are literal
  2288. module/attribute names, not variables. An abbrev table is set up
  2289. with skeleton expansions for compound statement templates.
  2290. \\{renpy-mode-map}"
  2291. :group 'renpy
  2292. (set (make-local-variable 'font-lock-defaults)
  2293. '(renpy-font-lock-keywords nil nil nil nil
  2294. (font-lock-syntactic-keywords
  2295. . renpy-font-lock-syntactic-keywords)
  2296. ;; This probably isn't worth it.
  2297. ;; (font-lock-syntactic-face-function
  2298. ;; . renpy-font-lock-syntactic-face-function)
  2299. ))
  2300. (set (make-local-variable 'parse-sexp-lookup-properties) t)
  2301. (set (make-local-variable 'parse-sexp-ignore-comments) t)
  2302. (set (make-local-variable 'comment-start) "# ")
  2303. (set (make-local-variable 'indent-line-function) #'renpy-indent-line)
  2304. (set (make-local-variable 'indent-region-function) #'renpy-indent-region)
  2305. (set (make-local-variable 'paragraph-start) "\\s-*$")
  2306. (set (make-local-variable 'fill-paragraph-function) 'renpy-fill-paragraph)
  2307. (set (make-local-variable 'require-final-newline) mode-require-final-newline)
  2308. (set (make-local-variable 'add-log-current-defun-function)
  2309. #'renpy-current-defun)
  2310. (set (make-local-variable 'outline-regexp)
  2311. (rx (* space) (or "class" "def" "elif" "else" "except" "finally"
  2312. "for" "if" "try" "while" "with")
  2313. symbol-end))
  2314. (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n")
  2315. (set (make-local-variable 'outline-level) #'renpy-outline-level)
  2316. (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil)
  2317. (make-local-variable 'renpy-saved-check-command)
  2318. (set (make-local-variable 'beginning-of-defun-function)
  2319. 'renpy-beginning-of-defun)
  2320. (set (make-local-variable 'end-of-defun-function) 'renpy-end-of-defun)
  2321. (add-hook 'which-func-functions 'renpy-which-func nil t)
  2322. (setq imenu-create-index-function 'imenu-default-create-index-function)
  2323. (setq imenu-generic-expression renpy-generic-imenu)
  2324. (set (make-local-variable 'eldoc-documentation-function)
  2325. #'renpy-eldoc-function)
  2326. (add-hook 'eldoc-mode-hook
  2327. (lambda () (run-renpy nil t)) ; need it running
  2328. nil t)
  2329. (set (make-local-variable 'symbol-completion-symbol-function)
  2330. 'renpy-partial-symbol)
  2331. (set (make-local-variable 'symbol-completion-completions-function)
  2332. 'renpy-symbol-completions)
  2333. ;; Fixme: should be in hideshow. This seems to be of limited use
  2334. ;; since it isn't (can't be) indentation-based. Also hide-level
  2335. ;; doesn't seem to work properly.
  2336. (add-to-list 'hs-special-modes-alist
  2337. `(renpy-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#"
  2338. ,(lambda (arg)
  2339. (renpy-end-of-defun)
  2340. (skip-chars-backward " \t\n"))
  2341. nil))
  2342. (set (make-local-variable 'skeleton-further-elements)
  2343. '((< '(backward-delete-char-untabify (min renpy-indent
  2344. (current-column))))
  2345. (^ '(- (1+ (current-indentation))))))
  2346. ;; Let's not mess with hippie-expand. Symbol-completion should rather be
  2347. ;; bound to another key, since it has different performance requirements.
  2348. ;; (if (featurep 'hippie-exp)
  2349. ;; (set (make-local-variable 'hippie-expand-try-functions-list)
  2350. ;; (cons 'symbol-completion-try-complete
  2351. ;; hippie-expand-try-functions-list)))
  2352. ;; Renpy defines TABs as being 8-char wide.
  2353. (set (make-local-variable 'tab-width) 8)
  2354. (unless font-lock-mode (font-lock-mode 1))
  2355. (when renpy-guess-indent (renpy-guess-indent))
  2356. ;; Let's make it harder for the user to shoot himself in the foot.
  2357. (unless (= tab-width renpy-indent)
  2358. (setq indent-tabs-mode nil))
  2359. )
  2360. ;; Not done automatically in Emacs 21 or 22.
  2361. (defcustom renpy-mode-hook nil
  2362. "Hook run when entering Renpy mode."
  2363. :group 'renpy
  2364. :type 'hook)
  2365. (custom-add-option 'renpy-mode-hook 'imenu-add-menubar-index)
  2366. (custom-add-option 'renpy-mode-hook
  2367. (lambda ()
  2368. "Turn off Indent Tabs mode."
  2369. (setq indent-tabs-mode nil)))
  2370. (custom-add-option 'renpy-mode-hook 'turn-on-eldoc-mode)
  2371. (custom-add-option 'renpy-mode-hook 'abbrev-mode)
  2372. (custom-add-option 'renpy-mode-hook 'renpy-setup-brm)
  2373. (defun renpy-in-literal ()
  2374. (syntax-ppss-context (syntax-ppss)))
  2375. ; Indents a paragraph. We also handle strings properly.
  2376. (defun renpy-fill-paragraph (&optional justify)
  2377. (interactive)
  2378. (if (eq (renpy-in-literal) 'string)
  2379. (let* ((string-indentation (renpy-string-indentation))
  2380. (fill-prefix (renpy-string-fill-prefix))
  2381. (fill-column (- fill-column string-indentation))
  2382. (fill-paragraph-function nil)
  2383. (indent-line-function nil)
  2384. )
  2385. (message "fill prefix: %S" fill-prefix)
  2386. (renpy-fill-string (renpy-string-start))
  2387. t
  2388. )
  2389. (renpy-fill-paragraph-2 justify)
  2390. )
  2391. )
  2392. ; Indents the current line.
  2393. (defun renpy-indent-line (&optional arg)
  2394. (interactive)
  2395. ; Let python-mode indent. (Always needed to keep python-mode sane.)
  2396. (renpy-indent-line-2)
  2397. ; Reindent strings if appropriate.
  2398. (save-excursion
  2399. (beginning-of-line)
  2400. (if (eq (renpy-in-literal) 'string)
  2401. (progn
  2402. (delete-horizontal-space)
  2403. (indent-to (renpy-string-indentation))
  2404. )
  2405. ))
  2406. (if ( < (current-column) (current-indentation) )
  2407. (back-to-indentation) )
  2408. )
  2409. ; Computes the start of the current string.
  2410. (defun renpy-string-start ()
  2411. (nth 8 (parse-partial-sexp (point-min) (point)))
  2412. )
  2413. ; Computes the amount of indentation needed to put the current string
  2414. ; in the right spot.
  2415. (defun renpy-string-indentation ()
  2416. (+ 1
  2417. (save-excursion
  2418. (- (goto-char (renpy-string-start))
  2419. (progn (beginning-of-line) (point)))
  2420. )
  2421. )
  2422. )
  2423. (provide 'renpy)