]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/ada-mode/ada-skel.el
ada-mode 5.1.3, wisi 1.0.4
[gnu-emacs-elpa] / packages / ada-mode / ada-skel.el
index 53c513ed6b163f2756723e8a95f986d529d3c7a1..a6216c174252e89df640191948eb30d2ec8c3ec6 100755 (executable)
@@ -1,6 +1,6 @@
 ;;; ada-skel.el --- an extension to Ada mode for inserting statement skeletons
 
-;; Copyright (C) 1987, 1993, 1994, 1996-2013  Free Software Foundation, Inc.
+;; Copyright (C) 1987, 1993, 1994, 1996-2014  Free Software Foundation, Inc.
 
 ;; Authors: Stephen Leake <stephen_leake@stephe-leake.org>
 
 
 ;;;;; user variables, example skeletons intended to be overwritten
 
-(defcustom ada-skel-initial-string "header"
+(defcustom ada-skel-initial-string
+  "{header}
+--  Emacs note: Type C-c C-e with point after the above placeholder
+--
+--  This text was inserted by ada-skel-initial-string;
+--  M-x customize-variable <RET> ada-skel-initial-string <RET>
+--  (info \"(ada-mode)Statement skeletons\")"
   "*String to insert in empty buffer.
 This could end in a token recognized by `ada-skel-expand'."
   :type 'string
@@ -150,7 +156,7 @@ This could end in a token recognized by `ada-skel-expand'."
   "is\n"
   "begin\n"
   _
-  "end " str ";")
+  "end " str ";" >)
 
 (define-skeleton ada-skel-function-spec
   "Insert a function type specification with name from `str'."
@@ -337,7 +343,6 @@ trailing `...' if there are more keys."
       (concat (mapconcat 'car alist-1 " | ") " | ... : "))
   ))
 
-;;;###autoload
 (defun ada-skel-expand (&optional name)
   "Expand the token or placeholder before point to a skeleton, as defined by `ada-skel-token-alist'.
 A token is a symbol in the current syntax.
@@ -405,20 +410,27 @@ it is a name, and use the word before that as the token."
   (if old
       ;; hippie is asking us to try the "next" completion; we don't have one
       nil
-    (let ((pos (point)))
+    (let ((pos (point))
+         (undo-len (if (eq 't pending-undo-list)
+                       0
+                     (length pending-undo-list))))
       (undo-boundary)
       (condition-case nil
          (progn
            (ada-skel-expand)
            t)
        ('error
-        ;; undo ada-case-adjust, motion
-        (undo)
+        ;; undo hook action if any
+        (unless (or (eq 't pending-undo-list)
+                    (= undo-len (length pending-undo-list)))
+          (undo))
+
+        ;; undo motion
         (goto-char pos)
         nil)))))
 
 (defun ada-skel-setup ()
-  "Setup a buffer ada-skel."
+  "Setup a buffer for ada-skel."
   (add-hook 'skeleton-end-hook 'ada-indent-statement nil t)
   (when (and ada-skel-initial-string
             (= (buffer-size) 0))