summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <eschulte@eric-schultes-macbook.local>2009-04-22 16:16:59 -0700
committerEric Schulte <eschulte@eric-schultes-macbook.local>2009-04-22 16:16:59 -0700
commitca6dcc189725f5dee19cc653e07eecd24d8e3452 (patch)
tree1b5cd390ceffecb11a37bea2b379fe5c23e2e9cc
parent578a7b95747304eef06f50f9b1af2eae6ca9616c (diff)
downloadorg-mode-ca6dcc189725f5dee19cc653e07eecd24d8e3452.tar.gz
now using the new `org-tab-first-hook' to cycle visibility of source blocks
-rw-r--r--litorgy/litorgy-init.el (renamed from litorgy/init.el)6
-rw-r--r--litorgy/litorgy-ui.el19
2 files changed, 16 insertions, 9 deletions
diff --git a/litorgy/init.el b/litorgy/litorgy-init.el
index 94a51f4..c583a04 100644
--- a/litorgy/init.el
+++ b/litorgy/litorgy-init.el
@@ -1,4 +1,4 @@
-;;; init.el --- loads litorgy
+;;; litorgy-init.el --- loads litorgy
;; Copyright (C) 2009 Eric Schulte
@@ -41,5 +41,5 @@
(require 'litorgy-lisp)
(require 'litorgy-R)
-(message "litorgy loaded")
-;;; init.el ends here
+(provide 'litorgy-init)
+;;; litorgy-init.el ends here
diff --git a/litorgy/litorgy-ui.el b/litorgy/litorgy-ui.el
index c4eb0e4..0afad6e 100644
--- a/litorgy/litorgy-ui.el
+++ b/litorgy/litorgy-ui.el
@@ -33,19 +33,23 @@
;;; Code:
(require 'litorgy)
-(defadvice org-cycle (around litorgy-ui-org-cycle-src-block activate)
- "Intercept calls to org-cycle to toggle the visibility of a source code block."
- (if (save-excursion
+(defun litorgy-ui-src-block-cycle-maybe ()
+ "Detect if this is context for a litorgical src-block and if so
+then run `litorgy-execute-src-block'."
+ (let ((case-fold-search t))
+ (if (save-excursion
(beginning-of-line 1)
(looking-at litorgy-src-block-regexp))
- (litorgy-ui-src-block-cycle)
- ad-do-it))
+ (progn (call-interactively 'litorgy-ui-src-block-cycle)
+ t) ;; to signal that we took action
+ nil))) ;; to signal that we did not
(defun litorgy-ui-src-block-cycle ()
"Cycle the visibility of the current source code block"
(interactive)
;; should really do this once in an (org-mode hook)
(add-to-invisibility-spec '(litorgy-ui . t))
+ (message "trying out source block")
(save-excursion
(beginning-of-line)
(if (re-search-forward litorgy-src-block-regexp nil t)
@@ -56,7 +60,10 @@
(overlays-at start)))
(remove-overlays start end 'invisible 'litorgy-ui)
(overlay-put (make-overlay start end) 'invisible 'litorgy-ui)))
- (error "not looking at source code block"))))
+ (error "not looking at a source block"))))
+
+;; org-tab-after-check-for-cycling-hook
+(add-hook 'org-tab-first-hook 'litorgy-ui-src-block-cycle-maybe)
(provide 'litorgy-ui)
;;; litorgy-ui ends here