Guest User

Highlight org-babel block being evaluated

a guest
Aug 31st, 2014
292
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.       (unwind-protect ad-do-it
  31.         (setq org-babel-evaluation-timer (timer-create))
  32.         (timer-set-function org-babel-evaluation-timer
  33.                             'org-babel-remove-overlay)
  34.         (timer-set-time org-babel-evaluation-timer
  35.                         (time-add (current-time) (seconds-to-time 0.5)))
  36.         (timer-activate org-babel-evaluation-timer)))))
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×