SHOW:
|
|
- or go back to the newest paste.
1 | (defun org-babel-block-range () | |
2 | "Return the begin and end points of the current src block" | |
3 | ;; based on org-babel-mark-block | |
4 | (let ((head (org-babel-where-is-src-block-head))) | |
5 | (when head | |
6 | (save-excursion | |
7 | (goto-char head) | |
8 | (looking-at org-babel-src-block-regexp)) | |
9 | (cons (match-beginning 0) (match-end 0))))) | |
10 | ||
11 | (defvar org-babel-evaluation-overlay nil) | |
12 | (defvar org-babel-evaluation-timer nil) | |
13 | (defun org-babel-remove-overlay () | |
14 | (when org-babel-evaluation-timer | |
15 | (cancel-timer org-babel-evaluation-timer) | |
16 | (setq org-babel-evaluation-timer nil)) | |
17 | (when org-babel-evaluation-overlay | |
18 | (delete-overlay org-babel-evaluation-overlay) | |
19 | (setq org-babel-evaluation-overlay nil))) | |
20 | ||
21 | (defadvice org-babel-execute-src-block (around progress nil activate) | |
22 | (unless org-babel-current-src-block-location ;; don't handle this yet | |
23 | (let ((range (org-babel-block-range))) | |
24 | (org-babel-remove-overlay) | |
25 | (setq org-babel-evaluation-overlay | |
26 | (make-overlay (car range) (cdr range) (current-buffer) nil nil)) | |
27 | (overlay-put org-babel-evaluation-overlay 'priority 2) | |
28 | (overlay-put org-babel-evaluation-overlay 'face | |
29 | '(:background "yellow")) | |
30 | (redisplay) | |
31 | (unwind-protect ad-do-it | |
32 | (setq org-babel-evaluation-timer (timer-create)) | |
33 | (timer-set-function org-babel-evaluation-timer | |
34 | 'org-babel-remove-overlay) | |
35 | (timer-set-time org-babel-evaluation-timer | |
36 | - | (time-add (current-time) (seconds-to-time 0.5))) |
36 | + | (time-add (current-time) (seconds-to-time 0.1))) |
37 | (timer-activate org-babel-evaluation-timer))))) |