Giter Club home page Giter Club logo

mhc's Introduction

MHC – Message Harmonized Calendaring system.

https://badge.fury.io/rb/mhc.svg http://melpa.org/packages/mhc-badge.svg

DESCRIPTION

MHC is a simple and powerful calendar tool, which consists of a CLI tool written in Ruby (mhc) and a nifty Emacs frontend UI (mhc.el).

You can get the latest version from:

MHC has following features:

  • Easy import from existing Emacs buffers
    • MHC will guess the title, date, time and description from the content of buffer.
  • Simple plain-text data format
    • MHC stores articles in similar format to MH (email); you can manipulate them by many other text-manipulation tools, editors, UNIX command-line tools or your own scripts.
  • Flexible output format
    • Currently plain-text, iCalendar, S-formula (mhc.el, calfw), org-table, howm, JSON: (full-calendar) are supported.
  • Selective export to Google Calendar with flexible filters and modifiers.
    • MHC can export custom-filtered calendars to Google Calendar via CalDaV. Check mhc-config.yml for details.

SYSTEM REQUIREMENTS

  • Ruby 2.1 or newer
  • Emacs 24 or newer

INSTALL AND SETUP

Ruby CLI (mhc)

mhc CLI command can be installed from rubygems.org.

$ gem install mhc

Or, if you want to install mhc in a sandbox (recommended), Bunlder would help you:

$ gem install bundler
$ mkdir /path/to/install/mhc
$ cd /path/to/install/mhc
$ bundle init
$ echo 'gem "mhc"' >> Gemfile
$ bundle install --path=vendor/bundle --binstubs=bin
$ export PATH=/path/to/install/mhc/bin:$PATH

Then, initialize config file and spool directory:

$ mhc init ~/mhc

# Read comments in config.yml carefully
$ vi ~/.config/mhc/config.yml

# Add Japanese Holidays if needed.
$ cp samples/japanese-holidays.mhcc ~/mhc/presets/

Check if mhc is working correctly:

$ mhc scan thismonth

Emacs UI (mhc.el)

You have to install Ruby CLI before install mhc.el

MHC is now available on MELPA. If you set up packaging system correctly, You can install mhc with package.el (M-x package-install mhc). Check MELPA usage for details.

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

USAGE

Ruby CLI (mhc)

mhc help

Emacs UI (mhc.el)

Keybind

  1. Jump and Show

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

    KeyFunction
    <Show previous month
    PShow previous year
    >Show next month
    NShow next year
    gGo to specific month
    vToggle message window
    RET/SPC/./DELShow/scroll message buffer
    /Search by keyword
  2. Manipulate articles
    KeyFunction
    ECreate a new article draft interactively
    MOpen pointed article to edit
    DDelete pointed article
    CCopy article temporally as a reusable template
    RCopy article like C using completing-read
    YSame as E but use the template stored by C
  3. Draft Buffer
    KeyFunction
    C-cC-cFinish editing and register to DB
    C-cC-qDiscard editing buffer w/o touching DB

Article format

Example

MHC stores every article in the form of RFC822-like format. Once you open a new article draft in Emacs by typing E, You may feel the draft is very similar to email’s one. This is an example of MHC article:

X-SC-Subject: Home party
X-SC-Location: my second house
X-SC-Day: 20150715
X-SC-Time: 18:00-21:00
X-SC-Category: Private Party
X-SC-Cond:
X-SC-Recurrence-Tag: HomeParty
X-SC-Duration:
X-SC-Record-Id: C34D89F5-27FA-4243-AC6C-168D8D243D9A
X-SC-Sequence: 0

This is a sample schedule article about a home party scheduled on
20150715 18:00-21:00. MHC schedule articles are similar to RFC822
style message like this.  In the header part, you can place any extra
headers you want.  if you import an article from existing email, you
may want to insert the original email headers such as Subject,
From, Date.

Time related headers

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

  • X-SC-Day
  • X-SC-Time
  • X-SC-Cond
  • X-SC-Duration

X-SC-Day

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

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

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:

X-SC-Time: 10:00-12:00
X-SC-Time: 10:00

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:

KeywordPurpose
01/02/.../31Day of month
1st/2nd/3rd/4th/5th/LastWeek order in a month
Sun/Mon/.../SatDay of week
Jan/Feb/.../DecName of month

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)

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:

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).

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:

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).

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 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.

INFORMATION FOR DEVELOPERS

INSTALL for developers:

  1. Install rbenv + ruby-build (see https://github.com/sstephenson/rbenv#basic-github-checkout for details)
    $ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
    $ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
    # Edit your shell dot files to add some path and environment variables.
        
  2. Install Latest Ruby and bundler
    # Install ruby 2.1.2
    $ rbenv install 2.1.2
    
    # Installation check
    $ rbenv global 2.1.2
    $ ruby -v # -> You will see: ruby 2.1.2...
    
    # Install bundler for your new Ruby
    $ gem install bundler
    
    # If you want to use Ruby in your sytem, say /usr/bin/ruby
    $ rbenv global system
    $ ruby -v
        
  3. Clone MHC from github
    $ git clone [email protected]:yoshinari-nomura/mhc.git ~/src/mhc
        
  4. Set default ruby version in MHC project
    $ cd ~/src/mhc
    $ echo '2.1.2' > .ruby-version
    $ ruby -v # -> You will see: ruby 2.1.2...
        
  5. Install requied gem packages in sandbox ~/src/mhc/vendor/bundle
    $ cd ~/src/mhc
    $ bundle install --path vendor/bundle
        
  6. Initialize config file and spool directory
    $ bin/mhc init ~/mhc
    
    Guessing current local timezone ...
              ok  guess timezone ... Asia/Tokyo
    Making directries under ~/mhc ...
          create  ~/mhc/draft
          create  ~/mhc/inbox
          create  ~/mhc/presets
          create  ~/mhc/spool
          create  ~/mhc/trash
          create  ~/mhc/status/cache
          create  ~/mhc/status/log
          create  ~/mhc/status/sync_channels
    Copying config file(s) into ~/.config/mhc/config.yml ...
              ok  copy ~/.config/mhc/config.yml
    Done.
    
    # Read comments in config.yml carefully
    $ vi ~/.config/mhc/config.yml
    
    # Add Japanese Holidays if needed.
    $ cp samples/japanese-holidays.mhcc ~/mhc/presets/
    
    # Add ~/src/mhc/bin directory to your $PATH for dogfooding
    $ export PATH=$HOME/src/mhc/bin:$PATH
        
  7. Byte-compile Emacs client
    $ cd emacs
    $ make
        
  8. Add setup in your .emacs.d/init.el
    (setq load-path
          (cons "~/src/mhc/emacs" load-path))
    (autoload 'mhc "mhc" "Message Harmonized Calendar system." t)
    (autoload 'mhc-import "mhc" "Import a schedule." t)
    
    ;; M-x mhc
        
  9. Check if TODAY is good.
    $ mhc scan today
        

You may add ~/src/mhc/bin directory to your $PATH for dogfooding

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 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.

HOW TO CONVERT FROM THE OLD MHC SPOOL

update-uuid.sh would help you.

New format is:

  • X-SC-Record-Id is now in UUID style.
  • Each filename is in the form of {UUID}.mhc, not [0-9]+.
  • UUID in X-SC-Record-Id is same as its file’s base name.
  • All articles are flatly placed in TOP/spool/ directory.
$ ./update-uuid.sh ~/Mail/schedule ~/mhc

Converting... logfile will be in /Users/nom/mhc/update-uuid.sh34485.log

For Japanese people, character-code conversion might be needed.

$ cd ~/mhc/spool
$ find . -name '*.mhc' | xargs -n 10 nkf --overwrite

mhc's People

Contributors

ikazuhiro avatar koie avatar okada-takuya avatar river24 avatar tats avatar uwabami avatar ykasap avatar yoshinari-nomura avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mhc's Issues

iCalendarファイルをMHCに取り込むためのパッチ

添付ファイルで送られてきたicsファイルをMewで開いてMHCに取り込むのを想定したパッチです。

diff --git a/bin/mhc b/bin/mhc
--- a/bin/mhc
+++ b/bin/mhc
@@ -143,6 +143,19 @@ class MhcCLI < Thor
   end # todo

   ################################################################
+  # Command: ics2mhc
+  ################################################################
+  desc "ics2mhc ICSFILE", "convert iCalender to MHC"
+
+  def ics2mhc(icalfile)
+    File.open(icalfile, "r") do |file|
+      ics_string = file.read
+      ev = Mhc::Event.new_from_ics(ics_string)
+      puts Mhc::Converter::Emacs.new.to_emacs(ev.dump_header)
+    end
+  end
+
+  ################################################################
   # Command: completions
   ################################################################
   desc "completions [COMMAND]", "List available commands or options for COMMAND", :hide => true
diff --git a/emacs/mhc.el b/emacs/mhc.el
--- a/emacs/mhc.el
+++ b/emacs/mhc.el
@@ -823,6 +823,14 @@ the default action of this command is ch
   (interactive)
   (mhc-import-from-string (current-kill 0)))

+(defun mhc-import-from-ics ()
+  (interactive)
+  (let ((mhc-header (mhc-process-send-command-with-buffer "ics2mhc" (current-buffer))))
+    (mhc-window-push)
+    (mhc-draft-new mhc-header
+                   `(("x-sc-record-id" . ,(mhc-record-create-id))
+                     ("x-sc-sequence"  . 0)))))
+
 (defun mhc-import-from-string (string)
   "Create new schedule draft from STRING."
   (with-temp-buffer

RubyGemsにYAML.loadの挙動変更に対応したバージョンのgemを公開してほしい

概要

  • RubyGemsに mhc 1.2.5 のgemを公開してほしい。
  • Rubyの3系(3.1以降)から YAML.load() の挙動が変更されている。
  • mhcにおいては、コミット1965818で上記の挙動変更に対応している。
  • しかし、RubyGemで公開されている mhc 1.2.4 のgemは上記の対応が入る前にリリースされたバージョンになっている。
  • コミット1965818の内容を含んだ mhc 1.2.5 をRubyGemsにリリースしてほしい。

再現手順

  • FreeBSD-13.2(amd64)環境では、以下の手順で問題を再現できます。
$ sudo pkg install ruby rubygem-gems git
$
$ # Rubyのバージョンは3.1でYAML.load()の挙動が変更されている。
$ ruby --version
ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [amd64-freebsd13]
$
$ gem search -r mhc

*** REMOTE GEMS ***

mhc (1.2.4)
mhc-project-doc (1.0.2)
$
$ sudo gem install mhc -v 1.2.4
$ mhc init ~/mhc
$
$ # mhcのコマンド実行でエラーが発生する。
$ # (emacs向けmhcインタフェースでは"Wrong type argument: listp, /usr/local/lib/ruby/3\.1/psych\.rb:368:in"エラーが発生する)
$ mhc help
/usr/local/lib/ruby/3.1/psych.rb:368:in `load': wrong number of arguments (given 2, expected 1) (ArgumentError)
        from /usr/local/lib/ruby/gems/3.1/gems/mhc-1.2.4/lib/mhc/config.rb:55:in `create_from_yaml_string'
        from /usr/local/lib/ruby/gems/3.1/gems/mhc-1.2.4/lib/mhc/config.rb:51:in `create_from_yaml_file'
        from /usr/local/lib/ruby/gems/3.1/gems/mhc-1.2.4/lib/mhc/config.rb:214:in `create_from_file'
        from /usr/local/lib/ruby/gems/3.1/gems/mhc-1.2.4/bin/mhc:342:in `block in setup_global_options'
        from /usr/local/lib/ruby/gems/3.1/gems/mhc-1.2.4/bin/mhc:331:in `exit_on_error'
        from /usr/local/lib/ruby/gems/3.1/gems/mhc-1.2.4/bin/mhc:341:in `setup_global_options'
        from /usr/local/lib/ruby/gems/3.1/gems/mhc-1.2.4/bin/mhc:317:in `invoke_command'
        from /usr/local/lib/ruby/gems/3.1/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
        from /usr/local/lib/ruby/gems/3.1/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
        from /usr/local/lib/ruby/gems/3.1/gems/mhc-1.2.4/bin/mhc:388:in `<top (required)>'
        from /usr/local/bin/mhc:25:in `load'
        from /usr/local/bin/mhc:25:in `<main>'

発生要因

  • リポジトリの履歴を確認する。 YAML.load() の対応が入ったコミット1965818よりも前に 1.24 のタグが打たれている。
$ git clone https://github.com/yoshinari-nomura/mhc.git
$ cd mhc
$ git blame lib/mhc/config.rb | grep ':unsafe_load'
19658186 (Yoshinari Nomura 2022-10-12 17:51:53 +0900  55)         hash = if YAML.respond_to?(:unsafe_load)
$ git log
...
commit 1965818653fd4789eb12fc5bcf5345c552547d59
Author: Yoshinari Nomura <[email protected]>
Date:   Wed Oct 12 17:51:53 2022 +0900

    Support YAML loader bundled with Ruby 3.1
...
commit 33d8ca1a1beb2b63e720e17525bdda3cc878e5ed (tag: v1.2.4)
Author: Yoshinari Nomura <[email protected]>
Date:   Fri Nov 13 09:01:54 2020 +0900

    Version 1.2.4
  • RubyGemには mhc 1.2.5 のバージョンはまだ存在していない。
$ curl -sI https://rubygems.org/gems/mhc/versions/1.2.4 | head -n1
HTTP/2 200
$ curl -sI https://rubygems.org/gems/mhc/versions/1.2.5 | head -n1
HTTP/2 404

回避方法(workaround)

  • lib/mhc/config.rbコミット1965818の修正内容をバックポートすることで、 mhc 1.2.4 でも問題を回避することができる。
$ diff -u ../rubygem/lib/mhc/config.rb ./lib/mhc/config.rb
--- ../rubygem/lib/mhc/config.rb        2020-11-13 09:09:38.000000000 +0900
+++ ./lib/mhc/config.rb 2024-02-22 05:47:40.213281000 +0900
@@ -52,7 +52,11 @@
       end

       def self.create_from_yaml_string(yaml_string, filename = nil)
-        hash = YAML.load(yaml_string, filename) || {}
+        hash = if YAML.respond_to?(:unsafe_load)
+                 YAML.unsafe_load(yaml_string, filename: filename)
+               else
+                 YAML.load(yaml_string, filename)
+               end || {}
         return new(hash)
       end

Duplicated X-SC-Record-Id: in samples/japanese-holidays.mhcc

There are 2 entries which have X-SC-Record-Id: B78EAAEE-9963-4573-9EC7-0879F8940AEE in samples/japanese-holidays.mhcc.

X-SC-Subject: 天皇誕生日
X-SC-Category: Holiday Japanese
X-SC-Cond: 29 Apr
X-SC-Duration: 19480429-19980429
X-SC-Record-Id: B78EAAEE-9963-4573-9EC7-0879F8940AEE

X-SC-Subject: みどりの日
X-SC-Category: Holiday Japanese
X-SC-Cond: 29 Apr
X-SC-Duration: 19890429-20060429
X-SC-Record-Id: B78EAAEE-9963-4573-9EC7-0879F8940AEE

`mhc sync` uses insecure https connection

In webdav.rb, verify_mode is set to OpenSSL::SSL::VERIFY_NONE and
not configurable.

It should be set to OpenSSL::SSL::VERIFY_PEER to verify the certificate.
(Also ca_path, ca_file or so should be configurable.)

google -> mhc sync failed

Google側の予定を mhc に sync しようとした所

    ABOUT [email protected] => ow_side1_to_side2 (norecord vs created)
    COPYING: (overwrite) [email protected]
    CALDAV put_if_match :uid => [email protected], :etag =>  ...failed: (undefined
    method `size' for nil:NilClass)
    COPY: failed.

となりました. 手元の Ruby は

    ruby -v
    ruby 2.1.2p95 (2014-05-08) [x86_64-linux-gnu]

です. 何かお気付きの点はありますでしょうか...

手元で登録→Google Calendar側への反映はできています.

日付の区切り文字に %- を使えるようにするパッチ

--- a/emacs/mhc-summary.el
+++ b/emacs/mhc-summary.el
@@ -171,6 +171,8 @@ which are replaced by the given informat
         'face mhc-tmp-day-face)
     (?/ (if mhc-tmp-first "/" " ")
         'face mhc-tmp-day-face)
+    (?- (if mhc-tmp-first "-" " ")
+        'face mhc-tmp-day-face)
     (?S " " 'face mhc-tmp-day-face)
     (?M (mhc-summary/line-month-string)
         'face mhc-tmp-day-face)

use URI.decode_www_form_component instead of URI.unescape(obsoleted)

diff --git a/lib/mhc/caldav.rb b/lib/mhc/caldav.rb
index 57f00fe..7c18fdb 100644
--- a/lib/mhc/caldav.rb
+++ b/lib/mhc/caldav.rb
@@ -26,7 +26,7 @@ module Mhc
              D:propstat/D:prop/caldav:calendar-data
           ).map{|e| xmldoc.elements[e].text rescue nil}
 
-        info.href = URI.unescape(href)
+        info.href = URI.decode_www_form_component(href)
         info.uid = File.basename(info.href, ".ics")
         info.status = status
         info.content_type = content_type

"update-uuid.sh" collects events in "schedule/trash"

"update-uuid.sh" collects all events of old mhc in the directory of "schedule",
not only proper events, but also deleted events in "schedule/trash".

Of course, maybe I should empty "schedule/trash" before run "update-uuid.sh".
But the following change for line 35 of "update-uuid.sh" will help me.

for file in $(find "$OLD_MHC_TOP_DIR" -type f -name '*[0-9]' | grep -v trash)

X-SC-Alarm:で単位を複数形を許容するパッチ

たぶん古いmhcでは複数形がokだったとおもいます。

diff --git a/emacs/mhc-parse.el b/emacs/mhc-parse.el
--- a/emacs/mhc-parse.el
+++ b/emacs/mhc-parse.el
@@ -102,7 +102,7 @@
   (mhc-logic-parse-old-style-date (mhc-schedule-condition schedule))
   (mhc-parse/time record schedule))

-(defconst mhc-parse/alarm-regexp "^[0-9]+ \\(minute\\|hour\\|day\\)$")
+(defconst mhc-parse/alarm-regexp "^[0-9]+ \\(minute\\|hour\\|day\\)s?$")

 (defun mhc-parse/alarm (record schedule)
   (let ((alarm (mhc-parse/continuous-lines)))

mhc command --helpでヘルプを表示してほしい

mhc help command でヘルプを表示できますが、やっぱり--helpでも表示してほしい。

% bin/mhc version --help
Unknown switches "--help"
Deprecation warning: Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `MhcCLI`
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.

こんなかんじで:

% bin/mhc version --help
Usage:
  mhc version

Options:
  [--help], [--no-help], [--skip-help]           # Show help
  [--debug], [--no-debug], [--skip-debug]        # Set debug flag
  [--profile], [--no-profile], [--skip-profile]  # Set profiler flag
  [--config=FILE]                                # Set config path (default: ~/.config/mhc/config.yml)

Show version

xoauth?

Do you have any plan about XOAUTH for google calendar API?

update-uuid.sh is bash

Hi,

% checkbashisms update-uuid.sh
possible bashism in update-uuid.sh line 47 (should be >word 2>&1):
done >& "$LOG_FILE"

I think, The shebang of this sciprt should be "/bin/bash" instead of "/bin/sh".

Best Wishes,

mhc-wl don't display schedule summary

Wanderlust で、個々のスケジュールのサマリー表示ができません。
(登録、およびカレンダー上での予定の表示は可能です)

可能であれば修正して pull req を送りますが、とりあえず報告までに。

Wanderlust の MH 形式が、数字ファイル名しかハンドリングできない、とかだったら嫌ですね...。

mhc-draft-validate-buffer で wrong-type-argument sequencep Could となる

  1. Emacs 26.1にmelpaからmhc-20180519.2027をインストール
  2. 月次予定を表示
  3. 任意の日で予定を作成
  4. mhc-draft-finish すると下記エラーになる
Debugger entered--Lisp error: (wrong-type-argument sequencep Could)
  replace-regexp-in-string("[.\015\n]+\\'" "" Could)
  (error "ERROR: %s" (replace-regexp-in-string "[.\015\n]+\\'" "" validation))
  (if (and (stringp validation) (string-match "^OK" validation)) (message "Validation passed.") (error "ERROR: %s" (replace-regexp-in-string "[.\015\n]+\\'" "" validation)))
  (let ((validation (mhc-process-send-command-with-buffer "validate --format=emacs" (or buffer (current-buffer))))) (if (and (stringp validation) (string-match "^OK" validation)) (message "Validation passed.") (error "ERROR: %s" (replace-regexp-in-string "[.\015\n]+\\'" "" validation))))
  mhc-draft-validate-buffer()
  mhc-draft-finish()
  funcall-interactively(mhc-draft-finish)
  call-interactively(mhc-draft-finish nil nil)
  command-execute(mhc-draft-finish)

Inconsistency date separater between *.rb and *.el files

Emacs's MHC-Draft mode accepts ,as date separater but MHC script does not. For example,

X-SC-Day: 20150601, 20150602

I can mhc-draft-finish with such header, but MHC script accepts only , outputs error message and stops.M-x mhc can't run anymore. Which should be correct?

TODO/DONEの表示

昔のmhcのようにttyでもTODO/DONEが表示されるようにするパッチです。
アイコンの代わりに任意の文字(絵文字も可)が表示できるようにするのがよさそうですがコードをかけなかったので。

--- a/emacs/mhc-face.el
+++ b/emacs/mhc-face.el
@@ -101,6 +101,8 @@ refer to mhc-calendar-hnf-face-alist-int
     (mhc-summary-face-conflict  . (nil "white"       "purple"))
     (mhc-summary-face-recurrence . (nil "black"      "green"))
     (mhc-summary-face-secret    . (nil "gray"        nil))
+    (mhc-summary-face-todo      . (nil "red "        nil))
+    (mhc-summary-face-done      . (nil nil           nil))
     ;;
     (mhc-minibuf-face-candidate . (nil nil           "yellow"))
     ;;
diff --git a/emacs/mhc-summary.el b/emacs/mhc-summary.el
--- a/emacs/mhc-summary.el
+++ b/emacs/mhc-summary.el
@@ -223,6 +223,13 @@ which are replaced by the given informat
            (car (mhc-schedule-categories mhc-tmp-schedule)))))
     (?l (mhc-summary/line-location-string)
         'face 'mhc-summary-face-location)
+    (?t (cond
+         ((mhc-schedule-in-category-p mhc-tmp-schedule "done") "[X]")
+         ((mhc-schedule-in-category-p mhc-tmp-schedule "todo") "[ ]"))
+        'face
+        (cond
+         ((mhc-schedule-in-category-p mhc-tmp-schedule "done") 'mhc-summary-face-done)
+         ((mhc-schedule-in-category-p mhc-tmp-schedule "todo") 'mhc-summary-face-todo)))
     (?\( (if mhc-tmp-first "(" " ")
          'face mhc-tmp-day-face)
     (?\) (if mhc-tmp-first ")" " ")

feature request: category filter for mhc sync

Currently mhc sync synchronize all the schedule entries.
In addition to a command-line option (like mhc2gcal), it might be useful to
have a default filter entry in .mhc/config.yml for synchronizing two or more
google secondary calendars based on categories (public vs private etc).

start timeとend timeが同じ場合にend timeを表示しないようにするパッチ

昔のmhcや今のmhc scan だと開始時刻しか設定されてない予定は開始時刻だけ表示するので、elispの方で対応するパッチです。mhc scan --format=emacs の方で対応してもよいのかもしれません。

diff --git a/emacs/mhc-summary.el b/emacs/mhc-summary.el
--- a/emacs/mhc-summary.el
+++ b/emacs/mhc-summary.el
@@ -184,7 +184,8 @@ which are replaced by the given informat
             (make-string 5 ? )
           (format "%02d:%02d" (/ mhc-tmp-begin 60) (% mhc-tmp-begin 60)))
         'face 'mhc-summary-face-time)
-    (?e (if (null mhc-tmp-end)
+    (?e (if (or (null mhc-tmp-end)
+                (and mhc-tmp-begin (= mhc-tmp-end mhc-tmp-begin)))
             (make-string 6 ? )
           (format "-%02d:%02d" (/ mhc-tmp-end 60) (% mhc-tmp-end 60)))
         'face 'mhc-summary-face-time)

misleading version number

Recently mhc has drastically been changed, so please consider
version bumping, from 0.25 to 1.0, 2.0 or so.

`warning: kconv ...` が表示される

rbenv install 3.3.0 でruby 3.3.0をいれてmhc環境をつくったらmhcコマンドがwarningメッセージを出しました。

lib/mhc.rb:3: warning: kconv is found in nkf, which will no longer be part of the default gems since Ruby 3.4.0. Add nkf to your Gemfile or gemspec.

ただしい解決方法は理解してないのですが、ネットを検索して出てきた対処コードをまねてパッチしたらwarningメッセージは消えました。(参考にしたPR-> ruby/nkf#15)

diff --git a/mhc.gemspec b/mhc.gemspec
--- a/mhc.gemspec
+++ b/mhc.gemspec
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
   spec.add_runtime_dependency "ri_cal",      ">= 0.8.8"
   spec.add_runtime_dependency "tzinfo",      ">= 1.2.2"
   spec.add_runtime_dependency "tzinfo-data", ">= 1.2015.4"
+  spec.add_runtime_dependency "nkf"

   spec.add_development_dependency "rake"
   spec.add_development_dependency "rspec"

ruby configure.rb --disable-palm fails

When I run ruby configure.rb --disable-palm on revision be14b04 it fails because mhc-sync.in is missing:

# ruby configure.rb --disable-palm ruby is .. /usr/local/opt/ruby/bin/ruby emacs is .. /usr/local/bin/emacs emacs is .. /usr/local/bin/emacs make is .. /usr/bin/make creating mhc-sync .../Users/dholm/.dotfiles/emacs/.emacs.d/el-get/mhc/mhc-make.rb:415:in initialize': No such file or directory @ rb_sysopen - mhc-sync.in (Errno::ENOENT)
from /Users/dholm/.dotfiles/emacs/.emacs.d/el-get/mhc/mhc-make.rb:415:in open' from /Users/dholm/.dotfiles/emacs/.emacs.d/el-get/mhc/mhc-make.rb:415:in replace_keywords1'
from /Users/dholm/.dotfiles/emacs/.emacs.d/el-get/mhc/mhc-make.rb:310:in block in replace_keywords' from /Users/dholm/.dotfiles/emacs/.emacs.d/el-get/mhc/mhc-make.rb:306:in each'
from /Users/dholm/.dotfiles/emacs/.emacs.d/el-get/mhc/mhc-make.rb:306:in replace_keywords' from configure.rb:113:in

'`

mhc-file-sync is unusable in Emacs

In Emacs, C-c . S (mhc-file-sync) is unusable, because the external command
mhc-sync is obsolete. Please mention mhc sync, or unbind the key.

"mhc init" fails

Hello, whould you help me with mhc init ?
It fails returning msg below.

$ mhc init ~/mhc                                                                                                                     341ms  Mon Aug  5 20:06:01 2019
Guessing current local timezone ...
          ok  guess timezone ... Asia/Tokyo
Making directries under /Users/ahayashi/mhc ...
      failed  uninitialized constant Mhc::Command::Init::FileUtils
Did you mean?  FileTest /Users/ahayashi/mhc/draft
      failed  uninitialized constant Mhc::Command::Init::FileUtils
Did you mean?  FileTest /Users/ahayashi/mhc/inbox
      failed  uninitialized constant Mhc::Command::Init::FileUtils
Did you mean?  FileTest /Users/ahayashi/mhc/presets
      failed  uninitialized constant Mhc::Command::Init::FileUtils
Did you mean?  FileTest /Users/ahayashi/mhc/spool
      failed  uninitialized constant Mhc::Command::Init::FileUtils
Did you mean?  FileTest /Users/ahayashi/mhc/trash
      failed  uninitialized constant Mhc::Command::Init::FileUtils
Did you mean?  FileTest /Users/ahayashi/mhc/status/cache
      failed  uninitialized constant Mhc::Command::Init::FileUtils
Did you mean?  FileTest /Users/ahayashi/mhc/status/log
      failed  uninitialized constant Mhc::Command::Init::FileUtils
Did you mean?  FileTest /Users/ahayashi/mhc/status/sync_channels
Copying config file(s) into ~/.config/mhc/config.yml ...
      failed  uninitialized constant Mhc::Command::Init::FileUtils
Did you mean?  FileTest /Users/ahayashi/.config/mhc
      failed  No such file or directory /Users/ahayashi/.config/mhc/config.yml
10 error(s) were occurred.

Would you tell me where I made a mistake?

Subjectが設定されていないときには (no subject) と表示するパッチ

たまたまX-SC-Subject:の行頭に変な文字を入力してしまったために、画面上では空白の予定となって気づかなくなってしまっていた(google calendarの方で気づいた)ので、たいていはsubjectを空白にする必要はないと思うので (no subject) と表示するパッチです。

diff --git a/emacs/mhc-summary.el b/emacs/mhc-summary.el
--- a/emacs/mhc-summary.el
+++ b/emacs/mhc-summary.el
@@ -500,7 +500,10 @@ If BANNER is set, it is printed on the h
 (defun mhc-summary/line-subject-string ()
   (if mhc-tmp-private
       (and mhc-tmp-schedule mhc-summary-string-secret)
-    (or (mhc-schedule-subject mhc-tmp-schedule) "")))
+    (let ((s (mhc-schedule-subject mhc-tmp-schedule)))
+      (if s
+          (if (equal s "") "(no subject)" s)
+        ""))))

can't create `~/.config/mhc` directory

Hi,

mhc init failed because this command does not create ~/.config/mhc, as follows:

       % bundle exec ruby bin/mhc init ~/mhc
       Guessing current local timezone ...
                 ok  guess timezone ... Asia/Tokyo
       Making directries under /home/uwabami/mhc ...
              create /home/uwabami/mhc/draft
              create /home/uwabami/mhc/inbox
              create /home/uwabami/mhc/presets
              create /home/uwabami/mhc/spool
              create /home/uwabami/mhc/trash
              create /home/uwabami/mhc/status/cache
              create /home/uwabami/mhc/status/log
              create /home/uwabami/mhc/status/sync_channels
       Copying config file(s) into ~/.config/mhc/config.yml ...
             failed  No such file or directory /home/uwabami/.config/mhc/config.yml
       1 error(s) were occurred.

When I create ~/.config/mhc before execute mhc init, all fine:

    % mkdir -p ~/.config/mhc
    % bundle exec ruby bin/mhc init ~/mhc
    Guessing current local timezone ...
              ok  guess timezone ... Asia/Tokyo
    Making directries under /home/uwabami/mhc ...
          create  /home/uwabami/mhc/draft
          create  /home/uwabami/mhc/inbox
          create  /home/uwabami/mhc/presets
          create  /home/uwabami/mhc/spool
          create  /home/uwabami/mhc/trash
          create  /home/uwabami/mhc/status/cache
          create  /home/uwabami/mhc/status/log
          create  /home/uwabami/mhc/status/sync_channels
    Copying config file(s) into ~/.config/mhc/config.yml ...
              ok  copy /home/uwabami/.config/mhc/config.yml
    Done.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.