# HG changeset patch # User Nick Roberts # Date 1147296669 0 # Node ID aaf48e9df47bdc54216606b7320e9979dde6a1e5 # Parent 45305d1ce4f785777c7063b587778ceb6ddbadcc (comint-insert-input): Just make it when comint-use-prompt regexp is nil (default) and with the mouse. (comint-copy-old-input): Reinstate from 2004-06-23. (comint-mode-map): Bind C-c C-m to it. diff -r 45305d1ce4f7 -r aaf48e9df47b lisp/comint.el --- a/lisp/comint.el Wed May 10 21:30:18 2006 +0000 +++ b/lisp/comint.el Wed May 10 21:31:09 2006 +0000 @@ -458,7 +458,7 @@ (define-key map "\C-c\C-c" 'comint-interrupt-subjob) (define-key map "\C-c\C-z" 'comint-stop-subjob) (define-key map "\C-c\C-\\" 'comint-quit-subjob) - (define-key map "\C-c\C-m" 'comint-insert-input) + (define-key map "\C-c\C-m" 'comint-copy-old-input) (define-key map "\C-c\C-o" 'comint-delete-output) (define-key map "\C-c\C-r" 'comint-show-output) (define-key map "\C-c\C-e" 'comint-show-maximum-output) @@ -502,7 +502,7 @@ (define-key map [menu-bar inout kill-input] '("Kill Current Input" . comint-kill-input)) (define-key map [menu-bar inout copy-input] - '("Copy Old Input" . comint-insert-input)) + '("Copy Old Input" . comint-copy-old-input)) (define-key map [menu-bar inout forward-matching-history] '("Forward Matching Input..." . comint-forward-matching-input)) (define-key map [menu-bar inout backward-matching-history] @@ -797,36 +797,28 @@ (set-process-coding-system proc decoding encoding)) proc)) -(defun comint-insert-input (&optional event) +(defun comint-insert-input (event) "In a Comint buffer, set the current input to the previous input at point." ;; This doesn't use "e" because it is supposed to work ;; for events without parameters. - (interactive (list last-input-event)) - (when event - (posn-set-point (event-end event))) - (if comint-use-prompt-regexp - (let ((input (funcall comint-get-old-input)) - (process (get-buffer-process (current-buffer)))) - (if (not process) - (error "Current buffer has no process") - (goto-char (process-mark process)) - (insert input))) - (let ((pos (point))) - (if (not (eq (field-at-pos pos) 'input)) - ;; No input at POS, fall back to the global definition. - (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. - (goto-char (point-max)) - ;; First delete any old unsent input at the end - (delete-region - (or (marker-position comint-accum-marker) - (process-mark (get-buffer-process (current-buffer)))) - (point)) - ;; Insert the input at point - (insert (field-string-no-properties pos)))))) + (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* ((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. + (goto-char (point-max)) + ;; First delete any old unsent input at the end + (delete-region + (or (marker-position comint-accum-marker) + (process-mark (get-buffer-process (current-buffer)))) + (point)) + ;; Insert the input at point + (insert (field-string-no-properties pos))))) ;; Input history processing in a buffer @@ -1905,6 +1897,17 @@ (comint-bol) (buffer-substring-no-properties (point) (line-end-position))))) +(defun comint-copy-old-input () + "Insert after prompt old input at point as new input to be edited. +Calls `comint-get-old-input' to get old input." + (interactive) + (let ((input (funcall comint-get-old-input)) + (process (get-buffer-process (current-buffer)))) + (if (not process) + (error "Current buffer has no process") + (goto-char (process-mark process)) + (insert input)))) + (defun comint-skip-prompt () "Skip past the text matching regexp `comint-prompt-regexp'. If this takes us past the end of the current line, don't skip at all."