# HG changeset patch # User Richard M. Stallman # Date 868993622 0 # Node ID de905e8be2e0a2ecae72367de293297f6d98da0d # Parent 8836f8af1fb51d905894f9bce2b404de666499f1 (tmm-prompt): Use save-excursion around completing-read code. (tmm-add-prompt): Clean up using save-selected-window and with-current-buffer. diff -r 8836f8af1fb5 -r de905e8be2e0 lisp/tmm.el --- a/lisp/tmm.el Tue Jul 15 19:00:36 1997 +0000 +++ b/lisp/tmm.el Tue Jul 15 19:07:02 1997 +0000 @@ -184,20 +184,21 @@ (setq history (append history history history history)) (setq tmm-c-prompt (nth (- history-len 1 index-of-default) history)) (add-hook 'minibuffer-setup-hook 'tmm-add-prompt) - (unwind-protect - (setq out - (completing-read - (concat gl-str " (up/down to change, PgUp to menu): ") - tmm-km-list nil t nil - (cons 'history (- (* 2 history-len) index-of-default)))) - (save-excursion - (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt) - (if (get-buffer "*Completions*") - (progn - (set-buffer "*Completions*") - (use-local-map tmm-old-comp-map) - (bury-buffer (current-buffer))))) - ))) + (save-excursion + (unwind-protect + (setq out + (completing-read + (concat gl-str " (up/down to change, PgUp to menu): ") + tmm-km-list nil t nil + (cons 'history (- (* 2 history-len) index-of-default)))) + (save-excursion + (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt) + (if (get-buffer "*Completions*") + (progn + (set-buffer "*Completions*") + (use-local-map tmm-old-comp-map) + (bury-buffer (current-buffer))))) + )))) (setq choice (cdr (assoc out tmm-km-list))) (and (null choice) (> (length out) (length tmm-c-prompt)) @@ -323,21 +324,17 @@ (remove-hook 'completion-setup-hook 'tmm-completion-delete-prompt)) (if tmm-completion-prompt (progn - (set-buffer "*Completions*") - (goto-char 1) + (set-buffer "*Completions*") + (goto-char 1) (insert tmm-completion-prompt))) ) - (save-excursion + (save-selected-window (other-window 1) ; Electric-pop-up-window does ; not work in minibuffer - (set-buffer (window-buffer (Electric-pop-up-window "*Completions*"))) - - (setq tmm-old-comp-map (tmm-define-keys nil)) + (Electric-pop-up-window "*Completions*") + (with-current-buffer "*Completions*" + (setq tmm-old-comp-map (tmm-define-keys nil)))) - (select-window win) ; Cannot use - ; save-window-excursion, since - ; it restores the size - ) (insert tmm-c-prompt))) (defun tmm-delete-map ()