diff options
Diffstat (limited to 'lisp/org/org-src.el')
-rw-r--r-- | lisp/org/org-src.el | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el index da08777a44c..99d7c6f7fda 100644 --- a/lisp/org/org-src.el +++ b/lisp/org/org-src.el @@ -338,7 +338,7 @@ where BEG and END are buffer positions and CONTENTS is a string." (skip-chars-backward " \r\t\n") (line-beginning-position 1)) (org-element-property :value datum))) - ((memq type '(fixed-width table)) + ((memq type '(fixed-width latex-environment table)) (let ((beg (org-element-property :post-affiliated datum)) (end (progn (goto-char (org-element-property :end datum)) (skip-chars-backward " \r\t\n") @@ -881,6 +881,28 @@ Throw an error when not at such a table." (table-recognize) t)) +(defun org-edit-latex-environment () + "Edit LaTeX environment at point. +\\<org-src-mode-map> +The LaTeX environment is copied into a new buffer. Major mode is +set to the one associated to \"latex\" in `org-src-lang-modes', +or to `latex-mode' if there is none. + +When done, exit with `\\[org-edit-src-exit]'. The edited text \ +will then replace +the LaTeX environment in the Org mode buffer." + (interactive) + (let ((element (org-element-at-point))) + (unless (and (eq (org-element-type element) 'latex-environment) + (org-src--on-datum-p element)) + (user-error "Not in a LaTeX environment")) + (org-src--edit-element + element + (org-src--construct-edit-buffer-name (buffer-name) "LaTeX environment") + (org-src--get-lang-mode "latex") + t) + t)) + (defun org-edit-export-block () "Edit export block at point. \\<org-src-mode-map> @@ -898,7 +920,10 @@ Throw an error when not at an export block." (unless (and (eq (org-element-type element) 'export-block) (org-src--on-datum-p element)) (user-error "Not in an export block")) - (let* ((type (downcase (org-element-property :type element))) + (let* ((type (downcase (or (org-element-property :type element) + ;; Missing export-block type. Fallback + ;; to default mode. + "fundamental"))) (mode (org-src--get-lang-mode type))) (unless (functionp mode) (error "No such language mode: %s" mode)) (org-src--edit-element |