summaryrefslogtreecommitdiff
path: root/lisp/comint.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2007-01-29 02:31:22 +0000
committerChong Yidong <cyd@stupidchicken.com>2007-01-29 02:31:22 +0000
commit445de73cf6f9faf042b52bc48dcf5041ee261dfb (patch)
tree3080e6e9e3fad5bad7fe9228b83689214e8f65e1 /lisp/comint.el
parent0e66b003a748db190268cd6463cc48645a4481e1 (diff)
downloademacs-445de73cf6f9faf042b52bc48dcf5041ee261dfb.tar.gz
(comint-insert-input): Handle situation where the selected buffer is
not the clicked buffer.
Diffstat (limited to 'lisp/comint.el')
-rw-r--r--lisp/comint.el27
1 files changed, 18 insertions, 9 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index cd5a9a9c13a..26b0add8b76 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -803,17 +803,27 @@ buffer. The hook `comint-exec-hook' is run after each exec."
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 @@ buffer. The hook `comint-exec-hook' is run after each exec."
(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
;; ===========================================================================