Go to Google Groups Home
Groups 
Advanced Groups Search    Preferences    Groups Help 
 
Groups search result 1 for organizer-mode.el group:*emacs* 

Search Result 1
From: Thomas R. Shannon (tshanno@lumc.edu)
Subject: organizer-mode.el - revised
Newsgroups: gnu.emacs.sources
View: (This is the only article in this thread) | Original Format
Date: 2002-06-17 03:30:57 PST
As I suspected, there were some serious bugs that prevented some
people from using the mode "out of the box".  My thanks to those brave
souls who gave the initial post a try.  The version below should be
more usable.

For those who had trouble getting started, this version should work
better.  I've tried to make the directions in the Commentary section a
bit more clear, as well.

Tom Shannon
tshanno@lumc.edu

;;; organizer-mode.el --- major mode for editing organizer list files

;;; Commentary:
;;  This code borrows heavily and shamelessly from todo-mode.el.  Many
;;  of the functions are directly from that code with only minor
;;  alteration.  The following is information regarding that package.

;; =======================
;; todo-mode.el --- major mode for editing todo list files
;; Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.

;; Author: Oliver Seidel <os10000@seidel-space.de>
;;   [Not clear the above works, July 2000]
;; Created: 2 Aug 1997
;; Version: Id: todo-mode.el,v 1.47.4.1 2001/11/13 04:12:45 rms Exp
;; Keywords: calendar, todo
;; ========================= 

;; The following code is meant to provide functions to allow use as an
;; organizer.  The easiest install method is to simply put the
;; organizer-mode.el file into you home directory, create a directory
;; to put organizer pages in and put the following into your .emacs
;; file:

;;  (require 'todo-mode)
;;  (load-file "~/organizer-mode.el")
;; (setq organizer-directory "/You_directory_containing_organizer_files")
;; (add-hook 'diary-hook 'appt-make-list)
;; (diary 0)
;; (setq list-diary-entries-hook
;;      '(include-other-diary-files sort-diary-entries))
;; (setq diary-display-hook 'fancy-diary-display)
;; (add-hook 'calendar-load-hook (define-key calendar-mode-map "O" 'organizer-view-other-diary-entries))


;; To create a new organizer file, simply use the "organizer-show"
;; command and type in the name of the new file when prompted.  Don't
;; forget to create and organizer-directory.  The default is
;; ~/Organizer.  Insert entries using the smae commands as those for
;; the todo-mode but the commands use "organizer" instead of "todo" as
;; the first word.  For instance, use "organizer-insert-item-here" to
;; insert new items into the file.

;;  I decided to put this mode together because I was intensely
;;  dissatisified with Personal Information Managers for Linux as the
;;  programs now stand.  It's my opinion that you should be able to
;;  use you computer like you would use an organizer that you carry
;;  around.  In other words, if you want to work on a project, you
;;  look at the proper page in your organizer, which provides all of
;;  the information needed to start working.  Its my opinion that a
;;  proper computer organizer should allow you to start with the
;;  proper "page" and do anything from there.

;;  I thought emacs was the best place to start if you're going to
;;  do this because its possible to do nearly everything with it to
;;  begin with.  It has a pretty good calendar and todo-mode which are
;;  essential.  It also allows you to read news (gnus) and mail (vm)
;;  and has a pretty good contact manager/addressbook (bbdb).

;;  The organizer pages in this package are really just todo files
;;  that are organized in one or more directories.  Usually the
;;  organizer-directory is the root of this tree.  Pages can be
;;  displayed with the command organizer-show or, if you have the
;;  Fancy Diary display set up for your calendar and diary (as I have
;;  done above), organizer-view-other-diary-entries.  organizer-show
;;  is also used to create new pages and new entries in existing pages
;;  (organizer-insert-item or organizer-insert-item-here).

;;  As stated above, an entry into an organizer page is nothing more
;;  than a todo entry.  Indeed, the all of the todo-mode functions
;;  (with "organizer" substituted for "todo") are there and the
;;  shortcut keys are the same.  For instance, I might have the
;;  following entries in my "development" organizer page:

;;  Brian Barry
;;  ~/mail/organizer_mail
;;  comp.emacs
;;  ~/code/organizer-mode.el
;;  ~/code
;;  My_programs
;;  http://www.emacswiki.org/cgi-bin/wiki.pl?SiteMap
;;  ~/junk.jpg

;;  These entries allow you to do the following:

;;  Access Brian Barry in bbdb with bbdb-at-point.
;;  Access organizer_mail with vm-at-point.  
;;  Access comp.emacs with gnus-at-point. 
;;  Call up organizer-mode.el or the directory with code
;;  with find-file-at-point.
;;  Access the related organizer page, My_programs, with
;;  organizer-at-point.
;;  Access the URL with w3m-browse-url, browse-url-netscape or some other variation.
;;  Access junk.jpg with its associated dired-guess-shell-alist-user
;;  command (xv in my case) using organizer-shell-command-at-point

;; You can, therefore, do nearly anything associated with the project
;; simply by going to the organizer page and using the proper command.
;;  Your work, therefore, becomes task based.  These commands can (and
;;  probably should) be bound to shortcut keys.  At some point I'll
;;  get around to customizing them so that you can input your own
;;  commands and use your own mail/news/addressbooks.  For now, the
;;  package will be best for emacs people like me who practically live
;;  with the program running and do nearly everything with it.

;;  As you can see, the ffap (find file at point) package is pretty
;;  much essential to using this mode effectively.  All of the above
;;  commands are either a part of that package or written by me using
;;  it.  It would be helpful for you to read the info files for this
;;  command, as well as for the todo-mode and calendar mode, if you
;;  want to get the most out of organizer-mode.

;;  In addition, there are a few additional features which are
;;  implemented with the organizer-view-other-diary-entries when you
;;  have the Fancy Diary display operable.  This command is probably
;;  the best one to use when you don't actually need to create a new
;;  page or add entries to an existing one.  You start by calling the
;;  calendar and putting the cursor on the relevant date (usually the
;;  current one).  When you call the function, the computer first
;;  displays the contents of your page.  It then searches through your
;;  diary and the .todo file for entries which contain the name of the
;;  organizer file and also displays them.  For instance, my
;;  "development" organizer page will not only display the information
;;  above (which is in ~/my_organizer_directory/development"), but
;;  will also display the todo entry "finish organizer-mode.el,
;;  development" and the appointment "June 14, 2002 9:00am send Brain
;;  file, development" entry from my diary file on June 14.

;; In addition, by putting the proper information in the right places,
;; all of you work becomes linked.  For instance, in the notes field
;; of Brain's bbdb entry, I might put "development".  Now with
;; organizer-at-point, I can call up the proper page from his bbdb
;; entry.  Or I could put "~/mail/Brian" which will allow me to access
;; the related email box.  The same goes with todo entries and
;; calendar entries.  If used correctly, everything can be associated
;; to make access to information from anywhere go smoothly.

;;  Have fun.

;; Shortcut keys:
;; O    calendar-mode   organizer-view-other-diary-entries

;; All shortcut keys once you are in organizer-mode are the same as
;; those in todo-mode.

;; Todo: 
;; 1)  Allow the program to search organizer pages and the bbdb
;; datebase as it does the todo and diary files now in repsonse to
;; organizer-view-other-diary-entries
;; 2)  Allow the user to easily customize the mail, new and
;; addressbook programs.  Right now this can only be done by altering
;; the code.

;;; History:

;; Version $Version$
;; Fixed bug where a hard coded directory was used instead of
;; diary-file-temp.
;; Fixed bug which messed up insertion the last entry in the todo file
;; during organizer-view-other-diary-entries
;; Header and doc strings conform better to standards as defined by
;; checkdoc.
;; Changed the name of the internal 'srchfn' to 'organizer-srchfn'.
;; This function is no longer interactive.
;; The file is now under RCS control.
;; Modified Commentary to recommend (add-hook 'diary-hook
;; 'appt-make-list) and (diary 0) be added to the .emacs file for
;; installation.


;; Author: Thomas R. Shannon <tshanno@lumc.edu>
;; Created: 12 Jun, 2002
;; Version $Id: organizer-mode.el,v 1.2 2002/06/17 10:28:59 tshanno Exp $
;; Keywords: calendar, todo, organizer

;; ---------------------------------------------------------------------------

;;; Code:

;; User-configurable variables:

(defvar organizer-directory "~/Organizer/"
"Directory where organizer pages can be found.  Must have the trailing forward slash.")

(defgroup organizer nil
  "Maintain a list of organizer items."
  :link '(emacs-commentary-link "organizer-mode")
  :version "21.2"
  :group 'calendar)

(defcustom organizer-prefix     "&%%(equal (calendar-current-date) date)"
  "*TODO mode prefix for entries.

This is useful in conjunction with `calendar' and `diary' if you use

#include \"~/.todo-do\"

in your diary file to include your organizer list file as part of your
diary.  With the default value \"*/*\" the diary displays each entry
every day and it may also be marked on every day of the calendar.
Using \"&%%(equal (calendar-current-date) date)\" instead will only
show and mark organizer entreis for today, but may slow down processing of
the diary file somewhat."
  :type 'string
  :group 'organizer)
(defcustom organizer-prefix-prefix     "&%%"
  "*ORAGANIZER mode pre-prefix for entries.  All entries must start with this."
  :type 'string
  :group 'organizer)
(defcustom organizer-file    "~/.organizer-do"
  "*ORGANIZER mode list file."
  :type 'file
  :group 'organizer)
(defcustom diary-file-temp    "~/diary-delete-me"
  "*ORGANIZER mode list file."
  :type 'file
  :group 'organizer)
(defcustom organizer-file-done  "~/.organizer-done"
  "*ORGANIZER mode archive file."
  :type 'file
  :group 'organizer)
(defcustom organizer-mode-hook  nil
  "*ORGANIZER mode hooks."
  :type 'hook
  :group 'organizer)
(defcustom organizer-edit-mode-hook nil
  "*ORGANIZER Edit mode hooks."
  :type 'hook
  :group 'organizer)
(defcustom organizer-insert-threshold 0
  "*ORGANIZER mode insertion accuracy.

If you have 8 items in your ORGANIZER list, then you may get asked 4
questions by the binary insertion algorithm.  However, you may not
really have a need for such accurate priorities amongst your ORGANIZER
items.  If you now think about the binary insertion halfing the size
of the window each time, then the threshhold is the window size at
which it will stop.  If you set the threshhold to zero, the upper and
lower bound will coincide at the end of the loop and you will insert
your item just before that point.  If you set the threshhold to,
e.g. 8, it will stop as soon as the window size drops below that
amount and will insert the item in the approximate centre of that
window."
  :type 'integer
  :group 'organizer)
(defvar organizer-edit-buffer " *ORGANIZER Edit*"
  "ORGANIZER Edit buffer name.")
(defcustom organizer-file-top "~/.organizer-top"
  "*ORGANIZER mode top priorities file.

Not in ORGANIZER format, but diary compatible.
Automatically generated when `organizer-save-top-priorities' is non-nil."
  :type 'string
  :group 'organizer)

(defcustom organizer-print-function 'ps-print-buffer-with-faces
  "*Function to print the current buffer."
  :type 'symbol
  :group 'organizer)
(defcustom organizer-show-priorities 1
  "*Default number of priorities to show by \\[organizer-top-priorities].
0 means show all entries."
  :type 'integer
  :group 'organizer)
(defcustom organizer-print-priorities 0
  "*Default number of priorities to print by \\[organizer-print].
0 means print all entries."
  :type 'integer
  :group 'organizer)
(defcustom organizer-remove-separator t
  "*Non-nil to remove category separators in\
\\[organizer-top-priorities] and \\[organizer-print]."
  :type 'boolean
  :group 'organizer)
(defcustom organizer-save-top-priorities-too nil
  "*Non-nil makes `organizer-save' automatically save top-priorities in `organizer-file-top'."
  :type 'boolean
  :group 'organizer)

;; Thanks for the ISO time stamp format go to Karl Eichwalder <ke@suse.de>
;; My format string for the appt.el package is "%3b %2d, %y, %02I:%02M%p".
;;
(defcustom organizer-time-string-format
  "%:y/%02m/%02d %02H:%02M"
  "*ORGANIZER mode time string format for done entries.
For details see the variable `time-stamp-format'."
  :type 'string
  :group 'organizer)

(defcustom organizer-entry-prefix-function 'organizer-entry-timestamp-initials
  "*Function producing text to insert at start of organizer entry."
  :type 'symbol
  :group 'organizer)
(defcustom organizer-initials (or (getenv "INITIALS") (user-login-name))
  "*Initials of organizer item author."
  :type 'string
  :group 'organizer)

(autoload 'time-stamp-string "time-stamp")

(defun organizer-entry-timestamp-initials ()
  "Prepend timestamp and your initials to the head of a ORGANIZER entry."
  (let ((time-stamp-format organizer-time-string-format))
    (concat (time-stamp-string) " " organizer-initials ": ")))

;; ---------------------------------------------------------------------------

;; Set up some helpful context ...

(defvar organizer-categories nil
  "ORGANIZER categories.")

(defvar organizer-cats nil
  "Old variable for holding the ORGANIZER categories.
Use `organizer-categories' instead.")

(defvar organizer-previous-line 0
  "Previous line asked about.")

(defvar organizer-previous-answer 0
  "Previous answer got.")

(defvar organizer-mode-map
  (let ((map (make-keymap)))
    (suppress-keymap map t)
    (define-key map "+" 'organizer-forward-category)
    (define-key map "-" 'organizer-backward-category)
    (define-key map "d" 'organizer-file-item) ;done/delete
    (define-key map "e" 'organizer-edit-item)
    (define-key map "E" 'organizer-edit-multiline)
    (define-key map "f" 'organizer-file-item)
    (define-key map "i" 'organizer-insert-item)
    (define-key map "I" 'organizer-insert-item-here)
    (define-key map "j" 'organizer-jump-to-category)
    (define-key map "k" 'organizer-delete-item)
    (define-key map "l" 'organizer-lower-item)
    (define-key map "n" 'organizer-forward-item)
    (define-key map "p" 'organizer-backward-item)
    (define-key map "P" 'organizer-print)
    (define-key map "q" 'organizer-quit)
    (define-key map "r" 'organizer-raise-item)
    (define-key map "s" 'organizer-save)
    (define-key map "S" 'organizer-save-top-priorities)
    (define-key map "t" 'organizer-top-priorities)
    map)
  "ORGANIZER mode keymap.")

(defvar organizer-category-number 0 "ORGANIZER category number.")

(defvar organizer-tmp-buffer-name " *organizer tmp*")

(defvar organizer-category-sep (make-string 75 ?-)
  "Category separator.")

(defvar organizer-category-beg " --- "
  "Category start separator to be prepended onto category name.")

(defvar organizer-category-end "--- End"
  "Separator after a category.")

(defvar organizer-header "-*- mode: organizer; "
  "Header of organizer files.")

;; ---------------------------------------------------------------------------

(defun organizer-category-select ()
  "Make ORGANIZER mode display the current category correctly."
  (let ((name (nth organizer-category-number organizer-categories)))
    (setq mode-line-buffer-identification
;;          (concat "Category: " name))
          (concat "Category: " (format "%18s" name)))
    (widen)
    (goto-char (point-min))
    (search-forward-regexp
     (concat "^"
             (regexp-quote (concat organizer-prefix organizer-category-beg name))
             "$"))
    (let ((begin (1+ (line-end-position))))
      (search-forward-regexp (concat "^" organizer-category-end))
      (narrow-to-region begin (line-beginning-position))
      (goto-char (point-min)))))
(defalias 'organizer-cat-slct 'organizer-category-select)

(defun organizer-forward-category ()
  "Go forward to ORGANIZER list of next category."
  (interactive)
  (setq organizer-category-number
        (mod (1+ organizer-category-number) (length organizer-categories)))
  (organizer-category-select))
(defalias 'organizer-cmd-forw 'organizer-forward-category)

(defun organizer-backward-category ()
  "Go back to ORGANIZER list of previous category."
  (interactive)
  (setq organizer-category-number
        (mod (1- organizer-category-number) (length organizer-categories)))
  (organizer-category-select))
(defalias 'organizer-cmd-back 'organizer-backward-category)

(defun organizer-backward-item ()
  "Select previous entry of ORGANIZER list."
  (interactive)
;;  (search-backward-regexp (concat "^" (regexp-quote organizer-prefix)) nil t)
  (search-backward-regexp (concat "^" (regexp-quote organizer-prefix-prefix)) nil t)
  (message ""))
(defalias 'organizer-cmd-prev 'organizer-backward-item)

(defun organizer-forward-item (&optional count)
  "Select COUNT-th next entry of ORGANIZER list."
  (interactive "P")
  (if (listp count) (setq count (car count)))
  (end-of-line)
;;  (search-forward-regexp (concat "^" (regexp-quote organizer-prefix))
;;                         nil 'goto-end count)
  (search-forward-regexp (concat "^" (regexp-quote organizer-prefix-prefix))
                         nil 'goto-end count)
  (beginning-of-line)
  (message ""))
(defalias 'organizer-cmd-next 'organizer-forward-item)

(defun organizer-save ()
  "Save the ORGANIZER list."
  (interactive)
  (save-excursion
    (save-restriction
      (save-buffer)
      (if organizer-save-top-priorities-too (organizer-save-top-priorities))
      )))
(defalias 'organizer-cmd-save 'organizer-save)

(defun organizer-quit ()
  "Done with ORGANIZER list for now."
  (interactive)
  (widen)
  (organizer-save)
  (message "")
;;   (bury-buffer))
  (kill-this-buffer))
(defalias 'organizer-cmd-done 'organizer-quit)

(defun organizer-edit-item ()
  "Edit current ORGANIZER list entry."
  (interactive)
  (let ((item (organizer-item-string)))
    (if (organizer-string-multiline-p item)
        (organizer-edit-multiline)
      (let ((new (read-from-minibuffer "Edit: " item)))
        (organizer-remove-item)
        (insert new "\n")
        (organizer-backward-item)
        (message "")))))
(defalias 'organizer-cmd-edit 'organizer-edit-item)

(defun organizer-edit-multiline ()
  "Set up a buffer for editing a multiline ORGANIZER list entry."
  (interactive)
  (let ((buffer-name (generate-new-buffer-name organizer-edit-buffer))(organizer buffer-file-name))
    (switch-to-buffer
     (make-indirect-buffer
;;      (file-name-nondirectory organizer-file-do) buffer-name))
;;       (setq organizer (read-file-name "Organizer page: " organizer-directory))
      (file-name-nondirectory organizer) buffer-name))
    (message "To exit, simply kill this buffer and return to list.")
    (organizer-edit-mode)
    (narrow-to-region (organizer-item-start) (organizer-item-end))))

;;;###autoload
(defun organizer-add-category (cat)
  "Add new category CAT to the ORGANIZER list."
  (interactive "sCategory: ")
  (save-window-excursion
    (setq organizer-categories (cons cat organizer-categories))
;;    (setq organizer (read-file-name "Organizer page: " organizer-directory))
     (setq organizer buffer-file-name)
    (find-file organizer)
    (widen)
    (goto-char (point-min))
    (let ((posn (search-forward "-*- mode: organizer; " 17 t)))
      (if (not (null posn)) (goto-char posn))
      (if (equal posn nil)
          (progn
            (insert "-*- mode: organizer; \n")
            (forward-char -1))
        (kill-line)))
    (insert (format "organizer-categories: %S; -*-" organizer-categories))
    (forward-char 1)
    (insert (format "%s%s%s\n%s\n%s %s\n"
                    organizer-prefix organizer-category-beg cat
                    organizer-category-end
                    organizer-prefix organizer-category-sep)))
  0)

(defun organizer-add-category-no-prompt (cat organizer)
  "Add new category CAT to the ORGANIZER list."
  (interactive "sCategory: ")
  (save-window-excursion
    (setq organizer-categories (cons cat organizer-categories))
;;    (setq organizer (read-file-name "Organizer page: " organizer-directory))
;;     (setq organizer buffer-file-name)
    (find-file organizer)
    (widen)
    (goto-char (point-min))
    (let ((posn (search-forward "-*- mode: organizer; " 17 t)))
      (if (not (null posn)) (goto-char posn))
      (if (equal posn nil)
          (progn
            (insert "-*- mode: organizer; \n")
            (forward-char -1))
        (kill-line)))
    (insert (format "organizer-categories: %S; -*-" organizer-categories))
    (forward-char 1)
    (insert (format "%s%s%s\n%s\n%s %s\n"
                    organizer-prefix organizer-category-beg cat
                    organizer-category-end
                    organizer-prefix organizer-category-sep)))
  0)

;;;###autoload
(defun organizer-add-item-non-interactively (new-item category)
  "Insert NEW-ITEM in ORGANIZER list as a new entry in CATEGORY."
  (save-excursion
    (organizer-show-no-prompt))
;;     (organizer-show))
  (save-excursion
    (if (string= "" category)
        (setq category (nth organizer-category-number organizer-categories)))
    (let ((cat-exists (member category organizer-categories)))
      (setq organizer-category-number
            (if cat-exists
                (- (length organizer-categories) (length cat-exists))
              (organizer-add-category category))))
    (organizer-show-no-prompt)
;;     (organizer-show)
    (setq organizer-previous-line 0)
    (let ((top 1)
	  (bottom (1+ (count-lines (point-min) (point-max)))))
      (while (> (- bottom top) organizer-insert-threshold)
	(let* ((current (/ (+ top bottom) 2))
	       (answer (if (< current bottom)
			   (organizer-more-important-p current) nil)))
	  (if answer
	      (setq bottom current)
	    (setq top (1+ current)))))
      (setq top (/ (+ top bottom) 2))
      ;; goto-line doesn't have the desired behavior in a narrowed buffer
      (goto-char (point-min))
      (forward-line (1- top)))
    (insert new-item "\n")
    (organizer-backward-item)
    (organizer-save)
    (message "")))

;;;###autoload
(defun organizer-insert-item (arg)
  "Insert new ORGANIZER list entry.
With a prefix argument solicit the category, otherwise use the current
category."
  (interactive "P")
  (save-excursion
    (if (not (string-equal mode-name "ORGANIZER")) (organizer-show))
    (let* ((new-item (concat organizer-prefix " "
			     (read-from-minibuffer
			      "New ORGANIZER entry: "
			      (if organizer-entry-prefix-function
				  (funcall organizer-entry-prefix-function)))))
	   (categories organizer-categories)
	   (history (cons 'categories (1+ organizer-category-number)))
	   (current-category (nth organizer-category-number organizer-categories))
	   (category
	    (if arg
		current-category
	      (completing-read (concat "Category [" current-category "]: ")
			       (organizer-category-alist) nil nil nil
			       history current-category))))
      (organizer-add-item-non-interactively new-item category))))

(defalias 'organizer-cmd-inst 'organizer-insert-item)

(defun organizer-insert-item-here ()
  "Insert new ORGANIZER list entry under the cursor."
  (interactive "")
;;  (split-window-vertically 5)
;;  (shell-command "find /home/tshanno/Organizer -regex \".*[^~]\" -printf %f\\\\t")
;;  (switch-to-buffer "*Shell Command Output*")
;;  (fill-paragraph (point))
;;  (other-window 1)
  (save-excursion
    (if (not (string-equal mode-name "ORGANIZER")) (organizer-show))
    (let* ((new-item (concat organizer-prefix " "
			     (read-from-minibuffer
			      "New ORGANIZER entry: "
			      (if organizer-entry-prefix-function
				  (funcall organizer-entry-prefix-function))))))
      (insert (concat new-item "\n"))))
;;  (other-window -1)
;;  (kill-this-buffer)
;;  (other-window 1)
;;  (delete-other-windows)
  )

(defun organizer-more-important-p (line)
  "Ask whether entry is more important than the one at LINE."
  (if (not (equal organizer-previous-line line))
      (progn
        (setq organizer-previous-line line)
        (goto-char (point-min))
        (forward-line (1- organizer-previous-line))
        (let ((item (organizer-item-string-start)))
          (setq organizer-previous-answer
                (y-or-n-p (concat "More important than '" item "'? "))))))
  organizer-previous-answer)
(defalias 'organizer-ask-p 'organizer-more-important-p)

(defun organizer-delete-item ()
  "Delete current ORGANIZER list entry."
  (interactive)
  (if (> (count-lines (point-min) (point-max)) 0)
      (let* ((organizer-entry (organizer-item-string-start))
             (organizer-answer (y-or-n-p (concat "Permanently remove '"
                                            organizer-entry "'? "))))
        (if organizer-answer
            (progn
              (organizer-remove-item)
              (organizer-backward-item)))
        (message ""))
    (error "No ORGANIZER list entry to delete")))
(defalias 'organizer-cmd-kill 'organizer-delete-item)

(defun organizer-raise-item ()
  "Raise priority of current entry."
  (interactive)
  (if (> (count-lines (point-min) (point)) 0)
      (let ((item (organizer-item-string)))
        (organizer-remove-item)
        (organizer-backward-item)
        (save-excursion
          (insert item "\n"))
        (message ""))
    (error "No ORGANIZER list entry to raise")))
(defalias 'organizer-cmd-rais 'organizer-raise-item)

(defun organizer-lower-item ()
  "Lower priority of current entry."
  (interactive)
  (if (> (count-lines (point) (point-max)) 1)
      ;; Assume there is a final newline
      (let ((item (organizer-item-string)))
        (organizer-remove-item)
        (organizer-forward-item)
        (save-excursion
          (insert item "\n"))
        (message ""))
    (error "No ORGANIZER list entry to lower")))
(defalias 'organizer-cmd-lowr 'organizer-lower-item)

(defun organizer-file-item (&optional comment)
  "File the current ORGANIZER list entry away, annotated with an optional COMMENT."
  (interactive "sComment: ")
  (or (> (count-lines (point-min) (point-max)) 0)
      (error "No ORGANIZER list entry to file away"))
  (let ((time-stamp-format organizer-time-string-format))
    (if (and comment (> (length comment) 0))
	(progn
	  (goto-char (organizer-item-end))
	  (insert
	   (if (save-excursion (beginning-of-line)
;;			       (looking-at (regexp-quote organizer-prefix)))
			       (looking-at (regexp-quote organizer-prefix-prefix)))
	       " "
	     "\n\t")
	   "(" comment ")")))
    (goto-char (organizer-item-end))
    (insert " [" (nth organizer-category-number organizer-categories) "]")
    (goto-char (organizer-item-start))
    (let ((temp-point (point)))
;;      (if (looking-at (regexp-quote organizer-prefix))
      (if (looking-at (regexp-quote organizer-prefix-prefix))
	  (replace-match (time-stamp-string))
	;; Standard prefix -> timestamp
	;; Else prefix non-standard item start with timestamp
	(insert (time-stamp-string)))
;;       (setq organizer (read-file-name "Organizer page: " organizer-directory))
    (setq organizer buffer-file-name)
      (append-to-file temp-point (1+ (organizer-item-end)) organizer)
      (delete-region temp-point (1+ (organizer-item-end))))
    (organizer-backward-item)
    (message "")))

;; ---------------------------------------------------------------------------

;; Utility functions:


;;;###autoload
(defun organizer-top-priorities (&optional nof-priorities category-pr-page)
  "List top priorities for each category.

Number of entries for each category is given by NOF-PRIORITIES which
defaults to \'organizer-show-priorities\'.

If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted
between each category."

  (interactive "P")
  (or nof-priorities (setq nof-priorities organizer-show-priorities))
  (if (listp nof-priorities)            ;universal argument
      (setq nof-priorities (car nof-priorities)))
  (let ((organizer-print-buffer-name organizer-tmp-buffer-name)
        ;;(organizer-print-category-number 0)
        (organizer-category-break (if category-pr-page " " ""))
        (cat-end
         (concat
          (if organizer-remove-separator
              (concat organizer-category-end "\n"
                      (regexp-quote organizer-prefix) " " organizer-category-sep "\n")
            (concat organizer-category-end "\n"))))
        beg end)
    (organizer-show)
    (save-excursion
      (save-restriction
        (widen)
        (copy-to-buffer organizer-print-buffer-name (point-min) (point-max))
        (set-buffer organizer-print-buffer-name)
        (goto-char (point-min))
        (when (re-search-forward (regexp-quote organizer-header) nil t)
	  (beginning-of-line 1)
	  (delete-region (point) (line-end-position)))
        (while (re-search-forward       ;Find category start
                (regexp-quote (concat organizer-prefix organizer-category-beg))
                nil t)
          (setq beg (+ (line-end-position) 1)) ;Start of first entry.
          (re-search-forward cat-end nil t)
          (setq end (match-beginning 0))
          (replace-match organizer-category-break)
          (narrow-to-region beg end)    ;In case we have too few entries.
          (goto-char (point-min))
          (if (= 0 nof-priorities)      ;Traverse entries.
              (goto-char end)            ;All entries
            (organizer-forward-item nof-priorities))
          (setq beg (point))
          (delete-region beg end)
          (widen))
        (and (looking-at " ") (replace-match "")) ;Remove trailing form-feed.
        (goto-char (point-min))         ;Due to display buffer
        ))
    ;; Could have used switch-to-buffer as it has a norecord argument,
    ;; which is nice when we are called from e.g. organizer-print.
    ;; Else we could have used pop-to-buffer.
    (display-buffer organizer-print-buffer-name)
    (message "Type C-x 1 to remove %s window.  M-C-v to scroll the help."
             organizer-print-buffer-name)))

(defun organizer-save-top-priorities (&optional nof-priorities)
  "Save top priorities for each category in `organizer-file-top'.

Number of entries for each category is given by NOF-PRIORITIES which
defaults to `organizer-show-priorities'."
  (interactive "P")
  (save-window-excursion
    (save-excursion
      (save-restriction
        (organizer-top-priorities nof-priorities)
        (set-buffer organizer-tmp-buffer-name)
        (write-file organizer-file-top)
        (kill-this-buffer)))))

;;;###autoload
(defun organizer-print (&optional category-pr-page)
  "Print organizer summary using `organizer-print-function'.
If CATEGORY-PR-PAGE is non-nil, a page separator `^L' is inserted
between each category.

Number of entries for each category is given by `organizer-print-priorities'."
  (interactive "P")
  (save-window-excursion
    (save-excursion
      (save-restriction
	(organizer-top-priorities organizer-print-priorities
			     category-pr-page)
	(set-buffer organizer-tmp-buffer-name)
	(and (funcall organizer-print-function)
	     (kill-this-buffer))
	(message "Organizer printing done.")))))

(defun organizer-jump-to-category ()
  "Jump to a category.  Default is previous category."
  (interactive)
  (let* ((categories organizer-categories)
         (history (cons 'categories (1+ organizer-category-number)))
	 (default (nth organizer-category-number organizer-categories))
	 (category (completing-read
                    (concat "Category [" default "]: ")
                    (organizer-category-alist) nil nil nil history default)))
    (if (string= "" category)
        (setq category (nth organizer-category-number organizer-categories)))
    (setq organizer-category-number
          (if (member category organizer-categories)
              (- (length organizer-categories)
                 (length (member category organizer-categories)))
            (organizer-add-category category)))
    (organizer-show)))

(defun organizer-line-string ()
  "Return current line in buffer as a string."
  (buffer-substring (line-beginning-position) (line-end-position)))

(defun organizer-item-string-start ()
  "Return the start of this ORGANIZER list entry as a string."
  ;; Suitable for putting in the minibuffer when asking the user
  (let ((item (organizer-item-string)))
    (if (> (length item) 60)
        (setq item (concat (substring item 0 56) "...")))
    item))

(defun organizer-item-start ()
  "Return point at start of current ORGANIZER list item."
  (save-excursion
    (beginning-of-line)
    (if (not (looking-at (regexp-quote organizer-prefix-prefix)))
        (search-backward-regexp
         (concat "^" (regexp-quote organizer-prefix-prefix)) nil t))
    (point)))

(defun organizer-item-end ()
  "Return point at end of current ORGANIZER list item."
  (save-excursion
    (end-of-line)
    (search-forward-regexp
     (concat "^" (regexp-quote organizer-prefix-prefix)) nil 'goto-end)
    (1- (line-beginning-position))))

(defun organizer-remove-item ()
  "Delete the current entry from the ORGANIZER list."
  (delete-region (organizer-item-start) (1+ (organizer-item-end))))

(defun organizer-item-string ()
  "Return current ORGANIZER list entry as a string."
  (buffer-substring (organizer-item-start) (organizer-item-end)))

(defun organizer-string-count-lines (string)
  "Return the number of lines STRING spans."
  (length (split-string string "\n")))

(defun organizer-string-multiline-p (string)
  "Return non-nil if STRING spans several lines."
  (> (organizer-string-count-lines string) 1))

(defun organizer-category-alist ()
  "Generate an alist for use in `completing-read' from `organizer-categories'."
  (mapcar #'list organizer-categories))

;; ---------------------------------------------------------------------------

(easy-menu-define organizer-menu organizer-mode-map "Organizer Menu"
                  '("Organizer"
                    ["Next category"        organizer-forward-category t]
                    ["Previous category"    organizer-backward-category t]
                    ["Jump to category"     organizer-jump-to-category t]
                    ["Show top priority items" organizer-top-priorities t]
                    ["Print categories"     organizer-print t]
                    "---"
                    ["Edit item"            organizer-edit-item t]
                    ["File item"            organizer-file-item t]
                    ["Insert new item"      organizer-insert-item t]
                    ["Insert item here"     organizer-insert-item-here t]
                    ["Kill item"            organizer-delete-item t]
                    "---"
                    ["Lower item priority"  organizer-lower-item t]
                    ["Raise item priority"  organizer-raise-item t]
                    "---"
                    ["Next item"            organizer-forward-item t]
                    ["Previous item"        organizer-backward-item t]
                    "---"
                    ["Save"                 organizer-save t]
                    ["Save Top Priorities"  organizer-save-top-priorities t]
                    "---"
                    ["Quit"                 organizer-quit t]
                    ))

;; As calendar reads .organizer-do before organizer-mode is loaded.
;;;###autoload
(defun organizer-mode ()
  "Major mode for editing ORGANIZER lists.

\\{organizer-mode-map}"
  (interactive)
  (setq major-mode 'organizer-mode)
  (setq mode-name "ORGANIZER")
  (use-local-map organizer-mode-map)
  (easy-menu-add organizer-menu)
  (run-hooks 'organizer-mode-hook))

(eval-when-compile
  (defvar date)
  (defvar entry))

;; Read about this function in the setup instructions above!
;;;###autoload
(defun organizer-cp ()
  "Make a diary entry appear only in the current date's diary."
  (if (equal (calendar-current-date) date)
      entry))

(define-derived-mode organizer-edit-mode text-mode "ORGANIZER Edit"
  "Major mode for editing items in the ORGANIZER list.

\\{organizer-edit-mode-map}")

;;;###autoload
(defun organizer-show ()
  "Show ORGANIZER list."
  (interactive)
  (setq organizer-file (read-file-name "Organizer page: " organizer-directory))
  (if (file-exists-p organizer-file)
      (find-file organizer-file)
;;    (set organizer-categories nil)
;;    (set organizer-cats nil)
    (organizer-initial-setup organizer-file))
  (if (null organizer-categories)
      (if (null organizer-cats)
          (error "Error in %s: No categories in list `organizer-categories'"
                 organizer-file)
        (goto-char (point-min))
        (and (search-forward "organizer-cats:" nil t)
             (replace-match "organizer-categories:"))
        (make-local-variable 'organizer-categories)
        (setq organizer-categories organizer-cats)))
  (beginning-of-line)
  (organizer-category-select))

(defun organizer-show-no-prompt ()
  "Show ORGANIZER list."
;;  (interactive)
;;  (setq organizer-file (read-file-name "Organizer page: " organizer-directory))
  (if (file-exists-p organizer-file)
      (find-file organizer-file)
;;    (set organizer-categories nil)
;;    (set organizer-cats nil)
    (organizer-initial-setup organizer-file))
  (if (null organizer-categories)
      (if (null organizer-cats)
          (error "Error in %s: No categories in list `organizer-categories'"
                 organizer-file)
        (goto-char (point-min))
        (and (search-forward "organizer-cats:" nil t)
             (replace-match "organizer-categories:"))
        (make-local-variable 'organizer-categories)
        (setq organizer-categories organizer-cats)))
  (beginning-of-line)
  (organizer-category-select))

(defun organizer-initial-setup (organizer)
  "Set up things to work properly in ORGANIZER mode."
;;  (setq organizer (read-file-name "Organizer page: " organizer-directory))
  (find-file organizer)
;;  (switch-to-buffer (file-name-nondirectory organizer))
  (erase-buffer)
  (organizer-mode)
  (organizer-add-category-no-prompt (concat "End of " (file-name-nondirectory organizer)) organizer))


;; (defvar organizer-prefix "%%(equal (calendar-current-date) date) "
;; "Default prefix for noew organizer entries with trailing space.")

;; (defvar organizer-prefix-prefix "%%"
;; "Default prefix for noew organizer entries with trailing space.")

(defun organizer-yank-to-organizer ()
  "Yank kill buffer to the end of a diary file, save and close.  Only
works on one entry at a time since the prefix if only put on the first
line."
  (interactive)
  (setq organizer-file (read-file-name "Organizer page: " organizer-directory))
  (setq prefx (read-string "Prefix with space: " organizer-prefix))
  (save-excursion
    (find-file organizer-file)
    (end-of-buffer)
    (newline)
    (insert-string prefx)
    (yank)
    (end-of-buffer)
    (save-buffer)
    (kill-this-buffer)))

(defun organizer-dired-yank-to-organizer ()
  "Yank full filename and path from dired at prompt to the end of a
diary file, save and close."
  (interactive)
  (setq organizer (read-file-name "Organizer page: " organizer-directory))
  (setq prefx (read-string "Prefix with space: " organizer-prefix))
  (dired-copy-filename-as-kill 0)
  (save-excursion
    (find-file organizer)
    (end-of-buffer)
    (newline)
    (insert-string prefx)
    (yank)
    (end-of-buffer)
    (save-buffer)
    (kill-this-buffer)))

(defun bbdb-at-point ()
  "Start BBDB, searching for name at point."
    (interactive)
    (require 'ffap)
    (let ((str (ffap-string-at-point)))
      (bbdb str nil)))

(defun organizer-shell-command-at-point ()
  "Perform shell command upon the full file name at the cursor in any buffer."
  (interactive)
  (require 'ffap)
  (let ((str (ffap-string-at-point)))
    (dired-at-point)
    (setq shcom "shell command on file ")
    (let ((filestr (concat (dired-guess-shell-command shcom (list str)) " " str)))
      (shell-command  filestr)
      (kill-this-buffer))))

(defun organizer-at-point ()
  "Open a diary with the name at the cursor."
    (interactive)
    (require 'ffap)
    (let ((str (ffap-string-at-point)))
      (let ((filestr (concat organizer-directory str)))
      (find-file filestr))))

(defun organizer-find-file ()
  "Open the full file name and path at the cursor."
    (interactive)
    (require 'ffap)
    (let ((filestr (ffap-string-at-point)))
      (find-file filestr)))

(defun organizer-open-organizer ()
  "Open a diary file for editing."
  (interactive)
  (setq organizer (read-file-name "Organizer page: " organizer-directory))
  (find-file organizer))

;; (defun organizer-view-other-diary-entries (arg)
(defun organizer-view-other-diary-entries ()
  "Open an organizer diary file for Fancy viewing."
;;   (interactive "p")
  (interactive)
  (setq organizer (read-file-name "Organizer page: " organizer-directory))
  (organizer-hidden-view-other-diary-entries number-of-diary-entries "~/diary" organizer)
;;   (organizer-hidden-view-other-diary-entries arg "~/diary" organizer)
  (other-window 1))

(defun echo-at-point ()
  "Get string from buffer and echo.  For testing.  See `ffap'."
  (interactive)
  (require 'ffap)
  (let ((str (ffap-string-at-point)))
    (message "The string at the cursor is \"%s\"." str)))

(defun todo-show-alternate-file ()
  "Show an alternate TODO list."
  (interactive)
  (setq todo-file-alt (read-file-name "FTodo file: " organizer-directory))
  (if (file-exists-p todo-file-alt)
      (find-file todo-file-alt)
    (todo-initial-setup))
  (if (null todo-categories)
      (if (null todo-cats)
          (error "Error in %s: No categories in list `todo-categories'"
                 todo-file-alt)
        (goto-char (point-min))
        (and (search-forward "todo-cats:" nil t)
             (replace-match "todo-categories:"))
        (make-local-variable 'todo-categories)
        (setq todo-categories todo-cats)))
  (beginning-of-line)
  (todo-category-select))

(defun vm-at-point ()
  "Start vm and open folder name at point.  Requires full path to
mailbox in buffer unless in dired."
    (interactive)
    (require 'ffap)
    (let ((filestr (ffap-string-at-point)))
      (vm filestr)))

(defun gnus-at-point ()
  "Start gnus and open folder name at cursor on page.  Requires that
gnus be set up before hand."
    (interactive)
    (require 'ffap)
    (let ((groupstr (ffap-string-at-point)))
      (gnus)
      (gnus-fetch-group groupstr)))

(defun organizer-insert-diary-entry (arg)
  "Insert a diary entry for the date indicated by point.  Prefix arg
will make the entry nonmarking.  Based upon insert-diary-entry but
allows you to chhose the diary file."
  (interactive "P")
  (setq organizer (read-file-name "Organizer page: " organizer-directory))
  (make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t t)
                    arg organizer))

(defun telnet-at-point ()
  "Start gnus and open folder name at cursor on page.  Requires that
gnus be set up before hand."
    (interactive)
    (require 'ffap)
    (let ((serverstr (ffap-string-at-point)))
      (telnet serverstr)))

(defun rlogin-at-point ()
  "Start gnus and open folder name at cursor on page.  Requires that
gnus be set up before hand."
    (interactive)
    (require 'ffap)
    (let ((serverstr (ffap-string-at-point)))
      (rlogin serverstr)))

(defun rsh-at-point ()
  "Start gnus and open folder name at cursor on page.  Requires that
gnus be set up before hand."
    (interactive)
    (require 'ffap)
    (let ((serverstr (ffap-string-at-point)))
      (rlogin serverstr)))

(defun organizer-view-diary-entries (arg)
  "Prepare and display a buffer with diary entries.
Searches the file named in `diary-file' for entries that
match ARG days starting with the date indicated by the cursor position
in the displayed three-month calendar."
  (interactive "p")
  (let ((d-file (substitute-in-file-name diary-file)) (o-file (substitute-in-file-name organizer-file)))
    (if (and (and d-file (file-exists-p d-file)) (and o-file (file-exists-p o-file)))
        (if (and (file-readable-p d-file) (file-readable-p o-file))
            (organizer-list-diary-entries (calendar-cursor-to-date t) arg)
          (error "Diary file is not readable!"))
      (error "You don't have a diary file!"))))

(defun organizer-hidden-view-other-diary-entries (arg d-file o-file)
;; (defun organizer-hidden-view-other-diary-entries (arg d-file)
  "Prepare and display buffer of diary entries from an alternative diary file.
Prompts for a file name and searches that file for entries that match ARG
days starting with the date indicated by the cursor position in the displayed
three-month calendar."
  (interactive
   (list (cond ((null current-prefix-arg) 1)
               ((listp current-prefix-arg) (car current-prefix-arg))
               (t current-prefix-arg))
	 (read-file-name "Enter diary file name: " default-directory nil t)))
  (let ((diary-file d-file) (organizer-file o-file))
    (organizer-view-diary-entries arg)))

(defun organizer-list-diary-entries (date number)
;; (defun list-diary-entries (date number)
  "Create and display a buffer containing the relevant lines in `diary-file'.
The arguments are DATE and NUMBER; the entries selected are those
for NUMBER days starting with date DATE.  The other entries are hidden
using selective display.

Returns a list of all relevant diary entries found, if any, in order by date.
The list entries have the form ((month day year) string specifier) where
\(month day year) is the date of the entry, string is the entry text, and
specifier is the applicability.  If the variable `diary-list-include-blanks'
is t, this list includes a dummy diary entry consisting of the empty string)
for a date with no diary entries.

After the list is prepared, the hooks `nongregorian-diary-listing-hook',
`list-diary-entries-hook', `diary-display-hook', and `diary-hook' are run.
These hooks have the following distinct roles:

    `nongregorian-diary-listing-hook' can cull dates from the diary
        and each included file.  Usually used for Hebrew or Islamic
        diary entries in files.  Applied to *each* file.

    `list-diary-entries-hook' adds or manipulates diary entries from
        external sources.  Used, for example, to include diary entries
        from other files or to sort the diary entries.  Invoked *once* only,
        before the display hook is run.

    `diary-display-hook' does the actual display of information.  If this is
        nil, `simple-diary-display' will be used.  Use `add-hook' to set this to
        `fancy-diary-display', if desired.  If you want no diary display, use
        `add-hook' to set this to ignore.

    `diary-hook' is run last.  This can be used for an appointment
        notification function."

  (organizer-srchfn)
  (if (< 0 number)
      (let* ((original-date date);; save for possible use in the hooks
             (old-diary-syntax-table)
             (diary-entries-list)
             (date-string (calendar-date-string date))
             (o-file (substitute-in-file-name organizer-file))
	     (diary-file "~/diary-delete-me")
             (d-file (substitute-in-file-name diary-file)))
        (message "Preparing diary...")
        (save-excursion
	  (find-file d-file)
          (let ((diary-buffer (find-buffer-visiting d-file)))
;; 	    (if (not diary-buffer)
;; 		(set-buffer (find-file-noselect d-file t))
	      (find-file o-file)
	      (setq o-buff (buffer-name))
	      (append-to-buffer diary-buffer (point-min) (point-max))
	      (kill-buffer o-buff)
	      (set-buffer diary-buffer)
	      (or (verify-visited-file-modtime diary-buffer)
		  (revert-buffer t t)))
;; )
          (setq selective-display t)
          (setq selective-display-ellipses nil)
          (setq old-diary-syntax-table (syntax-table))
          (set-syntax-table diary-syntax-table)
          (unwind-protect
            (let ((buffer-read-only nil)
                  (diary-modified (buffer-modified-p))
                  (mark (regexp-quote diary-nonmarking-symbol)))
              ;; First and last characters must be ^M or \n for
              ;; selective display to work properly
              (goto-char (1- (point-max)))
              (if (not (looking-at "\^M\\|\n"))
                  (progn
                    (goto-char (point-max))
                    (insert-string "\^M")))
              (goto-char (point-min))
              (if (not (looking-at "\^M\\|\n"))
                  (insert-string "\^M"))
              (subst-char-in-region (point-min) (point-max) ?\n ?\^M t)
              (calendar-for-loop i from 1 to number do
                 (let ((d diary-date-forms)
                       (month (extract-calendar-month date))
                       (day (extract-calendar-day date))
                       (year (extract-calendar-year date))
                       (entry-found (list-sexp-diary-entries date)))
                   (while d
                     (let*
                          ((date-form (if (equal (car (car d)) 'backup)
                                          (cdr (car d))
                                        (car d)))
                          (backup (equal (car (car d)) 'backup))
                          (dayname
                           (concat
                            (calendar-day-name date) "\\|"
                            (substring (calendar-day-name date) 0 3) ".?"))
                          (monthname
                           (concat
                            "\\*\\|"
                            (calendar-month-name month) "\\|"
                            (substring (calendar-month-name month) 0 3) ".?"))
                          (month (concat "\\*\\|0*" (int-to-string month)))
                          (day (concat "\\*\\|0*" (int-to-string day)))
                          (year
                           (concat
                            "\\*\\|0*" (int-to-string year)
                            (if abbreviated-calendar-year
                                (concat "\\|" (format "%02d" (% year 100)))
                              "")))
                          (regexp
                           (concat
                            "\\(\\`\\|\^M\\|\n\\)" mark "?\\("
                            (mapconcat 'eval date-form "\\)\\(")
                            "\\)"))
                          (case-fold-search t))
                       (goto-char (point-min))
                       (while (re-search-forward regexp nil t)
                         (if backup (re-search-backward "\\<" nil t))
                         (if (and (or (char-equal (preceding-char) ?\^M)
                                      (char-equal (preceding-char) ?\n))
                                  (not (looking-at " \\|\^I")))
                             ;;  Diary entry that consists only of date.
                             (backward-char 1)
                           ;; Found a nonempty diary entry--make it visible and
                           ;; add it to the list.
                           (setq entry-found t)
                           (let ((entry-start (point))
                                 (date-start))
                             (re-search-backward "\^M\\|\n\\|\\`")
                             (setq date-start (point))
                             (re-search-forward "\^M\\|\n" nil t 2)
                             (while (looking-at " \\|\^I")
                               (re-search-forward "\^M\\|\n" nil t))
                             (backward-char 1)
                             (subst-char-in-region date-start
                                (point) ?\^M ?\n t)
                             (add-to-diary-list
                              date
                              (buffer-substring-no-properties
                               entry-start (point))
                              (buffer-substring-no-properties
                               (1+ date-start) (1- entry-start)))))))
                     (setq d (cdr d)))
                   (or entry-found
                       (not diary-list-include-blanks)
                       (setq diary-entries-list 
                             (append diary-entries-list
                                     (list (list date "" "")))))
                   (setq date
                         (calendar-gregorian-from-absolute
                           (1+ (calendar-absolute-from-gregorian date))))
                   (setq entry-found nil)))
              (set-buffer-modified-p diary-modified))
          (set-syntax-table old-diary-syntax-table))
        (goto-char (point-min))
        (run-hooks 'nongregorian-diary-listing-hook
                   'list-diary-entries-hook)
        (if diary-display-hook
            (run-hooks 'diary-display-hook)
          (simple-diary-display))
        (run-hooks 'diary-hook)
        diary-entries-list
	(set-buffer (find-buffer-visiting d-file))
	(save-buffer)
	(kill-this-buffer)
	  (if (file-exists-p diary-file-temp)
	      (delete-file diary-file-temp))
;;	  (if (file-exists-p "/home/tshanno/diary-delete-me~")
;;	      (delete-file "/home/tshanno/diary-delete-me~"))
))
      ))

(defun organizer-srchfn ()
"Used internally by 'organizer-mode.el' to search diary, todo files
and, eventually, others for entries relevant to the current organizer
file and inserts them into a temporary buffer.  Relevant files are
defines as those with contain the name of the current organizer file."
  (setq d-file (substitute-in-file-name diary-file))
  (find-file d-file)
  (let ((d-buff (buffer-name)))
    (message d-buff)
    (setq t-file diary-file-temp)
    (setq to-file todo-file-do)
    (find-file to-file)
    (kill-ring-save (point-min) (point-max))
    (kill-this-buffer)
    (switch-to-buffer "todo-temp")
    (yank)
    (end-of-buffer)
    (insert-string "\njunk string\n")
    (beginning-of-buffer)
    (setq to-buff (buffer-name))
    (setq todn-file todo-file-done)
    (find-file todn-file)
    (kill-ring-save (point-min) (point-max))
    (kill-this-buffer)
    (switch-to-buffer "todn-temp")
    (yank)
    (end-of-buffer)
    (insert-string "\njunk string\n")
    (beginning-of-buffer)
    (setq todn-buff (buffer-name))
    (find-file organizer-file)
    (setq o-buff (file-name-nondirectory organizer-file))
    (kill-buffer o-buff)
    (find-file t-file)
    (let ((t-buff (buffer-name)))
      (set-buffer d-buff)
      (setq ind 1)
	 (if (search-forward o-buff nil t) (setq ind 1) (setq ind 0))
       (while (equal ind 1)
	 (message "here")
	 (if (re-search-backward "^[^\t ]" nil t) (setq ind 1) (setq ind 0))
	 (let ((beg (point)))
	   (if (search-forward o-buff nil t) (setq ind 1) (setq ind 0))
	   (if (re-search-forward "^[^\t ]" nil t) (setq ind 1) (setq ind 0))
	   (backward-char 1)
	   (kill-ring-save beg (point))
	   (set-buffer t-buff)
	   (yank)
	   (set-buffer d-buff)
	   (if (search-forward o-buff nil t) (setq ind 1) (setq ind 0))
	 ))
      (set-buffer to-buff)
      (setq ind 1)
	 (if (search-forward o-buff nil t) (setq ind 1) (setq ind 0))
       (while (equal ind 1)
	 (message "here")
	 (if (re-search-backward "^[^\t ]" nil t) (setq ind 1) (setq ind 0))
	 (let ((beg (point)))
	   (if (search-forward o-buff nil t) (setq ind 1) (setq ind 0))
	   (if (re-search-forward "^[^\t ]" nil t) (setq ind 1) (setq ind 0))
	   (backward-char 1)
	   (kill-ring-save beg (point))
	   (set-buffer t-buff)
	   (yank)
	   (set-buffer to-buff)
	   (if (search-forward o-buff nil t) (setq ind 1) (setq ind 0))
	 ))
      (set-buffer todn-buff)
      (setq ind 1)
	 (if (search-forward o-buff nil t) (setq ind 1) (setq ind 0))
       (while (equal ind 1)
	 (message "here")
	 (if (re-search-backward "^[^\t ]" nil t) (setq ind 1) (setq ind 0))
	 (let ((beg (point)))
	   (if (search-forward o-buff nil t) (setq ind 1) (setq ind 0))
	   (if (re-search-forward "^[^\t ]" nil t) (setq ind 1) (setq ind 0))
	   (backward-char 1)
	   (kill-ring-save beg (point))
	   (set-buffer t-buff)
	   (yank)
	   (set-buffer todn-buff)
	   (if (search-forward o-buff nil t) (setq ind 1) (setq ind 0))
	 ))

       (set-buffer t-buff)
       (save-buffer t-buff)
;;        (kill-buffer t-buff)
;;        (kill-buffer d-buff)
       (kill-this-buffer)
       (set-buffer d-buff)
       (kill-this-buffer)
       (set-buffer to-buff)
       (kill-this-buffer)
       (set-buffer todn-buff)
       (kill-this-buffer)
)))

(provide 'organizer-mode)

;;; organizer-mode.el ends here

-- 
Quote of the Day for June 14, 2002
Never let your sense of morals get in the way of doing what's right.
            -- Isaac Asimov


Google Home - Advertise with Us - Search Solutions - News and Resources - Language Tools - Jobs, Press, Cool Stuff...

©2002 Google