1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-29 11:02:33 +00:00

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.
This commit is contained in:
Carsten Dominik 2009-06-08 08:52:25 +02:00
parent a554e0ce5c
commit 5f3b2c275c
3 changed files with 22 additions and 1 deletions

View File

@ -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.

View File

@ -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))))

View File

@ -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