# HG changeset patch # User Henry S. Thompson # Date 1758818843 -3600 # Node ID 1b36ef117dc52500b4f27c82c6592778841055df # Parent 8e0e16f4763cadc5dc83a46ee92bc4b5bf3583f6 stale? diff -r 8e0e16f4763c -r 1b36ef117dc5 shared/prompt-for-word.el --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shared/prompt-for-word.el Thu Sep 25 17:47:23 2025 +0100 @@ -0,0 +1,47 @@ +;; Last edited: Wed Nov 14 14:20:08 1990 +;;; define an interlisp-style prompt-for-word +(provide 'prompt-for-word) + +(defun prompt-for-word (prompt candidate completion-table keymap) + "prompt for a word using PROMPT, and CANDIDATE as first choice. +If any inserting characters are typed, they replace the candidate. +Uses KEYMAP if non-nil, otherwise +if completion-table is non-nil, + uses minibuffer-local-must-match-map plus ^N to exit as is, + thereby allowing New answers, +otherwise uses minibuffer-local-map." + (let ((current-window (selected-window)) + (echo-keystrokes 0) + char) + (select-window (minibuffer-window)) + (erase-buffer) + (insert prompt candidate) + (setq char (read-char)) + (let ((str (make-string 1 char))) + (if (eq (or (local-key-binding str) + (global-key-binding str)) + 'self-insert-command) + (setq candidate nil))) + (select-window current-window) + (if (boundp 'unread-command-event) + ;; lemacs + (setq unread-command-event + (character-to-event char)) + (setq unread-command-char char)) + (let ((minibuffer-completion-table completion-table) + (minibuffer-completion-confirm nil)) + ;; not quite the same as completing-read, because you can't + ;; get m-c-c nil and m-m-map simultaneously + (read-from-minibuffer prompt candidate + (or keymap + (if completion-table + ;; allow ^N to exit with non-match for + ;; new names + pfw-map + minibuffer-local-map)))))) + +(defvar pfw-map (let ((new (copy-keymap minibuffer-local-must-match-map))) + (define-key new "\C-n" 'exit-minibuffer) + new) + "special completion map for prompt-for-word (q.v.)") +