From ee3e4358439e6737bb82720f565a229943845b6a Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 20 Nov 2009 11:05:35 +0100 Subject: [PATCH] Make sure sorting also works in files without final newline --- lisp/ChangeLog | 3 +++ lisp/org.el | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9ed69665a..a841f8d79 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2009-11-20 Carsten Dominik + * org.el (org-sort-entries-or-items): Make sure that the final + entry has a newline before doing the sorting. + * org-agenda.el (org-agenda-diary-entry-in-org-file): Get the text property at the beginning of the line. diff --git a/lisp/org.el b/lisp/org.el index c8a8e84de..6139ddc56 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6861,7 +6861,9 @@ WITH-CASE, the sorting considers case as well." ((org-at-item-p) ;; we will sort this plain list (org-beginning-of-item-list) (setq start (point)) - (org-end-of-item-list) (setq end (point)) + (org-end-of-item-list) + (or (bolp) (insert "\n")) + (setq end (point)) (goto-char start) (setq plain-list-p t what "plain list")) @@ -6871,6 +6873,7 @@ WITH-CASE, the sorting considers case as well." (org-back-to-heading) (setq start (point) end (progn (org-end-of-subtree t t) + (or (bolp) (insert "\n")) (org-back-over-empty-lines) (point)) what "children") @@ -6881,7 +6884,15 @@ WITH-CASE, the sorting considers case as well." ;; we will sort the top-level entries in this file (goto-char (point-min)) (or (org-on-heading-p) (outline-next-heading)) - (setq start (point) end (point-max) what "top-level") + (setq start (point)) + (goto-char (point-max)) + (beginning-of-line 1) + (when (looking-at ".*?\\S-") + ;; File ends in a non-white line + (end-of-line 1) + (insert "\n")) + (setq end (point-max)) + (setq what "top-level") (goto-char start) (show-all)))