org.el (org-insert-heading): Fix bug about wrong conversion of lines with :END: or #+end_ into headlines
* org.el (org-insert-heading): Reveal context when called interactively. Fix bug about wrong conversion of lines with :END: or #+end_ into headlines. (org-in-drawer-p): New function. (org-meta-return): Use `org-catch-invisible-edits' and the `org-in-drawer-p' to check whether we are within a drawer. Thanks to Muchenxuan Tong and John Hendy who reported these errors.
This commit is contained in:
parent
bb0492d717
commit
862b91e8db
22
lisp/org.el
22
lisp/org.el
|
@ -7495,6 +7495,7 @@ and create a new headline with the text in the current line after point
|
||||||
When INVISIBLE-OK is set, stop at invisible headlines when going back.
|
When INVISIBLE-OK is set, stop at invisible headlines when going back.
|
||||||
This is important for non-interactive uses of the command."
|
This is important for non-interactive uses of the command."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
|
(if (org-called-interactively-p 'any) (org-reveal))
|
||||||
(cond
|
(cond
|
||||||
((or (= (buffer-size) 0)
|
((or (= (buffer-size) 0)
|
||||||
(and (not (save-excursion
|
(and (not (save-excursion
|
||||||
|
@ -7550,7 +7551,7 @@ This is important for non-interactive uses of the command."
|
||||||
(blank-a (cdr (assq 'heading org-blank-before-new-entry)))
|
(blank-a (cdr (assq 'heading org-blank-before-new-entry)))
|
||||||
(blank (if (eq blank-a 'auto) empty-line-p blank-a))
|
(blank (if (eq blank-a 'auto) empty-line-p blank-a))
|
||||||
pos hide-previous previous-pos)
|
pos hide-previous previous-pos)
|
||||||
(if ;; At the beginning of a heading, open a new line for insertiong
|
(if ;; At the beginning of a heading, open a new line for insertion
|
||||||
(and (bolp) (org-at-heading-p)
|
(and (bolp) (org-at-heading-p)
|
||||||
(not eops)
|
(not eops)
|
||||||
(or (bobp)
|
(or (bobp)
|
||||||
|
@ -7579,7 +7580,10 @@ This is important for non-interactive uses of the command."
|
||||||
((and (not arg) (not on-heading) (not on-empty-line)
|
((and (not arg) (not on-heading) (not on-empty-line)
|
||||||
(not (save-excursion
|
(not (save-excursion
|
||||||
(beginning-of-line 1)
|
(beginning-of-line 1)
|
||||||
(looking-at org-list-full-item-re))))
|
(or (looking-at org-list-full-item-re)
|
||||||
|
;; Don't convert :end: lines to headline
|
||||||
|
(looking-at "^\\s-*:end:")
|
||||||
|
(looking-at "^\\s-*#\\+end_?")))))
|
||||||
(beginning-of-line 1))
|
(beginning-of-line 1))
|
||||||
(org-insert-heading-respect-content
|
(org-insert-heading-respect-content
|
||||||
(if (not eops)
|
(if (not eops)
|
||||||
|
@ -20575,9 +20579,10 @@ number of stars to add."
|
||||||
Calls `org-insert-heading' or `org-table-wrap-region', depending on context.
|
Calls `org-insert-heading' or `org-table-wrap-region', depending on context.
|
||||||
See the individual commands for more information."
|
See the individual commands for more information."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
|
(org-check-before-invisible-edit 'insert)
|
||||||
(cond
|
(cond
|
||||||
((run-hook-with-args-until-success 'org-metareturn-hook))
|
((run-hook-with-args-until-success 'org-metareturn-hook))
|
||||||
((or (org-at-drawer-p) (org-at-property-p))
|
((or (org-at-drawer-p) (org-in-drawer-p) (org-at-property-p))
|
||||||
(newline-and-indent))
|
(newline-and-indent))
|
||||||
((org-at-table-p)
|
((org-at-table-p)
|
||||||
(call-interactively 'org-table-wrap-region))
|
(call-interactively 'org-table-wrap-region))
|
||||||
|
@ -21541,6 +21546,17 @@ block from point."
|
||||||
names))
|
names))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
(defun org-in-drawer-p ()
|
||||||
|
"Is point within a drawer?"
|
||||||
|
(save-match-data
|
||||||
|
(let ((case-fold-search t)
|
||||||
|
(lim-up (save-excursion (outline-previous-heading)))
|
||||||
|
(lim-down (save-excursion (outline-next-heading))))
|
||||||
|
(org-between-regexps-p
|
||||||
|
(concat "^[ \t]*:" (regexp-opt org-drawers) ":")
|
||||||
|
"^[ \t]*:end:.*$"
|
||||||
|
lim-up lim-down))))
|
||||||
|
|
||||||
(defun org-occur-in-agenda-files (regexp &optional nlines)
|
(defun org-occur-in-agenda-files (regexp &optional nlines)
|
||||||
"Call `multi-occur' with buffers for all agenda files."
|
"Call `multi-occur' with buffers for all agenda files."
|
||||||
(interactive "sOrg-files matching: \np")
|
(interactive "sOrg-files matching: \np")
|
||||||
|
|
Loading…
Reference in New Issue