summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-02-01 21:30:54 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-02-01 21:30:54 +0100
commit2b5fbfa473098ca99f4aab059df311d7aeabdee3 (patch)
tree62f3c7f0b0c73ff7384955530cec5e77397aeadc
parent86efe9248454780daeeda7be960b37405744f032 (diff)
downloadorg-mode-2b5fbfa473098ca99f4aab059df311d7aeabdee3.tar.gz
Implement `org-edit-latex-environment'
* lisp/org-src.el (org-edit-latex-environment): New function. * lisp/org.el (org-edit-special): Use new function.
-rw-r--r--etc/ORG-NEWS6
-rw-r--r--lisp/org-src.el24
-rw-r--r--lisp/org.el2
3 files changed, 31 insertions, 1 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index df34067..806b04f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -63,6 +63,12 @@ to the following
list as their first argument.
** New features
+*** ~org-edit-special~ can edit LaTeX environments
+
+Using ~C-c '~ on a LaTeX environment opens a sub-editing buffer. By
+default, major mode in that buffer is ~latex-mode~, but it can be
+changed by configuring ~org-src-lang-modes~.
+
*** Agenda
**** New variable : ~org-agenda-show-future-repeats~
**** New variable : ~org-agenda-prefer-last-repeat~
diff --git a/lisp/org-src.el b/lisp/org-src.el
index b45306e..d07655e 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -332,7 +332,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")
@@ -853,6 +853,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>
diff --git a/lisp/org.el b/lisp/org.el
index 38fce70..8eca958 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20920,6 +20920,7 @@ When at a table, call the formula editor with `org-table-edit-formulas'.
When in a source code block, call `org-edit-src-code'.
When in a fixed-width region, call `org-edit-fixed-width-region'.
When in an export block, call `org-edit-export-block'.
+When in a LaTeX environment, call `org-edit-latex-environment'.
When at an #+INCLUDE keyword, visit the included file.
When at a footnote reference, call `org-edit-footnote-reference'
On a link, call `ffap' to visit the link at point.
@@ -20964,6 +20965,7 @@ Otherwise, return a user error."
(`example-block (org-edit-src-code))
(`export-block (org-edit-export-block))
(`fixed-width (org-edit-fixed-width-region))
+ (`latex-environment (org-edit-latex-environment))
(_
;; No notable element at point. Though, we may be at a link or
;; a footnote reference, which are objects. Thus, scan deeper.