From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Guido Van Hoecke Newsgroups: gmane.emacs.help Subject: Re: eshell prompt function error Date: Mon, 22 Oct 2012 18:44:12 +0200 Message-ID: References: <155DEC68569B714B86C2C7075F5EDA9826952674@DAKIYA1.pegasus.local> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1350924294 325 80.91.229.3 (22 Oct 2012 16:44:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Oct 2012 16:44:54 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: Doug Lewan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 22 18:45:02 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TQL7Z-00056X-BG for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Oct 2012 18:44:57 +0200 Original-Received: from localhost ([::1]:54778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQL7R-0001tr-0O for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Oct 2012 12:44:49 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQL7K-0001t7-Ve for help-gnu-emacs@gnu.org; Mon, 22 Oct 2012 12:44:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQL7D-0001Gu-0J for help-gnu-emacs@gnu.org; Mon, 22 Oct 2012 12:44:42 -0400 Original-Received: from mail-vc0-f169.google.com ([209.85.220.169]:60119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQL7C-0001Gp-R0 for help-gnu-emacs@gnu.org; Mon, 22 Oct 2012 12:44:34 -0400 Original-Received: by mail-vc0-f169.google.com with SMTP id fl17so3728638vcb.0 for ; Mon, 22 Oct 2012 09:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=2pdxbhhunxsdCUXAeJbAH216tDz20QCxQq3i1I9vkL4=; b=IQS5XQLGyhjUGhxahujiHGkueZZTDdxHwJCqdOkFIJ+BGeuHh6jxnwgzqvN6okcV4f I5jJFfMUoQivuKXLsbjpMI6H2TBkPziK9/2dfGn5XugUisiWfGKtj7CXqh2RgQX3K8cj GWCyka164dcw3e149RZx8AnaYGNzOd6PPRmNQgah1s9U5tjpbWsgm+FwlqbSUJz8Ts2c rjsjAwfiZFQZgLdZIS8DwMuWHOCtxA/h5XldbfGe0bDbxh1FkANIFJtaMuFy4egw2fsj dwSFC9yzEu87EvuG0WlmUx0H+Dw+Asgn1twHer6vIGJtA98uncbhb93luv0B3Ia2C06j tI1A== Original-Received: by 10.52.76.103 with SMTP id j7mr12668514vdw.22.1350924273163; Mon, 22 Oct 2012 09:44:33 -0700 (PDT) Original-Received: by 10.220.6.207 with HTTP; Mon, 22 Oct 2012 09:44:12 -0700 (PDT) In-Reply-To: <155DEC68569B714B86C2C7075F5EDA9826952674@DAKIYA1.pegasus.local> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.220.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87362 Archived-At: Doug, There's probably some interaction with other parts of my initialisation code. Trying to build a pure test case, I started an emasc --no-init-file, sourced the eshell.clear and the eshell-prompt-function and - as you said - they work fine. So I'll start hunting for some code that could interact. Thanks for your reply. Kind regards, Guido On 22 October 2012 13:42, Doug Lewan wrote: > Guido, > > I have no problems with this. Specifically, using eshell/clear like a shell command or via M-x both seem to work. > > Could you provide an error case? > > Thanks. > > ,Doug > > >> -----Original Message----- >> From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org >> [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On >> Behalf Of Guido Van Hoecke >> Sent: Saturday, 2012 October 20 09:49 >> To: help-gnu-emacs@gnu.org >> Subject: eshell prompt function error >> >> Hi, >> >> I am not very proficient in lisp, so I would like some advise. >> >> I like my eshell prompt of the form >> >> 2012-10-20 15:21 ~/dir/subdir >> $ >> >> I use following function gratefully based upon code in >> http://www.northbound-train.com/emacs/em-joc.el >> >> (setq eshell-prompt-function >> (lambda () >> (let ((prompt (eshell/pwd)) >> (now (format-time-string "\n%Y-%m-%d %H:%M " (current- >> time))) >> (home-dir (expand-file-name "~"))) >> ;; get rid of the nasty backslashes >> (while (string-match "\\\\" home-dir) >> (setq home-dir (replace-match "/" nil t home-dir))) >> >> ;; match home-dir at the begining of the line >> ;; be careful not to match `/users/foo.old' if $HOME is >> `/users/foo' >> (if (string-match >> (concat "^\\(" home-dir "\\)\\(/.*\\)?$") >> prompt) >> >> (setq prompt (replace-match >> (if (and (match-string 2)) >> "~\\2" >> "~") >> nil >> nil >> prompt >> 0))) >> >> ;; return the prompt >> ;; -tack on \n$ or \n# depending on user id >> (concat now prompt >> (if (= (user-uid) 0) "\n# " "\n$ "))))) >> >> Works fine 99,99% of the time >> >> I also want to clear my eshell buffer from time to time and copied >> (thank you oh original author) following method: >> >> (defun eshell/clear () >> "04Dec2001 - sailor, to clear the eshell buffer." >> (interactive) >> (let ((inhibit-read-only t)) >> (erase-buffer))) >> >> Can somebody explain why my prompt function does not work anymore after >> having issued the clear command? >> >> It prints following text in the eshell buffer and no longer shows a >> prompt: >> >> Args out of range: 13, 38 >> >> When entering a command in this promptless buffer, it does work and >> shows the prompt after executing the command. >> >> I'd like to know what causes this and how to avoid it. >> >> Any one? >> >> Thanks in advance, >> >> >> Guido >> >> -- >> La-dee-dee, la-dee-dah. >> >> http://vanhoecke.org ... and go2 places! >