comparison lisp/wid-edit.el @ 18638:ac27714a02cf

(widget-field-use-before-change): Reenable for Emacs 20. (widget-choose): Using keyboard, if all choices are diabled, just report an error.
author Richard M. Stallman <rms@gnu.org>
date Sun, 06 Jul 1997 23:12:14 +0000
parents d95acbbb4ac7
children 904dcdbb8576
comparison
equal deleted inserted replaced
18637:62cf644c438b 18638:ac27714a02cf
298 ;; Construct a menu of the choices 298 ;; Construct a menu of the choices
299 ;; and then use it for prompting for a single character. 299 ;; and then use it for prompting for a single character.
300 (let* ((overriding-terminal-local-map 300 (let* ((overriding-terminal-local-map
301 (make-sparse-keymap)) 301 (make-sparse-keymap))
302 map choice (next-digit ?0) 302 map choice (next-digit ?0)
303 some-choice-enabled
303 value) 304 value)
304 ;; Define SPC as a prefix char to get to this menu. 305 ;; Define SPC as a prefix char to get to this menu.
305 (define-key overriding-terminal-local-map " " 306 (define-key overriding-terminal-local-map " "
306 (setq map (make-sparse-keymap title))) 307 (setq map (make-sparse-keymap title)))
307 (save-excursion 308 (save-excursion
312 (setq choice (car items) items (cdr items)) 313 (setq choice (car items) items (cdr items))
313 (if (consp choice) 314 (if (consp choice)
314 (let* ((name (car choice)) 315 (let* ((name (car choice))
315 (function (cdr choice))) 316 (function (cdr choice)))
316 (insert (format "%c = %s\n" next-digit name)) 317 (insert (format "%c = %s\n" next-digit name))
317 (define-key map (vector next-digit) function))) 318 (define-key map (vector next-digit) function)
319 (setq some-choice-enabled t)))
318 ;; Allocate digits to disabled alternatives 320 ;; Allocate digits to disabled alternatives
319 ;; so that the digit of a given alternative never varies. 321 ;; so that the digit of a given alternative never varies.
320 (setq next-digit (1+ next-digit))) 322 (setq next-digit (1+ next-digit)))
321 (insert "\nC-g = Quit")) 323 (insert "\nC-g = Quit"))
324 (or some-choice-enabled
325 (error "None of the choices is currently meaningful"))
322 (define-key map [?\C-g] 'keyboard-quit) 326 (define-key map [?\C-g] 'keyboard-quit)
323 (define-key map [t] 'keyboard-quit) 327 (define-key map [t] 'keyboard-quit)
324 (setcdr map (nreverse (cdr map))) 328 (setcdr map (nreverse (cdr map)))
325 ;; Unread a SPC to lead to our new menu. 329 ;; Unread a SPC to lead to our new menu.
326 (setq unread-command-events (cons ?\ unread-command-events)) 330 (setq unread-command-events (cons ?\ unread-command-events))
373 :type 'boolean 377 :type 'boolean
374 :group 'widgets) 378 :group 'widgets)
375 379
376 (defcustom widget-field-use-before-change 380 (defcustom widget-field-use-before-change
377 (or (> emacs-minor-version 34) 381 (or (> emacs-minor-version 34)
378 (> emacs-major-version 20) 382 (>= emacs-major-version 20)
379 (string-match "XEmacs" emacs-version)) 383 (string-match "XEmacs" emacs-version))
380 "Non-nil means use `before-change-functions' to track editable fields. 384 "Non-nil means use `before-change-functions' to track editable fields.
381 This enables the use of undo, but doesn'f work on Emacs 19.34 and earlier. 385 This enables the use of undo, but doesn't work on Emacs 19.34 and earlier.
382 Using before hooks also means that the :notify function can't know the 386 Using before hooks also means that the :notify function can't know the
383 new value." 387 new value."
384 :type 'boolean 388 :type 'boolean
385 :group 'widgets) 389 :group 'widgets)
386 390