* idle-timer for processing all buffers with selected minor-mode.
@ 2012-10-28 19:17 Oleksandr Gavenko
2012-10-28 19:38 ` Tom
0 siblings, 1 reply; 2+ messages in thread
From: Oleksandr Gavenko @ 2012-10-28 19:17 UTC (permalink / raw)
To: help-gnu-emacs
While I playing with dumb implementation for:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12747
I got question. Firstly what I think (is I right?):
Emacs allow move complicate job to time when it idle by using
'run-with-idle-timer'. But action performed by timer global for whole Emacs.
So it must check environment before making actual action. For example check
if current buffer in desired major/minor-mode to prevent harms:
(defun diff-auto+-refine-action ()
(when (eq major-mode 'diff-mode)
(diff-refine-hunk)))
(run-with-idle-timer 2 t 'diff-auto+-refine-action)
Next my questions:
Is it good to enumerate all buffers with selected major/miror-mode in idle
timer and perform action on all of them?
Is that only way to perform actions in background on selected buffers?
Please advise me best practices or point to source code that implement
asked techniques.
--
Best regards!
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: idle-timer for processing all buffers with selected minor-mode.
2012-10-28 19:17 idle-timer for processing all buffers with selected minor-mode Oleksandr Gavenko
@ 2012-10-28 19:38 ` Tom
0 siblings, 0 replies; 2+ messages in thread
From: Tom @ 2012-10-28 19:38 UTC (permalink / raw)
To: help-gnu-emacs
Oleksandr Gavenko <gavenkoa <at> gmail.com> writes:
>
> While I playing with dumb implementation for:
>
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12747
>
> I got question. Firstly what I think (is I right?):
>
> Emacs allow move complicate job to time when it idle by using
> 'run-with-idle-timer'.
A hook is better in this case. This is what I use for
refining all chunks automatically:
(add-hook 'diff-mode-hook 'my-diff-stuff)
(defun my-diff-stuff ()
(unless (or (eq this-command 'dvc-diff)
(eq this-command 'dvc-generic-refresh)
(> (buffer-size) 20000))
(my-refine-all-diff-hunks)))
(defun my-refine-all-diff-hunks ()
(interactive)
(condition-case nil
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(diff-hunk-next)))
(error nil)))
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-28 19:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-28 19:17 idle-timer for processing all buffers with selected minor-mode Oleksandr Gavenko
2012-10-28 19:38 ` Tom
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.