all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to really clear eshell buffer?
@ 2018-06-08  9:13 Florian Lindner
  2018-06-08 17:50 ` Bob Newell
       [not found] ` <mailman.1526.1528480263.1292.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Florian Lindner @ 2018-06-08  9:13 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I want to really clear an eshell buffer, which means that all former output is deleted, not just scrolled away.
eshell/clear only scrolls away, eshell-truncate-buffer also does not clear. comint-clear-buffer gives an error message,
probably because eshell is not comint mode.

Thanks,
Florian



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to really clear eshell buffer?
  2018-06-08  9:13 How to really clear eshell buffer? Florian Lindner
@ 2018-06-08 17:50 ` Bob Newell
  2018-06-09  6:10   ` Colin Baxter
       [not found] ` <mailman.1526.1528480263.1292.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 10+ messages in thread
From: Bob Newell @ 2018-06-08 17:50 UTC (permalink / raw)
  Cc: help-gnu-emacs

> I want to really clear an eshell buffer, which means that all former output is deleted, not just scrolled away.

(defun clear-eshell ()
(interactive)
(setq inhibit-read-only t)
(kill-region (point-min) (point-max)))

I don't see any real need to switch back to read-only mode.

Tie to a key if you wish and run while in the eshell buffer.





-- 
Bob Newell
Honolulu, Hawai`i

Sent via Linux Mint 17.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to really clear eshell buffer?
  2018-06-08 17:50 ` Bob Newell
@ 2018-06-09  6:10   ` Colin Baxter
  2018-06-09  6:27     ` Colin Baxter
  0 siblings, 1 reply; 10+ messages in thread
From: Colin Baxter @ 2018-06-09  6:10 UTC (permalink / raw)
  To: Bob Newell; +Cc: help-gnu-emacs

>>>>> "Bob" == Bob Newell <bobnewell@bobnewell.net> writes:

    >> I want to really clear an eshell buffer, which means that all
    >> former
    Bob> output is deleted, not just scrolled away.

    Bob> (defun clear-eshell () (interactive) (setq inhibit-read-only t)
    Bob> (kill-region (point-min) (point-max)))

    Bob> I don't see any real need to switch back to read-only mode.

    Bob> Tie to a key if you wish and run while in the eshell buffer.
If you do, via say:

(add-hook 'eshell-mode-hook
          (lambda () (local-set-key (kbd "C-l") #'clear-eshell)))

then the eshell prompt is lost - regained if RET is entered.

Best wishes,



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to really clear eshell buffer?
  2018-06-09  6:10   ` Colin Baxter
@ 2018-06-09  6:27     ` Colin Baxter
  0 siblings, 0 replies; 10+ messages in thread
From: Colin Baxter @ 2018-06-09  6:27 UTC (permalink / raw)
  To: Bob Newell; +Cc: help-gnu-emacs

>>>>> "Colin" == Colin Baxter <m43cap@yandex.com> writes:

>>>>> "Bob" == Bob Newell <bobnewell@bobnewell.net> writes:
    >>> I want to really clear an eshell buffer, which means that all
    >>> former
    Bob> output is deleted, not just scrolled away.

    Bob> (defun clear-eshell () (interactive) (setq inhibit-read-only t)
    Bob> (kill-region (point-min) (point-max)))

    Bob> I don't see any real need to switch back to read-only mode.

    Bob> Tie to a key if you wish and run while in the eshell buffer.
    Colin> If you do, via say:

    Colin> (add-hook 'eshell-mode-hook (lambda () (local-set-key (kbd
    Colin> "C-l") #'clear-eshell)))

    Colin> then the eshell prompt is lost - regained if RET is entered.

Just need to add (eshell-send-input) to the defun. Sorry about the
noise.

Best wishes,



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to really clear eshell buffer?
       [not found] ` <mailman.1526.1528480263.1292.help-gnu-emacs@gnu.org>
@ 2018-06-09 20:02   ` Emanuel Berg
  2018-06-09 20:58     ` Emanuel Berg
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg @ 2018-06-09 20:02 UTC (permalink / raw)
  To: help-gnu-emacs

Bob Newell wrote:

>> I want to really clear an eshell buffer,
>> which means that all former output is
>> deleted, not just scrolled away.
>
> (defun clear-eshell ()
> (interactive)
> (setq inhibit-read-only t)
> (kill-region (point-min) (point-max)))
>
> I don't see any real need to switch back to
> read-only mode.

Hit DEL and you'll see the need. (Besides it is
an unexpected side effect not evident from the
function name.)

Second, you also kill the prompt string this
way. Sure, it returns with RET, but this isn't
how one would expect clear to work. It should,
IMO, work just like in a VT with the state
unchanged WRT read-only, and with the prompt
intact, only the material removed!

Thrid, with `kill-region', the material ends up
in the kill ring. Unclear if this is intuitive
or not?

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to really clear eshell buffer?
  2018-06-09 20:02   ` Emanuel Berg
@ 2018-06-09 20:58     ` Emanuel Berg
  2018-06-09 21:39       ` Emanuel Berg
                         ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Emanuel Berg @ 2018-06-09 20:58 UTC (permalink / raw)
  To: help-gnu-emacs

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

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to really clear eshell buffer?
  2018-06-09 20:58     ` Emanuel Berg
@ 2018-06-09 21:39       ` Emanuel Berg
  2018-06-10  0:08       ` Bob Newell
       [not found]       ` <mailman.1611.1528589338.1292.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2018-06-09 21:39 UTC (permalink / raw)
  To: help-gnu-emacs

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

In the thread about ERC, the question was
raised why one couldn't just throw away the IRC
logs and be done with it.

Here, the question is the same, only opposite,
why would one want to throw the previous work
and IO away?

I remember using the Linux VT before I learned
about tmux [1], it was very annoying that one
could never scroll back to see information
already processed. Note that this limitation
was always there, and one didn't even have to
(ab)use clear, still, using clear this way
brings me back to that very
frustrated situation.

To clear the screen to clear one's thoughts,
i.e. to focus, is one thing, but then why is it
necessary to remove the material altogether,
why isn't just hiding it above enough?

[1] I hear one can do the same with screen and
    probably some other software as well.

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to really clear eshell buffer?
  2018-06-09 20:58     ` Emanuel Berg
  2018-06-09 21:39       ` Emanuel Berg
@ 2018-06-10  0:08       ` Bob Newell
       [not found]       ` <mailman.1611.1528589338.1292.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 10+ messages in thread
From: Bob Newell @ 2018-06-10  0:08 UTC (permalink / raw)
  Cc: help-gnu-emacs

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

Much better in many ways. It doesn't disturb the kill-ring and limits
the scope of inhibit-read-only. Thank you. Please realize that I threw
something together in literally one minute, and I am the first to say
that I still have much to learn.

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.

-- 
Bob Newell
Honolulu, Hawai`i

Sent via Linux Mint 17.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to really clear eshell buffer?
       [not found]       ` <mailman.1611.1528589338.1292.help-gnu-emacs@gnu.org>
@ 2018-06-10 11:19         ` Emanuel Berg
  2018-06-10 14:08           ` Emanuel Berg
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg @ 2018-06-10 11:19 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to really clear eshell buffer?
  2018-06-10 11:19         ` Emanuel Berg
@ 2018-06-10 14:08           ` Emanuel Berg
  0 siblings, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2018-06-10 14:08 UTC (permalink / raw)
  To: help-gnu-emacs

> 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.

(defun eclear ()
  (interactive)
  (when (eq major-mode 'eshell-mode)
    (goto-char (point-max))
    (let ((inhibit-read-only t))
      (delete-region (point-min) (point-at-bol)) )))

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-06-10 14:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-08  9:13 How to really clear eshell buffer? Florian Lindner
2018-06-08 17:50 ` Bob Newell
2018-06-09  6:10   ` Colin Baxter
2018-06-09  6:27     ` Colin Baxter
     [not found] ` <mailman.1526.1528480263.1292.help-gnu-emacs@gnu.org>
2018-06-09 20:02   ` Emanuel Berg
2018-06-09 20:58     ` Emanuel Berg
2018-06-09 21:39       ` Emanuel Berg
2018-06-10  0:08       ` Bob Newell
     [not found]       ` <mailman.1611.1528589338.1292.help-gnu-emacs@gnu.org>
2018-06-10 11:19         ` Emanuel Berg
2018-06-10 14:08           ` Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.