X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/4cf8c95d95cfa21eb40331ea4c606783f247b196..4e8612f5a9f66454732daa6c35b60453cce05953:/packages/ada-mode/ada-skel.el diff --git a/packages/ada-mode/ada-skel.el b/packages/ada-mode/ada-skel.el old mode 100755 new mode 100644 index 53c513ed6..95442226e --- a/packages/ada-mode/ada-skel.el +++ b/packages/ada-mode/ada-skel.el @@ -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 @@ -67,7 +67,13 @@ ;;;;; 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 ada-skel-initial-string +-- (info \"(ada-mode)Statement skeletons\")" "*String to insert in empty buffer. This could end in a token recognized by `ada-skel-expand'." :type 'string @@ -103,6 +109,10 @@ This could end in a token recognized by `ada-skel-expand'." ) +;; override ada-mode 4.01 autoloaded functions +(define-obsolete-function-alias 'ada-header 'ada-skel-header "24.4" + "Insert a descriptive header at the top of the file.") + ;;;;; Ada skeletons (alphabetical) (define-skeleton ada-skel-accept @@ -139,7 +149,7 @@ This could end in a token recognized by `ada-skel-expand'." (define-skeleton ada-skel-for "Insert a for loop statement with an optional name (from `str')." () - str & ":\n" + str & " :\n" "for " _ " loop\n" "end loop " str | -1 ";") @@ -150,7 +160,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 +347,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 +414,36 @@ 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) + (error + ;; 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-next-placeholder () + "Move point to after next placeholder." + (skip-syntax-forward "^!") + (skip-syntax-forward "w!")) + +(defun ada-skel-prev-placeholder () + "Move point to after previous placeholder." + (skip-syntax-backward "^!")) + (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)) @@ -429,6 +454,8 @@ it is a name, and use the word before that as the token." (provide 'ada-skel) (setq ada-expand 'ada-skel-expand) +(setq ada-next-placeholder 'ada-skel-next-placeholder) +(setq ada-prev-placeholder 'ada-skel-prev-placeholder) (add-hook 'ada-mode-hook 'ada-skel-setup)