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: eshell prompt function error Date: Sat, 20 Oct 2012 15:48:36 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1350740948 1988 80.91.229.3 (20 Oct 2012 13:49:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Oct 2012 13:49:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 20 15:49:16 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 1TPZQO-0005NI-Sd for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Oct 2012 15:49:12 +0200 Original-Received: from localhost ([::1]:51037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPZQH-000397-CL for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Oct 2012 09:49:05 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPZQC-000391-5t for help-gnu-emacs@gnu.org; Sat, 20 Oct 2012 09:49:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TPZQA-0006zT-S0 for help-gnu-emacs@gnu.org; Sat, 20 Oct 2012 09:49:00 -0400 Original-Received: from mail-wg0-f49.google.com ([74.125.82.49]:55865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPZQA-0006ym-Ld for help-gnu-emacs@gnu.org; Sat, 20 Oct 2012 09:48:58 -0400 Original-Received: by mail-wg0-f49.google.com with SMTP id gg4so769189wgb.30 for ; Sat, 20 Oct 2012 06:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=Zmf03MUqqcB2lO48X8VLN9WbhScs/LvIvQyeOnrsAqY=; b=n/ENMwcE1tK4nW91x+zfkSvwDAB9tba/gJLN9i5otoLEKvde4d4ubtjagoc1F/Wo7W 8QQ1RxTYqFIf/uCK6KqCqGtuEZaI6uhrx5ODcvkKOk+hNNWYk4i8nAryfpsy+PZrQKMX XpHcOysFHlgEuAUSo63YY1fgprsSTXntfUt6Ws/DjeuJJ7h6koGQ4ejev+NbKr9P7u3e fDiD+5Sj/rVyZcmry3e2h1YCvVRi4Dmrncfn4QFo9/2sRrWJiFFDuvKuBnJa4Z/SXQSW Cs8RPX6Im5jgKyN2gcukcXJMvtTSFPM2yr41VZHc6jyQQEU3B3XZFCkkWgVec9eU3gPC afSA== Original-Received: by 10.180.79.202 with SMTP id l10mr9657631wix.9.1350740937110; Sat, 20 Oct 2012 06:48:57 -0700 (PDT) Original-Received: by 10.223.97.14 with HTTP; Sat, 20 Oct 2012 06:48:36 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.49 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:87341 Archived-At: 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!