X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/4cf8c95d95cfa21eb40331ea4c606783f247b196..11b82017b758f099f530d3351d37145d87a339a9:/packages/ada-mode/gpr-skel.el diff --git a/packages/ada-mode/gpr-skel.el b/packages/ada-mode/gpr-skel.el old mode 100755 new mode 100644 index 6ce550932..9990f0944 --- a/packages/ada-mode/gpr-skel.el +++ b/packages/ada-mode/gpr-skel.el @@ -1,6 +1,6 @@ ;;; gpr-skel.el --- an extension to Gpr mode for inserting statement skeletons -;; Copyright (C) 2013 Free Software Foundation, Inc. +;; Copyright (C) 2013, 2014 Free Software Foundation, Inc. ;; Authors: Stephen Leake @@ -41,7 +41,7 @@ ;;;;; user variables, example skeletons intended to be overwritten -(defcustom gpr-skel-initial-string "header\nproject" +(defcustom gpr-skel-initial-string "{header}\n{project}" "*String to insert in empty buffer. This could end in a token recognized by `gpr-skel-expand'." :type 'string @@ -94,14 +94,14 @@ Each user will probably want to override this." (define-skeleton gpr-skel-package "Insert a package with name from `str'." - () + "Package name: " "package " str " is\n" _ "end " str ";") (define-skeleton gpr-skel-project "Insert a project with name from `str'." - () + "Project name: " "project " str " is\n" _ "end " str ";") @@ -144,12 +144,11 @@ trailing `...' if there are more keys." (concat (mapconcat 'car alist-1 " | ") " | ... : ")) )) -;;;###autoload (defun skeleton-expand (&optional name) "Expand the token or placeholder before point to a skeleton, as defined by `skeleton-token-alist'. A token is a symbol in the current syntax. A placeholder is a symbol enclosed in generic comment delimiters. -If the word before point is not in `gpr-skel-token-alist', assume +If the word before point is not in `skeleton-token-alist', assume it is a name, and use the word before that as the token." (interactive "*") @@ -213,17 +212,32 @@ 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 (sequencep pending-undo-list) (length pending-undo-list) 0))) (undo-boundary) (condition-case nil (progn (skeleton-expand) t) - ('error - ;; undo hook action, motion - (undo) + (error + ;; undo hook action if any + (unless (= undo-len (if (sequencep pending-undo-list) (length pending-undo-list) 0)) + (undo)) + + ;; undo motion (goto-char pos) nil))))) + +(defun skeleton-next-placeholder () + "Move point forward to start of next placeholder." + (interactive) + (skip-syntax-forward "^!")) + +(defun skeleton-prev-placeholder () + "Move point forward to start of next placeholder." + (interactive) + (skip-syntax-backward "^!")) + ;; end FIXME: ;;;;; token alist, setup