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: Wed, 08 Dec 2010 15:35:49 -0000
User-agent: G2/1.0

On Nov 12, 4:28 am, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > (defun compile-and-preview ()
> >   (interactive)
> >   (compile compile-command)
> >   (graphviz-dot-preview)
> > )
>
> `compile' doesn't wait for the compilation to finish, so maybe the
> problem is simply that graphviz-dot-preview gets run before the
> compilation finished.
>
>         Stefan

Thanks that improved it but still a problem:

I have currently (my additions to graphviz-dot-mode.el below)
1. with compile changed to call process it works when called *twice*
not once
2. I get the message
foo.png changed on disk; really edit the buffer (y,n,r,C-h)

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.

The small change Ive made to graphviz-dot-mode.el is that instead of
the message: buffer needs to be saved I just (basic-save-buffer)




(load-file "graphviz-dot-mode.el")
(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 my-compile()
  (interactive)
  (let ((cp (apply 'call-process graphviz-dot-dot-program
         nil  ; infile
         '("dot-output" "dot-errors")  ; destination buffer
         nil  ; dont keep on redisplaying
         (mk-cmdline)
        )))
    (message "call process returned %s" cp))
)
(defun c-p ()
  (interactive)
  (my-compile)
  (graphviz-dot-preview)
  ;(mypreview)
)


(global-set-key [f5] 'c-p)

;; (defun new-newline()
;;   (interactive)
;;   (c-p)
;;   (newline))


(defun mypreview ()
  "Attempt"
  (interactive)
  (if (buffer-modified-p)
      (basic-save-buffer))
  (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))
    (normal-mode t)
    (revert-buffer t t )
    (display-buffer b)))


reply via email to

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