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

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

Re: elisp: interactive and non-interactive diffs


From: rustom
Subject: Re: elisp: interactive and non-interactive diffs
Date: Thu, 2 Dec 2010 05:18:57 -0800 (PST)
User-agent: G2/1.0

On Dec 1, 10:53 pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> >> > What I need is a way of the emacs buffer tracking the external file
> >> > rather than the usual other way round.  Usually the latest version is
> >> > in the buffer and file-saves (and autosaves to #file# ) makes the file
> >> > track emacs.
> >> > Thats is just like in gv if one sets the watch option the gv display
> >> > keeps changing as the external file changes, here too I want to keep
> >> > reverting the buffer as it changes.
> >> You probably want auto-revert-mode.
> > Now what happens is that the buffer in image mode goes into text mode
> > and Ive to switch to it and do C-c C-c (sometimes twice)
>
> Hmm... that reminds me of a similar bug I've fixed.  Can you try with
> the latest pretest of 23.3 (aka 23.2.90 IIRC) and if it still fails
> there file a bug-report about it?
>
>         Stefan

My net connection is suddenly flaky -- will not do a 200M download
without packing up
Should get right in a couple of days...

So I tried the autorevert.el from
http://bazaar.launchpad.net/~vcs-imports/emacs/trunk/annotate/head%3A/lisp/autorevert.el
but the bug is still there.

For now Ive pasted my code below. Can you try it?
To try:
You need a dot file in one window (Ive put a trivial one also below)
F5 should start a preview window
After that Return should be 'electric' ie it should refresh the graph
window

-------------elisp code -------------------
(setq graphviz-dot-dot-program "dot")
(setq graphviz-dot-preview-extension "png")
(setq auto-revert-interval 2)

(defun mk-cmdline ()
  (list (concat "-T" graphviz-dot-preview-extension)
        buffer-file-name
        "-o"
        (concat (file-name-sans-extension buffer-file-name)
                "."
                graphviz-dot-preview-extension)))
(defun graphviz-dot-compile()
  (interactive)
  (if (buffer-modified-p)
      (basic-save-buffer))
  (apply 'call-process graphviz-dot-dot-program
         nil  ; no infile
         '("dot-output" "dot-errors")  ; destination buffer, error file
         nil  ; dont keep on redisplaying
         (mk-cmdline)))

(defun graphviz-dot-preview ()
  (interactive)
  (let* ((f (concat (file-name-sans-extension (buffer-file-name))
                    "."
                    graphviz-dot-preview-extension))
         (b (file-name-nondirectory f)))
    (set-buffer (find-file-noselect b t))
    (auto-revert-mode 1)
    (display-buffer b)))

(add-hook 'after-revert-hook 'image-toggle-display)

(defun compile-preview ()
  (interactive)
  (graphviz-dot-compile)
  (graphviz-dot-preview)
)

(global-set-key [f5] 'compile-preview)

(defun newline-compile ()
  (interactive)
  (newline)
  (graphviz-dot-compile))

(global-set-key (kbd "RET") 'newline-compile)


------------- graphviz graph -----------
graph G {
        a [color="blue", fontcolor="green"]
        a -- q -- r -- a
}



reply via email to

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