From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.devel Subject: Re: comint-accumulate-marker Date: Mon, 17 Apr 2006 11:06:36 -0700 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1145297250 1136 80.91.229.2 (17 Apr 2006 18:07:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 17 Apr 2006 18:07:30 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 17 20:07:27 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FVY83-0004iE-N0 for ged-emacs-devel@m.gmane.org; Mon, 17 Apr 2006 20:07:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FVY83-0000qA-6E for ged-emacs-devel@m.gmane.org; Mon, 17 Apr 2006 14:07:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FVY7o-0000py-73 for emacs-devel@gnu.org; Mon, 17 Apr 2006 14:07:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FVY7n-0000pb-Bl for emacs-devel@gnu.org; Mon, 17 Apr 2006 14:06:59 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FVY7n-0000pY-7n for emacs-devel@gnu.org; Mon, 17 Apr 2006 14:06:59 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FVY8U-0007ij-Ej for emacs-devel@gnu.org; Mon, 17 Apr 2006 14:07:42 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FVY7W-0004cK-Gd for emacs-devel@gnu.org; Mon, 17 Apr 2006 20:06:42 +0200 Original-Received: from turtle.as.arizona.edu ([128.196.208.207]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Apr 2006 20:06:42 +0200 Original-Received: from jdsmith by turtle.as.arizona.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Apr 2006 20:06:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 148 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: turtle.as.arizona.edu User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:52970 Archived-At: On Sat, 15 Apr 2006 22:09:39 -0400, Richard Stallman wrote: > In a terminal > shell, using up arrow to recall history doesn't clobber the partially > complete command you are composin. If you go back down, it is still > there (even if it's blank). Not so in comint modes. Going down with > M-p only wraps you around the input ring. > > This would clearly be an improvement. Can you implement it? Here is a patch which implements this behavior. I've added a custom variable controlling whether it is on or off, and have left it off by default for now. If people like it and think it would be generically useful, I can enable it by default. JD Index: comint.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/comint.el,v retrieving revision 1.337 diff -w -b -c -c -r1.337 comint.el *** comint.el 27 Mar 2006 08:50:20 -0000 1.337 --- comint.el 17 Apr 2006 17:59:10 -0000 *************** *** 251,256 **** --- 251,263 ---- file) :group 'comint) + (defcustom comint-save-partial-input nil + "*If non-nil, save partial input at the prompt when cycling through history. + The saved input is recovered when moving off of the end of input + history in either direction. If no input, restores blank line." + :type 'boolean + :group 'comint) + (defcustom comint-scroll-to-bottom-on-input nil "*Controls whether input to interpreter causes window to scroll. If nil, then do not scroll. If t or `all', scroll all windows showing buffer. *************** *** 558,563 **** --- 565,573 ---- "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,643 **** --- 648,654 ---- (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) *************** *** 1034,1043 **** (ring-length comint-input-ring)) arg))) (defun comint-previous-input (arg) ! "Cycle backwards through input history." (interactive "*p") (comint-previous-matching-input "." arg)) (defun comint-next-input (arg) "Cycle forwards through input history." --- 1045,1078 ---- (ring-length comint-input-ring)) arg))) + (defun comint-previous-input (arg) ! "Cycle backwards through input history. ! Save incomplete input if `comint-save-partial-input' is non-nil." (interactive "*p") + (if comint-save-partial-input + (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) + (progn + (goto-char (point-max)) + (comint-delete-input) + (when (> (length comint-stored-incomplete-input) 0) + (insert comint-stored-incomplete-input) + (message "Incomplete input restored")) + (setq comint-input-ring-index nil)) + ;; If leaving 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))) + (goto-char (point-max)) (comint-previous-matching-input "." arg)) + (comint-previous-matching-input "." arg))) (defun comint-next-input (arg) "Cycle forwards through input history." *************** *** 1077,1082 **** --- 1112,1125 ---- (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))) + (defun comint-previous-matching-input (regexp n) "Search backwards through input history for match for REGEXP. \(Previous history elements are earlier commands.) *************** *** 1090,1100 **** (error "Not found") (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)) (insert (ring-ref comint-input-ring pos))))) (defun comint-next-matching-input (regexp n) --- 1133,1139 ---- (error "Not found") (setq comint-input-ring-index pos) (message "History item: %d" (1+ pos)) ! (comint-delete-input) (insert (ring-ref comint-input-ring pos))))) (defun comint-next-matching-input (regexp n)