From: Stefan Monnier Date: Mon, 19 Oct 2015 13:20:23 +0000 (-0400) Subject: * f90-interface-browser: Merge from upstream X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/3804f2992d7381416b96c75e280c9ad252b3108c?hp=-c * f90-interface-browser: Merge from upstream --- 3804f2992d7381416b96c75e280c9ad252b3108c diff --combined packages/f90-interface-browser/f90-interface-browser.el index 604c2f1a7,5761b8722..d499ba021 --- a/packages/f90-interface-browser/f90-interface-browser.el +++ b/packages/f90-interface-browser/f90-interface-browser.el @@@ -1,12 -1,11 +1,12 @@@ ;;; f90-interface-browser.el --- Parse and browse f90 interfaces -;; Copyright (C) 2011, 2012 Free Software Foundation, Inc +;; Copyright (C) 2011, 2012, 2013, 2014 Free Software Foundation, Inc ;; Author: Lawrence Mitchell ;; 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 @@@ -165,7 -164,10 +165,10 @@@ unqualified filename. "Hash table populated with all known f90 interfaces.") (defvar f90-types (make-hash-table :test 'equal) - "Hash table populated with all known f90 derived types.") + "Hash table populated with all known f90 derived types. + The keys are type names and the values are lists of pairs of the form + \(NAME . REST) where NAME is the name of a slot of that type and REST + describes that slot.") ;;; Inlineable utility functions (defsubst f90-specialisers (name interfaces) @@@ -201,10 -203,7 +204,7 @@@ level. For example, a LEVEL of 0 count (defsubst f90-get-slot-type (slot type) "Get the type of SLOT in TYPE." - (let ((fn (intern-soft (format "f90-type.%s.%s" - (f90-get-parsed-type-typename type) slot)))) - (when fn - (funcall fn (f90-get-type type))))) + (assoc slot (f90-get-type type))) (defsubst f90-merge-into-tags-completion-table (ctable) "Merge completions in CTABLE into the tags completion table." @@@ -283,7 -282,7 +283,7 @@@ the word at point. If MATCH-SUBLIST i the arglist is a sublist of the specialiser's arglist. For more details see `f90-approx-arglist-match' and `f90-browse-interface-specialisers'." - (interactive (let ((def (word-at-point))) + (interactive (let ((def (thing-at-point 'symbol))) (list (completing-read (format "Find interface/tag (default %s): " def) (f90-lazy-completion-table) @@@ -308,7 -307,7 +308,7 @@@ which ARGLIST-TO-MATCH is a sublist of If INVOCATION-POINT is non-nil it should be a `point-marker' indicating where we were called from, for jumping back to with `pop-tag-mark'." - (interactive (let ((def (word-at-point))) + (interactive (let ((def (thing-at-point 'symbol))) (list (completing-read (format "Interface%s: " (if def @@@ -506,26 -505,16 +506,16 @@@ default is the type of the variable. (fundamental-mode) (erase-buffer) (let* ((tname (format "type(%s)" type)) - (type-struct (f90-get-type (list nil tname))) - fns) - (when type-struct - (setq fns (loop for name in (funcall (intern-soft - (format "f90-type.%s.-varnames" - tname)) - type-struct) - collect (intern-soft (format "f90-type.%s.%s" - tname name))))) - (if (null type-struct) + (slots (f90-get-type (list nil tname)))) + (if (null slots) (insert (format "The type %s is not a known derived type." type)) (insert (format "type %s\n" type)) - (loop for fn in fns - for parsed = (funcall fn type-struct) - then (funcall fn type-struct) + (loop for slot in slots do (insert (format " %s :: %s\n" - (f90-format-parsed-slot-type parsed) - (f90-get-parsed-type-varname parsed)))) + (f90-format-parsed-slot-type slot) + (f90-get-parsed-type-varname slot)))) (insert (format "end type %s\n" type)) (f90-mode)) (goto-char (point-min)) @@@ -564,8 -553,7 +554,8 @@@ (format "%s :: foo" (f90-format-parsed-slot-type x))) arglist "\n"))) (f90-mode) - (font-lock-fontify-buffer) + (if (fboundp 'font-lock-ensure) + (font-lock-ensure) (font-lock-fontify-buffer)) (goto-char (point-min)) (mapconcat 'identity (loop while (not (eobp)) @@@ -594,6 -582,7 +584,6 @@@ first (length ARGLIST) args of SPECIALI (<= n-passed-args n-spec-args))) (loop for arg in arglist for spec-arg in spec-arglist - with match = nil unless (or (null arg) (string= (f90-get-parsed-type-typename arg) (f90-get-parsed-type-typename spec-arg))) @@@ -837,26 -826,7 +827,7 @@@ needs a reference count interface, so i (when slot (setf slots (nconc slot slots))) (forward-line 1)) - (eval (f90-make-type-struct type slots)) - (setq fn (intern-soft (format "make-f90-type.%s" type))) - (unless fn - (error "Something bad went wrong parsing type definition %s" type)) - (setf (gethash type f90-types) (funcall fn)))) - - (defun f90-make-type-struct (type slots) - "Create a struct describing TYPE with SLOTS." - (let ((struct-name (make-symbol (format "f90-type.%s" type))) - (varnames (reverse (mapcar (lambda (x) - (setq x (car x)) - (if (string-match "\\([^(]+\\)(" x) - (match-string 1 x) - x)) slots)))) - `(defstruct (,struct-name - (:conc-name ,(make-symbol (format "f90-type.%s." type)))) - (-varnames ',varnames :read-only t) - ,@(loop for (name . rest) in slots - collect `(,(make-symbol name) (cons ',name ',rest) - :read-only t))))) + (setf (gethash type f90-types) slots))) (defun f90-arglist-types () "Return the types of the arguments to the function at `point'." @@@ -916,7 -886,7 +887,7 @@@ ;; 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 + (loop for (type _name) in types do (insert (format "%s :: %s\n" (f90-format-parsed-slot-type type) @@@ -939,7 -909,7 +910,7 @@@ with slot B of type REAL, then A%B is r collect (save-excursion (save-restriction (when (re-search-forward - (format "^[ \t]*\\([^!\n].+?\\)[ \t]*::.*\\<%s\\>" + (format "^[ \t]*\\([^!\n].+?\\)[ \t]*::.*\\_<%s\\_>" arg) nil t) (goto-char (match-beginning 0)) (let ((type (assoc arg @@@ -1029,12 -999,13 +1000,12 @@@ dealt with correctly. (setcdr (assoc "dimension" dec) (1+ (f90-count-commas (match-string 2 name)))) - (add-to-list 'dec - (cons "dimension" - (1+ (f90-count-commas - (match-string 2 name)))) - t)) + (push (cons "dimension" + (1+ (f90-count-commas + (match-string 2 name)))) + dec)) (setq name (match-string 1 name))) - collect (cons name dec))))) + collect (cons name (nreverse dec)))))) (defun f90-split-declaration (dec) "Split and parse a type declaration DEC.