No Such Blog or Diary
リージョンを シェルコマンドの実行結果で置換2
- 2007-01-30 (Tue)
- ソフトウェア ( Meadow/Emacs )
ついでなので,元のリージョンの内容を出力の上部にコメントとして出力するものも作った.
(defun perform-command-region (start end command)
(interactive
(let (string)
(unless (mark)
(error "The mark is not set now, so there is no region"))
;; Do this before calling region-beginning
;; and region-end, in case subprocess output
;; relocates them while we are in the minibuffer.
(setq string (read-from-minibuffer "Shell command on region: "
nil nil nil
'shell-command-history))
;; call-interactively recognizes region-beginning and
;; region-end specially, leaving them in the history.
(list (region-beginning) (region-end) string)))
(let (exit-status)
;; Replace specified region with output from command.
(let ((swap (< start end)))
(goto-char start)
(kill-region start end)
(yank)
(push-mark (point) 'nomsg)
(setq exit-status
;; see describe-function
;; error output is marged into standard output
(call-process-region start end shell-file-name t
(list t t)
nil shell-command-switch command))
;; swap the point and mark if necessary
(and swap (exchange-point-and-mark))
;; mark current position
(setq p1 (point-marker))
(set-marker-insertion-type p1 nil)
;; yank the original contents
(yank nil)
(setq p2 (point-marker))
;; comment the yanked contents
(comment-region (marker-position p1) (marker-position p2))
(setq p1 nil)
(setq p1 nil))
exit-status))
(define-key global-map [(control meta ?!)] 'perform-command-region)
そして C-M-! で発動すると.これって comment-region がない場合にどうなるんだろう?
- Comments: 0
- TrackBack (Close): -
Emacs Lisp の関数定義を探す
- 2007-01-27 (Sat)
- ソフトウェア ( Meadow/Emacs )
describe-function というコマンドで見つかるらしい.
- Comments: 0
- TrackBack (Close): -
MoinMoinWiki で reStructured Text を
- 2006-12-29 (Fri)
- ソフトウェア ( Meadow/Emacs )
MoinMoin wiki で reStructuredText を使うのに Docutils が必要なので落としてきてインストールした.http://docutils.sourceforge.net/ から docutils-snapshot.tgz を落として展開.展開したディレクトリで次のコマンドを実行.これにてインストール完了.
python setup.py install
あとはページ先頭に
#format rst
としていすると reST を使える.
ついでに, アーカイブ内に入ってる docutils\tools\editors\emacs\rst.el を使うとMeadow とかで reSTmode が使えるのでちょっといいかも.微妙にセクション名とかのフォントカラーがあってなかった気もするが...
- Comments: 0
- TrackBack (Close): -
new XML mode and XQuery mode
- 2006-08-18 (Fri)
- ソフトウェア ( Meadow/Emacs )
複雑な XQuery を書くのにフォーマットが面倒なので導入してみた.
XQuery mode が nxml-mode を必要とするので両方とも以下から落として site-lisp に突っ込む.
http://www.thaiopensource.com/download/nxml-mode-20041004.tar.gz
http://www.emacswiki.org/cgi-bin/wiki/download/xquery-mode.el
あとはモードを自動で切り替えるために
(autoload 'xquery-mode "xquery-mode" "Major mode for editing XQuery code." t) (setq auto-mode-alist (cons '( "\\.xq\\'" . xquery-mode ) auto-mode-alist ))
とでも書いておけばよいかな.
ちょっと括弧の対応が取れてなかったりするが,とりあえず色が付きまくってありがたい.
- Comments: 0
- TrackBack (Close): -
color-theme
- 2006-02-21 (Tue)
- ソフトウェア ( Meadow/Emacs )
見た目が寂しいので color-theme.el を入れて色でもつけようかと.Emacs Lisp List から適当にたどって… と思ったらリンクが切れてるのでEmacsWiki で Version 6.5.5 を入手.んで,適当に site-lisp ディレクトリに突っ込んで (load "color-theme.el") とか叫ぶとエラーで読み込まれず… Wiki の最後のほうを見たら ISSUES に
easy-menu-get-map(nil ("Tools") nil) easy-menu-add-item(nil ("Tools") "--")
を
easy-menu-get-map(nil ("tools") nil) easy-menu-add-item(nil ("tools") "--")
にしろとあるのでそれに従ったらうまくいった.とりあえずよいテーマが無いので自分用の色を作りたい気分.
- Comments: 0
- TrackBack (Close): -
Meadow で文字コード変更
- 2005-03-24 (Thu)
- ソフトウェア ( Meadow/Emacs )
何度やっても忘れるのでここに書いておこう.Meadow での文字コード変更は
C-x Ret f M-x set-buffer-file-coding-system
だ.
- Comments: 0
- TrackBack (Close): -