org: Remove special whitespace treatment when moving subtree
* lisp/org.el (org-move-subtree-down): Remove special whitespace treatment. * testing/lisp/test-org.el (test-org/drag-element-backward): Accommodate test.
This commit is contained in:
parent
8cdefed80b
commit
a0a40a4651
29
lisp/org.el
29
lisp/org.el
|
@ -8164,32 +8164,22 @@ case."
|
||||||
(ins-point (make-marker))
|
(ins-point (make-marker))
|
||||||
(cnt (abs arg))
|
(cnt (abs arg))
|
||||||
(col (current-column))
|
(col (current-column))
|
||||||
beg beg0 end txt folded ne-beg ne-end ne-ins ins-end)
|
beg end txt folded)
|
||||||
;; Select the tree
|
;; Select the tree
|
||||||
(org-back-to-heading)
|
(org-back-to-heading)
|
||||||
(setq beg0 (point))
|
(setq beg (point))
|
||||||
(save-excursion
|
|
||||||
(setq ne-beg (org-back-over-empty-lines))
|
|
||||||
(setq beg (point)))
|
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(save-excursion (outline-end-of-heading)
|
(save-excursion (outline-end-of-heading)
|
||||||
(setq folded (org-invisible-p)))
|
(setq folded (org-invisible-p)))
|
||||||
(progn (org-end-of-subtree nil t)
|
(progn (org-end-of-subtree nil t)
|
||||||
(unless (eobp) (backward-char))))
|
(unless (eobp) (backward-char))))
|
||||||
(outline-next-heading)
|
(outline-next-heading)
|
||||||
(setq ne-end (org-back-over-empty-lines))
|
|
||||||
(setq end (point))
|
(setq end (point))
|
||||||
(goto-char beg0)
|
(goto-char beg)
|
||||||
(when (and (> arg 0) (org-first-sibling-p) (< ne-end ne-beg))
|
|
||||||
;; include less whitespace
|
|
||||||
(save-excursion
|
|
||||||
(goto-char beg)
|
|
||||||
(forward-line (- ne-beg ne-end))
|
|
||||||
(setq beg (point))))
|
|
||||||
;; Find insertion point, with error handling
|
;; Find insertion point, with error handling
|
||||||
(while (> cnt 0)
|
(while (> cnt 0)
|
||||||
(unless (and (funcall movfunc) (looking-at org-outline-regexp))
|
(unless (and (funcall movfunc) (looking-at org-outline-regexp))
|
||||||
(goto-char beg0)
|
(goto-char beg)
|
||||||
(user-error "Cannot move past superior level or buffer limit"))
|
(user-error "Cannot move past superior level or buffer limit"))
|
||||||
(setq cnt (1- cnt)))
|
(setq cnt (1- cnt)))
|
||||||
(when (> arg 0)
|
(when (> arg 0)
|
||||||
|
@ -8198,7 +8188,6 @@ case."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(org-back-over-empty-lines)
|
(org-back-over-empty-lines)
|
||||||
(or (bolp) (newline))))
|
(or (bolp) (newline))))
|
||||||
(setq ne-ins (org-back-over-empty-lines))
|
|
||||||
(move-marker ins-point (point))
|
(move-marker ins-point (point))
|
||||||
(setq txt (buffer-substring beg end))
|
(setq txt (buffer-substring beg end))
|
||||||
(org-save-markers-in-region beg end)
|
(org-save-markers-in-region beg end)
|
||||||
|
@ -8212,18 +8201,8 @@ case."
|
||||||
(org-reinstall-markers-in-region bbb)
|
(org-reinstall-markers-in-region bbb)
|
||||||
(move-marker ins-point bbb))
|
(move-marker ins-point bbb))
|
||||||
(or (bolp) (insert "\n"))
|
(or (bolp) (insert "\n"))
|
||||||
(setq ins-end (point))
|
|
||||||
(goto-char ins-point)
|
(goto-char ins-point)
|
||||||
(org-skip-whitespace)
|
(org-skip-whitespace)
|
||||||
(when (and (< arg 0)
|
|
||||||
(org-first-sibling-p)
|
|
||||||
(> ne-ins ne-beg))
|
|
||||||
;; Move whitespace back to beginning
|
|
||||||
(save-excursion
|
|
||||||
(goto-char ins-end)
|
|
||||||
(let ((kill-whole-line t))
|
|
||||||
(kill-line (- ne-ins ne-beg)) (point)))
|
|
||||||
(insert (make-string (- ne-ins ne-beg) ?\n)))
|
|
||||||
(move-marker ins-point nil)
|
(move-marker ins-point nil)
|
||||||
(if folded
|
(if folded
|
||||||
(outline-hide-subtree)
|
(outline-hide-subtree)
|
||||||
|
|
|
@ -3965,7 +3965,7 @@ Text.
|
||||||
;; Pathological case: handle call with point in blank lines right
|
;; Pathological case: handle call with point in blank lines right
|
||||||
;; after a headline.
|
;; after a headline.
|
||||||
(should
|
(should
|
||||||
(equal "* H2\n* H1\nText\n\n"
|
(equal "* H2\n\n* H1\nText\n"
|
||||||
(org-test-with-temp-text "* H1\nText\n* H2\n\n<point>"
|
(org-test-with-temp-text "* H1\nText\n* H2\n\n<point>"
|
||||||
(org-drag-element-backward)
|
(org-drag-element-backward)
|
||||||
(buffer-string)))))
|
(buffer-string)))))
|
||||||
|
|
Loading…
Reference in New Issue