diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-09-12 22:21:12 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-09-12 22:21:12 +0200 |
commit | cbbb754cae5f05ab11988bd9fd5bfc4f949bc968 (patch) | |
tree | ab1e32188db29a5ab791ad8da97a08d1ae1aab45 | |
parent | f76e8c2eb743cf42541723514e5dd659693aee3e (diff) | |
download | org-mode-cbbb754cae5f05ab11988bd9fd5bfc4f949bc968.tar.gz |
Allow M-RET to insert items within drawers
* lisp/org.el (org-meta-return): Allow M-RET to insert items within
drawers. Rewrite function.
This patch also allows a user to insert a headline within a drawer,
which will basically break it. The point is to leave user responsible
for his editing actions.
-rw-r--r-- | lisp/org.el | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lisp/org.el b/lisp/org.el index 997e740..ecc2612 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20690,17 +20690,22 @@ number of stars to add." (defun org-meta-return (&optional arg) "Insert a new heading or wrap a region in a table. -Calls `org-insert-heading' or `org-table-wrap-region', depending on context. -See the individual commands for more information." +Calls `org-insert-heading' or `org-table-wrap-region', depending +on context. See the individual commands for more information." (interactive "P") (org-check-before-invisible-edit 'insert) - (cond - ((run-hook-with-args-until-success 'org-metareturn-hook)) - ((or (org-at-drawer-p) (org-in-drawer-p) (org-at-property-p)) - (newline-and-indent)) - ((org-at-table-p) - (call-interactively 'org-table-wrap-region)) - (t (call-interactively 'org-insert-heading)))) + (or (run-hook-with-args-until-success 'org-metareturn-hook) + (let* ((element (org-element-at-point)) + (type (org-element-type element))) + (when (eq type 'table-row) + (setq element (org-element-property :parent element)) + (setq type 'table)) + (if (and (eq type 'table) + (eq (org-element-property :type element) 'org) + (>= (point) (org-element-property :contents-begin element)) + (< (point) (org-element-property :contents-end element))) + (call-interactively 'org-table-wrap-region) + (call-interactively 'org-insert-heading))))) ;;; Menu entries |