mmm-mode
mmm-mode はいままで3回くらい挑戦してると思うけどうまく使えたためしがないのであきらめている。
今度社内でemacs自慢大会やるつもりなのでそのときにだれかやってくれないかな。
こうしたいflymake
これ読んですぐ導入したflymake。上記サイトのを少し改造したらperlでもできたのでいまはjsとperlでリアルタイムでシンタックスエラーチェックができている。
僕はすごくtypoがおおいと思うのだけどこれを導入してからtypoではまることがずいぶん減った。もうないとこまるelispのひとつになってる。
ちなみにperl版はこんな感じにしている。
(require 'flymake)
;; flymake for perl
(defvar flymake-perl-err-line-patterns '(("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1)))
(defconst flymake-allowed-perl-file-name-masks '(("\\.pl$" flymake-perl-init)
                                               ("\\.pm$" flymake-perl-init)
                                               ("\\.t$" flymake-perl-init)))
(defun flymake-perl-init ()
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
                     'flymake-create-temp-inplace))
         (local-file (file-relative-name
                      temp-file
                      (file-name-directory buffer-file-name))))
    (list "perl" (list "-wc" local-file))))
(defun flymake-perl-load ()
  (interactive)
  (defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted)
    (setq flymake-check-was-interrupted t))
  (ad-activate 'flymake-post-syntax-check)
  (setq flymake-allowed-file-name-masks (append flymake-allowed-file-name-masks flymake-allowed-perl-file-name-masks))
  (setq flymake-err-line-patterns flymake-perl-err-line-patterns)
  (flymake-mode t))
(add-hook 'cperl-mode-hook '(lambda () (flymake-perl-load)))
でも、これだと単純に perl -wc しているだけで編集中の lib パスなどを @INC につっこまないため、その lib 以下にあるモジュールを use したりするとそこでエラーになってしまう。
なので今はモジュールやCatalystアプリの開発するときはいちいち emacs 上で M-x setenv してその lib パスを PERL5LIB にセットしている。。ちょうめんどくさい。。
そんでこれを自動化したいわけだがどうすればいいのかなぁ。
auto-save-buffers-enhancedでsvkのcoパス更新
~/.svk/config を起動時にしか見に行かないということで、emacs起動後にcoパスが増えた場合などリロードしたいとおもったら
M-: (auto-save-buffers-enhanced-add-svk-checkout-path-into-include-regexps)
とすればいいらしい。メモメモ。
こうだったらいいのに auto-save-buffers
開いてるファイルが svn(k) の copath だったらON、それ以外だったらOFFって自動でなるといいのになー。
今は
(run-with-idle-timer 0.5 t 'auto-save-buffers "^/home/typester/dev/" "^$")
とかしてるけれど、その領域でもたまにsvn管理じゃないファイルつかったりするし、それで自動保存されると困るし。
bm.el
(global-set-key "\M-1" 'bm-toggle) (global-set-key "\M-3" 'bm-next) (global-set-key "\M-2" 'bm-previous)
とかで設定してるけどまったく使ってない。
できた
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
emacsclient で開いたバッファを閉じるときに
Buffer `svk-commitvP9pW.tmp' still has clients; kill it? (yes or no)
などといわれるのをなくしたいのだが、どうすればいいのか! 強制yesでいいんだけど。
それとも C-x # 的なもので保存せずに閉じるものあるのかな。
snippet.el いれた
を見て便利そうなので導入。
elisp よくわかんねーので、psgml-mode と cperl-mode で動かしたかっただけなのにものすごい時間かかった。。
; snippet.el
(require 'snippet)
(require 'psgml)
(snippet-with-abbrev-table 'xml-mode-abbrev-table
  ("ahref" .  "<a href=\"$${url}\" title=\"$${title}\">$${title}</a>"))
(defvar cperl-mode-abbrev-table nil
  "Abbrev table in use in CPerl mode.")
(define-abbrev-table 'cperl-mode-abbrev-table ())
(snippet-with-abbrev-table 'cperl-mode-abbrev-table
  ("formy" .  "for my $${item} ($${items}) {\n}")
  ("cataction"  .  "sub $${fn} :$${attribute} {\n$>my ($self, $c) = @_;\n}"))
こんなんでいけた。
psgmlのxml-modeは普通にやったら xml-mode-abbrev-table なんてねーよっておこられるので、先に (require 'psgml) しておいたらいけた。
cperl-mode も同じ方法でやろうとしたらなんかエラーになったのでソース見たら、cperl-mode-abbrev-table がすでに定義されてあったら cperl-mode 側では上書きしないっぽい感じになっていたのでてけとうに定義してやったらいけた。うむ、よくわからん。
まぁつかえたからいいや的な。
あとはabbrev-tableふやすだけ~。
ido-mode
(iswitchb-mode 1)
をやめて
(ido-mode t)
をためしてみてる。
より。
iswitchbライクなバッファ切り替えと同じようなのをfind-fileでも使える。あとfind-file中にC-bするとバッファ切り替えに切り替わるのは人によっては便利かな。逆も可(バッファ切り替えじにC-fでfind-file)
どうなんだろうなこれは。すぐ戻すかもしれない。
あとnXML-modeもいれてみたけど、まだ使ってみていない。
Local variables on Recent emacs
最近のemacsではLocal variablesがあるファイルを開こうとすると
The local variables list in clmemo.txt
contains values that may not be safe (*).
Do you want to apply it?  You can type
y  -- to apply the local variables list.
n  -- to ignore the local variables list.
!  -- to apply the local variables list, and permanently mark these
      values (*) as safe (in the future, they will be set automatically.)
    mode : change-log
  * clmemo-mode : t
    tab-width : 4
    left-margin : 4
とかでるようになったらしい。へぇ、いいね。