help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comint history question


From: unfrostedpoptart
Subject: Re: comint history question
Date: Sun, 26 Apr 2009 19:44:01 -0700 (PDT)
User-agent: G2/1.0

On Apr 26, 6:33 pm, unfrostedpoptart <da...@therogoffs.com> 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.  How 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]