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

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

Re: How to really clear eshell buffer?


From: Emanuel Berg
Subject: Re: How to really clear eshell buffer?
Date: Sun, 10 Jun 2018 13:19:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Bob Newell wrote:

> One thing I question, though ... what you
> have here preserves the prompt but assumes
> that point is on the prompt line. This is
> probably the normal case but it is not the
> universal case. I suppose one could go to
> point-max and then back up a line, but for
> such an odd use case, I wonder how much
> perfection is necessary.

Aha, it was assumed that the user types
"eclear" and hits RET, but OK, now it should
work as an arbitrary command as well:

(defun eclear ()
  (interactive)
  (goto-char (point-max))
  (let ((inhibit-read-only t))
    (delete-region (point-min) (point-at-bol)) ))

Perhaps too arbitrary BTW - perhaps one should
add a guard that confirms that the mode is
EShell, because otherwise one could get used
to it (to invoke it like any command, not type
"ecelar" and hit RET) and then by mistake
"clear" some other useful buffer that way.

DANGER

-- 
underground experts united
http://user.it.uu.se/~embe8573


reply via email to

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