Browse Source

Sorting: Run a hook when done with sorting

Requested by Keith Swartz.
Carsten Dominik 16 years ago
parent
commit
7de716943f
2 changed files with 10 additions and 0 deletions
  1. 3 0
      lisp/ChangeLog
  2. 7 0
      lisp/org.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2009-05-14  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org.el (org-after-sorting-entries-or-items-hook): New hook.
+	(org-sort-entries-or-items): Run the new hook.
+
 	* org-agenda.el (org-agenda-get-progress): Never take time of day
 	from headline when displaying progress.
 

+ 7 - 0
lisp/org.el

@@ -6085,6 +6085,12 @@ With a double prefix argument, also remove duplicate entries."
 
 (defvar org-priority-regexp) ; defined later in the file
 
+(defvar org-after-sorting-entries-or-items-hook nil
+  "Hook that is run after a bunch of entries or items have been sorted.
+When children are sorted, the cursor is in the parent line when this
+hook gets called.  When a region or a plain list is sorted, the cursor
+will be in the first entry of the sorted region/list.")
+
 (defun org-sort-entries-or-items
   (&optional with-case sorting-type getkey-func compare-func property)
   "Sort entries on a certain level of an outline tree, or plain list items.
@@ -6311,6 +6317,7 @@ WITH-CASE, the sorting considers case as well."
           ((= dcst ?f) compare-func)
           ((= dcst ?p) '<)
           (t nil)))))
+    (run-hooks 'org-after-sorting-entries-or-items-hook)
     (message "Sorting entries...done")))
 
 (defun org-do-sort (table what &optional with-case sorting-type)