emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/comint.el,v


From: Chong Yidong
Subject: [Emacs-diffs] Changes to emacs/lisp/comint.el,v
Date: Mon, 29 Jan 2007 02:31:22 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Chong Yidong <cyd>      07/01/29 02:31:22

Index: comint.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/comint.el,v
retrieving revision 1.354
retrieving revision 1.355
diff -u -b -r1.354 -r1.355
--- comint.el   21 Jan 2007 03:53:12 -0000      1.354
+++ comint.el   29 Jan 2007 02:31:22 -0000      1.355
@@ -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
 ;; ===========================================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]