#
# old_revision [b43d4d7119d30c6d8535b5942fa664f6f78137b8]
#
# patch "ada-skel.el"
#  from [3c2af06be903b3cb7301d3dfcccef9739b0bec5b]
#    to [0564777897f13a5e098f58c092e33b5e5ef1233e]
#
============================================================
--- ada-skel.el	3c2af06be903b3cb7301d3dfcccef9739b0bec5b
+++ ada-skel.el	0564777897f13a5e098f58c092e33b5e5ef1233e
@@ -98,6 +98,24 @@
   "for " _ " loop\n"
   "end loop " str | -1 ";")
 
+(define-skeleton ada-skel-function
+  "Insert a function body with an optional name (from `str')."
+  ()
+  "function " str _ " return {return_type} is\n"
+  "begin\n"
+  "return " str ";\n"
+  "end " str | -1 ";")
+
+(define-skeleton ada-skel-function-x
+  "Insert an elaborate function body with an optional name (from `str')."
+  ()
+  "function " str " (" _ ") return {return_type} is\n"
+  "Result : {return_type};\n"
+  "begin\n"
+  "return Result;\n"
+  "exception when others => return " str | -1 ";\n"
+  "end " str | -1 ";")
+
 (define-skeleton ada-skel-if
   "Insert an if statement."
   ()
@@ -155,28 +173,41 @@ See `ada-find-other-file' to create libr
 ;;;;; token alist
 
 (defconst ada-skel-token-alist
-  '(("case" . ada-skel-case)
-    ("declare" . ada-skel-declare)
-    ("for" . ada-skel-for)
-    ("if" . ada-skel-if)
-    ("loop" . ada-skel-loop)
-    ("package" . ada-skel-package)
-    ("record" . ada-skel-record)
-    ("select" . ada-skel-select)
-    ("task" . ada-skel-task)
-    ("while" . ada-skel-while))
+  '(("case" . (ada-skel-case))
+    ("declare" . (ada-skel-declare))
+    ("for" . (ada-skel-for))
+    ("function" . (ada-skel-function   ada-skel-function-x))
+    ("if" . (ada-skel-if))
+    ("loop" . (ada-skel-loop))
+    ("package" . (ada-skel-package))
+    ("record" . (ada-skel-record))
+    ("select" . (ada-skel-select))
+    ("task" . (list ada-skel-task))
+    ("while" . (list ada-skel-while)))
   "alist of skeletons, indexed by a string. See `ada-skel-expand'.
 The string is normally the first Ada keyword in the skeleton, but can be anything.")
 
+(defun ada-skel-of-token (token)
+  "Find a skeleton associated with TOKEN in `ada-skel-token-alist'.
+If `current-prefix-arg' has a true value, then find the one that
+inserts more detail, if available.  The former otherwise."
+  (let ((avail (assoc-string token ada-skel-token-alist 'case-fold)))
+    (if avail
+        (if current-prefix-arg
+            (or (nth 2 avail) (nth 1 avail))
+          (nth 1 avail))
+      nil)))
+
 ;;;###autoload
 (defun ada-skel-expand (&optional name)
   "Expand the word before point to a skeleton, as defined by `ada-skel-token-alist'.
 If the word before point is not in `ada-skel-token-alist', assume
 it is a name, and use the word before that as the token."
   (interactive "*")
+  (skip-syntax-backward " ") ;; closing in
   (let* ((end (prog1 (point) (skip-syntax-backward "w_")))
 	 (token (buffer-substring-no-properties (point) end))
-	 (skel (cdr (assoc-string token ada-skel-token-alist))))
+	 (skel (ada-skel-of-token token)))
     (if skel
 	(progn
 	  ;; delete token and name. point is currently before token.
