yaottiの日記

2009-10-08

今日のelisp

14:53

簡単なもの

;; delete current opening file
(defun delete-current-buffer-file ()
  (interactive)
  (let ((file-name (buffer-file-name (current-buffer))))
    (if (y-or-n-p (format "Really delete file %s? " file-name))
        (progn
          (delete-file file-name)
          (message (format "%s has been deleted." file-name))))))

;; kill buffers except for *scratch* and *Message*
(defun kill-all-buffers ()
  (interactive)
  (dolist (buf (buffer-list))
    (kill-buffer buf))
  (cd "~"))

あとuniquifyを入れた.

;; installed uniquify
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)

uniquifyを入れたおかげで,anythingでのバッファ切り替え時に同じ名前のファイルが複数あってもディレクトリ名で一意に識別できるようになった.

というか重複関係なく,常にuniquify形式のバッファ名にすればいいのかもしれないけど.

VanilzaVanilza2012/06/06 13:50Pay-as-you-go never existed. And it is not a very sound pocliy, anyway.One problem is that one party would prefer to cut the budget to make ends meet, while the other would prefer to add taxes. That's a problem.Another problem is that there are always events that occur that would throw the budget out of balance. Every time there is a natural disaster, say, in Haiti or because of a hurricane, is it reasonable or rational to have to cut the budget or increase taxes to pay for the money spent on that? I contend it is not.PAYG is just another cop-out by Congresscritters who are afraid to make hard budget decisions and live (and be re-elected or not) by them. The biggest job of the Congress is to make those hard budget decisions and to be strong protectors of the public treasury. And in this biggest job, they have failed and failed miserably, not the least of which is that they do not want to be held responsible for making hard budget decisions that might harm their re-election chances.Debt is not necessarily evil, if it is kept within reason. The biggest cause of debt is government spending, especially the ever-increasing costs of the entitlements which are of dubious constitutionality at best.

atklprbqjccatklprbqjcc2012/06/07 04:43jH0Thb <a href="http://wolwvzejjyzq.com/">wolwvzejjyzq</a>

hyndpjjhyndpjj2012/06/07 10:11fqP612 , [url=http://slnuvicxmkva.com/]slnuvicxmkva[/url], [link=http://zawszkuhxfio.com/]zawszkuhxfio[/link], http://hgibvzobcesv.com/

aqfvsltaqfvslt2012/06/13 06:157nmjJQ , [url=http://zgnayllcmjja.com/]zgnayllcmjja[/url], [link=http://jinaitgsdplj.com/]jinaitgsdplj[/link], http://dlacealyglou.com/

BoyBoy2013/12/20 23:09To make money online you need kndwgeole , you need to know how , its very easy but you just need to know it ? Earning money online is just like earning money offline.Internet is just a medium that we use to do bussiness.I'm saying that anyone can make money online but you need to know how to do it ? You need to learn it and it will take time , it took me 2 years until I could earn $ 500+ everyday and I'm just 17 .If you want to make quick money right away , join this paid survey surveyscout.url-site. comits really good and I'm also doing this one , you can make more than $ 100 per day easily .another way is sell on ebay , if you don't have anything to sell, do you think all those powersellers have products to sell ? they also don't have , infact more than 50% of ebay sellers use dropshipper to sell .I would recommend salehoo.url-go. com , its the best dropshipper I have ever use and now also I'm selling soccer gears on ebay using this dropshipper.I hope I have help you , you can mail me if you want to ask anything regarding earning money online and I will be glad i could help you.jack Was this answer helpful?

2009-09-24

CarbonEmacs+zsh+ansi-termで4mと出る問題

| 21:41

shell-pop.elが便利 - Emacs/Lisp/Drill - Emacsグループのshell-popを試してみて,これは便利なので使っていこうと思ったんだけど,プロンプトの前に4mと出てうっとおしかったので調べてみた.

#17401 (emacs make-term: eterm-color not found due to new ncurses version) ? MacPorts によると,mac portで入れたzshを使っているとportがうまく設定(terminfo)を見付けられずに,4mという文字が出てしまうらしい.

sudo cp /opt/local/share/terminfo/65/eterm ~/.terminfo/65/eterm-color

で解決した.


shell-popが快適すぎる…すばらしいですね.

追記

garaemon(でぃぷりけいてっど)(@garaemon)さん | Twitterからの返信付きツイート

(setq system-uses-terminfo nil)

でいいらしい.

MohmadMohmad2012/08/19 05:12Okay I'm convinced. Let's put it to actoin.

cklgibxgcklgibxg2012/08/19 20:04RY2rio <a href="http://qjlfmjrlzggd.com/">qjlfmjrlzggd</a>

huftjhhuftjh2012/08/23 02:12bmOVd8 , [url=http://teikfmvhrcaf.com/]teikfmvhrcaf[/url], [link=http://lnldvipgtxfe.com/]lnldvipgtxfe[/link], http://ygfsztmrfkug.com/

2009-09-23

clmemo

16:28

純粋なEmacsの話ではないけど,clmemoについて.

clmemohtml化するchalowを試してみた.結構よさそう.

chalow - CHAngeLog On the Web

使い道としては

  • だらだらとclmemoを見たい
  • RSSを吐かせて,plaggerなどと組み合わせていい感じにしたものをメールとして受け取りたい
  • いつでもどこからでも,ある程度きちんとしたフォーマットで見られる

とかか.

もしprivateな内容を出してしまったらどうしよう,と思って躊躇ってたんだけど,

p:hogehoge

16:31

fuga

piyo

と書けばその部分はhtml化されないらしい.

私の ChangeLog メモ活用法

2009-09-14

flymakeでのシンタックスチェック

22:17

ちょっとした書き捨てプログラムにファイルに紐付いていないバッファ(*scratch*とか)を良く使うんだけど,その時flymakeがシンタックスチェックをしてくれないので追ってみた&解決した.


そもそもflymakeのメカニズムは,

  1. 現在のバッファ内容をコピーした,flymake用の一時ファイルを作成
  2. そのファイルをコンパイル(perlなどのLLなら実行)する
  3. エラーを吐くかチェックし,エラーなら該当部分にハイライト&メッセージ

というもの.


そこで,ファイルに紐付いていないバッファでflymakeしようとすると,編集中のファイルが存在しないため一時ファイルを作成できずうまく動かない,ということになる.

一時ファイルを作成する際に,buffer-file-nameとdefault-directoryという2つの変数を見ているようなので,flymakeをonにする前に以下のように適当なディレクトリ&ファイル名を指定してやれば良い.

(setq buffer-file-name "/tmp/perl-scratch.pl"
      default-directory "/tmp/")
(flymake-mode t)

実際に/tmp/perl-scratch.plは作成されてしまうので,kill-bufferにdefadviceで削除するロジック付けたほうが綺麗といえば綺麗かも.

ちなみにperlの書き捨てバッファは以下のような関数を作ってやっている.

(defun create-perl-buffer ()
  "Create a perl buffer like *scratch*"
  (interactive)
  (let* ((buf-name "*perl-scratch*")
         (buffer (get-buffer-create buf-name))
         (modules '(strict warnings Data::Dumper Perl6::Say)))
    (switch-to-buffer buffer)
    (if (= (buffer-size buffer) 0)
        (progn
          (dolist (m modules)
            (insert (format "use %s;\n" m)))
          (insert "\n")
          ;; flymakeによるシンタックスチェックを有効にするため,ファイルに紐付ける
          (setq buffer-file-name "/Users/hiroshige/tmp/perl-scratch.pl"
                default-directory "/Users/hiroshige/tmp/")
          (cperl-mode)
          (require 'perl-completion)
          (perl-completion-mode t)
          ))))
;; バッファ内容を実行
(defun perl-eval-buffer ()
  "Run buffer as Perl code"
  (interactive)
  (save-excursion
    (mark-whole-buffer)
    (shell-command-on-region (point) (mark) "perl"))
 )
(define-key cperl-mode-map "\C-cP" 'perl-eval-buffer)

M-x create-perl-bufferして適当にコード書いて,C-c P(M-x perl-eval-buffer)で実行というサイクル.


なんかemacsというよりperlの話だ.

flymakeの話に戻ると,flymakeの適当な関数に上の(setq buffer-file-name ...)をdefadviceで実行前にセットするようにすれば,他の言語においてもいい感じにやってくれるようになるはず.

BereniceBerenice2012/08/21 13:18Thanky Thanky for all this good infortmaion!

slrsdqduckrslrsdqduckr2012/08/21 18:41K8cmJE <a href="http://borjuogcxbcq.com/">borjuogcxbcq</a>

rdifhmsmtrdifhmsmt2012/08/25 01:47YySnGM , [url=http://tsoiotjscuyl.com/]tsoiotjscuyl[/url], [link=http://mhvejqomymec.com/]mhvejqomymec[/link], http://grupjsjncnhc.com/

2009-09-11

MacのDictionary.appをEmacsから引く

| 15:28

[Emacs]Carbon EmacsからDictionary.app(辞書)で単語を調べる: 旧式ひとりぶろぐを見て,open dict://を使って書いてみた.

(defun lookup-dictionary ()
  "Look up english words in Dictionary.app"
  (interactive)
  (let* ((word (read-from-minibuffer "word: " (thing-at-point 'word)))
         (dict-command (concat "open dict://" word)))
    (call-process-shell-command dict-command)))

最近elispをよく読んでいるおかげか,これぐらいならさくっと書けるようになってきた.嬉しい.

sakitosakito2009/09/12 13:34こことかも見ていただけると嬉しいです http://sakito.jp/mac/dictionary.html#python

yaottiyaotti2009/09/14 22:50>sakitoさん
dictionary.appの所,参考になりました.ありがとうございます:)

SherlySherly2012/02/20 06:59Full of slaeint points. Don't stop believing or writing!

zlqsugwgyezlqsugwgye2012/02/21 02:55Je9593 <a href="http://lfujkoldfrpn.com/">lfujkoldfrpn</a>

nhwdimnhwdim2012/02/21 22:535F2KJd , [url=http://ejrihfkcxmhl.com/]ejrihfkcxmhl[/url], [link=http://paytnuniteqd.com/]paytnuniteqd[/link], http://zzugrwptdiuj.com/

DaisyDaisy2013/12/29 03:49Good job mankig it appear easy.