diff options
author | Dan Davison <dandavison7@gmail.com> | 2010-12-22 11:50:42 +0000 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2010-12-22 11:50:42 +0000 |
commit | 7fa375d632ebdf1261d65a5b05431a06524d6273 (patch) | |
tree | ff3fe42dbc8ebe34cd6d6457f6097d11aec4f74c | |
parent | 478eabccbdefbf8e2c7d9284267335c84ad6adb5 (diff) | |
download | org-mode-7fa375d632ebdf1261d65a5b05431a06524d6273.tar.gz |
Avoid errors during fontification of src blocks.
* lisp/org-src.el (org-src-font-lock-fontify-block): Test, early on,
that a major-mode function corresponding to the language string
exists.
Thanks to Bernt Hansen for the report and investigation.
-rw-r--r-- | lisp/org-src.el | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/lisp/org-src.el b/lisp/org-src.el index c932b4a..f55e292 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -759,29 +759,29 @@ This function is called by emacs automatic fontification, as long as `org-src-fontify-natively' is non-nil. For manual fontification of code blocks see `org-src-fontify-block' and `org-src-fontify-buffer'" - (let* ((lang-mode (org-src-get-lang-mode lang)) - (string (buffer-substring-no-properties start end)) - (modified (buffer-modified-p)) - (org-buffer (current-buffer)) pos next) - (remove-text-properties start end '(face nil)) - (with-current-buffer - (get-buffer-create - (concat " org-src-fontification:" (symbol-name lang-mode))) - (delete-region (point-min) (point-max)) - (insert string) - (unless (eq major-mode lang-mode) (funcall lang-mode)) - (font-lock-fontify-buffer) - (setq pos (point-min)) - (while (setq next (next-single-property-change pos 'face)) - (put-text-property - (+ start (1- pos)) (+ start next) 'face - (get-text-property pos 'face) org-buffer) - (setq pos next))) - (add-text-properties - start end - '(font-lock-fontified t fontified t font-lock-multiline t)) - (set-buffer-modified-p modified)) - t) ;; Tell `org-fontify-meta-lines-and-blocks' that we fontified + (let ((lang-mode (org-src-get-lang-mode lang))) + (if (fboundp lang-mode) + (let ((string (buffer-substring-no-properties start end)) + (modified (buffer-modified-p)) + (org-buffer (current-buffer)) pos next) + (remove-text-properties start end '(face nil)) + (with-current-buffer + (get-buffer-create + (concat " org-src-fontification:" (symbol-name lang-mode))) + (delete-region (point-min) (point-max)) + (insert string) + (unless (eq major-mode lang-mode) (funcall lang-mode)) + (font-lock-fontify-buffer) + (setq pos (point-min)) + (while (setq next (next-single-property-change pos 'face)) + (put-text-property + (+ start (1- pos)) (+ start next) 'face + (get-text-property pos 'face) org-buffer) + (setq pos next))) + (add-text-properties + start end + '(font-lock-fontified t fontified t font-lock-multiline t)) + (set-buffer-modified-p modified))))) (defun org-src-fontify-block () "Fontify code block at point." |