diff options
| author | Nick Roberts | 2006-05-10 21:31:09 +0000 |
|---|---|---|
| committer | Nick Roberts | 2006-05-10 21:31:09 +0000 |
| commit | 3e12c6736d4a18f0b08e5689b3493eab74bb04e7 (patch) | |
| tree | 47dd45ce43162ccc1ca8737cdc75a558d0bd940c | |
| parent | afdf9b261c77adb7e2a630d482b8dc66ba82ef79 (diff) | |
| download | emacs-3e12c6736d4a18f0b08e5689b3493eab74bb04e7.tar.gz emacs-3e12c6736d4a18f0b08e5689b3493eab74bb04e7.zip | |
(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.
| -rw-r--r-- | lisp/comint.el | 61 |
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." | |||
| 458 | (define-key map "\C-c\C-c" 'comint-interrupt-subjob) | 458 | (define-key map "\C-c\C-c" 'comint-interrupt-subjob) |
| 459 | (define-key map "\C-c\C-z" 'comint-stop-subjob) | 459 | (define-key map "\C-c\C-z" 'comint-stop-subjob) |
| 460 | (define-key map "\C-c\C-\\" 'comint-quit-subjob) | 460 | (define-key map "\C-c\C-\\" 'comint-quit-subjob) |
| 461 | (define-key map "\C-c\C-m" 'comint-insert-input) | 461 | (define-key map "\C-c\C-m" 'comint-copy-old-input) |
| 462 | (define-key map "\C-c\C-o" 'comint-delete-output) | 462 | (define-key map "\C-c\C-o" 'comint-delete-output) |
| 463 | (define-key map "\C-c\C-r" 'comint-show-output) | 463 | (define-key map "\C-c\C-r" 'comint-show-output) |
| 464 | (define-key map "\C-c\C-e" 'comint-show-maximum-output) | 464 | (define-key map "\C-c\C-e" 'comint-show-maximum-output) |
| @@ -502,7 +502,7 @@ executed once when the buffer is created." | |||
| 502 | (define-key map [menu-bar inout kill-input] | 502 | (define-key map [menu-bar inout kill-input] |
| 503 | '("Kill Current Input" . comint-kill-input)) | 503 | '("Kill Current Input" . comint-kill-input)) |
| 504 | (define-key map [menu-bar inout copy-input] | 504 | (define-key map [menu-bar inout copy-input] |
| 505 | '("Copy Old Input" . comint-insert-input)) | 505 | '("Copy Old Input" . comint-copy-old-input)) |
| 506 | (define-key map [menu-bar inout forward-matching-history] | 506 | (define-key map [menu-bar inout forward-matching-history] |
| 507 | '("Forward Matching Input..." . comint-forward-matching-input)) | 507 | '("Forward Matching Input..." . comint-forward-matching-input)) |
| 508 | (define-key map [menu-bar inout backward-matching-history] | 508 | (define-key map [menu-bar inout backward-matching-history] |
| @@ -797,36 +797,28 @@ buffer. The hook `comint-exec-hook' is run after each exec." | |||
| 797 | (set-process-coding-system proc decoding encoding)) | 797 | (set-process-coding-system proc decoding encoding)) |
| 798 | proc)) | 798 | proc)) |
| 799 | 799 | ||
| 800 | (defun comint-insert-input (&optional event) | 800 | (defun comint-insert-input (event) |
| 801 | "In a Comint buffer, set the current input to the previous input at point." | 801 | "In a Comint buffer, set the current input to the previous input at point." |
| 802 | ;; This doesn't use "e" because it is supposed to work | 802 | ;; This doesn't use "e" because it is supposed to work |
| 803 | ;; for events without parameters. | 803 | ;; for events without parameters. |
| 804 | (interactive (list last-input-event)) | 804 | (interactive "e") |
| 805 | (when event | 805 | (mouse-set-point event) |
| 806 | (posn-set-point (event-end event))) | 806 | (let ((pos (point))) |
| 807 | (if comint-use-prompt-regexp | 807 | (if (not (eq (field-at-pos pos) 'input)) |
| 808 | (let ((input (funcall comint-get-old-input)) | 808 | ;; No input at POS, fall back to the global definition. |
| 809 | (process (get-buffer-process (current-buffer)))) | 809 | (let* ((keys (this-command-keys)) |
| 810 | (if (not process) | 810 | (last-key (and (vectorp keys) (aref keys (1- (length keys))))) |
| 811 | (error "Current buffer has no process") | 811 | (fun (and last-key (lookup-key global-map (vector last-key))))) |
| 812 | (goto-char (process-mark process)) | 812 | (and fun (call-interactively fun))) |
| 813 | (insert input))) | 813 | ;; There's previous input at POS, insert it at the end of the buffer. |
| 814 | (let ((pos (point))) | 814 | (goto-char (point-max)) |
| 815 | (if (not (eq (field-at-pos pos) 'input)) | 815 | ;; First delete any old unsent input at the end |
| 816 | ;; No input at POS, fall back to the global definition. | 816 | (delete-region |
| 817 | (let* ((keys (this-command-keys)) | 817 | (or (marker-position comint-accum-marker) |
| 818 | (last-key (and (vectorp keys) (aref keys (1- (length keys))))) | 818 | (process-mark (get-buffer-process (current-buffer)))) |
| 819 | (fun (and last-key (lookup-key global-map (vector last-key))))) | 819 | (point)) |
| 820 | (and fun (call-interactively fun))) | 820 | ;; Insert the input at point |
| 821 | ;; There's previous input at POS, insert it at the end of the buffer. | 821 | (insert (field-string-no-properties pos))))) |
| 822 | (goto-char (point-max)) | ||
| 823 | ;; First delete any old unsent input at the end | ||
| 824 | (delete-region | ||
| 825 | (or (marker-position comint-accum-marker) | ||
| 826 | (process-mark (get-buffer-process (current-buffer)))) | ||
| 827 | (point)) | ||
| 828 | ;; Insert the input at point | ||
| 829 | (insert (field-string-no-properties pos)))))) | ||
| 830 | 822 | ||
| 831 | 823 | ||
| 832 | ;; Input history processing in a buffer | 824 | ;; Input history processing in a buffer |
| @@ -1905,6 +1897,17 @@ the current line with any initial string matching the regexp | |||
| 1905 | (comint-bol) | 1897 | (comint-bol) |
| 1906 | (buffer-substring-no-properties (point) (line-end-position))))) | 1898 | (buffer-substring-no-properties (point) (line-end-position))))) |
| 1907 | 1899 | ||
| 1900 | (defun comint-copy-old-input () | ||
| 1901 | "Insert after prompt old input at point as new input to be edited. | ||
| 1902 | Calls `comint-get-old-input' to get old input." | ||
| 1903 | (interactive) | ||
| 1904 | (let ((input (funcall comint-get-old-input)) | ||
| 1905 | (process (get-buffer-process (current-buffer)))) | ||
| 1906 | (if (not process) | ||
| 1907 | (error "Current buffer has no process") | ||
| 1908 | (goto-char (process-mark process)) | ||
| 1909 | (insert input)))) | ||
| 1910 | |||
| 1908 | (defun comint-skip-prompt () | 1911 | (defun comint-skip-prompt () |
| 1909 | "Skip past the text matching regexp `comint-prompt-regexp'. | 1912 | "Skip past the text matching regexp `comint-prompt-regexp'. |
| 1910 | If this takes us past the end of the current line, don't skip at all." | 1913 | If this takes us past the end of the current line, don't skip at all." |