diff options
| author | Nick Roberts | 2006-05-10 00:34:02 +0000 |
|---|---|---|
| committer | Nick Roberts | 2006-05-10 00:34:02 +0000 |
| commit | 8c74ff69835635197047bb9602271559b7472cee (patch) | |
| tree | 4dd1331f61b982e7532f53fed6a5b9b6bd10b79a | |
| parent | 1ecaae6cc946143d9a03db5e73d96210e301e876 (diff) | |
| download | emacs-8c74ff69835635197047bb9602271559b7472cee.tar.gz emacs-8c74ff69835635197047bb9602271559b7472cee.zip | |
(comint-insert-input): Make it work when comint-use-prompt-regexp is t.
Use field-at-point.
| -rw-r--r-- | lisp/comint.el | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 946085661fc..7f6fd2c3ba9 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -802,28 +802,33 @@ buffer. The hook `comint-exec-hook' is run after each exec." | |||
| 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 (list last-input-event)) |
| 805 | (let ((pos (point))) | 805 | (when event |
| 806 | (if event (posn-set-point (event-end event))) | 806 | (posn-set-point (event-end event))) |
| 807 | (if (not (eq (get-char-property (point) 'field) 'input)) | 807 | (if comint-use-prompt-regexp |
| 808 | ;; No input at POS, fall back to the global definition. | 808 | (let ((input (funcall comint-get-old-input)) |
| 809 | (let* ((keys (this-command-keys)) | 809 | (process (get-buffer-process (current-buffer)))) |
| 810 | (last-key (and (vectorp keys) (aref keys (1- (length keys))))) | 810 | (if (not process) |
| 811 | (fun (and last-key (lookup-key global-map (vector last-key))))) | 811 | (error "Current buffer has no process") |
| 812 | (goto-char pos) | 812 | (goto-char (process-mark process)) |
| 813 | (and fun (call-interactively fun))) | 813 | (insert input))) |
| 814 | (setq pos (point)) | 814 | (let ((pos (point))) |
| 815 | ;; There's previous input at POS, insert it at the end of the buffer. | 815 | (if (not (eq (field-at-point pos) 'input)) |
| 816 | (goto-char (point-max)) | 816 | ;; No input at POS, fall back to the global definition. |
| 817 | ;; First delete any old unsent input at the end | 817 | (let* ((keys (this-command-keys)) |
| 818 | (delete-region | 818 | (last-key (and (vectorp keys) (aref keys (1- (length keys))))) |
| 819 | (or (marker-position comint-accum-marker) | 819 | (fun (and last-key (lookup-key global-map (vector last-key))))) |
| 820 | (process-mark (get-buffer-process (current-buffer)))) | 820 | (goto-char pos) |
| 821 | (point)) | 821 | (and fun (call-interactively fun))) |
| 822 | ;; Insert the input at point | 822 | (setq pos (point)) |
| 823 | (insert (buffer-substring-no-properties | 823 | ;; There's previous input at POS, insert it at the end of the buffer. |
| 824 | (previous-single-char-property-change (1+ pos) 'field) | 824 | (goto-char (point-max)) |
| 825 | (next-single-char-property-change pos 'field)))))) | 825 | ;; First delete any old unsent input at the end |
| 826 | 826 | (delete-region | |
| 827 | (or (marker-position comint-accum-marker) | ||
| 828 | (process-mark (get-buffer-process (current-buffer)))) | ||
| 829 | (point)) | ||
| 830 | ;; Insert the input at point | ||
| 831 | (insert (field-string-no-properties pos)))))) | ||
| 827 | 832 | ||
| 828 | ;; Input history processing in a buffer | 833 | ;; Input history processing in a buffer |
| 829 | ;; =========================================================================== | 834 | ;; =========================================================================== |