vera-mode.el 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475
  1. ;;; vera-mode.el --- major mode for editing Vera files
  2. ;; Copyright (C) 1997-2012 Free Software Foundation, Inc.
  3. ;; Author: Reto Zimmermann <reto@gnu.org>
  4. ;; Maintainer: Reto Zimmermann <reto@gnu.org>
  5. ;; Version: 2.28
  6. ;; Keywords: languages vera
  7. ;; WWW: http://www.iis.ee.ethz.ch/~zimmi/emacs/vera-mode.html
  8. ;; Yoni Rabkin <yoni@rabkins.net> contacted the maintainer of this
  9. ;; file on 18/3/2008, and the maintainer agreed that when a bug is
  10. ;; filed in the Emacs bug reporting system against this file, a copy
  11. ;; of the bug report be sent to the maintainer's email address.
  12. (defconst vera-version "2.18"
  13. "Vera Mode version number.")
  14. (defconst vera-time-stamp "2007-06-21"
  15. "Vera Mode time stamp for last update.")
  16. ;; This file is part of GNU Emacs.
  17. ;; GNU Emacs is free software: you can redistribute it and/or modify
  18. ;; it under the terms of the GNU General Public License as published by
  19. ;; the Free Software Foundation, either version 3 of the License, or
  20. ;; (at your option) any later version.
  21. ;; GNU Emacs is distributed in the hope that it will be useful,
  22. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. ;; GNU General Public License for more details.
  25. ;; You should have received a copy of the GNU General Public License
  26. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28. ;;; Commentary:
  29. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  30. ;; This package provides a simple Emacs major mode for editing Vera code.
  31. ;; It includes the following features:
  32. ;; - Syntax highlighting
  33. ;; - Indentation
  34. ;; - Word/keyword completion
  35. ;; - Block commenting
  36. ;; - Works under GNU Emacs and XEmacs
  37. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  38. ;; Documentation
  39. ;; See comment string of function `vera-mode' or type `C-h m' in Emacs.
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41. ;; Installation
  42. ;; Prerequisites: GNU Emacs 20.X/21.X, XEmacs 20.X/21.X
  43. ;; Put `vera-mode.el' into the `site-lisp' directory of your Emacs installation
  44. ;; or into an arbitrary directory that is added to the load path by the
  45. ;; following line in your Emacs start-up file (`.emacs'):
  46. ;; (setq load-path (cons (expand-file-name "<directory-name>") load-path))
  47. ;; If you already have the compiled `vera-mode.elc' file, put it in the same
  48. ;; directory. Otherwise, byte-compile the source file:
  49. ;; Emacs: M-x byte-compile-file -> vera-mode.el
  50. ;; Unix: emacs -batch -q -no-site-file -f batch-byte-compile vera-mode.el
  51. ;; Add the following lines to the `site-start.el' file in the `site-lisp'
  52. ;; directory of your Emacs installation or to your Emacs start-up file
  53. ;; (`.emacs'):
  54. ;; (autoload 'vera-mode "vera-mode" "Vera Mode" t)
  55. ;; (setq auto-mode-alist (cons '("\\.vr[hi]?\\'" . vera-mode) auto-mode-alist))
  56. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  57. ;;; Code:
  58. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  59. ;;; Variables
  60. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61. (defgroup vera nil
  62. "Customizations for Vera Mode."
  63. :prefix "vera-"
  64. :version "22.2"
  65. :group 'languages)
  66. (defcustom vera-basic-offset 2
  67. "*Amount of basic offset used for indentation."
  68. :type 'integer
  69. :group 'vera)
  70. (defcustom vera-underscore-is-part-of-word nil
  71. "*Non-nil means consider the underscore character `_' as part of word.
  72. An identifier containing underscores is then treated as a single word in
  73. select and move operations. All parts of an identifier separated by underscore
  74. are treated as single words otherwise."
  75. :type 'boolean
  76. :group 'vera)
  77. (defcustom vera-intelligent-tab t
  78. "*Non-nil means `TAB' does indentation, word completion and tab insertion.
  79. That is, if preceding character is part of a word then complete word,
  80. else if not at beginning of line then insert tab,
  81. else if last command was a `TAB' or `RET' then dedent one step,
  82. else indent current line.
  83. If nil, TAB always indents current line."
  84. :type 'boolean
  85. :group 'vera)
  86. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  87. ;;; Mode definitions
  88. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  89. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  90. ;; Key bindings
  91. (defvar vera-mode-map
  92. (let ((map (make-sparse-keymap)))
  93. ;; Backspace/delete key bindings.
  94. (define-key map [backspace] 'backward-delete-char-untabify)
  95. (unless (boundp 'delete-key-deletes-forward) ; XEmacs variable
  96. (define-key map [delete] 'delete-char)
  97. (define-key map [(meta delete)] 'kill-word))
  98. ;; Standard key bindings.
  99. (define-key map "\M-e" 'vera-forward-statement)
  100. (define-key map "\M-a" 'vera-backward-statement)
  101. (define-key map "\M-\C-e" 'vera-forward-same-indent)
  102. (define-key map "\M-\C-a" 'vera-backward-same-indent)
  103. ;; Mode specific key bindings.
  104. (define-key map "\C-c\t" 'indent-according-to-mode)
  105. (define-key map "\M-\C-\\" 'vera-indent-region)
  106. (define-key map "\C-c\C-c" 'vera-comment-uncomment-region)
  107. (define-key map "\C-c\C-f" 'vera-fontify-buffer)
  108. (define-key map "\C-c\C-v" 'vera-version)
  109. (define-key map "\M-\t" 'tab-to-tab-stop)
  110. ;; Electric key bindings.
  111. (define-key map "\t" 'vera-electric-tab)
  112. (define-key map "\r" 'vera-electric-return)
  113. (define-key map " " 'vera-electric-space)
  114. (define-key map "{" 'vera-electric-opening-brace)
  115. (define-key map "}" 'vera-electric-closing-brace)
  116. (define-key map "#" 'vera-electric-pound)
  117. (define-key map "*" 'vera-electric-star)
  118. (define-key map "/" 'vera-electric-slash)
  119. map)
  120. "Keymap for Vera Mode.")
  121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122. ;; Menu
  123. (require 'easymenu)
  124. (easy-menu-define vera-mode-menu vera-mode-map
  125. "Menu keymap for Vera Mode."
  126. '("Vera"
  127. ["(Un)Comment Out Region" vera-comment-uncomment-region (mark)]
  128. "--"
  129. ["Move Forward Statement" vera-forward-statement t]
  130. ["Move Backward Statement" vera-backward-statement t]
  131. ["Move Forward Same Indent" vera-forward-same-indent t]
  132. ["Move Backward Same Indent" vera-backward-same-indent t]
  133. "--"
  134. ["Indent Line" indent-according-to-mode t]
  135. ["Indent Region" vera-indent-region (mark)]
  136. ["Indent Buffer" vera-indent-buffer t]
  137. "--"
  138. ["Fontify Buffer" vera-fontify-buffer t]
  139. "--"
  140. ["Documentation" describe-mode]
  141. ["Version" vera-version t]
  142. ["Bug Report..." vera-submit-bug-report t]
  143. "--"
  144. ("Options"
  145. ["Indentation Offset..." (customize-option 'vera-basic-offset) t]
  146. ["Underscore is Part of Word"
  147. (customize-set-variable 'vera-underscore-is-part-of-word
  148. (not vera-underscore-is-part-of-word))
  149. :style toggle :selected vera-underscore-is-part-of-word]
  150. ["Use Intelligent Tab"
  151. (customize-set-variable 'vera-intelligent-tab
  152. (not vera-intelligent-tab))
  153. :style toggle :selected vera-intelligent-tab]
  154. "--"
  155. ["Save Options" customize-save-customized t]
  156. "--"
  157. ["Customize..." vera-customize t])))
  158. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  159. ;; Syntax table
  160. (defvar vera-mode-syntax-table
  161. (let ((syntax-table (make-syntax-table)))
  162. ;; punctuation
  163. (modify-syntax-entry ?\# "." syntax-table)
  164. (modify-syntax-entry ?\$ "." syntax-table)
  165. (modify-syntax-entry ?\% "." syntax-table)
  166. (modify-syntax-entry ?\& "." syntax-table)
  167. (modify-syntax-entry ?\' "." syntax-table)
  168. (modify-syntax-entry ?\* "." syntax-table)
  169. (modify-syntax-entry ?\- "." syntax-table)
  170. (modify-syntax-entry ?\+ "." syntax-table)
  171. (modify-syntax-entry ?\. "." syntax-table)
  172. (modify-syntax-entry ?\/ "." syntax-table)
  173. (modify-syntax-entry ?\: "." syntax-table)
  174. (modify-syntax-entry ?\; "." syntax-table)
  175. (modify-syntax-entry ?\< "." syntax-table)
  176. (modify-syntax-entry ?\= "." syntax-table)
  177. (modify-syntax-entry ?\> "." syntax-table)
  178. (modify-syntax-entry ?\\ "." syntax-table)
  179. (modify-syntax-entry ?\| "." syntax-table)
  180. ;; string
  181. (modify-syntax-entry ?\" "\"" syntax-table)
  182. ;; underscore
  183. (when vera-underscore-is-part-of-word
  184. (modify-syntax-entry ?\_ "w" syntax-table))
  185. ;; escape
  186. (modify-syntax-entry ?\\ "\\" syntax-table)
  187. ;; parentheses to match
  188. (modify-syntax-entry ?\( "()" syntax-table)
  189. (modify-syntax-entry ?\) ")(" syntax-table)
  190. (modify-syntax-entry ?\[ "(]" syntax-table)
  191. (modify-syntax-entry ?\] ")[" syntax-table)
  192. (modify-syntax-entry ?\{ "(}" syntax-table)
  193. (modify-syntax-entry ?\} "){" syntax-table)
  194. ;; comment
  195. (if (featurep 'xemacs)
  196. (modify-syntax-entry ?\/ ". 1456" syntax-table) ; XEmacs
  197. (modify-syntax-entry ?\/ ". 124b" syntax-table)) ; Emacs
  198. (modify-syntax-entry ?\* ". 23" syntax-table)
  199. ;; newline and CR
  200. (modify-syntax-entry ?\n "> b" syntax-table)
  201. (modify-syntax-entry ?\^M "> b" syntax-table)
  202. syntax-table)
  203. "Syntax table used in `vera-mode' buffers.")
  204. (defvar vera-mode-ext-syntax-table
  205. (let ((syntax-table (copy-syntax-table vera-mode-syntax-table)))
  206. ;; extended syntax table including '_' (for simpler search regexps)
  207. (modify-syntax-entry ?_ "w" syntax-table)
  208. syntax-table)
  209. "Syntax table extended by `_' used in `vera-mode' buffers.")
  210. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  211. ;; Mode definition
  212. ;;;###autoload (add-to-list 'auto-mode-alist (cons (purecopy "\\.vr[hi]?\\'") 'vera-mode))
  213. ;;;###autoload
  214. (define-derived-mode vera-mode prog-mode "Vera"
  215. "Major mode for editing Vera code.
  216. Usage:
  217. ------
  218. INDENTATION: Typing `TAB' at the beginning of a line indents the line.
  219. The amount of indentation is specified by option `vera-basic-offset'.
  220. Indentation can be done for an entire region \(`M-C-\\') or buffer (menu).
  221. `TAB' always indents the line if option `vera-intelligent-tab' is nil.
  222. WORD/COMMAND COMPLETION: Typing `TAB' after a (not completed) word looks
  223. for a word in the buffer or a Vera keyword that starts alike, inserts it
  224. and adjusts case. Re-typing `TAB' toggles through alternative word
  225. completions.
  226. Typing `TAB' after a non-word character inserts a tabulator stop (if not
  227. at the beginning of a line). `M-TAB' always inserts a tabulator stop.
  228. COMMENTS: `C-c C-c' comments out a region if not commented out, and
  229. uncomments a region if already commented out.
  230. HIGHLIGHTING (fontification): Vera keywords, predefined types and
  231. constants, function names, declaration names, directives, as well as
  232. comments and strings are highlighted using different colors.
  233. VERA VERSION: OpenVera 1.4 and Vera version 6.2.8.
  234. Maintenance:
  235. ------------
  236. To submit a bug report, use the corresponding menu entry within Vera Mode.
  237. Add a description of the problem and include a reproducible test case.
  238. Feel free to send questions and enhancement requests to <reto@gnu.org>.
  239. Official distribution is at
  240. URL `http://www.iis.ee.ethz.ch/~zimmi/emacs/vera-mode.html'
  241. The Vera Mode Maintainer
  242. Reto Zimmermann <reto@gnu.org>
  243. Key bindings:
  244. -------------
  245. \\{vera-mode-map}"
  246. ;; set local variables
  247. (require 'cc-cmds)
  248. (set (make-local-variable 'comment-start) "//")
  249. (set (make-local-variable 'comment-end) "")
  250. (set (make-local-variable 'comment-column) 40)
  251. (set (make-local-variable 'comment-start-skip) "/\\*+ *\\|//+ *")
  252. (set (make-local-variable 'comment-end-skip) " *\\*+/\\| *\n")
  253. (set (make-local-variable 'comment-indent-function) 'c-comment-indent)
  254. (set (make-local-variable 'paragraph-start) "^$")
  255. (set (make-local-variable 'paragraph-separate) paragraph-start)
  256. (set (make-local-variable 'indent-tabs-mode) nil)
  257. (set (make-local-variable 'indent-line-function) 'vera-indent-line)
  258. (set (make-local-variable 'parse-sexp-ignore-comments) t)
  259. ;; initialize font locking
  260. (set (make-local-variable 'font-lock-defaults)
  261. '(vera-font-lock-keywords nil nil ((?\_ . "w"))))
  262. ;; add menu (XEmacs)
  263. (easy-menu-add vera-mode-menu)
  264. ;; miscellaneous
  265. (message "Vera Mode %s. Type C-c C-h for documentation." vera-version))
  266. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  267. ;;; Vera definitions
  268. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  269. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  270. ;;; Keywords
  271. (defconst vera-keywords
  272. '(
  273. "after" "all" "any" "around" "assoc_index" "assoc_size" "async"
  274. "bad_state" "bad_trans" "before" "begin" "big_endian" "bind"
  275. "bin_activation" "bit_normal" "bit_reverse" "break" "breakpoint"
  276. "case" "casex" "casez" "class" "constraint" "continue"
  277. "coverage" "coverage_block" "coverage_def" "coverage_depth"
  278. "coverage_goal" "coverage_group" "coverage_option" "coverage_val"
  279. "cross_num_print_missing" "cross_auto_bin_max" "cov_comment"
  280. "default" "depth" "dist" "do"
  281. "else" "end" "enum" "exhaustive" "export" "extends" "extern"
  282. "for" "foreach" "fork" "function"
  283. "hdl_task" "hdl_node" "hide"
  284. "if" "illegal_self_transition" "illegal_state" "illegal_transition"
  285. "in" "interface" "invisible"
  286. "join"
  287. "little_endian" "local"
  288. "m_bad_state" "m_bad_trans" "m_state" "m_trans"
  289. "negedge" "new" "newcov" "non_rand" "none" "not" "null"
  290. "or" "ordered"
  291. "packed" "port" "posedge" "proceed" "prod" "prodget" "prodset"
  292. "program" "protected" "public"
  293. "rand" "randc" "randcase" "randseq" "repeat" "return" "rules"
  294. "sample" "sample_event" "shadow" "soft" "state" "static" "super"
  295. "task" "terminate" "this" "trans" "typedef"
  296. "unpacked"
  297. "var" "vca" "vector" "verilog_node" "verilog_task"
  298. "vhdl_node" "vhdl_task" "virtual" "virtuals" "visible" "void"
  299. "while" "wildcard" "with"
  300. )
  301. "List of Vera keywords.")
  302. (defconst vera-types
  303. '(
  304. "integer" "bit" "reg" "string" "bind_var" "event"
  305. "inout" "input" "output"
  306. "ASYNC" "CLOCK"
  307. "NDRIVE" "NHOLD" "NRX" "NRZ" "NR0" "NR1" "NSAMPLE"
  308. "PDRIVE" "PHOLD" "PRX" "PRZ" "PR0" "PR1" "PSAMPLE"
  309. )
  310. "List of Vera predefined types.")
  311. (defconst vera-q-values
  312. '(
  313. "gnr" "grx" "grz" "gr0" "gr1"
  314. "nr" "rx" "rz" "r0" "r1"
  315. "snr" "srx" "srz" "sr0" "sr1"
  316. )
  317. "List of Vera predefined VCA q_values.")
  318. (defconst vera-functions
  319. '(
  320. ;; system functions and tasks
  321. "alloc"
  322. "call_func" "call_task" "cast_assign" "close_conn" "cm_coverage"
  323. "cm_get_coverage" "cm_get_limit"
  324. "coverage_backup_database_file" "coverage_save_database"
  325. "delay"
  326. "error" "error_mode" "error_wait" "exit"
  327. "fclose" "feof" "ferror" "fflush" "flag" "fopen" "fprintf" "freadb"
  328. "freadb" "freadh" "freadstr"
  329. "get_bind" "get_bind_id" "get_conn_err" "get_cycle" "get_env"
  330. "get_memsize" "get_plus_arg" "get_systime" "get_time" "get_time_unit"
  331. "getstate"
  332. "initstate"
  333. "lock_file"
  334. "mailbox_get" "mailbox_put" "mailbox_receive" "mailbox_send"
  335. "make_client" "make_server"
  336. "os_command"
  337. "printf" "psprintf"
  338. "query" "query_str" "query_x"
  339. "rand48" "random" "region_enter" "region_exit" "rewind"
  340. "semaphore_get" "semaphore_put" "setstate" "signal_connect" "simwave_plot"
  341. "srandom" "sprintf" "sscanf" "stop" "suspend_thread" "sync"
  342. "timeout" "trace" "trigger"
  343. "unit_delay" "unlock_file" "up_connections"
  344. "urand48" "urandom" "urandom_range"
  345. "vera_bit_reverse" "vera_crc" "vera_pack" "vera_pack_big_endian"
  346. "vera_plot" "vera_report_profile" "vera_unpack" "vera_unpack_big_endian"
  347. "vsv_call_func" "vsv_call_task" "vsv_close_conn" "vsv_get_conn_err"
  348. "vsv_make_client" "vsv_make_server" "vsv_up_connections"
  349. "vsv_wait_for_done" "vsv_wait_for_input"
  350. "wait_child" "wait_var"
  351. ;; class methods
  352. "Configure" "DisableTrigger" "DoAction" "EnableCount" "EnableTrigger"
  353. "Event" "GetAssert" "GetCount" "GetFirstAssert" "GetName" "GetNextAssert"
  354. "Wait"
  355. "atobin" "atohex" "atoi" "atooct"
  356. "backref" "bittostr" "capacity" "compare" "constraint_mode"
  357. "delete"
  358. "empty"
  359. "find" "find_index" "first" "first_index"
  360. "get_at_least" "get_auto_bin" "get_cov_weight" "get_coverage_goal"
  361. "get_cross_bin_max" "get_status" "get_status_msg" "getc"
  362. "hash"
  363. "icompare" "insert" "inst_get_at_least" "inst_get_auto_bin_max"
  364. "inst_get_collect" "inst_get_cov_weight" "inst_get_coverage_goal"
  365. "inst_getcross_bin_max" "inst_query" "inst_set_at_least"
  366. "inst_set_auto_bin_max" "inst_set_bin_activation" "inst_set_collect"
  367. "inst_set_cov_weight" "inst_set_coverage_goal" "inst_set_cross_bin_max"
  368. "itoa"
  369. "last" "last_index" "len" "load"
  370. "match" "max" "max_index" "min" "min_index"
  371. "object_compare" "object_copy" "object_print"
  372. "pack" "pick_index" "pop_back" "pop_front" "post_pack" "post_randomize"
  373. "post_unpack" "postmatch" "pre_pack" "pre_randomize" "prematch" "push_back"
  374. "push_front" "putc"
  375. "query" "query_str"
  376. "rand_mode" "randomize" "reserve" "reverse" "rsort"
  377. "search" "set_at_least" "set_auto_bin_max" "set_bin_activation"
  378. "set_cov_weight" "set_coverage_goal" "set_cross_bin_max" "set_name" "size"
  379. "sort" "substr" "sum"
  380. "thismatch" "tolower" "toupper"
  381. "unique_index" "unpack"
  382. ;; empty methods
  383. "new" "object_compare"
  384. "post_boundary" "post_pack" "post_randomize" "post_unpack" "pre-randomize"
  385. "pre_boundary" "pre_pack" "pre_unpack"
  386. )
  387. "List of Vera predefined system functions, tasks and class methods.")
  388. (defconst vera-constants
  389. '(
  390. "ALL" "ANY"
  391. "BAD_STATE" "BAD_TRANS"
  392. "CALL" "CHECK" "CHGEDGE" "CLEAR" "COPY_NO_WAIT" "COPY_WAIT"
  393. "CROSS" "CROSS_TRANS"
  394. "DEBUG" "DELETE"
  395. "EC_ARRAYX" "EC_CODE_END" "EC_CONFLICT" "EC_EVNTIMOUT" "EC_EXPECT"
  396. "EC_FULLEXPECT" "EC_MBXTMOUT" "EC_NEXPECT" "EC_RETURN" "EC_RGNTMOUT"
  397. "EC_SCONFLICT" "EC_SEMTMOUT" "EC_SEXPECT" "EC_SFULLEXPECT" "EC_SNEXTPECT"
  398. "EC_USERSET" "EQ" "EVENT"
  399. "FAIL" "FIRST" "FORK"
  400. "GE" "GOAL" "GT" "HAND_SHAKE" "HI" "HIGH" "HNUM"
  401. "LE" "LIC_EXIT" "LIC_PRERR" "LIC_PRWARN" "LIC_WAIT" "LO" "LOAD" "LOW" "LT"
  402. "MAILBOX" "MAX_COM"
  403. "NAME" "NE" "NEGEDGE" "NEXT" "NO_OVERLAP" "NO_OVERLAP_STATE"
  404. "NO_OVERLAP_TRANS" "NO_VARS" "NO_WAIT" "NUM" "NUM_BIN" "NUM_DET"
  405. "OFF" "OK" "OK_LAST" "ON" "ONE_BLAST" "ONE_SHOT" "ORDER"
  406. "PAST_IT" "PERCENT" "POSEDGE" "PROGRAM"
  407. "RAWIN" "REGION" "REPORT"
  408. "SAMPLE" "SAVE" "SEMAPHORE" "SET" "SILENT" "STATE" "STR"
  409. "STR_ERR_OUT_OF_RANGE" "STR_ERR_REGEXP_SYNTAX" "SUM"
  410. "TRANS"
  411. "VERBOSE"
  412. "WAIT"
  413. "stderr" "stdin" "stdout"
  414. )
  415. "List of Vera predefined constants.")
  416. (defconst vera-rvm-types
  417. '(
  418. "VeraListIterator_VeraListIterator_rvm_log"
  419. "VeraListIterator_rvm_data" "VeraListIterator_rvm_log"
  420. "VeraListNodeVeraListIterator_rvm_log" "VeraListNodervm_data"
  421. "VeraListNodervm_log" "VeraList_VeraListIterator_rvm_log"
  422. "VeraList_rvm_data" "VeraList_rvm_log"
  423. "rvm_broadcast" "rvm_channel_class" "rvm_data" "rvm_data" "rvm_env"
  424. "rvm_log" "rvm_log_modifier" "rvm_log_msg" "rvm_log_msg" "rvm_log_msg_info"
  425. "rvm_log_watchpoint" "rvm_notify" "rvm_notify_event"
  426. "rvm_notify_event_config" "rvm_scheduler" "rvm_scheduler_election"
  427. "rvm_watchdog" "rvm_watchdog_port" "rvm_xactor" "rvm_xactor_callbacks"
  428. )
  429. "List of Vera-RVM keywords.")
  430. (defconst vera-rvm-functions
  431. '(
  432. "extern_rvm_atomic_gen" "extern_rvm_channel" "extern_rvm_scenario_gen"
  433. "rvm_OO_callback" "rvm_atomic_gen" "rvm_atomic_gen_callbacks_decl"
  434. "rvm_atomic_gen_decl" "rvm_atomic_scenario_decl" "rvm_channel"
  435. "rvm_channel_" "rvm_channel_decl" "rvm_command" "rvm_cycle" "rvm_debug"
  436. "rvm_error" "rvm_fatal" "rvm_note" "rvm_protocol" "rvm_report"
  437. "rvm_scenario_decl" "rvm_scenario_election_decl" "rvm_scenario_gen"
  438. "rvm_scenario_gen_callbacks_decl" "rvm_scenario_gen_decl"
  439. "rvm_trace" "rvm_transaction" "rvm_user" "rvm_verbose" "rvm_warning"
  440. )
  441. "List of Vera-RVM functions.")
  442. (defconst vera-rvm-constants
  443. '(
  444. "RVM_NUMERIC_VERSION_MACROS" "RVM_VERSION" "RVM_MINOR" "RVM_PATCH"
  445. "rvm_channel__SOURCE" "rvm_channel__SINK" "rvm_channel__NO_ACTIVE"
  446. "rvm_channel__ACT_PENDING" "rvm_channel__ACT_STARTED"
  447. "rvm_channel__ACT_COMPLETED" "rvm_channel__FULL" "rvm_channel__EMPTY"
  448. "rvm_channel__PUT" "rvm_channel__GOT" "rvm_channel__PEEKED"
  449. "rvm_channel__ACTIVATED" "rvm_channel__STARTED" "rvm_channel__COMPLETED"
  450. "rvm_channel__REMOVED" "rvm_channel__LOCKED" "rvm_channel__UNLOCKED"
  451. "rvm_data__EXECUTE" "rvm_data__STARTED" "rvm_data__ENDED"
  452. "rvm_env__CFG_GENED" "rvm_env__BUILT" "rvm_env__DUT_CFGED"
  453. "rvm_env__STARTED" "rvm_env__RESTARTED" "rvm_env__ENDED" "rvm_env__STOPPED"
  454. "rvm_env__CLEANED" "rvm_env__DONE" "rvm_log__DEFAULT" "rvm_log__UNCHANGED"
  455. "rvm_log__FAILURE_TYP" "rvm_log__NOTE_TYP" "rvm_log__DEBUG_TYP"
  456. "rvm_log__REPORT_TYP" "rvm_log__NOTIFY_TYP" "rvm_log__TIMING_TYP"
  457. "rvm_log__XHANDLING_TYP" "rvm_log__PROTOCOL_TYP" "rvm_log__TRANSACTION_TYP"
  458. "rvm_log__COMMAND_TYP" "rvm_log__CYCLE_TYP" "rvm_log__USER_TYP_0"
  459. "rvm_log__USER_TYP_1" "rvm_log__USER_TYP_2" "rvm_log__USER_TYP_3"
  460. "rvm_log__DEFAULT_TYP" "rvm_log__ALL_TYPES" "rvm_log__FATAL_SEV"
  461. "rvm_log__ERROR_SEV" "rvm_log__WARNING_SEV" "rvm_log__NORMAL_SEV"
  462. "rvm_log__TRACE_SEV" "rvm_log__DEBUG_SEV" "rvm_log__VERBOSE_SEV"
  463. "rvm_log__HIDDEN_SEV" "rvm_log__IGNORE_SEV" "rvm_log__DEFAULT_SEV"
  464. "rvm_log__ALL_SEVERITIES" "rvm_log__CONTINUE" "rvm_log__COUNT_AS_ERROR"
  465. "rvm_log__DEBUGGER" "rvm_log__DUMP" "rvm_log__STOP" "rvm_log__ABORT"
  466. "rvm_notify__ONE_SHOT_TRIGGER" "rvm_notify__ONE_BLAST_TRIGGER"
  467. "rvm_notify__HAND_SHAKE_TRIGGER" "rvm_notify__ON_OFF_TRIGGER"
  468. "rvm_xactor__XACTOR_IDLE" "rvm_xactor__XACTOR_BUSY"
  469. "rvm_xactor__XACTOR_STARTED" "rvm_xactor__XACTOR_STOPPED"
  470. "rvm_xactor__XACTOR_RESET" "rvm_xactor__XACTOR_SOFT_RST"
  471. "rvm_xactor__XACTOR_FIRM_RST" "rvm_xactor__XACTOR_HARD_RST"
  472. "rvm_xactor__XACTOR_PROTOCOL_RST" "rvm_broadcast__AFAP"
  473. "rvm_broadcast__ALAP" "rvm_watchdog__TIMEOUT"
  474. "rvm_env__DUT_RESET" "rvm_log__INTERNAL_TYP"
  475. "RVM_SCHEDULER_IS_XACTOR" "RVM_BROADCAST_IS_XACTOR"
  476. )
  477. "List of Vera-RVM predefined constants.")
  478. ;; `regexp-opt' undefined (`xemacs-devel' not installed)
  479. (unless (fboundp 'regexp-opt)
  480. (defun regexp-opt (strings &optional paren)
  481. (let ((open (if paren "\\(" "")) (close (if paren "\\)" "")))
  482. (concat open (mapconcat 'regexp-quote strings "\\|") close))))
  483. (defconst vera-keywords-regexp
  484. (concat "\\<\\(" (regexp-opt vera-keywords) "\\)\\>")
  485. "Regexp for Vera keywords.")
  486. (defconst vera-types-regexp
  487. (concat "\\<\\(" (regexp-opt vera-types) "\\)\\>")
  488. "Regexp for Vera predefined types.")
  489. (defconst vera-q-values-regexp
  490. (concat "\\<\\(" (regexp-opt vera-q-values) "\\)\\>")
  491. "Regexp for Vera predefined VCA q_values.")
  492. (defconst vera-functions-regexp
  493. (concat "\\<\\(" (regexp-opt vera-functions) "\\)\\>")
  494. "Regexp for Vera predefined system functions, tasks and class methods.")
  495. (defconst vera-constants-regexp
  496. (concat "\\<\\(" (regexp-opt vera-constants) "\\)\\>")
  497. "Regexp for Vera predefined constants.")
  498. (defconst vera-rvm-types-regexp
  499. (concat "\\<\\(" (regexp-opt vera-rvm-types) "\\)\\>")
  500. "Regexp for Vera-RVM keywords.")
  501. (defconst vera-rvm-functions-regexp
  502. (concat "\\<\\(" (regexp-opt vera-rvm-functions) "\\)\\>")
  503. "Regexp for Vera-RVM predefined system functions, tasks and class methods.")
  504. (defconst vera-rvm-constants-regexp
  505. (concat "\\<\\(" (regexp-opt vera-rvm-constants) "\\)\\>")
  506. "Regexp for Vera-RVM predefined constants.")
  507. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  508. ;;; Font locking
  509. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  510. ;; XEmacs compatibility
  511. (when (featurep 'xemacs)
  512. (require 'font-lock)
  513. (copy-face 'font-lock-reference-face 'font-lock-constant-face)
  514. (copy-face 'font-lock-preprocessor-face 'font-lock-builtin-face))
  515. (defun vera-font-lock-match-item (limit)
  516. "Match, and move over, any declaration item after point.
  517. Adapted from `font-lock-match-c-style-declaration-item-and-skip-to-next'."
  518. (condition-case nil
  519. (save-restriction
  520. (narrow-to-region (point-min) limit)
  521. ;; match item
  522. (when (looking-at "\\s-*\\(\\w+\\)")
  523. (save-match-data
  524. (goto-char (match-end 1))
  525. ;; move to next item
  526. (if (looking-at "\\(\\s-*\\(\\[[^]]*\\]\\s-*\\)?,\\)")
  527. (goto-char (match-end 1))
  528. (end-of-line) t))))
  529. (error t)))
  530. (defvar vera-font-lock-keywords
  531. (list
  532. ;; highlight keywords
  533. (list vera-keywords-regexp 1 'font-lock-keyword-face)
  534. ;; highlight types
  535. (list vera-types-regexp 1 'font-lock-type-face)
  536. ;; highlight RVM types
  537. (list vera-rvm-types-regexp 1 'font-lock-type-face)
  538. ;; highlight constants
  539. (list vera-constants-regexp 1 'font-lock-constant-face)
  540. ;; highlight RVM constants
  541. (list vera-rvm-constants-regexp 1 'font-lock-constant-face)
  542. ;; highlight q_values
  543. (list vera-q-values-regexp 1 'font-lock-constant-face)
  544. ;; highlight predefined functions, tasks and methods
  545. (list vera-functions-regexp 1 'vera-font-lock-function)
  546. ;; highlight predefined RVM functions
  547. (list vera-rvm-functions-regexp 1 'vera-font-lock-function)
  548. ;; highlight functions
  549. '("\\<\\(\\w+\\)\\s-*(" 1 font-lock-function-name-face)
  550. ;; highlight various declaration names
  551. '("^\\s-*\\(port\\|program\\|task\\)\\s-+\\(\\w+\\)\\>"
  552. 2 font-lock-function-name-face)
  553. '("^\\s-*bind\\s-+\\(\\w+\\)\\s-+\\(\\w+\\)\\>"
  554. (1 font-lock-function-name-face) (2 font-lock-function-name-face))
  555. ;; highlight interface declaration names
  556. '("^\\s-*\\(class\\|interface\\)\\s-+\\(\\w+\\)\\>"
  557. 2 vera-font-lock-interface)
  558. ;; highlight variable name definitions
  559. (list (concat "^\\s-*" vera-types-regexp "\\s-*\\(\\[[^]]+\\]\\s-+\\)?")
  560. '(vera-font-lock-match-item nil nil (1 font-lock-variable-name-face)))
  561. (list (concat "^\\s-*" vera-rvm-types-regexp "\\s-*\\(\\[[^]]+\\]\\s-+\\)?")
  562. '(vera-font-lock-match-item nil nil (1 font-lock-variable-name-face)))
  563. ;; highlight numbers
  564. '("\\([0-9]*'[bdoh][0-9a-fA-FxXzZ_]+\\)" 1 vera-font-lock-number)
  565. ;; highlight filenames in #include directives
  566. '("^#\\s-*include\\s-*\\(<[^>\"\n]*>?\\)"
  567. 1 font-lock-string-face)
  568. ;; highlight directives and directive names
  569. '("^#\\s-*\\(\\w+\\)\\>[ \t!]*\\(\\w+\\)?"
  570. (1 font-lock-builtin-face) (2 font-lock-variable-name-face nil t))
  571. ;; highlight `@', `$' and `#'
  572. '("\\([@$#]\\)" 1 font-lock-keyword-face)
  573. ;; highlight @ and # definitions
  574. '("@\\s-*\\(\\w*\\)\\(\\s-*,\\s-*\\(\\w+\\)\\)?\\>[^.]"
  575. (1 vera-font-lock-number) (3 vera-font-lock-number nil t))
  576. ;; highlight interface signal name
  577. '("\\(\\w+\\)\\.\\w+" 1 vera-font-lock-interface)
  578. )
  579. "Regular expressions to highlight in Vera Mode.")
  580. (defvar vera-font-lock-number 'vera-font-lock-number
  581. "Face name to use for @ definitions.")
  582. (defvar vera-font-lock-function 'vera-font-lock-function
  583. "Face name to use for predefined functions and tasks.")
  584. (defvar vera-font-lock-interface 'vera-font-lock-interface
  585. "Face name to use for interface names.")
  586. (defface vera-font-lock-number
  587. '((((class color) (background light)) (:foreground "Gold4"))
  588. (((class color) (background dark)) (:foreground "BurlyWood1"))
  589. (t (:italic t :bold t)))
  590. "Font lock mode face used to highlight @ definitions."
  591. :group 'font-lock-highlighting-faces)
  592. (defface vera-font-lock-function
  593. '((((class color) (background light)) (:foreground "DarkCyan"))
  594. (((class color) (background dark)) (:foreground "Orchid1"))
  595. (t (:italic t :bold t)))
  596. "Font lock mode face used to highlight predefined functions and tasks."
  597. :group 'font-lock-highlighting-faces)
  598. (defface vera-font-lock-interface
  599. '((((class color) (background light)) (:foreground "Grey40"))
  600. (((class color) (background dark)) (:foreground "Grey80"))
  601. (t (:italic t :bold t)))
  602. "Font lock mode face used to highlight interface names."
  603. :group 'font-lock-highlighting-faces)
  604. (defalias 'vera-fontify-buffer 'font-lock-fontify-buffer)
  605. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  606. ;;; Indentation
  607. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  608. (defvar vera-echo-syntactic-information-p nil
  609. "If non-nil, syntactic info is echoed when the line is indented.")
  610. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  611. ;; offset functions
  612. (defconst vera-offsets-alist
  613. '((comment . vera-lineup-C-comments)
  614. (comment-intro . vera-lineup-comment)
  615. (string . -1000)
  616. (directive . -1000)
  617. (block-open . 0)
  618. (block-intro . +)
  619. (block-close . 0)
  620. (arglist-intro . +)
  621. (arglist-cont . +)
  622. (arglist-cont-nonempty . 0)
  623. (arglist-close . 0)
  624. (statement . 0)
  625. (statement-cont . +)
  626. (substatement . +)
  627. (else-clause . 0))
  628. "Association list of syntactic element symbols and indentation offsets.
  629. Adapted from `c-offsets-alist'.")
  630. (defun vera-evaluate-offset (offset langelem symbol)
  631. "OFFSET can be a number, a function, a variable, a list, or one of
  632. the symbols + or -."
  633. (cond
  634. ((eq offset '+) (setq offset vera-basic-offset))
  635. ((eq offset '-) (setq offset (- vera-basic-offset)))
  636. ((eq offset '++) (setq offset (* 2 vera-basic-offset)))
  637. ((eq offset '--) (setq offset (* 2 (- vera-basic-offset))))
  638. ((eq offset '*) (setq offset (/ vera-basic-offset 2)))
  639. ((eq offset '/) (setq offset (/ (- vera-basic-offset) 2)))
  640. ((functionp offset) (setq offset (funcall offset langelem)))
  641. ((listp offset)
  642. (setq offset
  643. (let (done)
  644. (while (and (not done) offset)
  645. (setq done (vera-evaluate-offset (car offset) langelem symbol)
  646. offset (cdr offset)))
  647. (if (not done)
  648. 0
  649. done))))
  650. ((not (numberp offset)) (setq offset (symbol-value offset))))
  651. offset)
  652. (defun vera-get-offset (langelem)
  653. "Get offset from LANGELEM which is a cons cell of the form:
  654. \(SYMBOL . RELPOS). The symbol is matched against
  655. vera-offsets-alist and the offset found there is either returned,
  656. or added to the indentation at RELPOS. If RELPOS is nil, then
  657. the offset is simply returned."
  658. (let* ((symbol (car langelem))
  659. (relpos (cdr langelem))
  660. (match (assq symbol vera-offsets-alist))
  661. (offset (cdr-safe match)))
  662. (if (not match)
  663. (setq offset 0
  664. relpos 0)
  665. (setq offset (vera-evaluate-offset offset langelem symbol)))
  666. (+ (if (and relpos
  667. (< relpos (line-beginning-position)))
  668. (save-excursion
  669. (goto-char relpos)
  670. (current-column))
  671. 0)
  672. (vera-evaluate-offset offset langelem symbol))))
  673. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  674. ;; help functions
  675. (defsubst vera-point (position)
  676. "Return the value of point at certain commonly referenced POSITIONs.
  677. POSITION can be one of the following symbols:
  678. bol -- beginning of line
  679. eol -- end of line
  680. boi -- back to indentation
  681. ionl -- indentation of next line
  682. iopl -- indentation of previous line
  683. bonl -- beginning of next line
  684. bopl -- beginning of previous line
  685. This function does not modify point or mark."
  686. (save-excursion
  687. (cond
  688. ((eq position 'bol) (beginning-of-line))
  689. ((eq position 'eol) (end-of-line))
  690. ((eq position 'boi) (back-to-indentation))
  691. ((eq position 'bonl) (forward-line 1))
  692. ((eq position 'bopl) (forward-line -1))
  693. ((eq position 'iopl) (forward-line -1) (back-to-indentation))
  694. ((eq position 'ionl) (forward-line 1) (back-to-indentation))
  695. (t (error "Unknown buffer position requested: %s" position)))
  696. (point)))
  697. (defun vera-in-literal (&optional lim)
  698. "Determine if point is in a Vera literal."
  699. (save-excursion
  700. (let ((state (parse-partial-sexp (or lim (point-min)) (point))))
  701. (cond
  702. ((nth 3 state) 'string)
  703. ((nth 4 state) 'comment)
  704. (t nil)))))
  705. (defun vera-skip-forward-literal ()
  706. "Skip forward literal and return t if within one."
  707. (let ((state (save-excursion
  708. (if (fboundp 'syntax-ppss)
  709. (syntax-ppss)
  710. (parse-partial-sexp (point-min) (point))))))
  711. (when (nth 8 state)
  712. ;; Inside a string or comment.
  713. (goto-char (nth 8 state))
  714. (if (nth 3 state)
  715. ;; A string.
  716. (condition-case nil (forward-sexp 1)
  717. ;; Can't find end of string: it extends til end of buffer.
  718. (error (goto-char (point-max))))
  719. ;; A comment.
  720. (forward-comment 1))
  721. t)))
  722. (defun vera-skip-backward-literal ()
  723. "Skip backward literal and return t if within one."
  724. (let ((state (save-excursion
  725. (if (fboundp 'syntax-ppss)
  726. (syntax-ppss)
  727. (parse-partial-sexp (point-min) (point))))))
  728. (when (nth 8 state)
  729. ;; Inside a string or comment.
  730. (goto-char (nth 8 state))
  731. t)))
  732. (defsubst vera-re-search-forward (regexp &optional bound noerror)
  733. "Like `re-search-forward', but skips over matches in literals."
  734. (let (ret)
  735. (while (and (setq ret (re-search-forward regexp bound noerror))
  736. (vera-skip-forward-literal)
  737. (if bound (< (point) bound) t)))
  738. ret))
  739. (defsubst vera-re-search-backward (regexp &optional bound noerror)
  740. "Like `re-search-backward', but skips over matches in literals."
  741. (let (ret)
  742. (while (and (setq ret (re-search-backward regexp bound noerror))
  743. (vera-skip-backward-literal)
  744. (if bound (> (point) bound) t)))
  745. ret))
  746. (defun vera-forward-syntactic-ws (&optional lim skip-directive)
  747. "Forward skip of syntactic whitespace."
  748. (save-restriction
  749. (let* ((lim (or lim (point-max)))
  750. (here lim)
  751. (hugenum (point-max)))
  752. (narrow-to-region (point) lim)
  753. (while (/= here (point))
  754. (setq here (point))
  755. (forward-comment hugenum)
  756. (when (and skip-directive (looking-at "^\\s-*#"))
  757. (end-of-line))))))
  758. (defun vera-backward-syntactic-ws (&optional lim skip-directive)
  759. "Backward skip over syntactic whitespace."
  760. (save-restriction
  761. (let* ((lim (or lim (point-min)))
  762. (here lim)
  763. (hugenum (- (point-max))))
  764. (when (< lim (point))
  765. (narrow-to-region lim (point))
  766. (while (/= here (point))
  767. (setq here (point))
  768. (forward-comment hugenum)
  769. (when (and skip-directive
  770. (save-excursion (back-to-indentation)
  771. (= (following-char) ?\#)))
  772. (beginning-of-line)))))))
  773. (defmacro vera-prepare-search (&rest body)
  774. "Execute BODY with a syntax table that includes '_'."
  775. `(with-syntax-table vera-mode-ext-syntax-table ,@body))
  776. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  777. ;; comment indentation functions
  778. (defsubst vera-langelem-col (langelem &optional preserve-point)
  779. "Convenience routine to return the column of LANGELEM's relpos.
  780. Leaves point at the relpos unless PRESERVE-POINT is non-nil."
  781. (let ((here (point)))
  782. (goto-char (cdr langelem))
  783. (prog1 (current-column)
  784. (if preserve-point
  785. (goto-char here)))))
  786. (defun vera-lineup-C-comments (langelem)
  787. "Line up C block comment continuation lines.
  788. Nicked from `c-lineup-C-comments'."
  789. (save-excursion
  790. (let ((here (point))
  791. (stars (progn (back-to-indentation)
  792. (skip-chars-forward "*")))
  793. (langelem-col (vera-langelem-col langelem)))
  794. (back-to-indentation)
  795. (if (not (re-search-forward "/\\([*]+\\)" (vera-point 'eol) t))
  796. (progn
  797. (if (not (looking-at "[*]+"))
  798. (progn
  799. ;; we now have to figure out where this comment begins.
  800. (goto-char here)
  801. (back-to-indentation)
  802. (if (looking-at "[*]+/")
  803. (progn (goto-char (match-end 0))
  804. (forward-comment -1))
  805. (goto-char (cdr langelem))
  806. (back-to-indentation))))
  807. (- (current-column) langelem-col))
  808. (if (zerop stars)
  809. (progn
  810. (skip-chars-forward " \t")
  811. (- (current-column) langelem-col))
  812. ;; how many stars on comment opening line? if greater than
  813. ;; on current line, align left. if less than or equal,
  814. ;; align right. this should also pick up Javadoc style
  815. ;; comments.
  816. (if (> (length (match-string 1)) stars)
  817. (progn
  818. (back-to-indentation)
  819. (- (current-column) -1 langelem-col))
  820. (- (current-column) stars langelem-col)))))))
  821. (defun vera-lineup-comment (langelem)
  822. "Line up a comment start."
  823. (save-excursion
  824. (back-to-indentation)
  825. (if (bolp)
  826. ;; not indent if at beginning of line
  827. -1000
  828. ;; otherwise indent accordingly
  829. (goto-char (cdr langelem))
  830. (current-column))))
  831. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  832. ;; move functions
  833. (defconst vera-beg-block-re "{\\|\\<\\(begin\\|fork\\)\\>")
  834. (defconst vera-end-block-re "}\\|\\<\\(end\\|join\\(\\s-+\\(all\\|any\\|none\\)\\)?\\)\\>")
  835. (defconst vera-beg-substatement-re "\\<\\(else\\|for\\|if\\|repeat\\|while\\)\\>")
  836. (defun vera-corresponding-begin (&optional recursive)
  837. "Find corresponding block begin if cursor is at a block end."
  838. (while (and (vera-re-search-backward
  839. (concat "\\(" vera-end-block-re "\\)\\|" vera-beg-block-re)
  840. nil t)
  841. (match-string 1))
  842. (vera-corresponding-begin t))
  843. (unless recursive (vera-beginning-of-substatement)))
  844. (defun vera-corresponding-if ()
  845. "Find corresponding `if' if cursor is at `else'."
  846. (while (and (vera-re-search-backward "}\\|\\<\\(if\\|else\\)\\>" nil t)
  847. (not (equal (match-string 0) "if")))
  848. (if (equal (match-string 0) "else")
  849. (vera-corresponding-if)
  850. (forward-char)
  851. (backward-sexp))))
  852. (defun vera-beginning-of-statement ()
  853. "Go to beginning of current statement."
  854. (let (pos)
  855. (while
  856. (progn
  857. ;; search for end of previous statement
  858. (while
  859. (and (vera-re-search-backward
  860. (concat "[);]\\|" vera-beg-block-re
  861. "\\|" vera-end-block-re) nil t)
  862. (equal (match-string 0) ")"))
  863. (forward-char)
  864. (backward-sexp))
  865. (setq pos (match-beginning 0))
  866. ;; go back to beginning of current statement
  867. (goto-char (or (match-end 0) 0))
  868. (vera-forward-syntactic-ws nil t)
  869. (when (looking-at "(")
  870. (forward-sexp)
  871. (vera-forward-syntactic-ws nil t))
  872. ;; if "else" found, go to "if" and search again
  873. (when (looking-at "\\<else\\>")
  874. (vera-corresponding-if)
  875. (setq pos (point))
  876. t))
  877. ;; if search is repeated, go to beginning of last search
  878. (goto-char pos))))
  879. (defun vera-beginning-of-substatement ()
  880. "Go to beginning of current substatement."
  881. (let ((lim (point))
  882. pos)
  883. ;; go to beginning of statement
  884. (vera-beginning-of-statement)
  885. (setq pos (point))
  886. ;; go forward all substatement opening statements until at LIM
  887. (while (and (< (point) lim)
  888. (vera-re-search-forward vera-beg-substatement-re lim t))
  889. (setq pos (match-beginning 0)))
  890. (vera-forward-syntactic-ws nil t)
  891. (when (looking-at "(")
  892. (forward-sexp)
  893. (vera-forward-syntactic-ws nil t))
  894. (when (< (point) lim)
  895. (setq pos (point)))
  896. (goto-char pos)))
  897. (defun vera-forward-statement ()
  898. "Move forward one statement."
  899. (interactive)
  900. (vera-prepare-search
  901. (while (and (vera-re-search-forward
  902. (concat "[(;]\\|" vera-beg-block-re "\\|" vera-end-block-re)
  903. nil t)
  904. (equal (match-string 0) "("))
  905. (backward-char)
  906. (forward-sexp))
  907. (vera-beginning-of-substatement)))
  908. (defun vera-backward-statement ()
  909. "Move backward one statement."
  910. (interactive)
  911. (vera-prepare-search
  912. (vera-backward-syntactic-ws nil t)
  913. (unless (= (preceding-char) ?\))
  914. (backward-char))
  915. (vera-beginning-of-substatement)))
  916. (defun vera-forward-same-indent ()
  917. "Move forward to next line with same indent."
  918. (interactive)
  919. (let ((pos (point))
  920. (indent (current-indentation)))
  921. (beginning-of-line 2)
  922. (while (and (not (eobp))
  923. (or (looking-at "^\\s-*$")
  924. (> (current-indentation) indent)))
  925. (beginning-of-line 2))
  926. (if (= (current-indentation) indent)
  927. (back-to-indentation)
  928. (message "No following line with same indent found in this block")
  929. (goto-char pos))))
  930. (defun vera-backward-same-indent ()
  931. "Move backward to previous line with same indent."
  932. (interactive)
  933. (let ((pos (point))
  934. (indent (current-indentation)))
  935. (beginning-of-line -0)
  936. (while (and (not (bobp))
  937. (or (looking-at "^\\s-*$")
  938. (> (current-indentation) indent)))
  939. (beginning-of-line -0))
  940. (if (= (current-indentation) indent)
  941. (back-to-indentation)
  942. (message "No preceding line with same indent found in this block")
  943. (goto-char pos))))
  944. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  945. ;; syntax analysis
  946. (defmacro vera-add-syntax (symbol &optional relpos)
  947. "A simple macro to append the syntax in SYMBOL to the syntax list.
  948. try to increase performance by using this macro."
  949. `(setq syntax (cons (cons ,symbol ,(or relpos 0)) syntax)))
  950. (defun vera-guess-basic-syntax ()
  951. "Determine syntactic context of current line of code."
  952. (save-excursion
  953. (beginning-of-line)
  954. (let ((indent-point (point))
  955. syntax state placeholder)
  956. ;; determine syntax state
  957. (setq state (parse-partial-sexp (point-min) (point)))
  958. (cond
  959. ;; CASE 1: in a comment?
  960. ((nth 4 state)
  961. ;; skip empty lines
  962. (while (and (zerop (forward-line -1))
  963. (looking-at "^\\s-*$")))
  964. (vera-add-syntax 'comment (vera-point 'boi)))
  965. ;; CASE 2: in a string?
  966. ((nth 3 state)
  967. (vera-add-syntax 'string))
  968. ;; CASE 3: at a directive?
  969. ((save-excursion (back-to-indentation) (= (following-char) ?\#))
  970. (vera-add-syntax 'directive (point)))
  971. ;; CASE 4: after an opening parenthesis (argument list continuation)?
  972. ((and (nth 1 state)
  973. (or (= (char-after (nth 1 state)) ?\()
  974. ;; also for concatenation (opening '{' and ',' on eol/eopl)
  975. (and (= (char-after (nth 1 state)) ?\{)
  976. (or (save-excursion
  977. (vera-backward-syntactic-ws) (= (char-before) ?,))
  978. (save-excursion
  979. (end-of-line) (= (char-before) ?,))))))
  980. (goto-char (1+ (nth 1 state)))
  981. ;; is there code after the opening parenthesis on the same line?
  982. (if (looking-at "\\s-*$")
  983. (vera-add-syntax 'arglist-cont (vera-point 'boi))
  984. (vera-add-syntax 'arglist-cont-nonempty (point))))
  985. ;; CASE 5: at a block closing?
  986. ((save-excursion (back-to-indentation) (looking-at vera-end-block-re))
  987. ;; look for the corresponding begin
  988. (vera-corresponding-begin)
  989. (vera-add-syntax 'block-close (vera-point 'boi)))
  990. ;; CASE 6: at a block intro (the first line after a block opening)?
  991. ((and (save-excursion
  992. (vera-backward-syntactic-ws nil t)
  993. ;; previous line ends with a block opening?
  994. (or (/= (skip-chars-backward "{") 0) (backward-word 1))
  995. (when (looking-at vera-beg-block-re)
  996. ;; go to beginning of substatement
  997. (vera-beginning-of-substatement)
  998. (setq placeholder (point))))
  999. ;; not if "fork" is followed by "{"
  1000. (save-excursion
  1001. (not (and (progn (back-to-indentation) (looking-at "{"))
  1002. (progn (goto-char placeholder)
  1003. (looking-at "\\<fork\\>"))))))
  1004. (goto-char placeholder)
  1005. (vera-add-syntax 'block-intro (vera-point 'boi)))
  1006. ;; CASE 7: at the beginning of an else clause?
  1007. ((save-excursion (back-to-indentation) (looking-at "\\<else\\>"))
  1008. ;; find corresponding if
  1009. (vera-corresponding-if)
  1010. (vera-add-syntax 'else-clause (vera-point 'boi)))
  1011. ;; CASE 8: at the beginning of a statement?
  1012. ;; is the previous command completed?
  1013. ((or (save-excursion
  1014. (vera-backward-syntactic-ws nil t)
  1015. (setq placeholder (point))
  1016. ;; at the beginning of the buffer?
  1017. (or (bobp)
  1018. ;; previous line ends with a semicolon or
  1019. ;; is a block opening or closing?
  1020. (when (or (/= (skip-chars-backward "{};") 0)
  1021. (progn (back-to-indentation)
  1022. (looking-at (concat vera-beg-block-re "\\|"
  1023. vera-end-block-re))))
  1024. ;; if at a block closing, go to beginning
  1025. (when (looking-at vera-end-block-re)
  1026. (vera-corresponding-begin))
  1027. ;; go to beginning of the statement
  1028. (vera-beginning-of-statement)
  1029. (setq placeholder (point)))
  1030. ;; at a directive?
  1031. (when (progn (back-to-indentation) (looking-at "#"))
  1032. ;; go to previous statement
  1033. (vera-beginning-of-statement)
  1034. (setq placeholder (point)))))
  1035. ;; at a block opening?
  1036. (when (save-excursion (back-to-indentation)
  1037. (looking-at vera-beg-block-re))
  1038. ;; go to beginning of the substatement
  1039. (vera-beginning-of-substatement)
  1040. (setq placeholder (point))))
  1041. (goto-char placeholder)
  1042. (vera-add-syntax 'statement (vera-point 'boi)))
  1043. ;; CASE 9: at the beginning of a substatement?
  1044. ;; is this line preceded by a substatement opening statement?
  1045. ((save-excursion (vera-backward-syntactic-ws nil t)
  1046. (when (= (preceding-char) ?\)) (backward-sexp))
  1047. (backward-word 1)
  1048. (setq placeholder (point))
  1049. (looking-at vera-beg-substatement-re))
  1050. (goto-char placeholder)
  1051. (vera-add-syntax 'substatement (vera-point 'boi)))
  1052. ;; CASE 10: it must be a statement continuation!
  1053. (t
  1054. ;; go to beginning of statement
  1055. (vera-beginning-of-substatement)
  1056. (vera-add-syntax 'statement-cont (vera-point 'boi))))
  1057. ;; special case: look for a comment start
  1058. (goto-char indent-point)
  1059. (skip-chars-forward " \t")
  1060. (when (looking-at comment-start)
  1061. (vera-add-syntax 'comment-intro))
  1062. ;; return syntax
  1063. syntax)))
  1064. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1065. ;; indentation functions
  1066. (defun vera-indent-line ()
  1067. "Indent the current line as Vera code.
  1068. Return the amount of indentation change (in columns)."
  1069. (interactive)
  1070. (vera-prepare-search
  1071. (let* ((syntax (vera-guess-basic-syntax))
  1072. (pos (- (point-max) (point)))
  1073. (indent (apply '+ (mapcar 'vera-get-offset syntax)))
  1074. (shift-amt (- (current-indentation) indent)))
  1075. (when vera-echo-syntactic-information-p
  1076. (message "syntax: %s, indent= %d" syntax indent))
  1077. (unless (zerop shift-amt)
  1078. (beginning-of-line)
  1079. (delete-region (point) (vera-point 'boi))
  1080. (indent-to indent))
  1081. (if (< (point) (vera-point 'boi))
  1082. (back-to-indentation)
  1083. ;; If initial point was within line's indentation, position after
  1084. ;; the indentation. Else stay at same point in text.
  1085. (when (> (- (point-max) pos) (point))
  1086. (goto-char (- (point-max) pos))))
  1087. shift-amt)))
  1088. (defun vera-indent-buffer ()
  1089. "Indent whole buffer as Vera code.
  1090. Calls `indent-region' for whole buffer."
  1091. (interactive)
  1092. (message "Indenting buffer...")
  1093. (indent-region (point-min) (point-max) nil)
  1094. (message "Indenting buffer...done"))
  1095. (defun vera-indent-region (start end column)
  1096. "Indent region as Vera code."
  1097. (interactive "r\nP")
  1098. (message "Indenting region...")
  1099. (indent-region start end column)
  1100. (message "Indenting region...done"))
  1101. (defsubst vera-indent-block-closing ()
  1102. "If previous word is a block closing or `else', indent line again."
  1103. (when (= (char-syntax (preceding-char)) ?w)
  1104. (save-excursion
  1105. (backward-word 1)
  1106. (when (and (not (vera-in-literal))
  1107. (looking-at (concat vera-end-block-re "\\|\\<else\\>")))
  1108. (indent-according-to-mode)))))
  1109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1110. ;; electrifications
  1111. (defun vera-electric-tab (&optional prefix)
  1112. "Do what I mean (indent, expand, tab, change indent, etc..).
  1113. If preceding character is part of a word or a paren then `hippie-expand',
  1114. else if right of non whitespace on line then `tab-to-tab-stop',
  1115. else if last command was a tab or return then dedent one step or if a comment
  1116. toggle between normal indent and inline comment indent,
  1117. else indent `correctly'.
  1118. If `vera-intelligent-tab' is nil, always indent line."
  1119. (interactive "*P")
  1120. (if vera-intelligent-tab
  1121. (progn
  1122. (cond ((and (not (featurep 'xemacs)) (use-region-p))
  1123. (vera-indent-region (region-beginning) (region-end) nil))
  1124. ((memq (char-syntax (preceding-char)) '(?w ?_))
  1125. (let ((case-fold-search t)
  1126. (case-replace nil)
  1127. (hippie-expand-only-buffers
  1128. (or (and (boundp 'hippie-expand-only-buffers)
  1129. hippie-expand-only-buffers)
  1130. '(vera-mode))))
  1131. (vera-expand-abbrev prefix)))
  1132. ((> (current-column) (current-indentation))
  1133. (tab-to-tab-stop))
  1134. ((and (or (eq last-command 'vera-electric-tab)
  1135. (eq last-command 'vera-electric-return))
  1136. (/= 0 (current-indentation)))
  1137. (backward-delete-char-untabify vera-basic-offset nil))
  1138. (t (indent-according-to-mode)))
  1139. (setq this-command 'vera-electric-tab))
  1140. (indent-according-to-mode)))
  1141. (defun vera-electric-return ()
  1142. "Insert newline and indent. Indent current line if it is a block closing."
  1143. (interactive)
  1144. (vera-indent-block-closing)
  1145. (newline-and-indent))
  1146. (defun vera-electric-space (arg)
  1147. "Insert a space. Indent current line if it is a block closing."
  1148. (interactive "*P")
  1149. (unless arg
  1150. (vera-indent-block-closing))
  1151. (self-insert-command (prefix-numeric-value arg)))
  1152. (defun vera-electric-opening-brace (arg)
  1153. "Outdent opening brace."
  1154. (interactive "*P")
  1155. (self-insert-command (prefix-numeric-value arg))
  1156. (unless arg
  1157. (indent-according-to-mode)))
  1158. (defun vera-electric-closing-brace (arg)
  1159. "Outdent closing brace."
  1160. (interactive "*P")
  1161. (self-insert-command (prefix-numeric-value arg))
  1162. (unless arg
  1163. (indent-according-to-mode)))
  1164. (defun vera-electric-pound (arg)
  1165. "Insert `#' and indent as directive it first character of line."
  1166. (interactive "*P")
  1167. (self-insert-command (prefix-numeric-value arg))
  1168. (unless arg
  1169. (save-excursion
  1170. (backward-char)
  1171. (skip-chars-backward " \t")
  1172. (when (bolp)
  1173. (delete-horizontal-space)))))
  1174. (defun vera-electric-star (arg)
  1175. "Insert a star character. Nicked from `c-electric-star'."
  1176. (interactive "*P")
  1177. (self-insert-command (prefix-numeric-value arg))
  1178. (if (and (not arg)
  1179. (memq (vera-in-literal) '(comment))
  1180. (eq (char-before) ?*)
  1181. (save-excursion
  1182. (forward-char -1)
  1183. (skip-chars-backward "*")
  1184. (if (eq (char-before) ?/)
  1185. (forward-char -1))
  1186. (skip-chars-backward " \t")
  1187. (bolp)))
  1188. (indent-according-to-mode)))
  1189. (defun vera-electric-slash (arg)
  1190. "Insert a slash character. Nicked from `c-electric-slash'."
  1191. (interactive "*P")
  1192. (let* ((ch (char-before))
  1193. (indentp (and (not arg)
  1194. (eq last-command-event ?/)
  1195. (or (and (eq ch ?/)
  1196. (not (vera-in-literal)))
  1197. (and (eq ch ?*)
  1198. (vera-in-literal))))))
  1199. (self-insert-command (prefix-numeric-value arg))
  1200. (when indentp
  1201. (indent-according-to-mode))))
  1202. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1203. ;;; Miscellaneous
  1204. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1205. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1206. ;; Hippie expand customization (for expansion of Vera commands)
  1207. (defvar vera-abbrev-list
  1208. (append (list nil) vera-keywords
  1209. (list nil) vera-types
  1210. (list nil) vera-functions
  1211. (list nil) vera-constants
  1212. (list nil) vera-rvm-types
  1213. (list nil) vera-rvm-functions
  1214. (list nil) vera-rvm-constants)
  1215. "Predefined abbreviations for Vera.")
  1216. (defvar vera-expand-upper-case nil)
  1217. (eval-when-compile (require 'hippie-exp))
  1218. (defun vera-try-expand-abbrev (old)
  1219. "Try expanding abbreviations from `vera-abbrev-list'."
  1220. (unless old
  1221. (he-init-string (he-dabbrev-beg) (point))
  1222. (setq he-expand-list
  1223. (let ((abbrev-list vera-abbrev-list)
  1224. (sel-abbrev-list '()))
  1225. (while abbrev-list
  1226. (when (or (not (stringp (car abbrev-list)))
  1227. (string-match
  1228. (concat "^" he-search-string) (car abbrev-list)))
  1229. (setq sel-abbrev-list
  1230. (cons (car abbrev-list) sel-abbrev-list)))
  1231. (setq abbrev-list (cdr abbrev-list)))
  1232. (nreverse sel-abbrev-list))))
  1233. (while (and he-expand-list
  1234. (or (not (stringp (car he-expand-list)))
  1235. (he-string-member (car he-expand-list) he-tried-table t)))
  1236. (unless (stringp (car he-expand-list))
  1237. (setq vera-expand-upper-case (car he-expand-list)))
  1238. (setq he-expand-list (cdr he-expand-list)))
  1239. (if (null he-expand-list)
  1240. (progn (when old (he-reset-string))
  1241. nil)
  1242. (he-substitute-string
  1243. (if vera-expand-upper-case
  1244. (upcase (car he-expand-list))
  1245. (car he-expand-list))
  1246. t)
  1247. (setq he-expand-list (cdr he-expand-list))
  1248. t))
  1249. ;; function for expanding abbrevs and dabbrevs
  1250. (defalias 'vera-expand-abbrev
  1251. (make-hippie-expand-function '(try-expand-dabbrev
  1252. try-expand-dabbrev-all-buffers
  1253. vera-try-expand-abbrev)))
  1254. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1255. ;; Comments
  1256. (defun vera-comment-uncomment-region (beg end &optional _arg)
  1257. "Comment region if not commented, uncomment region if already commented."
  1258. (interactive "r\nP")
  1259. (goto-char beg)
  1260. (if (looking-at comment-start-skip)
  1261. (comment-region beg end '(4))
  1262. (comment-region beg end)))
  1263. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1264. ;; Help functions
  1265. (defun vera-customize ()
  1266. "Call the customize function with `vera' as argument."
  1267. (interactive)
  1268. (customize-group 'vera))
  1269. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1270. ;; Other
  1271. ;; remove ".vr" from `completion-ignored-extensions'
  1272. (setq completion-ignored-extensions
  1273. (delete ".vr" completion-ignored-extensions))
  1274. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1275. ;;; Bug reports
  1276. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1277. (defconst vera-mode-help-address "Reto Zimmermann <reto@gnu.org>"
  1278. "Address for Vera Mode bug reports.")
  1279. ;; get reporter-submit-bug-report when byte-compiling
  1280. (eval-when-compile
  1281. (require 'reporter))
  1282. (defun vera-submit-bug-report ()
  1283. "Submit via mail a bug report on Vera Mode."
  1284. (interactive)
  1285. ;; load in reporter
  1286. (and
  1287. (y-or-n-p "Do you want to submit a report on Vera Mode? ")
  1288. (require 'reporter)
  1289. (let ((reporter-prompt-for-summary-p t))
  1290. (reporter-submit-bug-report
  1291. vera-mode-help-address
  1292. (concat "Vera Mode " vera-version)
  1293. (list
  1294. ;; report all important variables
  1295. 'vera-basic-offset
  1296. 'vera-underscore-is-part-of-word
  1297. 'vera-intelligent-tab
  1298. )
  1299. nil nil
  1300. "Hi Reto,"))))
  1301. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1302. ;;; Documentation
  1303. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1304. (defun vera-version ()
  1305. "Echo the current version of Vera Mode in the minibuffer."
  1306. (interactive)
  1307. (message "Vera Mode %s (%s)" vera-version vera-time-stamp))
  1308. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1309. (provide 'vera-mode)
  1310. ;;; vera-mode.el ends here