Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
4875d6c1
Commit
4875d6c1
authored
Sep 13, 2010
by
Sébastien Villemot
Browse files
Added Dynare mode for Emacs contributed by Yannick Kalantzis
parent
c47b1775
Changes
3
Hide whitespace changes
Inline
Side-by-side
dynare.el
0 → 100644
View file @
4875d6c1
;;; dynare.el --- major mode to edit .mod files for dynare
;; Created: 2010 Sep 10
;; Version: 0.1
;; Copyright (C) 2010 Yannick Kalantzis
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, see
;; <http://www.gnu.org/licenses/>.
;; Keywords: dynare
;; To comment/uncomment, use `ALT-;'. See `comment-dwim' for further details.
;;; Installation:
;;
;; Put the this file as "dynare.el" somewhere on your load path, then
;; add this to your .emacs or site-init.el file:
;;
;; (require 'dynare)
;; (autoload 'dynare-mode "dynare" "Enter dynare mode." t)
;; (setq auto-mode-alist (cons '("\\.mod\\'" . dynare-mode) auto-mode-alist))
;;; Changelog
;; 2010-09-07 by Yannick Kalantzis
;; Minor changes. Add `require'. Add builtin operators `;' and `='.
;; 2010-09-06 by Yannick Kalantzis
;; Created.
;; Reproduces Xah Lee's instructions.
;; See <http://xahlee.org/emacs/elisp_syntax_coloring.html>
;; Very basic syntax highlighting: comments, some keywords.
;;; TODO
;; - indentation
;; - blocks templates "model/end", "initval/end", etc.
;; - functions to insert main keywords
;;; Code:
;; function to comment/uncomment text
(
defun
dynare-comment-dwim
(
arg
)
"Comment or uncomment current line or region in a smart way.
For detail, see `comment-dwim'."
(
interactive
"*P"
)
(
require
'newcomment
)
(
let
((
deactivate-mark
nil
)
(
comment-start
"//"
)
(
comment-end
""
))
(
comment-dwim
arg
)))
;; define several class of keywords
(
defvar
dynare-keywords
'
(
"var"
"varexo"
"parameters"
"model"
"initval"
"endval"
"end"
"shocks"
"periods"
"values"
"resid"
"for"
"endfor"
"define"
"in"
)
"dynare keywords."
)
(
defvar
dynare-functions
'
(
"simul"
"steady"
"check"
"rplot"
"dynatype"
)
"dynare functions."
)
;; create the regex string for each class of keywords
(
defvar
dynare-keywords-regexp
(
regexp-opt
dynare-keywords
'words
))
(
defvar
dynare-functions-regexp
(
regexp-opt
dynare-functions
'words
))
;; clear memory
(
setq
dynare-keywords
nil
)
(
setq
dynare-functions
nil
)
;; create the list for font-lock.
;; each class of keyword is given a particular face
(
setq
dynare-font-lock-keywords
`
(
(
,
dynare-functions-regexp
.
font-lock-function-name-face
)
(
,
dynare-keywords-regexp
.
font-lock-keyword-face
)
(
";\\|="
.
font-lock-builtin-face
)
))
;; define the major mode
(
define-derived-mode
dynare-mode
fundamental-mode
"dynare mode"
"dynare is a mode for editing mod files used by dynare."
(
setq
mode-name
"dynare mode"
)
;; modify the keymap
(
define-key
dynare-mode-map
[remap
comment-dwim]
'dynare-comment-dwim
)
;; define C++ style comment “/* ... */” and “// ...”
(
modify-syntax-entry
?\/
". 124b"
dynare-mode-syntax-table
)
;; "/" is the 1st and 2nd char of /* and */ (a-style) and the 2nd char of //
;; (b-style)
(
modify-syntax-entry
?*
". 23"
dynare-mode-syntax-table
)
;; "*" is the 2nd and 1st char of /* and */ (a-style only)
(
modify-syntax-entry
?\n
"> b"
dynare-mode-syntax-table
)
;; newline is the comment-end sequence of b-style comments
;; syntax highlighting
(
setq
font-lock-defaults
'
((
dynare-font-lock-keywords
)))
;; clear memory
(
setq
dynare-keywords-regexp
nil
)
(
setq
dynare-functions-regexp
nil
)
)
(
provide
'dynare
)
;;; dynare.el ends here
license.txt
View file @
4875d6c1
...
...
@@ -305,3 +305,20 @@ License: GPL-2+ with special Autoconf exception
configuration script generated by GNU Autoconf, you may include
it under the same distribution terms that you use for the rest
of that program.
Files: dynare.el
Copyright: 2010, Yannick Kalantzis
License: GPL-3+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>.
windows/dynare.nsi
View file @
4875d6c1
...
...
@@ -52,7 +52,7 @@ Section "Dynare core (preprocessor and M-files)"
SectionIn RO
!insertmacro DETERMINE_CONTEXT
SetOutPath $INSTDIR
File README.txt mexopts.bat ..\license.txt
File README.txt mexopts.bat ..\license.txt
..\dynare.el
SetOutPath $INSTDIR\matlab
File /r ..\matlab\*.m
...
...
@@ -145,6 +145,7 @@ Section "Uninstall"
Delete $INSTDIR\README.txt
Delete $INSTDIR\license.txt
Delete $INSTDIR\mexopts.bat
Delete $INSTDIR\dynare.el
Rmdir /r $INSTDIR\matlab
Rmdir /r $INSTDIR\mex
Rmdir /r $INSTDIR\dynare++
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment