From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#7585: 23.2.90; [PATCH] fix eshell-previous-matching-input Date: Tue, 14 Dec 2010 06:13:00 +0000 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1292307770 6233 80.91.229.12 (14 Dec 2010 06:22:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 14 Dec 2010 06:22:50 +0000 (UTC) Cc: John Wiegley , 7585@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 14 07:22:45 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PSOHd-00029p-7n for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Dec 2010 07:22:45 +0100 Original-Received: from localhost ([127.0.0.1]:34353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSOHc-0001Lw-8Y for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Dec 2010 01:22:44 -0500 Original-Received: from [140.186.70.92] (port=47119 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSOHV-0001Lr-6i for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2010 01:22:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PSOHQ-0007rJ-08 for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2010 01:22:37 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43699) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PSOHP-0007rF-Qh for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2010 01:22:31 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PSO2P-0002la-Qq; Tue, 14 Dec 2010 01:07:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Dec 2010 06:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7585 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 7585-submit@debbugs.gnu.org id=B7585.129230681510621 (code B ref 7585); Tue, 14 Dec 2010 06:07:01 +0000 Original-Received: (at 7585) by debbugs.gnu.org; 14 Dec 2010 06:06:55 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PSO2I-0002lG-4y for submit@debbugs.gnu.org; Tue, 14 Dec 2010 01:06:54 -0500 Original-Received: from mail-ww0-f46.google.com ([74.125.82.46]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PSO2G-0002l3-13 for 7585@debbugs.gnu.org; Tue, 14 Dec 2010 01:06:52 -0500 Original-Received: by wwj40 with SMTP id 40so240372wwj.15 for <7585@debbugs.gnu.org>; Mon, 13 Dec 2010 22:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=W0hStAfG0IaSdF59VGXZ8vd+tnPkrBfGcraF9ek6AZ4=; b=exIyUNe+N5AdRYkEQN8ZZqEhNots8QX8JSpnBRzQLSczV1jrXxFha0uucLpocc8dbK WIt2fZejyXHM37wyZpbvX/USCCxuz1faFkZaHs/MEjzVuPQotRRYEH1jjli2VMueXeGM Ia7bEK6KLjyZnvW8bqOSo7602mAvehLmfCoek= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=b9l2U5hTlv/nCZwdCS7mXxgJM2ujxSu5kIsY5XognFg0WhnbQjXehGujFwik+maugH QQzo5IC1tf06hDtNh06Kv6R4lzpiywpfFDwAx7izEjgrlF6NF3kVboUPw/35R4Rr6/1b Htt4H0AHJIK/TcbCJ7e8ykJfK/wBvghGB+8ek= Original-Received: by 10.216.185.2 with SMTP id t2mr1044007wem.70.1292307184088; Mon, 13 Dec 2010 22:13:04 -0800 (PST) Original-Received: from Victoria.local (cpc1-cmbg13-0-0-cust596.5-4.cable.virginmedia.com [86.9.122.85]) by mx.google.com with ESMTPS id m50sm1286010wek.8.2010.12.13.22.13.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 13 Dec 2010 22:13:02 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Mon, 13 Dec 2010 15:42:39 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.91 (Mac OS X 10.6.5) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 14 Dec 2010 01:07:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:42507 Archived-At: On 2010-12-13 20:42 +0000, Stefan Monnier wrote: >> Would something like the following acceptable? Thanks. Leo > > No, don't use `message': this is a real error, use `signal' or `error'. > > > Stefan OK. Here is the whole thing with the change of `message' to `error'. Without this patch, one usually gets an error like "Text is read-only" when M-n/p. So the error is obscure. The patch makes the error more useful. 2010-12-13 Leo * eshell/em-hist.el (eshell-previous-matching-input): Check point is located after eshell prompt in case `eshell-hist-move-to-end' is nil. lisp/eshell/em-hist.el | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index 45fe050..47e0b2b 100644 --- a/lisp/eshell/em-hist.el +++ b/lisp/eshell/em-hist.el @@ -837,16 +837,18 @@ With prefix argument N, search for Nth previous match. If N is negative, find the next or Nth next match." (interactive (eshell-regexp-arg "Previous input matching (regexp): ")) (setq arg (eshell-search-arg arg)) - (let ((pos (eshell-previous-matching-input-string-position regexp arg))) - ;; Has a match been found? - (if (null pos) - (error "Not found") - (setq eshell-history-index pos) - (unless (minibuffer-window-active-p (selected-window)) - (message "History item: %d" (- (ring-length eshell-history-ring) pos))) - ;; Can't use kill-region as it sets this-command - (delete-region eshell-last-output-end (point)) - (insert-and-inherit (eshell-get-history pos))))) + (if (<= eshell-last-output-end (point)) + (let ((pos (eshell-previous-matching-input-string-position regexp arg))) + ;; Has a match been found? + (if (null pos) + (error "Not found") + (setq eshell-history-index pos) + (unless (minibuffer-window-active-p (selected-window)) + (message "History item: %d" (- (ring-length eshell-history-ring) pos))) + ;; Can't use kill-region as it sets this-command + (delete-region eshell-last-output-end (point)) + (insert-and-inherit (eshell-get-history pos)))) + (error "Point not located after prompt"))) (defun eshell-next-matching-input (regexp arg) "Search forwards through input history for match for REGEXP. -- 1.7.3