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

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

Re: proper use of save-current-buffer, sleep-for not sleeping?


From: tyler
Subject: Re: proper use of save-current-buffer, sleep-for not sleeping?
Date: Sun, 06 Apr 2008 23:24:25 -0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

tyler <tyler@blackbart.sedgenet> writes:

Further experimenting on the same bit of code reveals it's really not
doing what I thought it was doing. I determined that for larger
functions, which presumably take longer to process, the clean-up of the
target buffer was happening before the process returned all the output.
So I tried modifying the sleep-for time. At this point I realised that
the function was not sleeping at all! In the code below I expect a 10
second pause - why doesn't it happen?

As an aside, I now realise that accept-process-output is probably more
appropriate in this context. However, I can't make that work either.

Cheers,

Tyler

(defun ess-eval-region (start end toggle &optional message)
  "Send the current region to the inferior ESS process.
With prefix argument toggle the meaning of `ess-eval-visibly-p';
this does not apply when using the S-plus GUI, see `ess-eval-region-ddeclient'."
  (interactive "r\nP")
  ;;(untabify (point-min) (point-max))
  ;;(untabify start end); do we really need to save-excursion?
  (ess-force-buffer-current "Process to load into: ")
  (message "Starting evaluation...")

  (if (ess-ddeclient-p)
      (ess-eval-region-ddeclient start end 'even-empty)
    ;; else: "normal", non-DDE behavior:
    (let ((visibly (if toggle (not ess-eval-visibly-p) ess-eval-visibly-p)))
      (if visibly
          (ess-eval-linewise (buffer-substring start end))
        (if ess-synchronize-evals
            (ess-eval-linewise (buffer-substring start end)
                               (or message "Eval region"))
          ;; else [almost always!]
          (let ((sprocess (get-ess-process ess-current-process-name)))
            (process-send-region sprocess start end)
            (process-send-string sprocess "\n"))))))

;;;;;;;;;;; should be sleeping here!!! ;;;;;;;;;;;;;
  (sleep-for 10)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (save-current-buffer
    (set-buffer (get-ess-buffer ess-current-process-name))
    (end-of-buffer)
    (comint-bol)
    (kill-line))

  (message "Finished evaluation")
  ;; return value
  (list start end))


reply via email to

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