* Instruct emacs --batch to wait for something
@ 2021-11-17 16:41 Rodrigo Morales
2021-11-18 16:20 ` Marcin Borkowski
0 siblings, 1 reply; 3+ messages in thread
From: Rodrigo Morales @ 2021-11-17 16:41 UTC (permalink / raw)
To: help-gnu-emacs
I'm trying to use Emacs as a tool for getting the text representation of
a website. For doing this, I'm using "eww" and I've written the
following command that I intend to use in the command line.
#+begin_src bash
emacs \
--batch \
--eval='(eww "https://www.gnu.org/software/emacs/manual/html_node/emacs/Intro.html")' \
--eval='(with-current-buffer "*eww*" (princ (buffer-string)))'
#+end_src
The problem with this command is that it shows the following instead of
showing the website.
#+RESULTS:
#+begin_example
Loading https://www.gnu.org/software/emacs/manual/html_node/emacs/Intro.html...
#+end_example
My question is: How can I instruct Emacs to wait for something when the
=--batch= flag is used?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Instruct emacs --batch to wait for something
2021-11-17 16:41 Instruct emacs --batch to wait for something Rodrigo Morales
@ 2021-11-18 16:20 ` Marcin Borkowski
2021-11-18 19:05 ` Rodrigo Morales
0 siblings, 1 reply; 3+ messages in thread
From: Marcin Borkowski @ 2021-11-18 16:20 UTC (permalink / raw)
To: Rodrigo Morales; +Cc: help-gnu-emacs
On 2021-11-17, at 17:41, Rodrigo Morales <moralesrodrigo1100@gmail.com> wrote:
> I'm trying to use Emacs as a tool for getting the text representation of
> a website. For doing this, I'm using "eww" and I've written the
> following command that I intend to use in the command line.
>
> #+begin_src bash
> emacs \
> --batch \
> --eval='(eww "https://www.gnu.org/software/emacs/manual/html_node/emacs/Intro.html")' \
> --eval='(with-current-buffer "*eww*" (princ (buffer-string)))'
> #+end_src
>
> The problem with this command is that it shows the following instead of
> showing the website.
>
> #+RESULTS:
> #+begin_example
> Loading https://www.gnu.org/software/emacs/manual/html_node/emacs/Intro.html...
> #+end_example
>
> My question is: How can I instruct Emacs to wait for something when the
> =--batch= flag is used?
I don't know, but did you try something blunt like
--eval='(sleep-for 5)'?
Of course, this would be very fragile and far from good practice...
Alternatively, maybe `eww-after-render-hook' would be useful?
Hth,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Instruct emacs --batch to wait for something
2021-11-18 16:20 ` Marcin Borkowski
@ 2021-11-18 19:05 ` Rodrigo Morales
0 siblings, 0 replies; 3+ messages in thread
From: Rodrigo Morales @ 2021-11-18 19:05 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> I don't know, but did you try something blunt like
> --eval='(sleep-for 5)'?
> Of course, this would be very fragile and far from good practice...
> Alternatively, maybe `eww-after-render-hook' would be useful?
Thanks for the help!
I was able to do what I was looking for with this hack (see code block
below), but now I have another problem: Some newlines are misplaced in
the *eww* buffer, for some reason. Please, continue reading.
#+begin_src dash
emacs \
-batch \
--eval="(setq _ (symbol-function 'kill-emacs))" \
--eval="(fset 'kill-emacs 'ignore)" \
--eval='(eww "https://www.gnu.org/software/emacs/manual/html_node/org/Introduction.html")' \
--eval="(add-hook 'eww-after-render-hook (lambda () (with-current-buffer \"*eww*\" (princ (buffer-string))) (funcall _)))"
#+end_src
#+RESULTS:
#+begin_example
Next:
Document
Structure,
Previous:
Top,
Up:
Top
[Contents][Index]
1
Introduction
• Summary Brief summary of what Org does.
• Installation Installing Org.
• Activation How to activate Org for certain buffers.
• Feedback Bug reports, ideas, patches, etc.
• Conventions Typesetting conventions used in this manual.
#+end_example
I can confirm that newlines are misplaced because when I open the same
URL in a running Emacs instance (the one that I'm also using to write
this response), the following is shown in the *eww* buffer when visiting
the same URL
(https://www.gnu.org/software/emacs/manual/html_node/org/Introduction.html).
#+BEGIN_SRC text
Next: Document Structure, Previous: Top, Up: Top [Contents][Index]
1 Introduction
• Summary Brief summary of what Org does.
• Installation Installing Org.
• Activation How to activate Org for certain buffers.
• Feedback Bug reports, ideas, patches, etc.
• Conventions Typesetting conventions used in this manual.
#+END_SRC
Do you know what might be causing this? Any help is appreciated.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-18 19:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-17 16:41 Instruct emacs --batch to wait for something Rodrigo Morales
2021-11-18 16:20 ` Marcin Borkowski
2021-11-18 19:05 ` Rodrigo Morales
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).