Mercurial > emacs
changeset 75491:1fa2c9c50f03
(comint-insert-input): Handle situation where the selected buffer is
not the clicked buffer.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Mon, 29 Jan 2007 02:31:22 +0000 |
parents | 1cf2ac308bdc |
children | cebbb89929e5 |
files | lisp/comint.el |
diffstat | 1 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/comint.el Mon Jan 29 01:22:53 2007 +0000 +++ b/lisp/comint.el Mon Jan 29 02:31:22 2007 +0000 @@ -803,17 +803,27 @@ proc)) (defun comint-insert-input (event) - "In a Comint buffer, set the current input to the previous input at point." + "In a Comint buffer, set the current input to the previous input at point. +If there is no previous input at point, run the command specified +by the global keymap (usually `mouse-yank-at-point')." (interactive "e") - (mouse-set-point event) - (let ((pos (point))) - (if (not (eq (field-at-pos pos) 'input)) - ;; No input at POS, fall back to the global definition. + (let ((pos (posn-point (event-end event))) + field input) + (with-selected-window (posn-window (event-end event)) + (and (setq field (field-at-pos pos)) + (setq input (field-string-no-properties pos)))) + (if (or (null comint-accum-marker) + (not (eq field 'input))) + ;; Fall back to the global definition if (i) the selected + ;; buffer is not a comint buffer (which can happen if a + ;; non-comint window was selected and we clicked in a comint + ;; window), or (ii) there is no input at POS. (let* ((keys (this-command-keys)) (last-key (and (vectorp keys) (aref keys (1- (length keys))))) (fun (and last-key (lookup-key global-map (vector last-key))))) - (and fun (call-interactively fun))) - ;; There's previous input at POS, insert it at the end of the buffer. + (and fun (not (eq fun 'comint-insert-input)) + (call-interactively fun))) + ;; Otherwise, insert the previous input. (goto-char (point-max)) ;; First delete any old unsent input at the end (delete-region @@ -821,8 +831,7 @@ (process-mark (get-buffer-process (current-buffer)))) (point)) ;; Insert the input at point - (insert (field-string-no-properties pos))))) - + (insert input)))) ;; Input history processing in a buffer ;; ===========================================================================