Welcome, Guest
Username: Password: Remember me

TOPIC: Major mode for Emacs to edit Telemac cas files

Major mode for Emacs to edit Telemac cas files 9 years 7 months ago #16572

  • Lux
  • Lux's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 96
  • Thank you received: 39
Hi all,

In the same idea as j.lhomme did for Notepad++, I share here my configuration for editing cas files with Emacs (which is an extensible and customizable opensource cross-platform editor).

The shared files (link to download is at the end of the post) consist of a major mode written for telemac cas file edition, containing multiple text files and scripts.

Firstly, the telemac .dico files have been parsed and text files generated (with the python3 script: ~/.emacs.d/my-packages/telemac-mode/generate_files_from_all_dico.py).
This first step can be run again to use a different version of telemac, but the generated files (for telemac dico from V7P0R1) are included in the shared files.

The text files are then read by Emacs to define the telemac major mode (itself written in Emacs Lisp) for the different modules of telemac (artemis, postel3d, sisyphe, stbtel, telemac2d, telemac3d and tomawac).

The main features are:
* selection of module and language (to define the right keywords)
* syntax highlighting
* keyword auto-completion
* popup documentation/help of the current keyword (analyzes the current line)

The principle is the following:
The major telemac-mode should be active (can be set automatically with the .cas file extension) and then the functions are accessible (to change the module or the language for example).
It is possible to edit cas files with different modules and/or languages without mixing them (they are defined locally in each buffer).
The module and language are set automatically (deduced from the filename prefix if possible or with the default value), but should be set manually if necessary with the defined functions: telemac-set-module and telemac-toggle-lang.

A documentation is available in the upper commented part of the telemac-mode.el file.

Find below a screenshot combinaison to illustrate the features :

screenshot_telemac-mode.png



Finally, in parsing the dico files, I noticed some problems:
* keyword "OPTION FOR THE DISPERSION" (sisyphe) has no default value in english, but has one in french.
* "LISTING PRINTOUT PERIOD" (telemac2d) is a duplicated keyword in english, but has two different corresponding french keyword.

You will find below a minimal working example in a zip. It includes also the auto-complete Emacs package (which is a recommanded dependencies). After merging ith your ~/.emacs.d, it should work (but it requires a newer version of Emacs, if possible >=24).
A complete implementation example is also avaiblable on my .emacs.d on github).



All suggestions and remarks are welcomed.

Hope it will be useful,
Regards,
Luc
Attachments:
The administrator has disabled public write access.

Major mode for Emacs to edit Telemac cas files 9 years 7 months ago #16574

  • sebourban
  • sebourban's Avatar
  • OFFLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
Thank you very much Luc, this looks like a very mature development.

Again we will incorporate in the enxt release of the system under the \optionals\addons directory.

Your contribution is much appreciated.

Sébastien.

PS: why python 3 already -- do you think it is time for us to think about python 3 ?
The administrator has disabled public write access.

Major mode for Emacs to edit Telemac cas files 9 years 7 months ago #16580

  • Lux
  • Lux's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 96
  • Thank you received: 39
I did in Python3 because I am used to and started from scratch.
The differences with Python2 are not minor but subtile, but there are still some packages which are not supported yet in python3, here is a list for example.
Because there are already a lot of scripts written for python27 for telemac, the conversion can be time-consumming but is recommended for the future. I do not know when it is the approrpiate time to switch to, because it depends on contributors, time to spend, packages, personal opinions/preferences... not an easy question.

Regards,
Luc
The administrator has disabled public write access.

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.