Spelling fixes.
[bpt/emacs.git] / lisp / cedet / srecode / fields.el
index f335b0f..f4d34a0 100644 (file)
@@ -1,6 +1,6 @@
 ;;; srecode/fields.el --- Handling type-in fields in a buffer.
 ;;
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
 ;;
 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
 
@@ -35,6 +35,8 @@
 ;; Each field has 2 overlays.  The second overlay allows control in
 ;; the character just after the field, but does not highlight it.
 
+;; @TODO - Cancel an old field array if a new one is about to be created!
+
 ;; Keep this library independent of SRecode proper.
 (require 'eieio)
 
   "While inserting a set of fields, collect in this variable.
 Once an insertion set is done, these fields will be activated.")
 
+\f
+;;; Customization
+;;
+
 (defface srecode-field-face
   '((((class color) (background dark))
      (:underline "green"))
@@ -51,6 +57,11 @@ Once an insertion set is done, these fields will be activated.")
   "*Face used to specify editable fields from a template."
   :group 'semantic-faces)
 
+(defcustom srecode-fields-exit-confirmation nil
+  "Ask for confirmation before leaving field editing mode."
+  :group 'srecode
+  :type  'boolean)
+
 ;;; BASECLASS
 ;;
 ;; Fields and the template region share some basic overlay features.
@@ -90,7 +101,7 @@ Has virtual :start and :end initializers.")
            ))
 
     ;; Create a temporary overlay now.  We have to use an overlay and
-    ;; not a marker becaues of the in-front insertion rules.  The rules
+    ;; not a marker because of the in-front insertion rules.  The rules
     ;; are backward from what is wanted while typing.
     (setq olay (make-overlay start end (current-buffer) t nil))
     (overlay-put olay 'srecode-init-only t)
@@ -187,7 +198,7 @@ If SET-TO is a string, then replace the text of OLAID wit SET-TO."
   (oset ir fields srecode-field-archive)
   (setq srecode-field-archive nil)
 
-  ;; Initailize myself first.
+  ;; Initialize myself first.
   (call-next-method)
   )
 
@@ -237,7 +248,7 @@ If SET-TO is a string, then replace the text of OLAID wit SET-TO."
        (remove-hook 'post-command-hook 'srecode-field-post-command t)
       (if (srecode-point-in-region-p ar)
          nil ;; Keep going
-       ;; We moved out of the temlate.  Cancel the edits.
+       ;; We moved out of the template.  Cancel the edits.
        (srecode-delete ar)))
     ))
 
@@ -313,7 +324,7 @@ Try to use this to provide useful completion when available.")
   )
 
 (defvar srecode-field-replication-max-size 100
-  "Maximum size of a field before cancelling replication.")
+  "Maximum size of a field before canceling replication.")
 
 (defun srecode-field-mod-hook (ol after start end &optional pre-len)
   "Modification hook for the field overlay.
@@ -327,7 +338,7 @@ PRE-LEN is used in the after mode for the length of the changed text."
           (inhibit-modification-hooks t)
           )
       ;; Sometimes a field is deleted, but we might still get a stray
-      ;; event.  Lets just ignore those events.
+      ;; event.  Let's just ignore those events.
       (when (slot-boundp field 'overlay)
        ;; First, fixup the two overlays, in case they got confused.
        (let ((main (oref field overlay))
@@ -429,7 +440,8 @@ PRE-LEN is used in the after mode for the length of the changed text."
 (defun srecode-field-exit-ask ()
   "Ask if the user wants to exit field-editing mini-mode."
   (interactive)
-  (when (y-or-n-p "Exit field-editing mode? ")
+  (when (or (not srecode-fields-exit-confirmation)
+           (y-or-n-p "Exit field-editing mode? "))
     (srecode-delete (srecode-active-template-region))))