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

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

RE: eshell prompt function error


From: Doug Lewan
Subject: RE: eshell prompt function error
Date: Mon, 22 Oct 2012 11:42:10 +0000

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!


reply via email to

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