From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: unfrostedpoptart Newsgroups: gmane.emacs.help Subject: Re: comint history question Date: Sun, 26 Apr 2009 19:44:01 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1240819382 30724 80.91.229.12 (27 Apr 2009 08:03:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Apr 2009 08:03:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 27 10:02:54 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LyIma-0004ci-Ub for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Apr 2009 06:49:33 +0200 Original-Received: from localhost ([127.0.0.1]:54734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LyIlB-0000Ef-Na for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Apr 2009 00:48:05 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!a5g2000pre.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 36 Original-NNTP-Posting-Host: 68.228.86.141 Original-X-Trace: posting.google.com 1240800241 32396 127.0.0.1 (27 Apr 2009 02:44:01 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 27 Apr 2009 02:44:01 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a5g2000pre.googlegroups.com; posting-host=68.228.86.141; posting-account=S61AnQkAAADt4_PSYpI-Tm-z1E4cd7xa User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:168765 X-Mailman-Approved-At: Mon, 27 Apr 2009 00:47:35 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:64030 Archived-At: On Apr 26, 6:33=A0pm, unfrostedpoptart wrote: > Hi. > > I use shell-mode for almost all my command shells. I don't understand > why the comint history (e.g. comint-previous-matching-input) doesn't > keep one and two-character commands. I frequently mess myself up by > hitting ctl-up ret to rerun the last command and instead run a > different command because the last one was only two characters (e.g. > ls). > > I'm actually running xemacs, but I don't that's an issue here. =A0How to > I get comint history to use all commands? I think I found it. Appears to be comint-input-filter. I added the following to my startup file: (defun two-char-history () (interactive) (defvar comint-input-filter #'(lambda (str) (and (not (string-match "\\`\\s *\\'" str)) ;; Ignore '!!' and kin (> (length str) 1))) "Predicate for filtering additions to input history. Takes one argument, the input. If non-nil, the input may be saved on the input history list. Save two character or more that isn't all whitespace.")) (add-hook 'comint-mode-hook 'two-char-history) This works, but I'm wondering if there's a way to make this cleaner. I'm not very good at elisp! David