マイナーモードのhamazou-modeを作成

Emacs上からasinを取ってくるためにスクリプトを書いてみた - yasuhisa's blogにあるスクリプトEmacsから実行するマイナーモードを作成した。

今のところドキュメントもキーバインドもなし。M-x hamazouを実行して検索文字列を入れるとそれをスクリプトに渡して実行するような実装。
リージョン指定で検索できるようになると便利かな、と思って作成しはじめたが、それはまだ実装されていない。

hatenahelper-modeでシンタックス・ハイライトを便利に

simple-hatena-modeと一緒にhatenahelper-modeを使おうという気になったので設定してみた。
便利そうなんだけどスーパーpre記法のときにシンタックス・ハイライトする場合にちょっと面倒だったので適当に書き換えた。私は使わないのでC-c C-sの方はそのまま。

--- hatenahelper-mode.el.orig	2007-11-20 04:35:47.000000000 +0900
+++ hatenahelper-mode.el	2007-11-20 05:30:27.000000000 +0900
@@ -101,6 +101,11 @@
 ;; hatena-mode ともども 非公式 debian パッケージを作る
 ;; w3m.el から使うときに便利になるよう拡張する
 
+;; シンタックス・ハイライトの補完リスト
+(defvar hatenahelper-syntax-highlight-language-list
+  '("awk" "c" "changelog" "cpp" "cs" "csc" "csh" "css" "cvs" "cvsrc" "diff"
+    "eruby" "haskell" "html" "java" "javascript" "jsp" "lisp" "perl" "php"
+    "python" "screen" "sh" "svn" "tags" "vim" "viminfo" "xhtml" "xml" "zsh"))
 
 ;;; Code:
 (defconst hatenahelper-mode-version 
@@ -230,10 +235,10 @@
   "Hatena blockquote prefix")
 (defvar hatenahelper-seikeizumi-textblock-suffix "|<"
   "Hatena blockquote suffix")
-(defvar hatenahelper-sonomama-textblock-prefix ">||"
-  "Hatena blockquote prefix")
-(defvar hatenahelper-sonomama-textblock-suffix "||<"
-  "Hatena blockquote suffix")
+;(defvar hatenahelper-sonomama-textblock-suffix ">||"
+;  "Hatena blockquote prefix")
+;(defvar hatenahelper-sonomama-textblock-suffix "||<"
+;  "Hatena blockquote suffix")
 (defvar hatenahelper-draft-tag-prefix "><!--"
   "Hatena Draft prefix")
 (defvar hatenahelper-draft-tag-suffix "--><"
@@ -331,10 +336,21 @@
   (hatenahelper-insert-block-aux hatenahelper-seikeizumi-textblock-prefix
     				 hatenahelper-seikeizumi-textblock-suffix))
 (defun hatenahelper-insert-sonomama-textblock ()
-  "Insert Hatena blockquote '>>| |<<' on current cursor position."
+  "Insert Hatena blockquote '>|| ||<' on current cursor position."
   (interactive)
-  (hatenahelper-insert-block-aux hatenahelper-sonomama-textblock-prefix
-    				 hatenahelper-sonomama-textblock-suffix))
+  (let
+      ((lang
+	(completing-read
+	 "language? " hatenahelper-syntax-highlight-language-list nil nil))
+       (syntax-highlight-prefix ">||")
+       (syntax-highlight-suffix "||<"))
+
+    (if (eq (length lang) 0)
+	nil
+      (setf syntax-highlight-prefix (format ">|%s|" lang)))
+
+    (hatenahelper-insert-block-aux syntax-highlight-prefix
+				   syntax-highlight-suffix)))
 (defun hatenahelper-insert-draft-tag ()
   "Insert Hatena Draft Tag '><--! --><' on current cursor position."
   (interactive)

補完する言語はhatenahelper-syntax-highlight-language-listに入れているけど私がなんとなく選んだものしか入ってないので適当に書き換えるなり再定義するなりしてください。

私はEmacsの初期化スクリプトに次のように書いています。

(defvar hatenahelper-syntax-highlight-language-list
  '("perl" "diff" "lisp" "ruby" "xhtml" "xml" "javascript"))

Emacs上ではUTF-8な生活をおくるようにした

simple-hatena-modeを使っていてEUC-JPなファイルをはてなグループにポストしたら文字化けして残念な思いをしたのでEmacs上ではUTF-8にするようにした。

simple-hatena-modeでは、クライアントのエンコーディングを設定しておけばいいだけという話もあるけど。

(set-default-coding-systems 'utf-8)
(set-buffer-file-coding-system 'utf-8-unix)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-process-coding-system '(euc-jp . utf-8))

localeがja_JP.eucJPなのでdefault-process-coding-systemはこんな感じに。

scim-input-padが動いてなかった

入力が面倒な漢字を必要としたのでscim-input-padを起動しようとしたら起動しなかった。去年の4月にビルドされたscim-input-pad-0.1.1-0vl1ではダメだった模様。とりあえずリビルドして更新。

リビルドしただけでは無理だった。こんなpatchをあてて解決。

diff -uNr scim-input-pad-0.1.1.orig/configure.ac scim-input-pad-0.1.1/configure.ac
--- scim-input-pad-0.1.1.orig/configure.ac	2005-12-06 12:06:26.000000000 +0900
+++ scim-input-pad-0.1.1/configure.ac	2007-11-25 23:44:10.000000000 +0900
@@ -84,7 +84,7 @@
 SCIM_ICONDIR=`$PKG_CONFIG --variable=icondir scim`
 SCIM_MODULEDIR=`$PKG_CONFIG --variable=moduledir scim`
 SCIM_DATADIR=`$PKG_CONFIG --variable=scimdatadir scim`
-SCIM_LIBEXECDIR=`$PKG_CONFIG --variable=moduledir scim`
+SCIM_LIBEXECDIR=`$PKG_CONFIG --variable=moduledir scim`/..
 
 if test "x$SCIM_ICONDIR" = "x"; then
   SCIM_ICONDIR=${datadir}/scim/icons