vera-mode.el 54 KB

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