yoshinari-nomura / mhc Goto Github PK
View Code? Open in Web Editor NEWMHC -- Message Harmonized Calendaring system
Home Page: http://www.quickhack.net/mhc/
License: Other
MHC -- Message Harmonized Calendaring system
Home Page: http://www.quickhack.net/mhc/
License: Other
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側への反映はできています.
mhc-db-add-exception-rule
function calls mhc-db-add-record-from-buffer
with two argument, RECORD and BUFFER. But mhc-db-add-record-from-buffer
does not accept RECORD argument.
昔の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)
"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)
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,
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.
たまたま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)
+ ""))))
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
Recently mhc has drastically been changed, so please consider
version bumping, from 0.25 to 1.0, 2.0 or so.
ruby 3.3 で mhc scan --format=html
をつかうとwarningがでます:
mhc/lib/mhc/formatter/html.rb:20: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
mhc/lib/mhc/formatter/html.rb:20: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.
https://docs.ruby-lang.org/ja/3.1/method/ERB/s/new.html
によれば
Ruby 2.6.0 から位置引数での safe_level, trim_mode, eoutvar の指定は非推奨です。 Ruby 3.2 で削除されました。 trim_mode と eoutvar の指定はキーワード引数に移行してください。
ということで
diff --git a/lib/mhc/formatter/html.rb b/lib/mhc/formatter/html.rb
--- a/lib/mhc/formatter/html.rb
+++ b/lib/mhc/formatter/html.rb
@@ -17,7 +17,7 @@ module Mhc
def format_header(context)
require "erb"
template_path = File.expand_path("full-calendar.html.erb", TEMPLATE_DIR)
- @template = ERB.new(File.open(template_path).read, nil, "-")
+ @template = ERB.new(File.open(template_path).read, trim_mode: "-")
return ""
end
と変更したらwarningは消えましたが、これだと古いruby(<3.2.0)で動かないでしょう。こまった。
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
--- 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)
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?
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 1.2.5
のgemを公開してほしい。YAML.load()
の挙動が変更されている。
mhc 1.2.4
のgemは上記の対応が入る前にリリースされたバージョンになっている。mhc 1.2.5
をRubyGemsにリリースしてほしい。$ 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
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
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
Do you have any plan about XOAUTH for google calendar API?
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).
添付ファイルで送られてきた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
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.)
昔の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 ")" " ")
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
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?
In Emacs, mhc-version is still "mhc 1.0.0". Please sync the version when releasing.
Wanderlust で、個々のスケジュールのサマリー表示ができません。
(登録、およびカレンダー上での予定の表示は可能です)
可能であれば修正して pull req を送りますが、とりあえず報告までに。
たぶん古い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)))
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.
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"
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.