emacs-devel
[Top][All Lists]
Advanced

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

showing process progress while waiting


From: Stephen Leake
Subject: showing process progress while waiting
Date: Wed, 04 Mar 2020 12:03:11 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (windows-nt)

I'm trying to display progress info to the user while they are forced to
wait.

There is a background process that is sending symbol info to Emacs; in
this case several thousand symbols, so it takes a while.

If the user invokes a function that requires the completion table using
those symbols, it waits until all symbols are sent, then returns the
table.

The wait is done in a loop like this:

  (with-current-buffer (process-buffer process)
    (when (eq command-type 'symbols)
      ;; show progress in mode line
      (setq gpr-query--symbols-progress "")
      (add-to-list 'mode-line-misc-info '("" gpr-query--symbols-progress " "))
      (force-mode-line-update))

    (while (and (process-live-p process)
                (not done))
      (message (concat "running gpr_query ..." (make-string wait-count ?.)))

      ;; process output is inserted before point, so move back over it to 
search it
      (goto-char search-start)
      (if (re-search-forward gpr-query-prompt (point-max) 1)
          (setq done t)
        ;; else wait for more input
        (unless (accept-process-output process 1.0)
          ;; accept-process returns non-nil when we got output, so we
          ;; did not wait for timeout.
          (setq wait-count (1+ wait-count))
          (when (eq command-type 'symbols)
            ;; update progress
            (force-mode-line-update)
            (redisplay))
          ))
      ))

There is a process filter on the background process that updates
gpr-query--symbols-progress to be "symbols 10%", then "symbols 20%" etc.

However, when I invoke this, the mode line is not updated until I
interrupt it with C-g.

What am I missing?

-- 
-- Stephe



reply via email to

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