diff options
author | Karoly Lorentey <lorentey@elte.hu> | 2006-04-19 16:23:46 +0000 |
---|---|---|
committer | Karoly Lorentey <lorentey@elte.hu> | 2006-04-19 16:23:46 +0000 |
commit | 447b0165acd09060977e05c843f81c0bee4aa4df (patch) | |
tree | 70cf2d254760a2cf68a10b67f8a3570c05fff9a5 /lisp/comint.el | |
parent | 4c57cca724993ab1334cc5c0b35c22b06daee0c3 (diff) | |
parent | 0fea1d10293b4c6d35c1e55b68cd26e91445213c (diff) | |
download | emacs-447b0165acd09060977e05c843f81c0bee4aa4df.tar.gz emacs-447b0165acd09060977e05c843f81c0bee4aa4df.tar.bz2 emacs-447b0165acd09060977e05c843f81c0bee4aa4df.zip |
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-216
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-217
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-218
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-219
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-220
Improve tq.el.
* emacs@sv.gnu.org/emacs--devo--0--patch-221
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-222
Update from CVS: src/puresize.h (PURESIZE_RATIO): Reduce to 10/6.
* emacs@sv.gnu.org/emacs--devo--0--patch-223
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-224
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-225
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-226
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-227
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-228
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-229
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-230
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-231
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-232
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-233
Update from CVS: lisp/progmodes/python.el (python-mode): Fix typo.
* emacs@sv.gnu.org/gnus--rel--5.10--patch-84
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-85
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-86
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-550
Diffstat (limited to 'lisp/comint.el')
-rw-r--r-- | lisp/comint.el | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 5ab00354f80..a44e252ca97 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -465,6 +465,7 @@ executed once when the buffer is created." (define-key map "\C-c\C-l" 'comint-dynamic-list-input-ring) (define-key map "\C-c\C-n" 'comint-next-prompt) (define-key map "\C-c\C-p" 'comint-previous-prompt) + (define-key map "\C-c\C-j" 'comint-restore-input) (define-key map "\C-c\C-d" 'comint-send-eof) (define-key map "\C-c\C-s" 'comint-write-output) (define-key map "\C-c." 'comint-insert-previous-argument) @@ -558,6 +559,9 @@ This is to support the command \\[comint-get-next-from-history].") "Non-nil if you are accumulating input lines to send as input together. The command \\[comint-accumulate] sets this.") +(defvar comint-stored-incomplete-input nil + "Stored input for history cycling.") + (put 'comint-replace-by-expanded-history 'menu-enable 'comint-input-autoexpand) (put 'comint-input-ring 'permanent-local t) (put 'comint-input-ring-index 'permanent-local t) @@ -638,6 +642,7 @@ Entry to this mode runs the hooks on `comint-mode-hook'." (make-local-variable 'comint-scroll-to-bottom-on-input) (make-local-variable 'comint-move-point-for-output) (make-local-variable 'comint-scroll-show-maximum-output) + (make-local-variable 'comint-stored-incomplete-input) ;; This makes it really work to keep point at the bottom. (make-local-variable 'scroll-conservatively) (setq scroll-conservatively 10000) @@ -1015,6 +1020,16 @@ See also `comint-read-input-ring'." (t arg))) +(defun comint-restore-input () + "Restore unfinished input." + (interactive) + (when comint-input-ring-index + (comint-delete-input) + (when (> (length comint-stored-incomplete-input) 0) + (insert comint-stored-incomplete-input) + (message "Input restored")) + (setq comint-input-ring-index nil))) + (defun comint-search-start (arg) "Index to start a directional search, starting at `comint-input-ring-index'." (if comint-input-ring-index @@ -1035,9 +1050,18 @@ Moves relative to `comint-input-ring-index'." arg))) (defun comint-previous-input (arg) - "Cycle backwards through input history." + "Cycle backwards through input history, saving input." (interactive "*p") - (comint-previous-matching-input "." arg)) + (if (and comint-input-ring-index + (or ;; leaving the "end" of the ring + (and (< arg 0) ; going down + (eq comint-input-ring-index 0)) + (and (> arg 0) ; going up + (eq comint-input-ring-index + (1- (ring-length comint-input-ring))))) + comint-stored-incomplete-input) + (comint-restore-input) + (comint-previous-matching-input "." arg))) (defun comint-next-input (arg) "Cycle forwards through input history." @@ -1077,6 +1101,14 @@ Moves relative to START, or `comint-input-ring-index'." (if (string-match regexp (ring-ref comint-input-ring n)) n))) +(defun comint-delete-input () + "Delete all input between accumulation or process mark and point." + (delete-region + ;; Can't use kill-region as it sets this-command + (or (marker-position comint-accum-marker) + (process-mark (get-buffer-process (current-buffer)))) + (point-max))) + (defun comint-previous-matching-input (regexp n) "Search backwards through input history for match for REGEXP. \(Previous history elements are earlier commands.) @@ -1088,13 +1120,13 @@ If N is negative, find the next or Nth next match." ;; Has a match been found? (if (null pos) (error "Not found") + ;; If leaving the edit line, save partial input + (if (null comint-input-ring-index) ;not yet on ring + (setq comint-stored-incomplete-input + (funcall comint-get-old-input))) (setq comint-input-ring-index pos) (message "History item: %d" (1+ pos)) - (delete-region - ;; Can't use kill-region as it sets this-command - (or (marker-position comint-accum-marker) - (process-mark (get-buffer-process (current-buffer)))) - (point)) + (comint-delete-input) (insert (ring-ref comint-input-ring pos))))) (defun comint-next-matching-input (regexp n) |