summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2010-01-22 11:21:55 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2010-01-22 11:28:37 +0100
commit4fc5ac29c6eb552d721b6fc5d665ea6678c1b92c (patch)
tree5e20ae1186ab2451a4c993ba41ba8a9ee0095304
parent2e53d9b137e8e96efbdff2daf256bab3635d9f9f (diff)
downloadorg-mode-4fc5ac29c6eb552d721b6fc5d665ea6678c1b92c.tar.gz
Make sure narrowing to subtree does not swallow headings
Jan Böcker writes: > Consider the following situation: > > * A > Some text. > * B > > - Place the cursor on A, press C-x n w (org-narrow-to-subtree). > - Go to the very end of the buffer and insert "xyz". > - C-x n w (widen). > > You end up with: > > * A > Some Text > xyz* B
-rwxr-xr-xlisp/ChangeLog6
-rw-r--r--lisp/org.el8
2 files changed, 12 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d607a07..ef30612 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-18 Jan Böcker <jan.boecker@jboecker.de>
+
+ * org.el (org-narrow-to-subtree): Position the end of the narrowed
+ region before the line with the next heading, to prevent the user
+ from prepending text to the next headline.
+
2010-01-20 Stephen Eglen <stephen@gnu.org>
* org-agenda.el (org-get-time-of-day): Use
diff --git a/lisp/org.el b/lisp/org.el
index d89618e..cd378b4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6023,7 +6023,9 @@ frame is not changed."
(outline-up-heading 1 t)))
(setq beg (point)
heading (org-get-heading))
- (org-end-of-subtree t t) (setq end (point)))
+ (org-end-of-subtree t t)
+ (if (org-on-heading-p) (backward-char 1))
+ (setq end (point)))
(if (and (buffer-live-p org-last-indirect-buffer)
(not (eq org-indirect-buffer-display 'new-frame))
(not arg))
@@ -6830,7 +6832,9 @@ If yes, remember the marker and the distance to BEG."
(save-match-data
(narrow-to-region
(progn (org-back-to-heading t) (point))
- (progn (org-end-of-subtree t t) (point))))))
+ (progn (org-end-of-subtree t t)
+ (if (org-on-heading-p) (backward-char 1))
+ (point))))))
(defun org-clone-subtree-with-time-shift (n &optional shift)
"Clone the task (subtree) at point N times.