Mercurial > hg > xemacs
comparison shared/prompt-for-word.el @ 76:1b36ef117dc5
stale?
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Thu, 25 Sep 2025 17:47:23 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 5:8e0e16f4763c | 76:1b36ef117dc5 |
|---|---|
| 1 ;; Last edited: Wed Nov 14 14:20:08 1990 | |
| 2 ;;; define an interlisp-style prompt-for-word | |
| 3 (provide 'prompt-for-word) | |
| 4 | |
| 5 (defun prompt-for-word (prompt candidate completion-table keymap) | |
| 6 "prompt for a word using PROMPT, and CANDIDATE as first choice. | |
| 7 If any inserting characters are typed, they replace the candidate. | |
| 8 Uses KEYMAP if non-nil, otherwise | |
| 9 if completion-table is non-nil, | |
| 10 uses minibuffer-local-must-match-map plus ^N to exit as is, | |
| 11 thereby allowing New answers, | |
| 12 otherwise uses minibuffer-local-map." | |
| 13 (let ((current-window (selected-window)) | |
| 14 (echo-keystrokes 0) | |
| 15 char) | |
| 16 (select-window (minibuffer-window)) | |
| 17 (erase-buffer) | |
| 18 (insert prompt candidate) | |
| 19 (setq char (read-char)) | |
| 20 (let ((str (make-string 1 char))) | |
| 21 (if (eq (or (local-key-binding str) | |
| 22 (global-key-binding str)) | |
| 23 'self-insert-command) | |
| 24 (setq candidate nil))) | |
| 25 (select-window current-window) | |
| 26 (if (boundp 'unread-command-event) | |
| 27 ;; lemacs | |
| 28 (setq unread-command-event | |
| 29 (character-to-event char)) | |
| 30 (setq unread-command-char char)) | |
| 31 (let ((minibuffer-completion-table completion-table) | |
| 32 (minibuffer-completion-confirm nil)) | |
| 33 ;; not quite the same as completing-read, because you can't | |
| 34 ;; get m-c-c nil and m-m-map simultaneously | |
| 35 (read-from-minibuffer prompt candidate | |
| 36 (or keymap | |
| 37 (if completion-table | |
| 38 ;; allow ^N to exit with non-match for | |
| 39 ;; new names | |
| 40 pfw-map | |
| 41 minibuffer-local-map)))))) | |
| 42 | |
| 43 (defvar pfw-map (let ((new (copy-keymap minibuffer-local-must-match-map))) | |
| 44 (define-key new "\C-n" 'exit-minibuffer) | |
| 45 new) | |
| 46 "special completion map for prompt-for-word (q.v.)") | |
| 47 |
