GNU   davin.50webs.com/research
Bringing to you notes for the ages

       Main Menu          Research Projects         Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address       Computer Games          Web Design          Java Training Wheels      The Fly (A Story)   
  Political Activism   Scruff the Cat       My Life Story          Smoking Cessation          Other Links      
Debugging Macros     String Class I     Linked List System I Java for C Programmers Naming Convention
    String Class II         How I use m4              Strings III                 Symmetrical I/O             Linked Lists II     
Run-Time Type Info   Virtual Methods      An Array System        Science & Religion            Submodes       
  Nested Packages      Memory Leaks    Garbage Collection      Internet & Poverty      What is Knowledge?
Limits of Evolution   Emacs Additions      Function Plotter           Romantic Love        The Next Big Thing
    Science Fiction     Faster Compilation Theory of Morality         Elisp Scoping               Elisp Advice      
  S.O.G.M. Pattern       Safe Properties         School Bullying          Charisma Control          Life and Death    
     Splitting Java          Multiple Ctors       Religious Beliefs         Conversation 1           Conversation 2    
   J.T.W. language    Emacs Additions II      Build Counter             Relation Plotter          Lisp++ Language  
  Memory Leaks II   Super Constructors CRUD Implementation Order a Website Form There Is An Afterlife
More Occam's Razor C to Java Translator Theory of Morality II


d-appt.el

    

;;; d-appt.el --- An improved appointment notification system

;; Copyright (C) 2006-2011 Davin Pearson

;; Author/Maintainer: Davin Pearson http://davin.50webs.com
;; Keywords: improved appt.el
;; Version: 1.0

;;; Commentary:

;; This file is not part of GNU Emacs.

;; With this file activated, every 30 minutes the message "okay Davin
;; it's time for a pause break so you should do something else which
;; is away from the computer." is played through your speakers.
;;
;; Also sound samples are played depending on the settings of your
;; ~/.diary file.

;;; Limitation of Warranty

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more detail.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs, see the file COPYING.  If not, see:
;;
;; <http://www.gnu.org/licenses/gpl-3.0.txt>.


;;; Install Instructions:
;; See the following URL for the latest info and a tarball:
;;
;; <http://davin.50webs.com/research/2010/mopa2e2.html#d-appt>
;;
;; Then untar the tarball to a folder pointed to by the Emacs variable
;; load-path and add the following line to your ~/.emacs file.
;;
;; (require 'd-appt)

;;; Known Bugs:

;; none!

;;; Code:

;; d-time--get-stamp is used from     d-time.el
;; d-say-number-improved is used from d-number-sayer.el

(require 'appt)
(require 'calendar)
(require 'd-number-sayer)
(require 'd-time)

(setq diary-date-forms (cons '(year "-" month "-" day "[^0-9]") diary-date-forms))

(setq appt-display-diary nil)

(defun d-appt-pause-break ()
  (message "Last pause break commencing at %s" (d-time--get-stamp))
  (setq f "appt-pause-break.wav")
  (if (file-exists-p f)
      (play-sound (list 'sound :file f :volume 1.0)))
  (setq f "/media/www/C1TB/sound-samples/emacs/appt-pause-break.wav")
  (if (file-exists-p f)
      (play-sound (list 'sound :file f :volume 1.0)))
  )

(let (hour)
  (setq hour (nth 2 (decode-time (current-time))))
  (when (and (< hour 21) (>= hour 15))
    (if (boundp 'd-appt-pause-timer) (cancel-timer d-appt-pause-timer))
    (setq d-appt-pause-timer (run-with-timer (* 60 30) (* 60 30) 'd-appt-pause-break))))

;; (appt-display-message "d:/sound-samples/emacs/appt-lecture-14-00.wav" 0)
(defun appt-display-message (string mins)
  "Bug: why no v
   NOTE: no time to go sample if (not (string-match \"alarm-off\" string)) "
  (save-match-data
    (when (and (= 0 mins) (string-match "alarm-on" string))
      (if (boundp 'd-appt-pause-timer)
          (cancel-timer d-appt-pause-timer))
      (setq d-appt-pause-timer (run-with-timer (* 60 25) (* 60 30) 'd-appt-pause-break)))
    (if (and (= 0 mins) (string-match "heater-off" string) (boundp 'd-appt-pause-timer))
        (cancel-timer d-appt-pause-timer))
    ;; -------------------------------------------------------------------------------------------
    (when (not (string-match "nothing" string))
      (message "*** time=%s string=%s mins=%s" (d-time--get-stamp) (d-trim-string string) mins)
      (let (ptr appt-file min)
        (save-match-data
          (when (not (string-match "alarm-off" string))
            (if (string-match "[a-z]:/[^ \t\r\n]*" string)
                (progn
                  (setq appt-file (substring string (match-beginning 0) (match-end 0)))
                  ;;(message "*** appt-file=%s" appt-file)
                  (when (string-match "\\.wa$" appt-file)
                    (setq appt-file (concat appt-file "v"))
                    ;;(message "*** added v")
                    )
                  ;;(message "*** appt-file=%s" appt-file)
                  ;;(message "*** Appointment=%s mins to go=%d" appt-file mins)
                  ;;(setq appt-file "d:/sound-samples/emacs/alarm-on-lecture.wav")
                  (when (and (not (string= "d:/sound-samples/emacs/alarm-on.wav" appt-file))
                             (string-match "\\(^.*\\)alarm-on\\(.*$\\)" appt-file))
                    (setq appt-file (concat (substring appt-file (match-beginning 1) (match-end 1))
                                            "appt"
                                            (substring appt-file (match-beginning 2) (match-end 2))))
                    (play-sound (list 'sound :file "d:/sound-samples/emacs/alarm-on.wav" :volume 1.0)))
                  ;;(debug)
                  (if (and appt-file (file-exists-p appt-file))
                      (play-sound (list 'sound :file appt-file :volume 1.0))
                    (play-sound (list 'sound :file "d:/sound-samples/emacs/appt-misc.wav" :volume 1.0))))
              ;;(debug)
              (play-sound (list 'sound :file "d:/sound-samples/emacs/appt-misc.wav" :volume 1.0)))
            ;;(assert (>= mins 0))
            (d-say-number-improved mins)
            (if (= 1 mins)
                (setq min "d:/sound-samples/emacs/numbers/minute-to-go.wav")
              (setq min "d:/sound-samples/emacs/numbers/minutes-to-go.wav"))
            (if (file-exists-p min)
                (play-sound (list 'sound :file min :volume 1.0))
              (beep)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          (cond
           ((string-match "alarm-on" string)
            (if (or (= mins 0) (= mins 1) (= mins 2))
                (save-window-excursion
                  (if (get-buffer "*Async Shell Command*") (kill-buffer "*Async Shell Command*"))
                  (shell-command (concat "\"/media/www/C1TB/Program Files/foobar2000/foobar2000.exe\" "
                                         "\"/media/www/C1TB/Documents and Settings/Davin Max Pearson/My Documents/list.fpl\" &")))))
           ((string-match "alarm-off" string)
            (if t (save-window-excursion
                    (if (get-buffer "*Async Shell Command*") (kill-buffer "*Async Shell Command*"))
                    (shell-command (concat "\"/media/www/C1TB/Program Files/foobar2000/foobar2000.exe\" /exit &")))))))))))

(setq appt-disp-window-function 'd-appt-disp-window-function)

(defun d-appt-disp-window-function ()
  (message "*** crud"))

(defun appt-disp-window (min-to-app new-time appt-msg)
  )

(defun simple-diary-display ()
  )

(defun d-appt-activate ()
  (interactive)
  (require 'appt)
  (appt-activate 1)
  (setq appt-audible t)
  (setq appt-display-mode-line nil)
  ;;(d-f4)
  )

;;(d-appt-activate)

(provide 'd-appt)
Back
| Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
| Email Address | Computer Games | Web Design | Java Training Wheels | The Fly (A Story) |
| Political Activism | Scruff the Cat | My Life Story | Smoking Cessation | Other Links |
| Debugging Macros | String Class I | Linked List System I | Java for C Programmers | Naming Convention |
| String Class II | How I use m4 | Strings III | Symmetrical I/O | Linked Lists II |
| Run-Time Type Info | Virtual Methods | An Array System | Science & Religion | Submodes |
| Nested Packages | Memory Leaks | Garbage Collection | Internet & Poverty | What is Knowledge? |
| Limits of Evolution | Emacs Additions | Function Plotter | Romantic Love | The Next Big Thing |
| Science Fiction | Faster Compilation | Theory of Morality | Elisp Scoping | Elisp Advice |
| S.O.G.M. Pattern | Safe Properties | School Bullying | Charisma Control | Life and Death |
| Splitting Java | Multiple Ctors | Religious Beliefs | Conversation 1 | Conversation 2 |
| J.T.W. language | Emacs Additions II | Build Counter | Relation Plotter | Lisp++ Language |
| Memory Leaks II | Super Constructors | CRUD Implementation | Order a Website Form | There Is An Afterlife |
| More Occam's Razor | C to Java Translator | Theory of Morality II
Last modified: Mon May 6 01:56:47 NZST 2019
Best viewed at 800x600 or above resolution.
© Copyright 1999-2019 Davin Pearson.
Please report any broken links to