Klimi's new dotfiles with stow.
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

1219 righe
35 KiB

  1. ;;; ess-stata-lang.el --- Stata customization -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 1999--2000, Thomas Lumley, A. J. Rossini, Brendan Halpin.
  3. ;; Copyright (C) 1997--2004 A.J. Rossini, Richard M. Heiberger, Martin
  4. ;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
  5. ;; Author: Thomas Lumley <thomas@biostat.washington.edu>,
  6. ;; Brendan Halpin <brendan@essex.ac.uk>
  7. ;; Created: 2 Nov 1997
  8. ;; Maintainer: ESS-core <ESS-core@r-project.org>
  9. ;; Keywords: languages
  10. ;; This file is part of ESS (Emacs Speaks Statistics).
  11. ;; This file is free software; you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either version 2, or (at your option)
  14. ;; any later version.
  15. ;; This file is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;; GNU General Public License for more details.
  19. ;; A copy of the GNU General Public License is available at
  20. ;; https://www.r-project.org/Licenses/
  21. ;;; Commentary:
  22. ;; This is based upon Version 0.4 of Stata mode.
  23. ;; Stata modes. Emacs modes for using the Stata statistical package
  24. ;; Modified from S-mode, comint-mode
  25. ;;
  26. ;; (c) Thomas Lumley 1997
  27. ;;
  28. ;; version 0.4 20/7/97
  29. ;;
  30. ;; This file is free software; you can redistribute it and/or modify
  31. ;; it under the terms of the GNU General Public License as published by
  32. ;; the Free Software Foundation; either version 2, or (at your option)
  33. ;; any later version.
  34. ;;
  35. ;; (for the GNU GPL see above)
  36. ;;; Code:
  37. (declare-function ess-help-mode "ess-help")
  38. (require 'make-regexp) ; it's now local to the directory.
  39. ;;(load-library "make-regexp") ;; this is necessary for
  40. ;; ado-set-font-lock-keywords
  41. ;; only needed in Emacs >= 22.x
  42. (require 'comint)
  43. (require 'ess-trns)
  44. (defconst ess-help-STA-sec-keys-alist
  45. '((?d . "Description")
  46. (?e . "Examples")
  47. (?o . "Options")
  48. (?s . "Also see")
  49. (?S . "Syntax")
  50. (?r . "Remarks")
  51. (?t . "Title"))
  52. "Help section keys.
  53. `key' indicates the keystroke to use to search for the section heading
  54. `string' in an Stata help file. `string' is used as part of a
  55. regexp-search, and so specials should be quoted.
  56. ")
  57. (defconst ess-help-STA-sec-regex "^[A-Z a-z]+:?\n-+\\|http:"
  58. "Reg(ular) Ex(pression) of section headers in help file.")
  59. (defun ado-set-font-lock-keywords ()
  60. "Create font lock keywords for Stata syntax. This is from the
  61. ado-mode of Bill Rising <brising@jhsph.edu>, and uses make-regexp."
  62. ;; (make-local-variable 'ado-font-lock-keywords)
  63. (interactive)
  64. (list
  65. ;; special highlighting
  66. ;; program definitions
  67. (eval-when-compile
  68. (make-regexps
  69. '(("^\\*!.*") font-lock-keyword-face)
  70. ))
  71. (eval-when-compile
  72. (make-regexps
  73. "^"
  74. '((
  75. "pr" "pro" "prog" "progr" "progra" "program"
  76. ) font-lock-keyword-face)
  77. "[ \t]+"
  78. '((
  79. "de" "def" "defi" "defin" "define"
  80. "di" "dir"
  81. "drop"
  82. "l" "li" "lis" "list"
  83. ) font-lock-type-face nil)
  84. "[ \t]+"
  85. '(("[_a-z]+[_a-z0-9]*") font-lock-keyword-face nil)
  86. ))
  87. (eval-when-compile
  88. (make-regexps
  89. '(("^[ \t]*version") font-lock-reference-face)
  90. "[ \t]*"
  91. '(("1.0 2.0 2.1 3.0 3.1 4.0 5.0 6 6.0") font-lock-type-face)
  92. ))
  93. (eval-when-compile
  94. (make-regexps
  95. "^"
  96. '(("end" "pause"
  97. ) font-lock-keyword-face)
  98. "[ /t]*.*$"
  99. ))
  100. ;; delimit command
  101. (eval-when-compile
  102. (make-regexps
  103. '(("^[ \t]*#delimit") font-lock-reference-face)
  104. "\\s-*"
  105. '(("\\(cr\\|;\\)\\s-*$") font-lock-type-face nil)
  106. ))
  107. ;; set command (with endless options!)
  108. (eval-when-compile
  109. (make-regexps
  110. '(("^[ \t]*set") font-lock-reference-face)
  111. "[ \t]+"
  112. '(("adosize" "ANSI"
  113. "b" "be" "bee" "beep" "checksum" "contents"
  114. "d" "di" "dis" "disp" "displ" "displa" "display"
  115. "g" "gr" "gra" "grap" "graph" "graphi" "graphic" "graphics"
  116. "help"
  117. "IBM"
  118. "l" "le" "lev" "leve" "level"
  119. "linesize"
  120. "lo" "log"
  121. "mat" "mats" "matsi" "matsiz" "matsize"
  122. "maxobs" "maxvar"
  123. "mem" "memo" "memor" "memory"
  124. "mo" "mor" "more"
  125. "obs"
  126. "ou" "out" "outp" "outpu" "output"
  127. "pagesize"
  128. "r" "rm" "rms" "rmsg"
  129. "se" "see" "seed" "seed0" "shell"
  130. "te" "tex" "text" "texts" "textsi" "textsiz" "textsize"
  131. "tr" "tra" "trac" "trace"
  132. "t" "ty" "typ" "type" "video"
  133. "vir" "virt" "virtu" "virtua" "virtual"
  134. )
  135. font-lock-reference-face t)
  136. "[ \t]*"
  137. '(("[a-zA-Z0-9]*") font-lock-type-face)
  138. ))
  139. ;; the constraint commands
  140. (eval-when-compile
  141. (make-regexps
  142. "[ \t]+"
  143. '((
  144. "cons" "const" "constr" "constra" "constrai" "constrain" "constraint"
  145. ) font-lock-reference-face)
  146. "[ \t]+"
  147. '((
  148. "d"
  149. "de" "def" "defi" "defin" "define"
  150. "di" "dir"
  151. "drop"
  152. "l" "li" "lis" "list"
  153. )
  154. font-lock-type-face)
  155. "\\b"
  156. ))
  157. ;; the confirm commands - could be a mess!
  158. (eval-when-compile
  159. (make-regexps
  160. "[ \t]+"
  161. '((
  162. "conf" "confi" "confir" "confirm"
  163. ) font-lock-reference-face)
  164. "[ \t]+"
  165. '((
  166. "e" "ex" "exi" "exis" "exist" "existe" "existen" "existenc" "existence"
  167. "f" "fi" "fil" "file"
  168. "n" "nu" "num" "numb" "numbe" "number"
  169. "v" "va" "var" "vari" "varia" "variab" "variabl" "variable"
  170. ) font-lock-type-face)
  171. "\\b"
  172. ))
  173. (eval-when-compile
  174. (make-regexps
  175. "[ \t]+"
  176. '((
  177. "conf" "confi" "confir" "confirm"
  178. ) font-lock-reference-face)
  179. "[ \t]+"
  180. '((
  181. "integer"
  182. ) font-lock-type-face)
  183. "[ \t]+"
  184. '((
  185. "n" "nu" "num" "numb" "numbe" "number"
  186. ) font-lock-type-face)
  187. "\\b"
  188. ))
  189. (eval-when-compile
  190. (make-regexps
  191. "[ \t]+"
  192. '((
  193. "conf" "confi" "confir" "confirm"
  194. ) font-lock-reference-face)
  195. "[ \t]+"
  196. '((
  197. "n" "ne" "new"
  198. ) font-lock-type-face)
  199. "[ \t]+"
  200. '((
  201. "f" "fi" "fil" "file"
  202. "v" "va" "var" "vari" "varia" "variab" "variabl" "variable"
  203. ) font-lock-type-face)
  204. "\\b"
  205. ))
  206. (eval-when-compile
  207. (make-regexps
  208. "[ \t]+"
  209. '((
  210. "conf" "confi" "confir" "confirm"
  211. ) font-lock-reference-face)
  212. "[ \t]+"
  213. '((
  214. "byte" "double" "float" "int" "long"
  215. "numeric"
  216. "str" "stri" "strin" "string"
  217. ) font-lock-type-face)
  218. "[ \t]+"
  219. '((
  220. "v" "va" "var" "vari" "varia" "variab" "variabl" "variable"
  221. ) font-lock-type-face)
  222. "\\b"
  223. ))
  224. ;;; the str# won't quite look right, but that's the breaks for using
  225. ;;; a tool like this...
  226. (eval-when-compile
  227. (make-regexps
  228. "[ \t]+"
  229. '((
  230. "conf" "confi" "confir" "confirm"
  231. ) font-lock-reference-face)
  232. "[ \t]+"
  233. '((
  234. "str"
  235. ) font-lock-type-face)
  236. "[1-9]+[0-9]*[ \t]+"
  237. '((
  238. "v" "va" "var" "vari" "varia" "variab" "variabl" "variable"
  239. ) font-lock-type-face)
  240. "\\b"
  241. ))
  242. ;; the estimates commands
  243. (eval-when-compile
  244. (make-regexps
  245. "[ \t]+"
  246. '((
  247. "est" "esti" "estim" "estima" "estimat" "estimate" "estimates"
  248. ) font-lock-reference-face)
  249. "[ \t]+"
  250. '((
  251. "clear"
  252. "di" "dir" "dis" "disp" "displ" "displa" "display"
  253. "drop"
  254. "h" "ho" "hol" "hold"
  255. "li" "lis" "list"
  256. "loc" "loca" "local"
  257. "mat" "matr" "matri" "matrix"
  258. "post"
  259. "repost"
  260. "sca" "scal" "scala" "scalar"
  261. "u" "un" "unh" "unho" "unhol" "unhold"
  262. )
  263. font-lock-type-face)
  264. "\\b"
  265. ))
  266. ;; the gph commands
  267. (eval-when-compile
  268. (make-regexps
  269. "[ \t]+"
  270. '((
  271. "gph"
  272. ) font-lock-reference-face)
  273. "[ \t]+"
  274. '((
  275. "arc"
  276. "box"
  277. "clear" "close"
  278. "font"
  279. "line"
  280. "open"
  281. "pen" "point"
  282. "text"
  283. "vline" "vpoint" "vpoly" "vtext"
  284. )
  285. font-lock-type-face)
  286. "\\b"
  287. ))
  288. ;; some of the matrix commands
  289. (eval-when-compile
  290. (make-regexps
  291. "[ \t]+"
  292. '(("mat" "matr" "matri" "matrix") font-lock-reference-face)
  293. "[ \t]+"
  294. '(("ac" "acc" "accu" "accum"
  295. "cole" "coleq"
  296. "coln" "colna" "colnam" "cloname" "colnames"
  297. "d" "def" "defi" "defin" "define"
  298. "di" "dir" "dispCns" "drop" "drop _all"
  299. "glsa" "glsac" "glsacc" "glsaccu" "glsaccum"
  300. "l" "li" "lis" "list" "makeCns" "mlou" "mlout" "post"
  301. "rowe" "roweq"
  302. "rown" "rowna" "rownam" "rowname" "rownames"
  303. "sco" "scor" "score"
  304. "sub" "subs" "subst" "substi" "substit" "substitu" "substitut" "substitute"
  305. "svd" "syme" "symei" "symeig" "symeige" "symeigen"
  306. "veca" "vecac" "vecacc" "vecaccu" "vecaccum"
  307. )
  308. font-lock-type-face)
  309. "\\b"
  310. ))
  311. ;; the ml commands
  312. (eval-when-compile
  313. (make-regexps
  314. "[ \t]+"
  315. '(("ml") font-lock-reference-face)
  316. "[ \t]+"
  317. '(("b" "be" "beg" "begi" "begin"
  318. "check" "count"
  319. "de" "dep" "depn" "depna" "depnam" "depname" "depnames"
  320. "di" "dis" "disp" "displ" "displa" "display"
  321. "f" "fu" "fun" "func" "funct" "functi" "functio" "function"
  322. "gr" "gra" "grap" "graph"
  323. "init"
  324. "max" "maxi" "maxim" "maximi" "maximiz" "maximize"
  325. "me" "met" "meth" "metho" "method"
  326. "ml" "mlo" "mlou" "mlout"
  327. "mo" "mod" "mode" "model"
  328. "pl" "plo" "plot"
  329. "po" "pos" "post"
  330. "q" "qu" "que" "quer" "query"
  331. "re" "rep" "repo" "repor" "report"
  332. "sa" "sam" "samp" "sampl" "sample"
  333. "se" "sea" "sear" "searc" "search"
  334. "trace")
  335. font-lock-type-face)
  336. "\\b"
  337. ))
  338. ;; the net commands
  339. (eval-when-compile
  340. (make-regexps
  341. "[ \t]+"
  342. '(("net") font-lock-reference-face)
  343. "[ \t]+"
  344. '((
  345. "cd"
  346. "d" "de" "des" "desc" "descr" "descri" "describ" "describe"
  347. "from" "get" "install"
  348. "link"
  349. "q" "qu" "que" "quer" "query")
  350. font-lock-type-face)
  351. "\\b"
  352. ))
  353. (eval-when-compile
  354. (make-regexps
  355. "[ \t]+"
  356. '(("net") font-lock-reference-face)
  357. "[ \t]+"
  358. '(("set") font-lock-reference-face)
  359. "[ \t]+"
  360. '(("ado" "other") font-lock-type-face)
  361. "\\b"
  362. ))
  363. (eval-when-compile
  364. (make-regexps
  365. "[ \t]+"
  366. '(("ado") font-lock-reference-face)
  367. "[ \t]+"
  368. '(("d" "de" "des" "desc" "descr" "descri" "describ" "describe"
  369. "dir"
  370. "uninstall")
  371. font-lock-type-face)
  372. "\\b"
  373. ))
  374. ;; the reshape commands
  375. (eval-when-compile
  376. (make-regexps
  377. "[ \t]+"
  378. '(("reshape") font-lock-keyword-face)
  379. "[ \t]+"
  380. '((
  381. "clear"
  382. "error"
  383. "i" "j"
  384. "long"
  385. "wide"
  386. "xi" "xij")
  387. font-lock-type-face)
  388. "\\b"
  389. ))
  390. ;; the return commands
  391. (eval-when-compile
  392. (make-regexps
  393. "[ \t]+"
  394. '(("ret" "retu" "retur" "return") font-lock-reference-face)
  395. "[ \t]+"
  396. '(("add" "clear" "local" "matrix" "scalar") font-lock-type-face)
  397. "\\b"
  398. ))
  399. (eval-when-compile
  400. (make-regexps
  401. "[ \t]+"
  402. '(("sret" "sretu" "sretur" "sreturn") font-lock-reference-face)
  403. "[ \t]+"
  404. '(("clear" "local") font-lock-type-face)
  405. "\\b"
  406. ))
  407. ;; the sts commands
  408. (eval-when-compile
  409. (make-regexps
  410. "[ \t]+"
  411. '(("sts") font-lock-reference-face)
  412. "[ \t]+"
  413. '((
  414. "g"
  415. "gen" "gene" "gener" "genera" "generat" "generate"
  416. "gr" "gra" "grap" "graph"
  417. "l" "li" "lis" "list"
  418. "t" "te" "tes" "test"
  419. )
  420. font-lock-type-face)
  421. "\\b"
  422. ))
  423. ;; the sw commands
  424. (eval-when-compile
  425. (make-regexps
  426. "[ \t]+"
  427. '(("sw") font-lock-reference-face)
  428. "[ \t]+"
  429. '((
  430. "cloglog" "cnreg" "cox" "ereg" "gamma" "glm" "gompertz" "hetprob"
  431. "llogist" "lnormal" "logistic" "logit" "ologit" "oprobit"
  432. "poisson" "probit" "qreg" "reg" "regr" "regre" "regres" "regress"
  433. "scobit" "tobit" "weibull"
  434. )
  435. font-lock-type-face)
  436. "\\b"
  437. ))
  438. ;; the window commands
  439. (eval-when-compile
  440. (make-regexps
  441. "[ \t]+"
  442. '((
  443. "win" "wind" "windo" "window"
  444. ) font-lock-reference-face)
  445. "[ \t]+"
  446. '((
  447. "d"
  448. "di" "dia" "dial" "dialo" "dialog"
  449. "dir" "drop"
  450. "fo" "fop" "fope" "fopen"
  451. "fs" "fsa" "fsav" "fsave"
  452. "l" "list"
  453. "push"
  454. "stop" "stopb" "stopbo" "stopbox"
  455. ) font-lock-type-face)
  456. "\\b"
  457. ))
  458. ;; the window controls
  459. (eval-when-compile
  460. (make-regexps
  461. "[ \t]+"
  462. '((
  463. "win" "wind" "windo" "window"
  464. ) font-lock-reference-face)
  465. "[ \t]+"
  466. '((
  467. "c" "co" "con" "cont" "contr" "contro" "control"
  468. ) font-lock-reference-face)
  469. '((
  470. "button" "check" "clear"
  471. "edit"
  472. "mcombo" "msimple"
  473. "radbegin"
  474. "radend"
  475. "radio"
  476. "scombo"
  477. "ssimple"
  478. "static"
  479. ) font-lock-type-face)
  480. "\\b"
  481. ))
  482. ;; the window manage commands
  483. (eval-when-compile
  484. (make-regexps
  485. "[ \t]+"
  486. '((
  487. "win" "wind" "windo" "window"
  488. ) font-lock-reference-face)
  489. "[ \t]+"
  490. '((
  491. "man" "mana" "manag" "manage"
  492. ) font-lock-reference-face)
  493. "[ \t]+"
  494. '((
  495. "forward"
  496. "minimize"
  497. "prefs load"
  498. "prefs save"
  499. "prefs default"
  500. "print graph"
  501. "print log"
  502. "restore"
  503. "update variable"
  504. )
  505. font-lock-type-face)
  506. "\\b"
  507. ))
  508. ;; the window menu commands
  509. (eval-when-compile
  510. (make-regexps
  511. "[ \t]+"
  512. '((
  513. "win" "wind" "windo" "window"
  514. ) font-lock-reference-face)
  515. "[ \t]+"
  516. '((
  517. "m" "me" "men" "menu"
  518. ) font-lock-reference-face)
  519. "[ \t]+"
  520. '((
  521. "append popout"
  522. "append string"
  523. "append separator"
  524. "clear"
  525. "popout"
  526. "set"
  527. )
  528. font-lock-type-face)
  529. "\\b"
  530. ))
  531. ;; the xwindow commands
  532. (eval-when-compile
  533. (make-regexps
  534. "[ \t]+"
  535. '((
  536. "xwin" "xwind" "xwindo" "xwindow"
  537. ) font-lock-reference-face)
  538. "[ \t]+"
  539. '((
  540. "de" "def" "defi" "defin" "define"
  541. "di" "dir"
  542. "drop"
  543. "l" "li" "lis" "list"
  544. )
  545. font-lock-type-face)
  546. "\\b"
  547. ))
  548. ;; all the endless Stata keywords (not in a good order)
  549. ;; first those keywords which must start line
  550. ;; note that these will look like text if preceded by a comment
  551. ;; (but comments shouldn't be before the command, anyway)
  552. (eval-when-compile
  553. (make-regexps
  554. "^[ \t]+"
  555. '((
  556. "cap" "capt" "captu" "captur" "capture"
  557. "char" "err" "erro" "error" "e" "ex" "exi" "exit"
  558. "par" "pars" "parse"
  559. "set"
  560. ) font-lock-reference-face)
  561. "\\b"
  562. ))
  563. ;; here are some keywords which appear in the middle of lines
  564. ;; note that the really short abbreviations could make a mess of things
  565. ;;
  566. ;; These are split to allow compiling!
  567. (eval-when-compile
  568. (make-regexps
  569. "\\b"
  570. '((
  571. "_huber" "_qreg" "_robust"
  572. "acprplot" "adjust"
  573. "adopath" "alpha"
  574. "an" "ano" "anov" "anova" "arch"
  575. "areg" "arima"
  576. "as" "ass" "asse" "asser" "assert"
  577. "avplot" "avplots"
  578. "bcskew0"
  579. "be" "bee" "beep"
  580. "biprobit" "bitest" "bitesti" "blogit"
  581. "boxcox" "bprobit" "br" "break" "brier"
  582. "bro" "brow" "brows" "browse"
  583. "bsqreg" "bstat" "by"
  584. "canon" "cat" "cc" "cci" "cchart" "centile" "cf" "ci" "cii"
  585. "clogi" "clogit" "clogitp" "cloglog"
  586. "close" "cmdtool"
  587. "cnr" "cnre" "cnreg" "cnsreg" "codebook" "compare"
  588. "copy"
  589. "cor" "corc" "corr" "corre" "correl" "correla" "correlat" "correlate"
  590. "corrgram"
  591. "cou" "coun" "count"
  592. "cox" "cprplot" "_crcswxx" "cs" "csi"
  593. "ct" "ctset" "cttost"
  594. "cumul" "cusum")
  595. font-lock-reference-face)
  596. "\\b"
  597. ))
  598. (eval-when-compile
  599. (make-regexps
  600. "[ \t]+"
  601. '((
  602. "d" "de" "des" "desc" "descr" "descri" "describ" "describe"
  603. "dfbeta" "dfuller" "di"
  604. "dir" "dis" "disp" "disp_res" "disp_s"
  605. "displ" "displa" "display"
  606. "do" "dotplot"
  607. "dprobit" "ds" "dstdize" "dwstat"
  608. "eivreg" "eq" "ereg"
  609. "fac" "fact" "facto" "factor"
  610. "fit" "for" "fpredict"
  611. "fracplot" "fracpoly" "fsl"
  612. ) font-lock-reference-face)
  613. "\\b"
  614. ))
  615. (eval-when-compile
  616. (make-regexps
  617. "[ \t]+"
  618. '((
  619. "gettoken" "gladder" "glm" "glmpred" "glogit" "gnbreg" "gompertz"
  620. "gphdot" "gphpen" "graph" "gprobit" "greigen" "grmeanby"
  621. "hadimvo" "hausman" "heckman" "heckprob" "hetprob" "hettest" "hilite"
  622. "hist" "hlu" "hotel"
  623. "iqreg" "istdize" "iis"
  624. "ins" "insp" "inspe" "inspec" "inspect"
  625. "integ" "intreg" "ir" "iri" "ivreg"
  626. "kap" "kappa" "kapwgt" "kdensity" "ksm" "ksmirnov" "ktau"
  627. "kwallis"
  628. ) font-lock-reference-face)
  629. "\\b"
  630. ))
  631. (eval-when-compile
  632. (make-regexps
  633. "[ \t]+"
  634. '((
  635. "l" "ladder" "lfit" "lincom" "linktest"
  636. "li" "lis" "list"
  637. "log"
  638. "logistic"
  639. "logi" "logit"
  640. "loneway" "lookfor"
  641. "lo" "loo" "look" "looku" "lookup"
  642. "lpredict" "lroc" "lrtest" "ls" "lsens" "lstat" "ltable" "lv" "lvr2plot"
  643. "man" "matcproc" "mcc" "mcci"
  644. "means"
  645. "mlog" "mlogi" "mlogit"
  646. "mor" "more"
  647. "mvreg" "mx_param"
  648. "n" "nbreg" "newey" "news"
  649. "nl" "nlinit"
  650. "no" "noi" "nois" "noisi" "noisil" "noisily"
  651. "note" "notes"
  652. "nptrend" "numlist"
  653. "olog" "ologi" "ologit"
  654. "ologitp"
  655. "on" "one" "onew" "onewa" "oneway"
  656. "oprob" "oprobi" "oprobit"
  657. "oprobitp"
  658. "orthog" "orthpoly"
  659. "ovtest")
  660. font-lock-reference-face)
  661. "\\b"
  662. ))
  663. (eval-when-compile
  664. (make-regexps
  665. "[ \t]+"
  666. '(("pac" "pchart" "pchi" "pcorr" "pergram"
  667. "pl" "plo" "plot"
  668. "pnorm" "poisgof" "poisson" "pperron"
  669. "prais"
  670. "prob" "probi" "probit"
  671. "prtest" "prtesti"
  672. "pwcorr" "pwd"
  673. "q" "qchi" "qnorm" "qqplot" "qreg" "quadchk" "quantile"
  674. "qu" "que" "quer" "query"
  675. "qui" "quie" "quiet" "quietl" "quietly"
  676. "ranksum" "rchart" "regdw" "regph"
  677. "reg" "reg3" "regr" "regre" "regres" "regress" "reshape"
  678. "rot" "rota" "rotat" "rotate"
  679. "rreg"
  680. "run" "runtest" "rvfplot" "rvpplot"
  681. ) font-lock-reference-face)
  682. "\\b"
  683. ))
  684. (eval-when-compile
  685. (make-regexps
  686. "[ \t]+"
  687. '((
  688. "sampsi" "sconfirm"
  689. "sco" "scobit" "scor" "score"
  690. "sdtest" "sdtesti" "search" "serrbar"
  691. "sfrancia" "shell" "shelltool" "shewhart" "signrank" "signtest"
  692. "sktest" "slog" "spearman" "spikeplt" "sqreg"
  693. "st" "st_is" "st_show" "st_ct"
  694. "stcox" "stcoxkm" "stcurv" "stdes"
  695. "stem"
  696. "stereg" "stir" "stmc" "stmh" "stphplot" "stphtest"
  697. "strate" "streg"
  698. "sts" "stse" "stset" "stsum" "stvary" "stweib"
  699. "su" "sum" "summ" "summa" "summar" "summari" "summariz" "summarize"
  700. "sureg"
  701. "svydes" "svyintrg" "svyivreg" "svylc" "svylogit"
  702. "svymean" "svymean" "svymlog" "svyolog" "svyoprob" "svypois" "svyprobt"
  703. "svyprop" "svyratio" "svyreg" "svyset" "svytab" "svytest" "svytotal"
  704. "swilk" "symmetry" "symmi" "symplot" "syntax" "sysdir"
  705. ) font-lock-reference-face)
  706. "\\b"
  707. ))
  708. (eval-when-compile
  709. (make-regexps
  710. "[ \t]+"
  711. '((
  712. "ta" "tab"
  713. "tab1" "tab2"
  714. "tabdisp"
  715. "tabi"
  716. "table"
  717. "tabu" "tabul" "tabula" "tabulat" "tabulate"
  718. "te" "tes" "test"
  719. "testnl" "testparm" "tis"
  720. "tob" "tobi" "tobit"
  721. "token" "tokeni" "tokeniz" "tokenize"
  722. "touch" "tsreport" "tsset" "tsunab" "ttest" "ttesti"
  723. "ty" "typ" "type"
  724. "unab" "using"
  725. "vce"
  726. "verinst" "vif" "vwls"
  727. "weibull" "which" "who" "wntestb" "wntestq"
  728. "xchart" "xcorr"
  729. "xtclog" "xtdes" "xtgee" "xtgls" "xthaus" "xtintreg"
  730. "xtlogit" "xtnbreg" "xtpois" "xtprobit"
  731. "xtrchh" "xtreg" "xtsum" "xttab" "xttest0" "xttobit" "xttrans"
  732. "zip" "zinb"
  733. ) font-lock-reference-face)
  734. "\\b"
  735. ))
  736. ;; conditional statements
  737. ;; if might not work right ('cuz it is also a keyword)
  738. (eval-when-compile
  739. (make-regexps
  740. "^[ \t]*\\sw+[ \t]*"
  741. '(("if"
  742. ) font-lock-reference-face t t)
  743. "\\b"
  744. ))
  745. (eval-when-compile
  746. (make-regexps
  747. "^[ \t]*"
  748. '(("if" "while"
  749. ) font-lock-reference-face t t)
  750. "[ \t]+.*{"
  751. ))
  752. ;; else statement (which must just have a {)
  753. (eval-when-compile
  754. (make-regexps
  755. "^[ \t]*"
  756. '(("else"
  757. ) font-lock-reference-face)
  758. "[ \t]*{"
  759. ))
  760. ;; short version of list --- which can get fooled if used as a var
  761. (eval-when-compile
  762. (make-regexps
  763. '(("^[ \t]*l\\b"
  764. ) font-lock-reference-face)
  765. ))
  766. ;; all the Stata options
  767. ;; commonly used options
  768. (eval-when-compile
  769. (make-regexps
  770. "[ \t]+"
  771. '(("byte" "int" "long" "str[1-9]+[0-9]?" "float" "double"
  772. "width" "maxobs" "maxvar"
  773. ) font-lock-type-face)
  774. "[ \t]+"
  775. ))
  776. ;; special local variables (used in parsing)
  777. (eval-when-compile
  778. (make-regexps
  779. "^[ \t]+\\(local\\)+[ \t]+"
  780. '(("varlist" "exp" "weight" "if" "in" "using" "options"
  781. ) font-lock-type-face nil t t)
  782. "\\b"
  783. ))
  784. ;; things used with display
  785. ;; since these are often split across lines, and Stata commands are hard
  786. ;; to delimit, this will highlight even if out of context
  787. (eval-when-compile
  788. (make-regexps
  789. "[ \t]+"
  790. '((
  791. "_c" "_co" "_con" "_cont" "_conti" "_contin" "_continu" "_continue"
  792. "_n" "_ne" "_new" "_newl" "_newli" "_newlin" "_newline"
  793. "_quote"
  794. "_r" "_re" "_req" "_requ" "_reque" "_reques" "_request"
  795. )
  796. font-lock-type-face)
  797. "\\b"
  798. ))
  799. (eval-when-compile
  800. (make-regexps
  801. "[ \t]+"
  802. '((
  803. "_col" "_colu" "_colum" "_column"
  804. "_d" "_du" "_dup"
  805. "_s" "_sk" "_ski" "_skip"
  806. )
  807. font-lock-type-face)
  808. "([1-9]+[0-9]*)\\b"
  809. ))
  810. (eval-when-compile
  811. (make-regexps
  812. "\\bin[ \t]+"
  813. '((
  814. "b" "bl" "blu" "blue"
  815. "g" "gr" "gre" "gree" "green"
  816. "r" "re" "red"
  817. "w" "wh" "whi" "whit" "white"
  818. "y" "ye" "yel" "yell" "yello" "yellow"
  819. ) font-lock-type-face)
  820. "\\b"
  821. ))
  822. ;; labels
  823. (eval-when-compile
  824. (make-regexps
  825. "[ \t]+"
  826. '(("lab" "labe" "label"
  827. ) font-lock-reference-face t)
  828. "[ \t]+"
  829. '((
  830. "da" "dat" "data"
  831. "de" "def" "defi" "defin" "define"
  832. "di" "dir"
  833. "drop"
  834. "l" "li" "lis" "list"
  835. "save"
  836. "val" "valu" "value" "values"
  837. "var" "vari" "varia" "variab" "variabl" "variable"
  838. ) font-lock-type-face nil t t)
  839. "[ \t]"
  840. ))
  841. ;; all Stata data-altering stuff
  842. (eval-when-compile
  843. (make-regexps
  844. "\\b"
  845. '((
  846. "_pctile" "_predict"
  847. "aorder" "append"
  848. "bcskew0" "bsample" "bs" "bstrap"
  849. "cd" "chdir" "clear" "compress"
  850. "contract" "convert" "cross"
  851. "dec" "deco" "decod" "decode"
  852. "discard" "drop" "dydx"
  853. "ed" "edi" "edit" "egen"
  854. "en" "enc" "enco" "encod" "encode"
  855. "erase"
  856. "expand"
  857. "fillin"
  858. "form" "forma" "format"
  859. "fracgen" "fracpred"
  860. "g" "ge" "gen" "gene" "gener" "genera" "generat" "generate"
  861. "gsort"
  862. "impute"
  863. "infile" "infix" "input" "insheet" "integ" "ipolate"
  864. "joinby"
  865. "keep"
  866. "lnskew0"
  867. ) font-lock-keyword-face)
  868. "\\b"
  869. ))
  870. (eval-when-compile
  871. (make-regexps
  872. "\\b"
  873. '((
  874. "mark" "markout" "marksample"
  875. "matname"
  876. "mer" "merg" "merge"
  877. "mkdir" "mkmat" "mkspline"
  878. "mleval" "mlmatsum" "mlsum""mlvecsum"
  879. "modify" "mov" "move"
  880. "mvdecode" "mvencode" "nlpred" "nobreak" "order"
  881. "ou" "out" "outf" "outfi" "outfil" "outfile"
  882. "outs" "outsh" "outshe" "outshee" "outsheet"
  883. "pctile"
  884. "post" "postclose" "postfile"
  885. "pre" "pred" "predi" "predic" "predict"
  886. "preserve" "range"
  887. "recast" "recode"
  888. "ren" "rena" "renam" "rename"
  889. "renpfix" "replace" "restore" "rm"
  890. "sappend"
  891. "sa" "sav" "save"
  892. "sample" "sdrop"
  893. "separate"
  894. "simul" "sinfile" "smerge"
  895. "smooth" "snapspan"
  896. "so" "sor" "sort"
  897. "ssave" "ssort" "stack"
  898. "stbase" "stfill" "stgen" "stjoin" "stsplit" "sttocc" "sttoct"
  899. "suse" "svmat"
  900. "tsfill" "tsrevar"
  901. "u" "us" "use"
  902. "xi" "xi:" "xtile" "xpose"
  903. "xtdata" "xtpred"
  904. ) font-lock-keyword-face)
  905. "\\b"
  906. ))
  907. ;; assignment of macros
  908. (eval-when-compile
  909. (make-regexps
  910. "^[ \t]*"
  911. '(("global" "local" "scalar"
  912. ) font-lock-reference-face)
  913. '(("\\([ \t]+[a-zA-Z_]+[a-zA-Z_0-9]*\\b\\)?"
  914. ) font-lock-variable-name-face t)
  915. ))
  916. ;; choosing temp names
  917. (eval-when-compile
  918. (make-regexps
  919. "^[ \t]*"
  920. '(("tempname" "tempfile" "tempvar"
  921. ) font-lock-reference-face)
  922. '(("\\([ \t]+[a-zA-Z_]+[a-zA-Z_0-9`']*\\)+"
  923. ) font-lock-type-face t)
  924. ))
  925. ;; all variable/macro stuff (put late so it will override)
  926. ;; internal constants
  927. (eval-when-compile
  928. (make-regexps
  929. "[^a-zA-Z]"
  930. '(("_merge" "_n" "_pi" "_rc" "_N"
  931. ) font-lock-variable-name-face)
  932. "[^a-zA-Z]"
  933. ))
  934. ;; some generated vars
  935. (eval-when-compile
  936. (make-regexps
  937. '(("_result([1-9]+)"
  938. ) font-lock-variable-name-face)
  939. ))
  940. ;; global macros
  941. (eval-when-compile
  942. (make-regexps
  943. '(("\\$[a-zA-Z_*]+[a-zA-Z_0-9]*"
  944. ) font-lock-variable-name-face t)
  945. ))
  946. ;; local macros
  947. (eval-when-compile
  948. (make-regexps
  949. "`+"
  950. '(("[a-zA-Z_`*]+[a-zA-Z_0-9]*" ;has glitch interior ` is highlighted
  951. ) font-lock-variable-name-face t)
  952. "'+"
  953. ))
  954. ;; other macro commands
  955. (eval-when-compile
  956. (make-regexps
  957. "[ \t]*"
  958. '((
  959. "ma" "mac" "macr" "macro"
  960. ) font-lock-reference-face)
  961. "[ \t]+"
  962. '((
  963. "de" "def" "define"
  964. "di" "dir"
  965. "drop"
  966. "l" "li" "lis" "list"
  967. "s" "sh" "shi" "shif" "shift"
  968. )
  969. font-lock-type-face)
  970. "[ \t]+"
  971. ))
  972. ;; stata 'functions' i.e. things which require () after them
  973. (eval-when-compile
  974. (make-regexps
  975. "\\b"
  976. '(("_caller"
  977. "abs" "acos" "asin" "atan" "autocode"
  978. "Binomial"
  979. "binorm"
  980. "chiprob" "comb" "cond" "cos"
  981. "d" "date" "digamma" "day"
  982. "dofh" "dofm" "dofq" "dofw" "dofy" "dow" "doy"
  983. "e" "exp"
  984. "float" "fprob" "gammap" "get" "group"
  985. "h" "halfyear" "halfyearly" "hofd"
  986. "ibeta" "index" "int"
  987. "invbinomial" "invchi" "invfprob" "invgammap" "invnchi" "invnorm" "invt"
  988. "length" "ln" "lnfact" "lngamma" "log" "log10" "lower" "ltrim"
  989. "m" "matrix" "max" "mdy" "min" "missing" "mod" "mofd" "month" "monthly"
  990. "nchi" "normd" "normprob" "npnchi"
  991. "q" "qofd" "quarter" "quarterly"
  992. "r" "real" "recode" "reldif" "replay" "return" "round" "rtrim"
  993. "s" "scalar" "sign" "sin" "sqrt" "string" "substr" "sum"
  994. "tan" "tprob" "trigamma" "trim"
  995. "uniform" "uniform0" "upper"
  996. "w" "week" "weekly" "wofd"
  997. "y" "year" "yearly" "yh" "ym" "yofd" "yq" "yw"
  998. )
  999. font-lock-reference-face t)
  1000. "("
  1001. ))
  1002. ;; stata 'functions' i.e. things which require [] after them
  1003. (eval-when-compile
  1004. (make-regexps
  1005. "\\b"
  1006. '(("_b" "_coef" "_se")
  1007. font-lock-reference-face t)
  1008. "\\["
  1009. ))
  1010. ;; common Stata options which require a () after them
  1011. (eval-when-compile
  1012. (make-regexps
  1013. "[, \t]+"
  1014. '(("bands" "by" "connect" "density" "gap" "iterate" "ltolerance" "margin"
  1015. "psize" "saving" "tlabel" "tolerance"
  1016. "xlabel" "xscale" "ylabel" "yscale")
  1017. font-lock-type-face t)
  1018. "("
  1019. ))
  1020. ;; egen 'function' options
  1021. (eval-when-compile
  1022. (make-regexps
  1023. "[ \t]*egen[ \t]+.*=[ \t]*"
  1024. '(("count" "diff" "fill" "group" "iqr"
  1025. "ma" "max" "mean" "median" "min" "mtr" "pctile"
  1026. "rank" "rfirst" "rlast" "rmax" "rmean" "rmin" "rmiss" "robs" "rsd" "rsum"
  1027. "sd" "std" "sum")
  1028. font-lock-reference-face t)
  1029. "(.*)"
  1030. ))
  1031. ;; All Custom ado files which are 'reliable' and which are not file killers
  1032. ;; this might be a useless endeavor --- but I cannot generate tag files
  1033. ;; all the s-extensions are listed under Stata's name (since they alter
  1034. ;; data and will be moved to the utils directory
  1035. (eval-when-compile
  1036. (make-regexps
  1037. "[ \t]*"
  1038. '(("addnote" "anypath" "autolab" "checkvar" "ck1icd9" "ckicd9"
  1039. "datetoe" "dattomdy" "den2dem" "dishis" "dtapath" "dupclean" "echo"
  1040. "exdupbil" "ezip2hsa" "getdate" "getlbl" "getnames" "getobs" "gplur"
  1041. "icd9" "issorted" "isfile" "jultoe" "jultof" "jultomdy" "knowndup"
  1042. "labeldir" "linker"
  1043. "markit" "makewide" "missize" "mpcounts"
  1044. "nodups" "notefile" "prov2zip"
  1045. "qcolsum" "qorder"
  1046. "random" "readraw" "readzip" "repart"
  1047. "setup" "stdrate"
  1048. "timeslot"
  1049. "wdatetoe" "wdatomdy" "zip2ezip"
  1050. "_addext" "_brclean" "_brckado" "_brdlog"
  1051. "_ckbad" "_ckdunno" "_ckdupl" "_ckmiss" "_ckok" "_ckwarn"
  1052. "_delimit" "_filenm" "_lookup" "_mk_ck"
  1053. ) font-lock-function-name-face)
  1054. "\\b"
  1055. ))
  1056. ))
  1057. (defvar ess-STA-mode-font-lock-defaults (ado-set-font-lock-keywords)
  1058. "Set the Stata mode font-lock keywords to Bill Rising's ado-mode keywords.")
  1059. (defvar STA-editing-alist
  1060. '((paragraph-start . (concat "[ \t\f]*$\\|" page-delimiter))
  1061. (paragraph-separate . (concat "[ \t\f]*$\\|" page-delimiter))
  1062. (paragraph-ignore-fill-prefix . t)
  1063. (comment-column . 40)
  1064. ;;(comment-indent-function . 'S-comment-indent)
  1065. ;;(ess-comment-indent . 'S-comment-indent)
  1066. ;;(ess-calculate-indent . 'ess-calculate-indent)
  1067. (ess-local-process-name . nil)
  1068. ;;(ess-keep-dump-files . 'ask)
  1069. (font-lock-defaults . '(ess-STA-mode-font-lock-defaults
  1070. nil nil ((?\. . "w")))))
  1071. "General options for editing Stata do and ado source files.")
  1072. ;; YOU USED TO HAVE TO (with Thomas's version):
  1073. ;;;;; Add the following to your .emacs file
  1074. ;;
  1075. ;;(autoload 'stata "~/ess-sta-l.el" "inferior stata mode" t )
  1076. ;;(autoload 'stata-help "stata" "stata help mode" t)
  1077. ;;(autoload 'stata-mode "~/ess-sta-l.el" "stata mode" t)
  1078. ;;
  1079. ;;(if (assoc "\\.do$" auto-mode-alist) nil
  1080. ;; (setq auto-mode-alist
  1081. ;; (append
  1082. ;; '(("\\.do$" . stata-mode)
  1083. ;; ("\\.ado$" . stata-mode))
  1084. ;; auto-mode-alist)))
  1085. ;;
  1086. ;; QUESTIONS TO ASK THOMAS:
  1087. ;; 1 - are 'help' and 'lookup' the same?
  1088. ;; 2 - what is the point of the review buffer?
  1089. ;; 3 - how to quit?
  1090. ;;
  1091. ;; NOTE: all of Thomas's functions have been left here, to be removed
  1092. ;; or merged into real locations as we work on this.
  1093. ;;
  1094. ;;;;;;;;; Things to change
  1095. (defvar stata-switches "-q"
  1096. "Switches to apply to stata invocation.")
  1097. (defvar stata-profile "~/.stataprofile"
  1098. "File to read on startup (nil for no file).")
  1099. (define-obsolete-function-alias 'stata-help 'ess-display-help-on-object "ESS[15.09]")
  1100. (define-obsolete-function-alias 'stata-lookup 'ess-display-help-apropos "ESS[16.03]")
  1101. ;; fixme? Hook this on C-c C-s /ess-execute-search does an R search() right now/
  1102. (defun stata-variables ()
  1103. "Stata variable list in other buffer."
  1104. (interactive)
  1105. (let* ((stata-process (get-process "stata"))
  1106. (stata-buffer (if stata-process
  1107. (process-buffer stata-process)
  1108. (error "Stata is not running.")))
  1109. oldpf oldpb oldpm)
  1110. (set-buffer stata-buffer)
  1111. (setq oldpf (process-filter stata-process))
  1112. (setq oldpb (process-buffer stata-process))
  1113. (setq oldpm (marker-position (process-mark stata-process)))
  1114. (save-excursion
  1115. (if stata-process nil (error "Stata is not running."))
  1116. (beginning-of-line)
  1117. (if (looking-at ". ") nil (error "Stata not ready."))
  1118. (save-excursion
  1119. (set-process-buffer stata-process
  1120. (get-buffer-create "*stata variables*"))
  1121. (set-process-filter stata-process 'inferior-ess-ordinary-filter)
  1122. (set-buffer "*stata variables*")
  1123. (setq buffer-read-only nil)
  1124. (erase-buffer)
  1125. (process-send-string stata-process "desc \n ")
  1126. (stata-prompt-wait stata-process)
  1127. (setq buffer-read-only t)
  1128. (set-buffer stata-buffer)
  1129. (set-process-buffer stata-process oldpb)
  1130. (set-marker (process-mark stata-process) oldpm)
  1131. (set-process-filter stata-process oldpf)))
  1132. (display-buffer "*stata variables*")
  1133. (goto-char (point-max))))
  1134. (defun stata-prompt-wait (proc &optional start-of-output)
  1135. "Wait for a prompt to appear at BOL of current buffer.
  1136. PROC is the stata process. Does not change point."
  1137. (if start-of-output nil (setq start-of-output (point-min)))
  1138. (save-excursion
  1139. (while (progn
  1140. ;; get output if there is some ready
  1141. (accept-process-output proc 0 50)
  1142. (goto-char (marker-position (process-mark proc)))
  1143. (beginning-of-line)
  1144. (if (< (point) start-of-output) (goto-char start-of-output))
  1145. (not (looking-at "^. "))))))
  1146. (cl-defmethod ess--help-major-mode (&context (ess-dialect "stata"))
  1147. (ess-stata-help-mode))
  1148. (define-derived-mode ess-stata-help-mode ess-help-mode "Stata help"
  1149. "Major mode for displaying Stata help in a read-only buffer.
  1150. Active commands are Help (\\[stata-help]) and hyperlink
  1151. (\\[stata-rehelp] or mouse-2)."
  1152. :group 'ess-Stata)
  1153. ;;; Suggested function from Brendan Halpin:
  1154. (defvar ess-STA-delimit-do-file "delimit-do.do")
  1155. (defun ess-STA-delimit-do ()
  1156. (save-excursion
  1157. (let ((commands (buffer-substring-no-properties (region-beginning)
  1158. (region-end))))
  1159. (set-buffer (get-buffer-create ess-STA-delimit-do-file))
  1160. (delete-region (point-min) (point-max))
  1161. (insert "#delimit ;\n"
  1162. commands
  1163. "\n#delimit cr\n")
  1164. (write-file ess-STA-delimit-do-file nil)
  1165. (comint-send-string "Stata"
  1166. (format "do %s \n" ess-STA-delimit-do-file)))))
  1167. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1168. (provide 'ess-stata-lang)
  1169. ;;; ess-stata-lang.el ends here