unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: tyler <tyler.smith@mail.mcgill.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: proper use of save-current-buffer, sleep-for not sleeping?
Date: Sun, 06 Apr 2008 23:24:25 -0300	[thread overview]
Message-ID: <873apy1jxi.fsf@blackbart.sedgenet> (raw)
In-Reply-To: 87ej9l2ev7.fsf@blackbart.sedgenet

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))


      parent reply	other threads:[~2008-04-07  2:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-05  2:51 proper use of save-current-buffer tyler
2008-04-05  2:59 ` tyler
2008-04-05  3:35   ` gnus email address fixed [Re: proper use of save-current-buffer] tyler
2008-04-05 10:10     ` gnus email address fixed Reiner Steib
2008-04-07  2:24 ` tyler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=873apy1jxi.fsf@blackbart.sedgenet \
    --to=tyler.smith@mail.mcgill.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).