;; ;; ;; ◆ hateda-mode ◆ ;; -- はてなダイアリー用のメジャーモードとはてダラとの連携ツール ;; ;; ;; ++++++++++++++++++++++++++++ ;; ●注意事項 ;; 無保証です。 ;; ;; ++++++++++++++++++++++++++++ ;; ●必要なもの ;; はてダラと連携する場合にははてダラ(=はてなダイアリーライター) ;; (結城浩さんによる:要Perl:http://www.hyuki.com/techinfo/hatena_diary_writer.html) ;; ;; ++++++++++++++++++++++++++++ ;; ●インストール方法 ;; hateda-mode を ~/site-lisp/ において、 ;; 以下を .xyzzy か siteinit.l に記述し、xyzzy を再起動する ;; ------------------- ;; (require "hateda-mode") ;; ;; 以下ははてダラと連携する場合のみ。設定しない場合には毎回訊いてきます ;; (setf hw::*hatedara-multi-accounts* ;; '(("userA" nil "~/etc" "-t") ;; ("userB" nil "c:/data/userB/" nil) ;; ("userC" nil "c:/" nil) ;; ;("ユーザ名" "パスワード" "ディレクトリ" "はてダラに毎回渡す引数") ;; )) ;; ;; 以下のように g:グループ名:ユーザ名 と書くとグループに投稿されます。 ;; (miyamukoさんによるパッチをとりこみました) ;; (setf hw::*hatedara-multi-accounts* ;; '(("userA" nil "~/hatena/userA" "-t") ;; ("g:groupA:userA" nil "~/hatena/groupA" "-t"))) ;; --------------------- ;; ;; ++++++++++++++++++++++++++++ ;; ●使い方 ;; M-x hw::hw 今日の日付のはてダラファイルを開きます ;; M-x hw::hateda-mode はてダモードを実行します ;; M-x hw::hws タイトル一覧 ;; ;; ○ はてダモードのキーバインド ;; C-* 選択範囲か、なければ現在行を見出しにします ;; C-- 選択範囲か、なければ現在行をリストにします ;; C-+ 選択範囲か、なければ現在行を数字つきリストにします ;; C-> 選択範囲か、なければ現在行を引用にします(>> .. <<) ;; C-| 選択範囲か、なければ現在行をPre記法でくくります(>| .. |<) ;; C-M-| 選択範囲か、なければ現在行をスーパーPre記法でくくります(>|| .. ||<) ;; C-c c はてダラを使って投稿します ;; C-c u はてダラを使って現在編集中のファイルを投稿します ;; ;; ★Shift-JISで日記を書いていて、グループへ投稿する場合の注意 ;; グループフォルダに以下の2行を記入した config.txt ファイルを配置してください。 ;; client_encoding:Shift_JIS ;; server_encoding:UTF-8 ;; 詳細は以下を参照してください。 ;; http://www.hyuki.com/techinfo/hatena_diary_writer.html#faq_groupdiary ;; ;; ++++++++++++++++++++++++++++ ;; ●謝辞 ;; このプログラムを書くにあたって wiki-mode.l を参考にさせていただきました。 ;; (http://www5d.biglobe.ne.jp/~lostland/xyzzy/) ;; ;; ++++++++++++++++++++++++++++ ;; ●ライセンス ;; このソースコードには NYSL Version 0.9982 が適用されます。 ;; 条文はファイルの末尾に付与されています。 ;; 2007/09/10 ver.0.3.1 グループへの投稿についての注意を追加しました。 ;; 2007/07/18 ver.0.3 amefura さんによる煮込まれ hateda-mode を取り込みました。 ;; miyamuko さんによるグループへの投稿パッチを取り込みました。 ;; 2006/09/19 ver.0.2.2 不具合対応・Netinstaller対応 ;; 2006/05/24 ver.0.2.1 不具合対応 ;; 2006/05/23 ver.0.2 マルチアカウント対応、編集関数を追加 ;; 2006/05/16 ver.0.1 公開 (eval-when (:compile-toplevel :load-toplevel :execute) (unless (find-package "hatena") (defpackage "hatena" (:use "lisp" "editor" "user") (:nicknames "hw")) )) (provide "hateda-mode") (in-package "hatena") ;; hateda-mode (defvar *hateda-mode-hook* nil) (defvar *hateda-edit-with-region* nil) (defvar *hateda-edit-with-line* t) ;; hatedara (defvar *hatedara-submit-hook* nil) (defvar *hatedara-after-submit-hook* nil) (defvar *hatedara-multi-accounts* nil) ;; (export '(*hateda-mode-hook* *hateda-mode-map* hateda-mode )) (export '(*hatedara-submit-hook* *hatedara-after-submit-hook* *hatedara-multi-accounts* hw hws hwv)) (export '( *hateda-headline-color* *hateda-readnext-color* *hateda-footnote-color* *hateda-entity-color* *hateda-comment-color* *hateda-list-color* *hateda-table-color* *hateda-quote-color* *hateda-pre-color* *hateda-autolink-color* *hateda-stoptag-color* *hateda-bold-color* )) (defvar *hateda-local-variable-list* '(hateda-mode hateda-regexp-keyword-list )) (defvar *hateda-headline-color* '(:color 9 12 :line :bold)) (defvar *hateda-readnext-color* '(:color 2 3 :line)) (defvar *hateda-footnote-color* '(:color 4 5)) (defvar *hateda-entity-color* '(:keyword 2 :bold)) (defvar *hateda-comment-color* '(:keyword :comment)) (defvar *hateda-list-color* '(:color 2 0 :bold)) (defvar *hateda-table-color* '(:color 3 0 :bold)) (defvar *hateda-quote-color* '(:color 6 0 :line)) (defvar *hateda-pre-color* '(:color 5 0 :line)) (defvar *hateda-autolink-color* '(:color 7 0)) (defvar *hateda-stoptag-color* '(:color 8 7)) (defvar *hateda-bold-color* '(:color 0 0 :bold)) (defvar *hateda-mode-map* nil) (unless *hateda-mode-map* (setq *hateda-mode-map* (make-sparse-keymap)) (define-key *hateda-mode-map* '(#\C-c #\c) 'hatedara-submit) (define-key *hateda-mode-map* '(#\C-c #\u) 'hatedara-submit-this) (define-key *hateda-mode-map* '#\C-+ 'hateda-num-list) (define-key *hateda-mode-map* '#\C-- 'hateda-list) (define-key *hateda-mode-map* '#\C-* 'hateda-heading) (define-key *hateda-mode-map* '#\C-> 'hateda-quote) (define-key *hateda-mode-map* '#\C-\| 'hateda-pre) (define-key *hateda-mode-map* '#\C-M-\| 'hateda-super-pre) ) (defun hateda-mode (&optional (arg nil sv)) "hateda-mode" (interactive) (kill-all-local-variables) (mapc 'make-local-variable *hateda-local-variable-list*) (setq mode-name "hateda") (setq buffer-mode 'hateda-mode) (make-local-variable 'build-summary-function) (setq build-summary-function 'hateda-build-summary-of-documents) (make-local-variable 'regexp-keyword-list) (setq hateda-regexp-keyword-list (compile-regexp-keyword-list `( ("^\\*\\{1,3\\}.+$" nil ((0 . ,*hateda-headline-color*))) ("^=====?$" nil ((0 . ,*hateda-readnext-color*))) ("^\\(\\+\\{1,3\\}\\|-\\{1,3\\}\\).*$" nil ((1 . ,*hateda-list-color*))) ("^\\(:\\)[^:]+\\(:\\).*$" nil ((1 . ,*hateda-list-color*) (2 . ,*hateda-list-color*))) ("^\\(|\\).+\\(|\\)$" nil ((1 . ,*hateda-table-color*) (2 . ,*hateda-table-color*))) ("((\\(.+\\)))" nil ((1 . ,*hateda-footnote-color*))) ("&#x?[0-9a-f]\\{5\\};" nil ((0 . ,*hateda-entity-color*))) ("^\\(>>\\|<<\\)$" nil ((0 . ,*hateda-quote-color*))) ("^\\(>|\\||<\\|>||\\|||<\\)$" nil ((0 . ,*hateda-pre-color*))) ("^\\(><.*\\|.*><\\)$" nil ((0 . ,*hateda-stoptag-color*))) ("s?https?://[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+" nil ((0 . ,*hateda-autolink-color*))) ("\\(id\\|question\\|a\\|b\\|d\\|f\\|g\\|idea\\|i\\|r\\|graph\\|map\\|isbn\\|asin\\|jan\\|ean\\):\\([^\"' \t]+\\)" nil ((1 . ,*hateda-bold-color*) (2 . ,*hateda-autolink-color*))) ("\\[\\[\\(.+\\)\\]\\]" nil ((1 . ,*hateda-autolink-color*))) ("\\[\\(keyword\\|d\\|b\\|search\\):\\(.+\\)\\]" nil ((1 . ,*hateda-bold-color*) (2 . ,*hateda-autolink-color*))) ))) (setq regexp-keyword-list hateda-regexp-keyword-list) (setq comment-start "") (setq comment-start-skip "