comparison lisp/custom/wid-edit.el @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents bfd6434d15b3
children 489f57a838ef
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
2 ;; 2 ;;
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: extensions 6 ;; Keywords: extensions
7 ;; Version: 1.9954 7 ;; Version: 1.9956
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
1273 found)) 1273 found))
1274 1274
1275 (defun widget-before-change (from to) 1275 (defun widget-before-change (from to)
1276 ;; This is how, for example, a variable changes its state to `modified'. 1276 ;; This is how, for example, a variable changes its state to `modified'.
1277 ;; when it is being edited. 1277 ;; when it is being edited.
1278 (let ((from-field (widget-field-find from)) 1278 (unless inhibit-read-only
1279 (to-field (widget-field-find to))) 1279 (let ((from-field (widget-field-find from))
1280 (cond ((not (eq from-field to-field)) 1280 (to-field (widget-field-find to)))
1281 (add-hook 'post-command-hook 'widget-add-change nil t) 1281 (cond ((not (eq from-field to-field))
1282 (error "Change should be restricted to a single field")) 1282 (add-hook 'post-command-hook 'widget-add-change nil t)
1283 ((null from-field) 1283 (error "Change should be restricted to a single field"))
1284 (add-hook 'post-command-hook 'widget-add-change nil t) 1284 ((null from-field)
1285 (error "Attempt to change text outside editable field")) 1285 (add-hook 'post-command-hook 'widget-add-change nil t)
1286 (widget-field-use-before-change 1286 (error "Attempt to change text outside editable field"))
1287 (condition-case nil 1287 (widget-field-use-before-change
1288 (widget-apply from-field :notify from-field) 1288 (condition-case nil
1289 (error (debug "Before Change"))))))) 1289 (widget-apply from-field :notify from-field)
1290 (error (debug "Before Change"))))))))
1290 1291
1291 (defun widget-add-change () 1292 (defun widget-add-change ()
1292 (make-local-hook 'post-command-hook) 1293 (make-local-hook 'post-command-hook)
1293 (remove-hook 'post-command-hook 'widget-add-change t) 1294 (remove-hook 'post-command-hook 'widget-add-change t)
1294 (make-local-hook 'before-change-functions) 1295 (make-local-hook 'before-change-functions)