planner-appt: fix highlighting in plan pages
[planner-el.git] / planner-experimental.el
blob3aaafbf25d2e9320feb90d2d981bae5ac557f5ef
1 ;;; planner-experimental.el --- Experimental functions for Emacs planner mode
2 ;;; Experimental functions for planner.el
4 ;; Copyright (C) 2004 Free Software Foundation, Inc.
6 ;; Author: Sacha Chua
8 ;; This file is not part of GNU Emacs.
10 ;; This is free software; you can redistribute it and/or modify it under
11 ;; the terms of the GNU General Public License as published by the Free
12 ;; Software Foundation; either version 2, or (at your option) any later
13 ;; version.
15 ;; This is distributed in the hope that it will be useful, but WITHOUT
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 ;; for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
25 ;;; Commentary:
27 (require 'planner)
29 ;;; Code:
31 ;;;_ + Searching
33 (defun planner-search-notes-next-match ()
34 "Jump to the next matching entry. Call after `planner-search-notes.'"
35 (interactive)
36 (if (buffer-live-p (get-buffer planner-search-notes-buffer))
37 (progn
38 (set-buffer planner-search-notes-buffer)
39 (forward-line -1)
40 (goto-char (planner-line-beginning-position))
41 (planner-follow-name-at-point))
42 (error "No current search.")))
44 (defun planner-search-notes-previous-match ()
45 "Jump to the previous matching entry. Call after `planner-search-notes.'"
46 (interactive)
47 (if (buffer-live-p (get-buffer planner-search-notes-buffer))
48 (progn
49 (set-buffer planner-search-notes-buffer)
50 (forward-line 1)
51 (goto-char (planner-line-beginning-position))
52 (planner-follow-name-at-point))
53 (error "No current search.")))
55 ;;;_* Tasks
57 (defun planner-remove-duplicates ()
58 "Remove duplicate tasks."
59 (interactive)
60 (goto-char (point-min))
61 (let ((today (planner-today))
62 (on-date (string-match planner-date-regexp (planner-page-name))))
63 (while (re-search-forward "^#[A-C][0-9]*\\s-+\\(.+\\)$" nil t)
64 (save-excursion
65 (let* ((task-info (planner-current-task-info))
66 (keep (planner-task-date task-info))
67 date
68 found
69 (start (match-beginning 0)))
70 (goto-char (planner-line-beginning-position))
71 (save-excursion
72 (unless on-date
73 (while (planner-find-task task-info (point))
74 ;; Determine the most recent one
75 (setq date (planner-task-date (planner-current-task-info)))
76 (when (or (and (string< keep today)
77 (string< keep date))
78 (string< date keep))
79 (setq keep date))
80 (forward-line 1))))
81 (while (planner-find-task task-info (point))
82 (if (string= keep
83 (planner-task-date (planner-current-task-info)))
84 (if found
85 (delete-region (planner-line-beginning-position)
86 (min (1+ (planner-line-end-position))
87 (point-max)))
88 (setq found t)
89 (forward-line 1))
90 (planner-delete-task))))))))
92 ;;;_* Local emacs vars.
93 ;;;Local variables:
94 ;;;allout-layout: (-1 0 : )
95 ;;;End:
97 (provide 'planner-experimental)
99 ;;; planner-experimental.el ends here