タグ

ブックマーク / trotr.hatenadiary.org (9)

  • .emacsの設定に役立つ関数 - trotrの日記

    .emacsの中で定義していて便利だなと感じる関数/マクロの紹介。 とりあえず、aifとand-let*はUtilityとして必要かなと思います。 他にon-offを切り替えるトグルスイッチ見たいな関数を楽に定義できるdef-toggleというものを定義して使っています。 utilities (require 'cl) (defmacro aif (p true-clause &rest false-clause) (declare (indent 2)) `(let ((it ,p)) (if it ,true-clause ,@false-clause))) (defun singlep (pair) (and (consp pair) (null (cdr pair)))) (defmacro and-let* (exp &rest body) (declare (indent 1)

    .emacsの設定に役立つ関数 - trotrの日記
    kitokitoki
    kitokitoki 2010/03/26
    (declare (indent 2)) かー。 (put 'aif 'lisp-indent-function 2) でも同じなんです.
  • カーソルの色を変えるelisp - trotrの日記

    何だか面白そうだったので http://d.hatena.ne.jp/kitokitoki/20100322/p3 http://d.hatena.ne.jp/hitode909/20100322/1269232929 違い emacs上で名前がつけられている全ての色からランダムで選ぶようにした run-with-idle-timerを使ってみた*1 blink-modeとか過去のカーソルの色を保存して戻せるようにした。 code ;;(cute-cursor t) ;開始 ;;(cute-cursor nil) ;終了 (require 'cl) (defun cute-cursor-random-color () (let* ((colors (defined-colors)) (c (nth (random (length colors)) colors))) (when (and

    カーソルの色を変えるelisp - trotrの日記
    kitokitoki
    kitokitoki 2010/03/25
    なにバトンですか?
  • 逆引きruby(文字列)をscheme(gauche)で2 - trotrの日記

    コメントをもらったので、その情報を元に追加します。 全体的にsrfi-13の手続きを把握しきれていなかったみたいです。 そして#`"..."を不完全な文字列と勘違いしていました(当は文字列補間の構文) 文字列中の式を評価し値を展開する(勘違い) #~""は不完全な文字列 #`"..." は文字列補間の構文で不完全な文字列とは呼ばないそうです。勘違いしてました。(#*"..." が不完全な文字列) 不完全な文字列と通常の文字列ではstring-lengthの返す値が違います。 また、writeで出力した場合にも、出力結果が異なります。 現在のエンコーディングで解釈しようのない文字列を不完全な文字列というみたいです。 ("Gauche - A Scheme Interpreter#不完全な文字列"より) (string-incomplete? "あaaa") ; => #f (string-

    逆引きruby(文字列)をscheme(gauche)で2 - trotrの日記
  • 2010-02-03

    人に自分の思ったことを伝えられない気がする。ヤバい。 なので、内容ともかく意味の通る文章を書く練習をする。 逆引きrubyの内容をscheme(gauche)で書いて、それを説明するようにしてみる。 間違ったところや気づかなかったところがあったりした場合には教えてください。 gaucheで文字列を使う場合、クラスを使用します。だからと言って、主に利用するのがクラスのメソッドというわけはありません。 文字列を結合する 文字列を更新する手続きは基的には用意されていません。文字列を結合する場合には、結合した文字列を新たに作りだすことになります。渡された文字列を結合した新しい文字列を返す手続きとしてstring-appendが使えます。string-appendは任意個の文字列を引数として取ることができます。 (define s "hello") (define s1 (string-appen

    2010-02-03
  • 書き初め - trotrの日記

    schemeの感覚で書くとこんな感じかもしれない。foldの代わりにreduceで (defun dirs-children (dirs &optional exclude) (let ((exclude* (or exclude (mapconcat 'identity '("\\.\\{1,2\\}$" "\\.git$" "\\.svn$") "\\|")))) (nreverse (reduce #'(lambda (acc file) (cond ((and exclude* (string-match exclude* file)) acc) ((file-directory-p file) (let ((children (directory-files file t))) (cons* (dirs-children children exclude*) acc))) (t

    書き初め - trotrの日記
  • count-up - trotrの日記

    http://d.hatena.ne.jp/kitokitoki/20091219 http://d.hatena.ne.jp/gongoZ/20091222 (defun count-up (d) (interactive "P") (when (looking-at "[0-9.]") (let ((col (current-column)) (beg (progn (skip-chars-backward "[0-9.]") (point))) (end (progn (skip-chars-forward "[0-9.]") (point)))) (let ((num (delete-and-extract-region beg end))) (insert (format "%s" (+ (string-to-number num) (or d 1))))) (move-to-c

    count-up - trotrの日記
    kitokitoki
    kitokitoki 2009/12/28
    gongoZさんのようなマイナス対応(こちらは-が連続していると意図しない動き)を考えてみます!
  • 2009-12-24

    勧められたので、keysnailを入れてみました。 ESCをMとして認識させたいのだけれど、上手くいきませんでした。 .keysnail.jsに以下を追加すればいいはず…だと思ったのですが。 key.isMetaKey = function (aEvent) { return KeyEvent.DOM_VK_ESCAPE == aEvent.keyCode || aEvent.altKey; }; 参考 http://wiki.github.com/mooz/keysnail/keysnail-how-to-japanese javascript:var KE = {};for(var i in KeyEvent)KE[i]=KeyEvent[i];alert(uneval(KE)); 追記 プラグインを書いてくれました、 ESC キーを Meta キーとして使うプラグイン - リタマス

    2009-12-24
  • emacsからtimeout付きでprocessを呼び出す2 - trotrの日記

    emacs側では以下の2つのようなプロセスを呼び出せばいいことに気づいた。 . 動作 その後 this-process 渡されたコマンドを実行して もう一方のprocessが終わってなかったら殺す。 that-process sleepして もう一方のprocessが終わってなかったら殺す。 ;(require 'cl) (defvar spscwt-hooked-process nil) (defvar spscwt-sentinel-function nil) (defun spscwt-process-will-be-kill (that-process &optional this-buf) (lexical-let ((that that-process) (buf this-buf)) (lambda (&rest args) (when (eq 'run (process-s

    emacsからtimeout付きでprocessを呼び出す2 - trotrの日記
  • emacsからタイムアウト付きでプロセスを呼び出す。 - trotrの日記

    なかなかうまく行かない。 with-timeoutはprocessの呼び出しに対応していない。 sleep-forは渡した秒数だけ待たないこともある。(原因不明) (sleep-for 3)が0.1xxx秒で終わってしまうことも 今のところはこのような感じ。(一応目的にあった振る舞いはするようになった) code (defvar spscwt-hooked-process nil) (defvar spscwt-wait-milliseconds 100) (defvar spscwt-warn-ignore nil) (defun spscwt-warn (buf warn-message) (with-current-buffer buf (goto-char (point-min)) (insert ";;-\"" warn-message "\"-;;\n\n") (message

    emacsからタイムアウト付きでプロセスを呼び出す。 - trotrの日記
  • 1