]> code.delx.au - gnu-emacs/blobdiff - lisp/wid-edit.el
Add a provide statement.
[gnu-emacs] / lisp / wid-edit.el
index 2392ccdfb4750fb5945a32ab364d176da0caf4a7..f659518ee0298d4700086f0a74d410039987ff5d 100644 (file)
@@ -382,10 +382,11 @@ new value.")
       (setq help-echo 'widget-mouse-help))
     (overlay-put overlay 'button widget)
     (overlay-put overlay 'keymap (widget-get widget :keymap))
+    (overlay-put overlay 'evaporate t)
     ;; We want to avoid the face with image buttons.
     (unless (widget-get widget :suppress-face)
-      (overlay-put overlay 'face (widget-apply widget :button-face-get))
-      (overlay-put overlay 'mouse-face widget-mouse-face))
+      (overlay-put overlay 'face (widget-apply widget :button-face-get)))
+    (overlay-put overlay 'pointer 'hand)
     (overlay-put overlay 'help-echo help-echo)))
 
 (defun widget-mouse-help (window overlay point)
@@ -401,6 +402,7 @@ new value.")
   "Specify sample for WIDGET between FROM and TO."
   (let ((overlay (make-overlay from to nil t nil)))
     (overlay-put overlay 'face (widget-apply widget :sample-face-get))
+    (overlay-put overlay 'evaporate t)
     (widget-put widget :sample-overlay overlay)))
 
 (defun widget-specify-doc (widget from to)
@@ -408,6 +410,7 @@ new value.")
   (let ((overlay (make-overlay from to nil t nil)))
     (overlay-put overlay 'widget-doc widget)
     (overlay-put overlay 'face widget-documentation-face)
+    (overlay-put overlay 'evaporate t)
     (widget-put widget :doc-overlay overlay)))
 
 (defmacro widget-specify-insert (&rest form)
@@ -1082,14 +1085,23 @@ the field."
   :type 'function
   :group 'widgets)
 
+(defun widget-narrow-to-field ()
+  "Narrow to field"
+  (interactive)
+  (let ((field (widget-field-find (point))))
+    (if field
+       (narrow-to-region (line-beginning-position) (line-end-position)))))
+
 (defun widget-complete ()
   "Complete content of editable field from point.
 When not inside a field, move to the previous button or field."
   (interactive)
   (let ((field (widget-field-find (point))))
     (if field
-       (widget-apply field :complete)
-      (error "Not in an editable field"))))
+       (save-restriction
+         (widget-narrow-to-field)
+         (widget-apply field :complete))
+         (error "Not in an editable field"))))
 
 ;;; Setting up the buffer.
 
@@ -1141,7 +1153,7 @@ When not inside a field, move to the previous button or field."
       field)))
 
 (defun widget-field-buffer (widget)
-  "Return the start of WIDGET's editing field."
+  "Return the buffer of WIDGET's editing field."
   (let ((overlay (widget-get widget :field-overlay)))
     (cond ((overlayp overlay)
           (overlay-buffer overlay))
@@ -1286,8 +1298,8 @@ Store the newly created widget in the :children attribute.
 The value of the :type attribute should be an unconverted widget type."
   (let ((value (widget-get widget :value))
        (type (widget-get widget :type)))
-    (widget-put widget :children 
-                (list (widget-create-child-value widget 
+    (widget-put widget :children
+                (list (widget-create-child-value widget
                                                  (widget-convert type)
                                                  value)))))
 
@@ -3150,6 +3162,8 @@ It will read a directory name from the minibuffer when invoked."
                (setq err "Empty sexp -- use `nil'?")
              (unless (widget-apply widget :match (read (current-buffer)))
                (setq err (widget-get widget :type-error))))
+           ;; Allow whitespace after expression.
+           (skip-syntax-forward "\\s-")
            (if (and (not (eobp))
                     (not err))
                (setq err (format "Junk at end of expression: %s"
@@ -3309,8 +3323,8 @@ Here we attempt to define my-list as a choice of either the constant
 nil, or a cons-cell containing a sexp and my-lisp.  This will not work
 because the `choice' widget does not allow recursion.
 
-Using the `lazy' widget you can overcome this problem, as in this 
-example: 
+Using the `lazy' widget you can overcome this problem, as in this
+example:
 
   (define-widget 'sexp-list 'lazy
     \"A list of sexps.\"
@@ -3319,7 +3333,7 @@ example:
   :format "%{%t%}: %v"
   ;; We don't convert :type because we want to allow recursive
   ;; datastructures.  This is slow, so we should not create speed
-  ;; critical widgets by deriving from this. 
+  ;; critical widgets by deriving from this.
   :convert-widget 'widget-value-convert-widget
   :value-create 'widget-type-value-create
   :value-get 'widget-child-value-get