Commit 75dc3850 authored by Dave Cooper's avatar Dave Cooper

added new emacs libraries

parent b78daa0f
Alert is a Growl-workalike for Emacs which uses a common notification
interface and multiple, selectable "styles", whose use is fully customizable
by the user.
# For module writers
Just use =alert= instead of =message= as follows:
(require 'alert)
;; This is the most basic form usage
(alert "This is an alert")
;; You can adjust the severity for more important messages
(alert "This is an alert" :severity 'high)
;; Or decrease it for purely informative ones
(alert "This is an alert" :severity 'trivial)
;; Alerts can have optional titles. Otherwise, the title is the
;; buffer-name of the (current-buffer) where the alert originated.
(alert "This is an alert" :title "My Alert")
;; Further, alerts can have categories. This allows users to
;; selectively filter on them.
(alert "This is an alert" :title "My Alert" :category 'debug)
# For users
For the user, there are several variables to control when and how alerts
are presented. By default, they appear in the minibuffer much the same
as a normal Emacs message. But there are many more possibilities:
- =alert-fade-time= ::
Normally alerts disappear after this many seconds, if the style
supports it. The default is 5 seconds.
- =alert-default-style= ::
Pick the style to use if no other config rule matches. The
default is =message=, but =growl= works well too.
- =alert-reveal-idle-time= ::
If a config rule choose to match on =idle=, this is how many
seconds idle the user has to be. Defaults to 5 so that users
don't miss any alerts, but 120 is also good.
- =alert-persist-idle-time= ::
After this many idle seconds, alerts will become sticky, and not
fade away more. The default is 15 minutes.
- =alert-log-messages= ::
By default, all alerts are logged to *Alerts* (and to *Messages*,
if the =message= style is being used). Set to nil to disable.
- =alert-hide-all-notifications= ::
Want alerts off entirely? They still get logged, however, unless
you've turned that off too.
- =alert-user-configuration= ::
This variable lets you control exactly how and when a particular
alert, a class of alerts, or all alerts, get reported -- or if at
all. Use this to make some alerts use Growl, while others are
completely silent.
# Programmatically adding rules
Users can also programmatically add configuration rules, in addition to
customizing =alert-user-configuration=. Here is one that the author
currently uses with ERC, so that the fringe gets colored whenever people
chat on BitlBee:
(alert-add-rule :status '(buried visible idle)
:severity '(moderate high urgent)
:mode 'erc-mode
:predicate
#'(lambda (info)
(string-match (concat "\\`[^&].*@BitlBee\\'")
(erc-format-target-and/or-network)))
:persistent
#'(lambda (info)
;; If the buffer is buried, or the user has been
;; idle for `alert-reveal-idle-time' seconds,
;; make this alert persistent. Normally, alerts
;; become persistent after
;; `alert-persist-idle-time' seconds.
(memq (plist-get info :status) '(buried idle)))
:style 'fringe
:continue t)
# Builtin alert styles
There are several builtin styles, and it is trivial to create new ones.
The builtins are:
| message | Uses the Emacs =message= facility |
| log | Logs the alert text to *Alerts*, with a timestamp |
| ignore | Ignores the alert entirely |
| fringe | Changes the current frame's fringe background color |
| growl | Uses Growl on OS X, if growlnotify is on the PATH |
# Defining new styles
To create a new style, you need to at least write a "notifier", which is
a function that receives the details of the alert. These details are
given in a plist which uses various keyword to identify the parts of the
alert. Here is a prototypical style definition:
(alert-define-style 'style-name :title "My Style's title"
:notifier
(lambda (info)
;; The message text is :message
(plist-get info :message)
;; The :title of the alert
(plist-get info :title)
;; The :category of the alert
(plist-get info :category)
;; The major-mode this alert relates to
(plist-get info :mode)
;; The buffer the alert relates to
(plist-get info :buffer)
;; Severity of the alert. It is one of:
;; `urgent'
;; `high'
;; `moderate'
;; `normal'
;; `low'
;; `trivial'
(plist-get info :severity)
;; Whether this alert should persist, or fade away
(plist-get info :persistent)
;; Data which was passed to `alert'. Can be
;; anything.
(plist-get info :data))
;; Removers are optional. Their job is to remove
;; the visual or auditory effect of the alert.
:remover
(lambda (info)
;; It is the same property list that was passed to
;; the notifier function.
))
This diff is collapsed.
This diff is collapsed.
Org-Pomodoro
============
This adds very basic support for
[Pomodoro technique](http://www.pomodorotechnique.com/)
in Emacs' org-mode.
With default customs:
You can start a pomodoro for the task at point or select one of the
last tasks that you clocked time for. Each clocked-in pomodoro
starts a timer of 25 minutes and after each pomodoro a break timer of
5 minutes is started automatically. Every 4 breaks a long break is
started with 20 minutes. All values are customizable.
Installation
============
Install from MELPA:
* Add MELPA to your EMACS installation:
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
* Install the package via `M-x package-install RET org-pomodoro`
Usage
=====
1. Move point to a task as you would do with `org-clock-in`.
Call `org-pomodoro` the task will be clocked-in.
2. When there's time for break, the task will be `org-clock-out`'ed
3. If you call `org-pomodoro` during a pomodoro, you'll be asked to reset
a pomodoro.
4. If you call `org-pomodoro` outside org-mode, you'll be presented
with list of recent tasks, as `C-u org-clock-in` would.
License
=======
This file 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, or (at your option)
any later version.
This file 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 details.
You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
;; -*- lexical-binding: t; -*-
;;; org-pomodoro-pidgin.el --- Integrate org-pomodoro and Pidgin
;;
;; Copyright (C) 2013 Damien Cassou
;;
;; Author: Damien Cassou <damien.cassou@gmail.com>
;; Created: 2013-07-11
;; Keywords: emacs package elisp pidgin pomodoro org-mode
;;
;; This file is NOT part of GNU Emacs.
;;
;; 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 2, 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 details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program ; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;
;;; commentary:
;;
;; Update Pidgin status as the Pomodoro progresses.
;;
;; (require 'org-pomodoro-pidgin)
;;
;;; code:
;;
;; The following code uses the "org-pompid" prefix for all "private"
;; functions (and an addition dash "-") and the "org-pomodoro-pidgin"
;; prefix for all "public" functions.
(require 'org-pomodoro)
(defgroup org-pomodoro-pidgin nil
"Customization group for the Pidgin integration with
org-pomodoro."
:group 'org-pomodoro)
(defcustom org-pomodoro-pidgin-busy-status
"Pomodoro ends at %s"
"Status message when a pomodoro is in progress.
The string will be passed to `format' with the time when pomodoro
ends."
:group 'org-pomodoro-pidgin)
(defcustom org-pomodoro-pidgin-break-status
"Available"
"Status message when a pomodoro is in progress."
:group 'org-pomodoro-pidgin)
(defun org-pompid--status-type-to-id (type)
"Convert the symbol TYPE to the correspond int32.
https://developer.pidgin.im/wiki/DbusHowto#CallingPidginmethods."
(case type
(offline 1)
(available 2)
(unavailable 3)
(invisible 4)
(away 5)
(mobile 7)
(tune 8)))
(defun org-pompid--call-method (method handler &rest args)
"Call METHOD with D-Bus and execute HANDLER upon answer.
ARGS lists additional parameters for METHOD."
(when
(member "im.pidgin.purple.PurpleService" (dbus-list-known-names :session))
(apply #'dbus-call-method-asynchronously
:session
"im.pidgin.purple.PurpleService"
"/im/pidgin/purple/PurpleObject"
"im.pidgin.purple.PurpleInterface"
method
handler
args)))
(defun org-pompid--set-status-message (status message)
"Update STATUS with the MESSAGE."
(org-pompid--call-method
"PurpleSavedstatusSetMessage"
nil
:int32 status
message))
(defun org-pompid--new-transient-status (type handler)
"Create a new status of TYPE and execute HANDLER when created."
(org-pompid--call-method
"PurpleSavedstatusNew"
handler
""
:int32 (org-pompid--status-type-to-id type)))
(defun org-pompid--activate (status)
"Make STATUS the current one in Piding."
(org-pompid--call-method
"PurpleSavedstatusActivate"
nil
:int32 status))
(defun org-pompid--change-status-message (type message)
"Create a new status of TYPE with MESSAGE.
TYPE must be valid for `org-pompid--status-type-to-id'."
(org-pompid--new-transient-status
type
(lambda (status)
(org-pompid--set-status-message status message)
(org-pompid--activate status))))
(defun org-pompid--format-message (message)
"Replace the %s in MESSAGE with the time when pomodoro ends."
(format
message
(format-time-string
"%H:%M"
(time-add (current-time) (seconds-to-time org-pomodoro-countdown)))))
(add-hook
'org-pomodoro-started-hook
(lambda ()
(org-pompid--change-status-message
'unavailable
(org-pompid--format-message org-pomodoro-pidgin-busy-status))))
(add-hook
'org-pomodoro-finished-hook
(lambda ()
(org-pompid--change-status-message
'available
org-pomodoro-pidgin-break-status)))
(add-hook
'org-pomodoro-killed-hook
(lambda ()
(org-pompid--change-status-message
'available
org-pomodoro-pidgin-break-status)))
(provide 'org-pomodoro-pidgin)
;;; org-pomodoro-pidgin.el ends here
;;; org-pomodoro-tests.el --- Org-pomodoro tests
;;; Commentary:
;; All tests for org-pomodoro.el.
;;; Code:
(ert-deftest org-pomodoro-expires-when-last-clockin-too-old ()
"Test the return value is true when org-pomodoro-last-clock-in is too old."
(let ((org-pomodoro-last-clock-in '(0 120 0 0))
(org-pomodoro-expiry-time 120))
(should (equal t (org-pomodoro-expires-p)))))
(ert-deftest org-pomodoro-expires-when-last-clockin-is-new ()
"Test the return value is false when org-pomodoro-last-clock-in is new."
(let ((org-pomodoro-last-clock-in (current-time))
(org-pomodoro-expiry-time 120))
(should (equal nil (org-pomodoro-expires-p)))))
;;; org-pomodoro-tests.el ends here
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment