summaryrefslogtreecommitdiff
path: root/lisp/comint.el
diff options
context:
space:
mode:
authorNick Roberts <nickrob@snap.net.nz>2006-05-10 00:34:02 +0000
committerNick Roberts <nickrob@snap.net.nz>2006-05-10 00:34:02 +0000
commit8c74ff69835635197047bb9602271559b7472cee (patch)
tree4dd1331f61b982e7532f53fed6a5b9b6bd10b79a /lisp/comint.el
parent1ecaae6cc946143d9a03db5e73d96210e301e876 (diff)
downloademacs-8c74ff69835635197047bb9602271559b7472cee.tar.gz
(comint-insert-input): Make it work when comint-use-prompt-regexp is t.
Use field-at-point.
Diffstat (limited to 'lisp/comint.el')
-rw-r--r--lisp/comint.el49
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."
;; 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
;; ===========================================================================