2012-01-01から1年間の記事一覧

ライブラリを遅延ロードするマクロ

特徴 引数一つで動く 複数の関数を同時に autoload にできる ライブラリのロード後に実行する式を書ける(eval-after-load を使う) ライブラリのパスを返す すでに autoload として定義されていれば、重複して定義しない quote して渡す(趣味) 基本的には…

term-mode で引数ありで任意のコマンドを実行

M-x term とかだと引数付けられないので。 (require 'term nil t) (defvar term-shell-command-history nil "History for `term-shell-command'") (defun term-shell-command (command &optional buffer-or-name) "Run COMMAND in terminal emulator. If BUF…

pasteboard.el

作りました。https://github.com/10sr/emacs-lisp/blob/master/pasteboard.elpbcopy および pbpaste と連携します。 (and (require 'pasteboard.el nil t) (turn-on-pasteboard)) tmux の内側で使う場合、 reattach-to-user-namespace が必要です。 通常、こ…

windowを任意の個数にだいたい等分するelisp

書きました。https://github.com/10sr/emacs-lisp/blob/master/divide-window.elrequireすると、 M-x divide-window-verticallyと M-x divide-window-horizontallyの2つが使えるようになります。 前置引数を用いることで、分割する数を指定できます。何も指…

ページ内のリンクをリストするエクステ

ext.add("list-url", function(){ var urls = []; var aa = window.content.document.getElementsByTagName("a"); var text = ""; var alt = ""; for (var i = 0; i < aa.length ; i++) { if(aa[i].href == ""){ continue; } if (aa[i].text == "" && aa[i].…

git-command.el

作った。 いちいちキーバインド覚えてらんねーということで、対話的なシェルと同じ感覚で使えるようなものを目指した。 エディタを起動するようなコマンドは上手くいかない。https://github.com/10sr/emacs-lisp/blob/master/git-command.el設定は例えばこん…

ページのソースを表示

ext.add('view-page-source', function(){ window.content.location.href = "view-source:" + window.content.location.href; }, 'view page source');

diredの隠しファイル表示をトグルするminor-mode

つくった。以下をdot.emacsに追加。 (when (require 'dired-list-all-mode nil t) (setq dired-listing-switches "-lhFG") (add-hook 'dired-mode-hook (lambda () (define-key dired-mode-map "a" 'dired-list-all-mode) )))

書き込み禁止、挿入、上書きの状態に応じてmodelineの色を変えるライブラリ

つくった。使い方: (require 'set-modeline-color nil t) 設定: (setq set-modeline-color-color-alist '((readonly "blue" "white") (overwrite "red" "white") (insert nil nil))) この機能どこかで既に見た気がしなくもない。

ターミナルエミュレータで起動したemacsで、ターミナルのタイトルを変える

マウスがただひたすらにウザいし、フォント設定をターミナルエミュレータと共有できるのが便利なので、いつもemacsは-nw付きで起動してる。 (defun set-terminal-title (&rest args) "" (interactive "sString to set as title: ") (let ((tty (frame-parame…

aurからパッケージをダウンロードし、ビルド前にソースを修正してインストールする

2012/4/8 追記 書き換えるところを少し増やした。 https://gist.github.com/2337613 ほんとはpatchか何か作った方がいいのかもしれないけど、archの流儀をよく分かってないので。 うちは、無線LANのチップにbroadcom-wlが必要なものを使用してる。 このドラ…

pacmanのキーサーバを設定する

先日、Arch Linuxをインストールした。 そのときのメモはここ。 いくつかのメモを https://www.jottit.com/zku6z/ にまとめてる。 インストール時に一番ハマったのは、パッケージの署名でのエラーだった。pacmanでパッケージをインストールしようとすると、…

IPアドレスを取得

ip-address(){ local ip=$(LANG=C ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{print $2}') test -n "$ip" && printf $1 $ip } ip-address [Addr:%s] 参考 http://d.hatena.ne.jp/gunshot/20081216/p1

バッテリーの状態をパーセントで取得

ただしとってもおそい battery-status(){ local dir=/sys/class/power_supply/BAT0 if test -d $dir then local st=$(cat $dir/status) local full=$(cat $dir/charge_full) local now=$(cat $dir/charge_now) local rate=$(expr $now \* 100 / $full) print…

ctl-x-mapがよく分からない

2012/4/7追記: (pc-selection-mode 1)があるとそれ以前のキー設定が元に戻ってしまうよう。 dot.emacsに (define-key ctl-x-map (kbd "C-x") nil) を書いても、C-x C-x の定義は C-x C-x runs the command exchange-point-and-mark-nomarkのままなのに、起…

global-hl-line-mode を term-mode で無効にする

めんどいので擬似的に (add-hook 'term-mode-hook (lambda () (set (make-local-variable 'hl-line-range-function) (lambda () '(0 . 0)))))

readonly時にモードラインの色を変える

2012/3/27 ライブラリ化した。 ここを参考に。 EmacsWiki: Changing Cursor Dynamically (defun my-set-mode-line-color-read-only () "" (let ((state (if buffer-read-only 'readonly (if overwrite-mode 'overwrite 'insert)))) (unless (eq state my-set…

pluginを半自動インストール

urlsにあるプラグインについてそれぞれインストールされてるか調べ、なかった場合インストールダイアログを出すext。 ext.add('auto-install-plugins', function(ev, arg){ var urls = [ 'https://github.com/mooz/keysnail/raw/master/plugins/yet-another-…