https://github.com/rosenbrockc/fortpy-el.git
git clone 'git://github.com/rosenbrockc/fortpy-el.git'
Fortpy-el provides an lisp package for emacs that integrates with fortpy to provide context-specific auto-completion and intellisense for Fortran 2003, including object oriented constructs. Auto-completion integration currently only available for emacs.
If you don't already have MELPA added to your packages list, you can execute the following in your *scratch*
buffer (using C-x C-e
.
;; Standard package.el + MELPA setup
;; (See also: https://github.com/milkypostman/melpa#usage)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
Once MELPA is on your package-archives list, execute M-x package-install RET fortpy RET
. After installing the package in emacs, add the following lines to your .emacs
file. Note that if you want it to work right away, you will need to do a C-x C-e
on each line.
;; Standard fortpy.el setting
(add-hook 'f90-mode-hook 'fortpy-setup)
(setq fortpy-complete-on-percent t)
(setq fortpy-complete-on-bracket t)
Finally, run the following command to complete the installation: M-x fortpy-install-server RET
.
In most real-usage scenarios, the out-of-the-box support for multiple libraries is incomplete. A configuration file can be created that gives additional information about source code folders to parse, server information for SSH editing over tramp and auto-completion configuration settings. After you have created a config.xml
file on your system, you need to configure an environment variable to tell Fortpy where to find it:
export FORTPY_CONFIG="~/path/to/config.xml"
NOTE: Environment variables for emacs are set when it first starts; adding a config.xml file will not affect the emacs isense support until you restart emacs.
If you have trouble installing automatically from MELPA, you can also try a manual installation:
M-x fortpy-install-server RET
NOTE: when you run fortpy-install-server
, emacs will use pip install
to add the fortpyepcserver.py to the default virtualenv managed by python-environment for emacs. As part of that setup, pip
will also install fortpy and its dependencies into the virtualenv.
If you are having trouble getting fortpy-install-server
to work, manually run pip install --upgrade virtualenv
and pip install --upgrade epc
outside of emacs. Then delete the ~/.emacs.d/.python-environments/default/ folder and re-run fortpy-install-server
.
If fortpy-install-server
hangs, you may need to install it manually:
pip install -U "/path/to/fortpy-el/directory"
. Take note of the location of the fortpyepcserver.pyc
file (i.e. which site-packages folder it got installed to). You will need this path in the next step.(setq fortpy-server-command '("/usr/bin/python" "/usr/local/lib/python2.7/site-packages/fortpyepcserver.pyc"))
Your python path and fortpyepcserver.pyc
path will likely be different. A complete example is included to help orient you.
Here are some of the things you can do once Fortpy is integrated with Emacs using fortpy.el:
Help with call signatures of functions and subroutines.
Completion suggestions for both methods and variables embedded in user-defined types.
Documentation strings for methods embedded in user-defined types.
Fortpy-el together with the Fortpy backend provide context specific auto-complete suggestions out-of-the-box for existing codes. However, to get the full benefit of the intellisense, you need to add XML Documentation Tags to your Fortran code files that describe the methods, types, members and variables in more detail.