Merge changes from emacs-23 branch
[bpt/emacs.git] / lisp / cedet / srecode / fields.el
index f335b0f..ceb5f77 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, 2010 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.
@@ -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)))
     ))
 
@@ -429,10 +440,12 @@ 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))))
 
 
 (provide 'srecode/fields)
 
+;; arch-tag: 00cea6f0-42ac-4b15-b778-46e6db0bfcb5
 ;;; srecode/fields.el ends here