X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/da0d153e1520b5af5d008412187bbcb1d686de48..78c09e0fa23f5b6eb77968b019650829eb5b97b4:/packages/f90-interface-browser/f90-interface-browser.el diff --git a/packages/f90-interface-browser/f90-interface-browser.el b/packages/f90-interface-browser/f90-interface-browser.el index 58ed588de..c33996cc7 100644 --- a/packages/f90-interface-browser/f90-interface-browser.el +++ b/packages/f90-interface-browser/f90-interface-browser.el @@ -5,7 +5,7 @@ ;; Author: Lawrence Mitchell ;; Created: 2011-07-06 ;; Available-from: http://github.com/wence-/f90-iface/ -;; Version: 1.0 +;; Version: 1.1 ;; COPYRIGHT NOTICE @@ -44,6 +44,12 @@ ;; so that you can use it on the M-. keybinding and it will fall back ;; to completing tag names if you don't want to look for an interface ;; definition. +;; In addition, if you're in a large procedure and want the list of +;; the variables in scope (perhaps you want to define a new loop +;; variable), you can use `f90-list-in-scope-vars' to pop up a buffer +;; giving a reasonable guess. Note this doesn't give you module +;; variables, or the variables of parent procedures if the current +;; subroutine is contained within another. ;; Derived types are also parsed, so that slot types of derived types ;; are given the correct type (rather than a UNION-TYPE) when arglist @@ -875,6 +881,51 @@ needs a reference count interface, so insert one." (goto-char (point-min)) (f90-arg-types names)))))) +(defun f90-list-in-scope-vars () + "Pop up a buffer showing all variables in scope in the procedure at `point'" + (interactive) + (let* ((e (save-excursion (f90-end-of-subprogram) (point))) + (b (save-excursion (f90-beginning-of-subprogram) (point))) + (str (buffer-substring-no-properties b e)) + types) + (with-temp-buffer + (with-syntax-table f90-mode-syntax-table + (insert str) + (goto-char (point-min)) + (f90-clean-comments) + (f90-clean-continuation-lines) + (forward-line 1) ; skip procedure name + (let ((not-done t) + type) + (while (and not-done (not (eobp))) + ;; skip "implicit none" which may appear at top of procedure + (when (looking-at "\\s-*implicit\\s-+none") + (forward-line 1)) + (when (not (looking-at "^\\s-*$")) + (setq type (ignore-errors (f90-parse-single-type-declaration))) + ;; If we were on a line with text and failed to parse a + ;; type, we must have reached the end of the type + ;; definitions, so don't push it on and finish. + (if type + (push type types) + (setq not-done nil))) + (forward-line 1))))) + (with-current-buffer (get-buffer-create "*Variables in scope*") + (setq buffer-read-only nil) + (erase-buffer) + (f90-mode) + ;; Show types of the same type together + (setq types (sort types (lambda (x y) + (string< (cadar x) (cadar y))))) + (loop for (type name) in types + do + (insert (format "%s :: %s\n" + (f90-format-parsed-slot-type type) + (f90-get-parsed-type-varname type)))) + (pop-to-buffer (current-buffer)) + (goto-char (point-min)) + (setq buffer-read-only t)))) + (defun f90-arg-types (names) "Given NAMES of arguments return their types.