From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Roden Newsgroups: gmane.emacs.devel Subject: Suggested patch for eshell (em-dirs.el) Date: Thu, 14 Apr 2011 10:57:26 -0400 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=00151747baa8eb97e504a0e2256b X-Trace: dough.gmane.org 1302793261 22641 80.91.229.12 (14 Apr 2011 15:01:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 14 Apr 2011 15:01:01 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 14 17:00:56 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QAO2R-0002Ba-T7 for ged-emacs-devel@m.gmane.org; Thu, 14 Apr 2011 17:00:56 +0200 Original-Received: from localhost ([::1]:50047 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAO2R-0003e2-G7 for ged-emacs-devel@m.gmane.org; Thu, 14 Apr 2011 11:00:55 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:36486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAO2P-0003cp-NY for emacs-devel@gnu.org; Thu, 14 Apr 2011 11:00:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QAO2O-0002NM-MK for emacs-devel@gnu.org; Thu, 14 Apr 2011 11:00:53 -0400 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:55096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAO2O-0002Mx-HM for emacs-devel@gnu.org; Thu, 14 Apr 2011 11:00:52 -0400 Original-Received: by fxm18 with SMTP id 18so1589217fxm.0 for ; Thu, 14 Apr 2011 08:00:50 -0700 (PDT) Original-Received: by 10.223.35.147 with SMTP id p19mr940205fad.13.1302793066092; Thu, 14 Apr 2011 07:57:46 -0700 (PDT) Original-Received: by 10.223.15.137 with HTTP; Thu, 14 Apr 2011 07:57:26 -0700 (PDT) X-Originating-IP: [96.239.59.178] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138479 Archived-At: --00151747baa8eb97e504a0e2256b Content-Type: text/plain; charset=ISO-8859-1 I made a tiny patch to eshell (specifically em-dirs.el) which makes it return non-nil when you successfully 'cd' into a directory. This means you can do: cd some-existing-directory && echo 'success' Without the patch, it never gets to the echo. I'm pretty much a lisp beginner, but this seems to work: diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index 1aa2c34..26256a2 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el @@ -403,4 +403,5 @@ in the minibuffer: (if eshell-list-files-after-cd ;; Let-bind eshell-last-command around this? (eshell-plain-command "ls" (cdr args))) - nil)))) + nil)) + "")) (put 'eshell/cd 'eshell-no-numeric-conversions t) It returns an empty string which satisfies the "&&" without printing any visible characters to the screen. In practice, it looks like this: ~ $ cd /tmp /tmp $ mkdir existing-dir /tmp $ cd non-existant && echo "success" No such directory found via CDPATH environment variable /tmp $ cd existing-dir && echo "success" success /tmp/existing-dir $ Any feedback would be appreciated. -Ted --00151747baa8eb97e504a0e2256b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I made a tiny patch to eshell (specifically em-dirs.el) which makes it= return non-nil when you successfully 'cd' into a directory. This m= eans you can do:

=A0=A0 cd some-existing-directory= && echo 'success'

Without the patch, it never gets to the echo.

I'm pretty much a lisp beginner, but this seems to work= :

diff --git a/lisp/eshell/em-dirs.el b/lisp/= eshell/em-dirs.el
index 1aa2c34..26256a2 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -403,4 +403,5 @@ in the = minibuffer:
=A0 (if eshell-list-files-after-cd
=A0 = =A0 =A0;; Let-bind eshell-last-command around this?
=A0 =A0 =A0(eshell-plai= n-command "ls" (cdr args)))
- nil)= )))
+ nil))
+ =A0 =A0""))

=A0
=A0(put 'eshell/cd 'eshell-no-numeric-conversions t)
=A0
It returns an empty string which satisfies the &qu= ot;&&" without printing any visible characters to the screen.<= /div>

In practice, it looks like this:

=A0=A0 ~ $ cd /tmp
=A0=A0 /tmp $ mkdir existing-di= r
=A0=A0 /tmp $ cd non-existant && echo "success&quo= t;
=A0=A0 No such directory found via CDPATH environment variable=
=A0=A0 /tmp $ cd existing-dir && echo "success"
=A0=A0 success
=A0=A0 /tmp/existing-dir $=A0

Any feedback would be appreciated.=A0

<= /div>
-Ted

--00151747baa8eb97e504a0e2256b--