summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-06-08 08:52:25 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2009-06-08 08:52:25 +0200
commit5f3b2c275c84a3863e0f02df6e5b997e435cce4f (patch)
treebc2028a6c4ff6e100edf820298a7ab7652752beb
parenta554e0ce5cdfc1749bc31f38b0fb702bbf8c5a35 (diff)
downloadorg-mode-5f3b2c275c84a3863e0f02df6e5b997e435cce4f.tar.gz
New hook `org-src-mode-hook'.
This commit adds a new hook `org-src-mode-hook'. The Hook run after Org switched a source code snippet to its Emacs mode. This hook will run - when editing a source code snippet with \"C-c '\". - When formatting a source code snippet for export with htmlize. You may want to use this hook for example to turn off `outline-minor-mode' or similar things which you want to have when editing a source code file, but which mess up the display of a snippet in Org exported files.
-rwxr-xr-xlisp/ChangeLog8
-rw-r--r--lisp/org-exp.el1
-rw-r--r--lisp/org-src.el14
3 files changed, 22 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9f21904..d09ca62 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-08 Carsten Dominik <carsten.dominik@gmail.com>
+
+ * org-exp.el (org-export-format-source-code-or-example): Run
+ `org-src-mode-hook'.
+
+ * org-src.el (org-src-mode-hook): New variable.
+ (org-edit-src-code): Run `org-src-mode-hook'.
+
2009-06-07 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-indent-line-function): Fix indentation of +#end lines.
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 5f18193..4e98bb9 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2219,6 +2219,7 @@ INDENT was the original indentation of the block."
(funcall mode)
(fundamental-mode))
(font-lock-fontify-buffer)
+ (run-hooks 'org-src-mode-hook)
(set-buffer-modified-p nil)
(org-export-htmlize-region-for-paste
(point-min) (point-max))))
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 2112ae2..a0bb301 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -89,6 +89,17 @@ When nil, the message will only be shown intermittently in the echo area."
:type 'boolean)
+(defvar org-src-mode-hook nil
+ "Hook run after Org switched a source code snippet to its Emacs mode.
+This hook will run
+
+- when editing a source code snippet with \"C-c '\".
+- When formatting a source code snippet for export with htmlize.
+
+You may want to use this hook for example to turn off `outline-minor-mode'
+or similar things which you want to have when editing a source code file,
+but which mess up the display of a snippet in Org exported files.")
+
(defvar org-protecting-blocks
'("src" "example" "latex" "ascii" "html" "docbook")
"Blocks that contain text that is quoted, i.e. not processed as Org syntax.
@@ -167,7 +178,8 @@ the edited version."
'(display nil invisible nil intangible nil))
(org-do-remove-indentation)
(let ((org-inhibit-startup t))
- (funcall lang-f))
+ (funcall lang-f)
+ (run-hooks 'org-src-mode-hook))
(set (make-local-variable 'org-edit-src-force-single-line) single)
(set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
(when lfmt