yoshinari-nomura / mhc

MHC -- Message Harmonized Calendaring system
http://www.quickhack.net/mhc/
Other
20 stars 12 forks source link
calendar emacs-lisp ruby

+TITLE: MHC -- Message Harmonized Calendaring system.

+AUTHOR: Yoshinari Nomura

+EMAIL:

+DATE: 2015-03-16

+OPTIONS: H:3 num:2 toc:nil

+OPTIONS: ^:nil @:t \n:nil ::t |:t f:t TeX:t

+OPTIONS: skip:nil

+OPTIONS: author:t

+OPTIONS: email:nil

+OPTIONS: creator:nil

+OPTIONS: timestamp:nil

+OPTIONS: timestamps:nil

+OPTIONS: d:nil

+OPTIONS: tags:t

+TEXT:

+DESCRIPTION:

+KEYWORDS:

+LANGUAGE: ja

+LATEX_CLASS: jsarticle

+LATEX_CLASS_OPTIONS: [a4j]

+LATEX_HEADER: \usepackage{plain-article}

+LATEX_HEADER: \renewcommand\maketitle{}

+LATEX_HEADER: \pagestyle{empty}

+LaTeX: \thispagestyle{empty}

[[file:https://badge.fury.io/rb/mhc.svg]] [[http://melpa.org/#/mhc][file:http://melpa.org/packages/mhc-badge.svg]]

* Emacs UI (mhc.el) You have to install Ruby CLI before install mhc.el*

MHC is now available on [[http://melpa.org/][MELPA]]. If you set up packaging system correctly, You can install mhc with package.el (=M-x= =package-install= =mhc=). Check [[https://github.com/milkypostman/melpa#usage][MELPA usage]] for details.

And then, =M-x mhc= will show up the monthly calendar.

** Emacs UI (mhc.el) *** Keybind 1) Jump and Show

   =n/p=, =h/j/k/l= would work as expected.

   | Key             | Function                   |
   |-----------------+----------------------------|
   | =<=             | Show previous month        |
   | =P=             | Show previous year         |
   | =>=             | Show next month            |
   | =N=             | Show next year             |
   | =g=             | Go to specific month       |
   | =v=             | Toggle message window      |
   | =RET/SPC/./DEL= | Show/scroll message buffer |
   | =/=             | Search by keyword          |

2) Manipulate articles

   | Key | Function                                       |
   |-----+------------------------------------------------|
   | =E= | Create a new article draft interactively       |
   | =M= | Open pointed article to edit                   |
   | =D= | Delete pointed article                         |
   | =C= | Copy article temporally as a reusable template |
   | =R= | Copy article like =C= using completing-read    |
   | =Y= | Same as =E= but use the template stored by =C= |

3) Draft Buffer

   | Key      | Function                               |
   |----------+----------------------------------------|
   | =C-cC-c= | Finish editing and register to DB      |
   | =C-cC-q= | Discard editing buffer w/o touching DB |

** Time related headers MHC has four types of headers to specify time/date-range or recurring conditions:

*** X-SC-Day =X-SC-Day:= specifies an enumeration of occurrence dates separated by white space:

+BEGIN_EXAMPLE

  X-SC-Day: 20150704          ... all-day event
  X-SC-Day: 20150704-20150705 ... two-days long single event
  X-SC-Day: 20150704 20150705 ... two all-day events
#+END_EXAMPLE

If =X-SC-Time:= is specified with =X-SC-Day:=,
=X-SC-Time:= acts on all enumerated dates in =X-SC-Day:=.
So, you cannot set multiple-days value (=20150704-20150705=) with =X-SC-Time:=.
You can also put =!= prefix to specify the exception days (See below about =X-SC-Cond:=)

*** X-SC-Time =X-SC-Time:= specifies a time range in a day or a point of time like:

+BEGIN_EXAMPLE

  X-SC-Time: 10:00-12:00
  X-SC-Time: 10:00
#+END_EXAMPLE
You can leave it blank for all-day events.

With the combination of =X-SC-Day:=, you can specify some particular
time-range of a day. Currently, you cannot specify a time-range
across the multiple days.

*** X-SC-Cond =X-SC-Cond:= defines a rule of recurrence; weekly, monthly or yearly. You can place these keywords in =X-SC-Cond:= separating by white spaces: | Keyword | Purpose | |----------------------------+-----------------------| | =01/02/.../31= | Day of month | | =1st/2nd/3rd/4th/5th/Last= | Week order in a month | | =Sun/Mon/.../Sat= | Day of week | | =Jan/Feb/.../Dec= | Name of month |

Example:
#+BEGIN_EXAMPLE
  X-SC-Cond: Fri         ... Every Friday
  X-SC-Cond: Tue Fri     ... Every Tueday and Friday
  X-SC-Cond: 31 Aug      ... August 31st every year
  X-SC-Cond: 1           ... First day on every month
  X-SC-Cond: 1st 3rd Fri ... First and Third Friday every month
  X-SC-Cond: Fri 13      ... 13th on every month or every Friday (not Friday 13th)
#+END_EXAMPLE

Sometimes you may want to set a particular date as exception.
In such case, you can exclude a date by placing =!YYYYMMDD=
in =X-SC-Day:=. For example:
#+BEGIN_EXAMPLE
  X-SC-Day: !20150715 20150716
  X-SC-Cond: Wed
  X-SC-Duration: 20150701-20150731

  This article occurs every Wednesday in July 2015 with the exception
  of 2015-07-15 (Wed) and inclusion of 2015-07-16 (Thu).
#+END_EXAMPLE

*** X-SC-Duration =X-SC-Duration:= acts on =X-SC-Cond:= to bounds the recurrence rule in an inclusive manner. Note that, =X-SC-Duration:= itself does not define any concrete occurrences and does not act on =X-SC-Day:=.

Example:
#+BEGIN_EXAMPLE
  X-SC-Day: !20150715 20150801
  X-SC-Cond: Wed
  X-SC-Duration: 20150701-20150731

  Every Wednesday in July 2015 with the exception
  of 2015-07-15 (Wed) and inclusion of 2015-08-01 (Sat).
#+END_EXAMPLE

** Headers for Grouping *** X-SC-Category =X-SC-Category:= is a space separated list of category It is useful for selective display both in CLI: : mhc scan today --category=Private and Emacs UI: : M-x mhc-set-default-category : Default Category: Private && !Party

Also useful sync with Google Calendar. See [[https://github.com/yoshinari-nomura/mhc/blob/master/samples/DOT.mhc-config.yml][mhc-config.yml]] for
details.

*** X-SC-Recurrence-Tag =X-SC-Recurrence-Tag:= is a tag for bundling multiple event articles as one recurring group.

MHC allows flexible description of repeating events using
=X-SC-Cond:=, =X-SC-Duration:=, or =X-SC-Day:=. However, we know
this is not sufficient.

For example, in my experience, some monthly meetings do not have
distinct recurring patterns such like "Third Wednesday of each
month." Instead, the next date is fixed by coordination during the meeting.

In such cases, it is difficult to mark these events as a series of related events.
That's why we need =X-SC-Recurrence-Tag:=

Using =X-SC-Recurrence-Tag:=, MHC suggests what event should be arranged.
: mhc stuck_recurrences
will tell you to make the next appointment.

For example, if you have "X-SC-Recurrence-Tag: Dentist" in your
articles of past dentist events, mhc will point out that you
forgot to make your next dentist appointment.

** DIRECTORY STRUCTURE *** Configuration Directory Default configuration directory is =~/.config/mhc=. If environment variable =MHC_CONFIG_HOME= or =XDG_CONFIG_HOME= is set, it is taken as =$MHC_CONFIG_HOME/mhc= or =$XDG_CONFIG_HOME/mhc=.

Configuration directory =~/.config/mhc= has these stuffs:
+ config.yml :: Configuration file (mandatory).
+ plugins :: Your home-made Ruby functions.
See [[file:samples][samples]] for details.

*** Spool Directory Location of the spool directory should be set by =TOPDIR:= element in =config.yml=.

For example, if you have =TOPDIR: ~/MHC= entry
in your =config.yml=, you will have these directory structure
under =~/MHC=:

+ spool/*.mhc :: MHC event database. All events are flatly located
                 in this directory in the form of ={x-sc-message-id}.mhc=
+ draft/*.mhc :: Draft files of events.
                 Opening a file in directory by Emacs,
                 and Typing =C-cC-c= will move the file into =spool= directory.
                 (Not implemented yet. Should be empty for now.)
+ inbox/*.mhc :: Mainly same as =spool=. You will have a chance to
                 review these events in this directory afterwards.
                 (Not implemented yet. Should be empty for now.)
+ presets/*.mhcc :: Database for fixed anniversary events
                    such as birthdays or national holidays.
+ trash/*.mhc :: Removed events from =spool= directory.
+ status/ ::
  + cache/* :: Cache files for speed-up.
               You can remove these files without any damage to MHC Database.
  + log/* :: log files for debug.
             You can remove these files without any damage to MHC DB.

  + sync_channels/* :: Sync records of MHC DB.
       If you remove any files under this directory,
       MHC Sync will be DAMAGED.