summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorNick Roberts <nickrob@snap.net.nz>2006-05-10 21:31:09 +0000
committerNick Roberts <nickrob@snap.net.nz>2006-05-10 21:31:09 +0000
commit3e12c6736d4a18f0b08e5689b3493eab74bb04e7 (patch)
tree47dd45ce43162ccc1ca8737cdc75a558d0bd940c /lisp
parentafdf9b261c77adb7e2a630d482b8dc66ba82ef79 (diff)
downloademacs-3e12c6736d4a18f0b08e5689b3493eab74bb04e7.tar.gz
(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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/comint.el61
1 files changed, 32 insertions, 29 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index c7e5b3bdddd..1b9d8df738f 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -458,7 +458,7 @@ executed once when the buffer is created."
(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 @@ executed once when the buffer is created."
(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 @@ buffer. The hook `comint-exec-hook' is run after each exec."
(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 @@ the current line with any initial string matching the regexp
(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."