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

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

Re: Need help with eshell hack


From: Mathias Dahl
Subject: Re: Need help with eshell hack
Date: Fri, 21 Dec 2007 00:32:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

Mathias Dahl <mathias.dahl@gmail.com> writes:

> It almost works. The problem is that when output from the command
> reaches the bottom of the visible part of the eshell window, the
> window isn't scrolled down to show the output.

I let go of the `save-excursion' + `set-buffer' approach, in other words
being a bad boy, and got this that seems to work for me:

(defun my-eshell-execute-current-line ()
  "Insert text of current line in eshell and execute."
  (interactive)
  (let ((command (buffer-substring
                  (save-excursion
                    (beginning-of-line)
                    (point))
                  (save-excursion
                    (end-of-line)
                    (point)))))
    (let ((buf (current-buffer)))
      (unless (get-buffer eshell-buffer-name)
        (eshell))
      (display-buffer eshell-buffer-name t)
      (switch-to-buffer-other-window eshell-buffer-name)
      (end-of-buffer)
      (eshell-kill-input)
      (insert command)
      (eshell-send-input)
      (end-of-buffer)
      (switch-to-buffer-other-window buf))))

It annoys be however that I could not get it working without using
switch-to-buffer... The docstring says to avoid use it.

Oh well,

/Mathias


reply via email to

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