* Mode for output analysis
@ 2010-12-21 15:49 Andrea Crotti
2010-12-21 18:31 ` Tassilo Horn
0 siblings, 1 reply; 2+ messages in thread
From: Andrea Crotti @ 2010-12-21 15:49 UTC (permalink / raw)
To: help-gnu-emacs
I have a log file which looks something like this:
--8<---------------cut here---------------start------------->8---
28.250000:
1: BEACON_EVENT_TRIGGERED(27)
1: BEACON_SENT
----------------------------------------
28.251000:
3: BEACON_RECEIVED(1)
3: NEIGHBOUR_UPDATED(1)
2: BEACON_RECEIVED(1)
2: NEIGHBOUR_UPDATED(1)
0: BEACON_RECEIVED(1)
0: NEIGHBOUR_UPDATED(1)
--8<---------------cut here---------------end--------------->8---
only today for the first time I thought to actually display the output
in emacs instead of the shell, and I produced:
--8<---------------cut here---------------start------------->8---
(defun pad-show-results (rerun)
"shows the results of the execution"
(interactive "Mrerun?:\n")
(let*
((script (if (null rerun) "./analyze.py" "./runner.py"))
(cmd (concat "cd $PAD_DIR && " script " 1")))
(if (buffer-live-p (get-buffer result-buffer-name))
(kill-buffer (get-buffer result-buffer-name)))
;; maybe can popup always on the same external frame instead
(pop-to-buffer "*pad-results*")
(message (concat "running command " cmd))
(insert (shell-command-to-string cmd))
(goto-line 0)
(compilation-mode)))
(setq compile-command "cd $PAD_DIR && make -j4")
(defun compile-and-show ()
"recompile and show the output of the new execution"
(interactive)
(recompile)
;; does the second command waits for the end of the first??
(pad-show-results t))
--8<---------------cut here---------------end--------------->8---
first a couple of questions:
- is it possible to rewrite on an existing buffer (which is read-only)
more easily than how I do (checking if exist, kill and then create a
new one)?
- am I sure in compile-and-show that the second expression is evaluated
after the compilation is over?
By default the subprocess are synchronous right?
And then I finally realized that I can do much much better, for example
- jump to where the expression shown is logged
- filter over regular expression, node number etc
I think I'll have to use overlays maybe and some black magic, do you
have any advice or example of library which does something like this??
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Mode for output analysis
2010-12-21 15:49 Mode for output analysis Andrea Crotti
@ 2010-12-21 18:31 ` Tassilo Horn
0 siblings, 0 replies; 2+ messages in thread
From: Tassilo Horn @ 2010-12-21 18:31 UTC (permalink / raw)
To: help-gnu-emacs
Andrea Crotti <andrea.crotti.0@gmail.com> writes:
Hi Andrea,
> first a couple of questions:
> - is it possible to rewrite on an existing buffer (which is read-only)
> more easily than how I do (checking if exist, kill and then create a
> new one)?
Use something along the lines of
(progn
(set-buffer (get-buffer-create "*My Result Buffer*"))
(let ((inhibit-read-only t))
(erase-buffer)
;; do stuff in buffer...
))
> - am I sure in compile-and-show that the second expression is evaluated
> after the compilation is over?
> By default the subprocess are synchronous right?
Evaluate
(progn (shell-command-to-string "sleep 5") (message "BING!"))
and see for yourself.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-21 18:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-21 15:49 Mode for output analysis Andrea Crotti
2010-12-21 18:31 ` Tassilo Horn
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.