Ho can I run an eshell command in another window keeping focus in the working one?
Let's say I'm scanning a buffer searching for a regexp (to be precise an URL) and every time I find it I want to run a command and see the output in another buffer but keeping the focus on the working one.
I'm working on this piece of code:
(while (search-forward-regexp "\\\\\\(?:href\\|url\\){\\([^}]+\\)}" nil t)
(save-excursion
(let ((URL (match-string 1))
(kill-buffer-query-functions nil))
(eshell-command
(concat
"lynx -cookies=1 -accept_all_cookies=1 -cookie_file=cookie.file "
URL))
;; I need to kill the buffer opened by the previous command
(kill-buffer "*lynx*")
)))
compile
command if you don't need an Eshell buffer per se -- e.g.,(compile "date")
.with-current-buffer
, you can use that to do stuff with another buffer ....with-temp-buffer
. If you will post an answer showing the use ofwith-current-buffer
I have pleasure to accept it. Otherwise I will post my own solution for the sake of completeness.