Mercurial > emacs
changeset 70548:289021558ff6
(comint-insert-input): Make it work when comint-use-prompt-regexp is t.
Use field-at-point.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Wed, 10 May 2006 00:34:02 +0000 |
parents | e184fae4f7dd |
children | c1933d4241b2 |
files | lisp/comint.el |
diffstat | 1 files changed, 27 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/comint.el Wed May 10 00:32:34 2006 +0000 +++ b/lisp/comint.el Wed May 10 00:34:02 2006 +0000 @@ -802,28 +802,33 @@ ;; This doesn't use "e" because it is supposed to work ;; for events without parameters. (interactive (list last-input-event)) - (let ((pos (point))) - (if event (posn-set-point (event-end event))) - (if (not (eq (get-char-property (point) 'field) '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))))) - (goto-char pos) - (and fun (call-interactively fun))) - (setq pos (point)) - ;; 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 (buffer-substring-no-properties - (previous-single-char-property-change (1+ pos) 'field) - (next-single-char-property-change pos 'field)))))) - + (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-point 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))))) + (goto-char pos) + (and fun (call-interactively fun))) + (setq pos (point)) + ;; 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 ;; ===========================================================================