[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Mode for output analysis
From: |
Andrea Crotti |
Subject: |
Mode for output analysis |
Date: |
Tue, 21 Dec 2010 16:49:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) |
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??
- Mode for output analysis,
Andrea Crotti <=