comparison lisp/wid-edit.el @ 90054:f2ebccfa87d4

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-74 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-709 Update from CVS: src/indent.c (Fvertical_motion): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-710 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-715 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-74 Update from CVS
author Miles Bader <miles@gnu.org>
date Wed, 08 Dec 2004 05:02:30 +0000
parents 3fd4a5c21153 4b3cfed7370f
children eac554634bfa
comparison
equal deleted inserted replaced
90053:fff5f1a61d92 90054:f2ebccfa87d4
337 ;; C-n/C-p act more naturally when entering/leaving the field. We 337 ;; C-n/C-p act more naturally when entering/leaving the field. We
338 ;; do this by making a small secondary overlay to contain just that 338 ;; do this by making a small secondary overlay to contain just that
339 ;; one character. 339 ;; one character.
340 (let ((overlay (make-overlay (1- to) to nil t nil))) 340 (let ((overlay (make-overlay (1- to) to nil t nil)))
341 (overlay-put overlay 'field 'boundary) 341 (overlay-put overlay 'field 'boundary)
342 ;; We need the real field for tabbing.
343 (overlay-put overlay 'real-field widget)
342 ;; Use `local-map' here, not `keymap', so that normal editing 344 ;; Use `local-map' here, not `keymap', so that normal editing
343 ;; works in the field when, say, Custom uses `suppress-keymap'. 345 ;; works in the field when, say, Custom uses `suppress-keymap'.
344 (overlay-put overlay 'local-map keymap) 346 (overlay-put overlay 'local-map keymap)
345 (overlay-put overlay 'face face) 347 (overlay-put overlay 'face face)
346 (overlay-put overlay 'help-echo help-echo)) 348 (overlay-put overlay 'help-echo help-echo))
1083 "Default function to call for completion inside fields." 1085 "Default function to call for completion inside fields."
1084 :options '(ispell-complete-word complete-tag lisp-complete-symbol) 1086 :options '(ispell-complete-word complete-tag lisp-complete-symbol)
1085 :type 'function 1087 :type 'function
1086 :group 'widgets) 1088 :group 'widgets)
1087 1089
1090 (defun widget-narrow-to-field ()
1091 "Narrow to field"
1092 (interactive)
1093 (let ((field (widget-field-find (point))))
1094 (if field
1095 (narrow-to-region (line-beginning-position) (line-end-position)))))
1096
1088 (defun widget-complete () 1097 (defun widget-complete ()
1089 "Complete content of editable field from point. 1098 "Complete content of editable field from point.
1090 When not inside a field, move to the previous button or field." 1099 When not inside a field, move to the previous button or field."
1091 (interactive) 1100 (interactive)
1092 (let ((field (widget-field-find (point)))) 1101 (let ((field (widget-field-find (point))))
1093 (if field 1102 (if field
1094 (widget-apply field :complete) 1103 (save-restriction
1095 (error "Not in an editable field")))) 1104 (widget-narrow-to-field)
1105 (widget-apply field :complete))
1106 (error "Not in an editable field"))))
1096 1107
1097 ;;; Setting up the buffer. 1108 ;;; Setting up the buffer.
1098 1109
1099 (defvar widget-field-new nil 1110 (defvar widget-field-new nil
1100 "List of all newly created editable fields in the buffer.") 1111 "List of all newly created editable fields in the buffer.")
1138 1149
1139 (defun widget-field-at (pos) 1150 (defun widget-field-at (pos)
1140 "Return the widget field at POS, or nil if none." 1151 "Return the widget field at POS, or nil if none."
1141 (let ((field (get-char-property (or pos (point)) 'field))) 1152 (let ((field (get-char-property (or pos (point)) 'field)))
1142 (if (eq field 'boundary) 1153 (if (eq field 'boundary)
1143 nil 1154 (get-char-property (or pos (point)) 'real-field)
1144 field))) 1155 field)))
1145 1156
1146 (defun widget-field-buffer (widget) 1157 (defun widget-field-buffer (widget)
1147 "Return the buffer of WIDGET's editing field." 1158 "Return the buffer of WIDGET's editing field."
1148 (let ((overlay (widget-get widget :field-overlay))) 1159 (let ((overlay (widget-get widget :field-overlay)))