--- /dev/null
+ * Fortran editing helpers for Emacs
+
+ ** Overview
+
+ You write (or work on) large, modern fortran code bases. These make
+ heavy use of function overloading and generic interfaces. Your brain
+ is too small to remember what all the specialisers are called.
+ Therefore, your editor should help you. This is an attempt to do
+ this for Emacs.
+
+ f90-interface-browser.el is a (simple-minded) parser of fortran that
+ understands a little about generic interfaces and derived types.
+
+ ** External functions
+
+ - =f90-parse-interfaces-in-dir= :: Parse all the fortran files in a
+ directory
+ - =f90-parse-all-interfaces= :: Parse all the fortran files in a
+ directory and recursively in its subdirectories
+ - =f90-browse-interface-specialisers= :: Pop up a buffer showing all
+ the specialisers for a particular generic interface (prompted
+ for with completion)
+ - =f90-find-tag-interface= :: On a procedure call, show a list of the
+ interfaces that match the (possibly typed) argument list. If no
+ interface is found, this falls back to =find-tag=.
+ - =f90-list-in-scope-vars= :: List all variables in local scope. This
+ just goes to the top of the current procedure and collects named
+ variables, so it doesn't work with module or global scope
+ variables or local procedures.
+ - =f90-show-type-definition= :: Pop up a buffer showing a derived type
+ definition.
+
+ ** Customisable variables
+
+ - =f90-file-extensions= :: A list of extensions that the parser will
+ use to decide if a file is a fortran file.
+
+ ** Details and caveats
+
+ The parser assumes you write fortran in the style espoused in Metcalf,
+ Reid and Cohen. Particularly, variable declarations use a double
+ colon to separate the type from the name list.
+
+ Here's an example of a derived type definition:
+ #+BEGIN_SRC f90
+ type foo
+ real, allocatable, dimension(:) :: a
+ integer, pointer :: b, c(:)
+ type(bar) :: d
+ end type foo
+ #+END_SRC
+
+ Here's a subroutine declaration:
+ #+BEGIN_SRC f90
+ subroutine foo(a, b)
+ integer, intent(in) :: a
+ real, intent(inout), dimension(:,:) :: b
+ ...
+ end subroutine foo
+ #+END_SRC
+
+ Local procedures whose names conflict with global ones will likely
+ confuse the parser. For example:
+ #+BEGIN_SRC f90
+ subroutine foo(a, b)
+ ...
+ end subroutine foo
+
+ subroutine bar(a, b)
+ ...
+ call subroutine foo
+ ...
+ contains
+ subroutine foo
+ ...
+ end subroutine foo
+ end subroutine bar
+ #+END_SRC
+
+ Also not handled are overloaded operators, scalar precision modifiers,
+ like =integer(kind=c_int)=, for which the precision is just ignored, and
+ many other of the hairier aspects of the fortran language.
;; Author: Lawrence Mitchell <wence@gmx.li>
;; Created: 2011-07-06
-;; Available-from: http://github.com/wence-/f90-iface/
+;; URL: http://github.com/wence-/f90-iface/
;; Version: 1.1
+;; Package-Type: simple
;; COPYRIGHT NOTICE
;;; Code:
;;; Preamble
- (eval-when-compile
- (require 'cl))
+ (require 'cl)
(require 'thingatpt)
(require 'f90)
(require 'etags)
(when fn
(funcall fn (f90-get-type type)))))
- (defun f90-lazy-completion-table ()
- "Lazily produce a completion table of all interfaces and tag names."
- (lexical-let ((buf (current-buffer)))
- (lambda (string pred action)
- (with-current-buffer buf
- (save-excursion
- ;; If we need to ask for the tag table, allow that.
- (let ((enable-recursive-minibuffers t))
- (visit-tags-table-buffer))
- (complete-with-action action (f90-merge-into-tags-completion-table f90-all-interfaces) string pred))))))
-
-
(defsubst f90-merge-into-tags-completion-table (ctable)
"Merge completions in CTABLE into the tags completion table."
(if (or tags-file-name tags-table-list)
table)
ctable))
+ (defun f90-lazy-completion-table ()
+ "Lazily produce a completion table of all interfaces and tag names."
+ (lexical-let ((buf (current-buffer)))
+ (lambda (string pred action)
+ (with-current-buffer buf
+ (save-excursion
+ ;; If we need to ask for the tag table, allow that.
+ (let ((enable-recursive-minibuffers t))
+ (visit-tags-table-buffer))
+ (complete-with-action action (f90-merge-into-tags-completion-table f90-all-interfaces) string pred))))))
+
(defsubst f90-extract-type-name (name)
"Return the typename from NAME.