Search This Blog

Wednesday, January 13, 2010

去死吧,spammer们

之前忙考试,没空收拾你们,这次全清理掉了。

to spammers: go back to hell.

Saturday, April 11, 2009

comint-within-quotes in emacs

the function comint-within-quotes tells whether the cursor in quotes by counting the number of quotes from a start position to an end position.
but it can not handle an empty string like this: ""
it counts the first quote but ignores the second one.
and the single quote ' in common lisp has it's special using other than quoting something,oh,well,I mean it quotes something not with a pair but a single one.
so I hope I can have the function count only double quotes when editing common lisp and this is what I've defuned:

(defun comint-within-single-quotes (beg end)
  (let ((countsq (comint-how-many-region "\\(\\=\\|[^\\\\]\\)\'" beg end)))
    (= (mod countsq 2) 1)))
(defun comint-within-double-quotes (beg end)
  (let ((countdq (comint-how-many-region "\\(\\=\\|[^\\\\]\\)\"" beg end)))
    (= (mod countdq 2) 1)))
(defun* comint-within-quotes-2 (beg end &key (quotes :both))
  (case quotes
    (:both (comint-within-quotes beg end))
    (:single (comint-within-single-quotes beg end))
    (:double (comint-within-double-quotes beg end))))  

Friday, September 12, 2008

ipython in emacs with dark background

I use a black bg color theme in emacs,while ipython outputs like this by default:

 
well,some part of the output is black,it sucks
after a travel in the source code of ipython.el and python-mode.el,I found that ipython.el add a "-color lightbg" to command args when start ipython by default,as following:


(unless (member "-colors" py-python-command-args)
(setq py-python-command-args
(nconc py-python-command-args
(list "-colors"
(cond
((eq frame-background-mode 'dark)
"Linux")
((eq frame-background-mode 'light)
"LightBG")
(t ; default (backg-mode isn't always set by XEmacs)
"LightBG"))))))

so I can either modify the py-python-command-args variable or frame-background-mode variable to stop it sucking.
I choose the latter one.
 
BTW:both ways the variable must be set before ipython.el is loaded,for the code above is runned while loading rather than in a function which runned later.