http://d.hatena.ne.jp/itouhiro/
で解決
# -*- coding:utf-8 -*-
print(u'こんにちは'.encode('utf-8'))
2011年6月28日
UnicodeEncodeError: 'ascii' codec can't encode character
cygwin ならできるけど、ntemacs + python-mode.el だと、C-c で
うまく変換できない。
# -*-mode:python; coding:utf-8-*-
print "あ"
print u"あ"
----------------------------------------------------
あ
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u3042' in position 0: ordinal not in range(128)
うまく変換できない。
# -*-mode:python; coding:utf-8-*-
print "あ"
print u"あ"
----------------------------------------------------
あ
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u3042' in position 0: ordinal not in range(128)
2011年6月22日
flymake と pyflakes の init.el (.emacs)
;; ------------------------------------------------------------------------
;; @ flymake で間違っているところをハイライトし、エラーとかをミニバッファへ
;; http://shnya.jp/blog/?category_name=emacs
;; http://d.hatena.ne.jp/khiker/20070630/emacs_ruby_flymake
;; http://d.hatena.ne.jp/khiker/20070720/emacs_flymake
;; http://d.hatena.ne.jp/nyaasan/20071216/p1
(require 'flymake)
;; flymakeの色を変更
;; (set-face-background 'flymake-errline "red4")
;; (set-face-background 'flymake-warnline "dark slate blue")
;; ruby での設定
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): file://(.*//)$" 1 2 nil 3)
flymake-err-line-patterns)
(add-hook
'ruby-mode-hook
'(lambda ()
;; Don't want flymake mode for ruby regions in rhtml files
(if (not (null buffer-file-name)) (flymake-mode))))
;; python での設定
;;===== PyFlakes
;; code checking via pyflakes+flymake
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("file://.py//'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
;; miniBuffer にエラーを出力
(defun flymake-show-and-sit ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(progn
(let* ((line-no (flymake-current-line-no) )
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info
line-no)))
(count (length line-err-info-list)))
(while (> count 0)
(when line-err-info-list
(let* ((file (flymake-ler-file (nth (1- count)
line-err-info-list)))
(full-file
(flymake-ler-full-file (nth (1- count)
line-err-info-list)))
(text (flymake-ler-text (nth (1- count)
line-err-info-list)))
(line (flymake-ler-line (nth (1- count)
line-err-info-list))))
(message "[%s] %s" line text)))
(setq count (1- count)))))
(sit-for 60.0))
;; キー割り当て
(global-set-key "\M-gn" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-next-error)
(when (equal line (line-number-at-pos))
(next-error)))))
(global-set-key "\M-gp" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-prev-error)
(when (equal line (line-number-at-pos))
(previous-error)))))
(global-set-key "\C-cd" 'flymake-show-and-sit)
;; @ flymake で間違っているところをハイライトし、エラーとかをミニバッファへ
;; http://shnya.jp/blog/?category_name=emacs
;; http://d.hatena.ne.jp/khiker/20070630/emacs_ruby_flymake
;; http://d.hatena.ne.jp/khiker/20070720/emacs_flymake
;; http://d.hatena.ne.jp/nyaasan/20071216/p1
(require 'flymake)
;; flymakeの色を変更
;; (set-face-background 'flymake-errline "red4")
;; (set-face-background 'flymake-warnline "dark slate blue")
;; ruby での設定
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): file://(.*//)$" 1 2 nil 3)
flymake-err-line-patterns)
(add-hook
'ruby-mode-hook
'(lambda ()
;; Don't want flymake mode for ruby regions in rhtml files
(if (not (null buffer-file-name)) (flymake-mode))))
;; python での設定
;;===== PyFlakes
;; code checking via pyflakes+flymake
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("file://.py//'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
;; miniBuffer にエラーを出力
(defun flymake-show-and-sit ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(progn
(let* ((line-no (flymake-current-line-no) )
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info
line-no)))
(count (length line-err-info-list)))
(while (> count 0)
(when line-err-info-list
(let* ((file (flymake-ler-file (nth (1- count)
line-err-info-list)))
(full-file
(flymake-ler-full-file (nth (1- count)
line-err-info-list)))
(text (flymake-ler-text (nth (1- count)
line-err-info-list)))
(line (flymake-ler-line (nth (1- count)
line-err-info-list))))
(message "[%s] %s" line text)))
(setq count (1- count)))))
(sit-for 60.0))
;; キー割り当て
(global-set-key "\M-gn" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-next-error)
(when (equal line (line-number-at-pos))
(next-error)))))
(global-set-key "\M-gp" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-prev-error)
(when (equal line (line-number-at-pos))
(previous-error)))))
(global-set-key "\C-cd" 'flymake-show-and-sit)
2011年6月21日
pyflakes を cygwin に入れる
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
sh setuptools-0.6c11-py2.6.egg
export HTTP_PROXY=XXX.XXX.XXX:XX
easy_install pyflakes
で、 sample.py を
print "Hello World!
で用意しておき、
# pyflakes sample.py
sample.py:1: EOL while scanning string literal
print "Hello World!
^
ここまでは慣れたもんだ・・・って、PROXYの設定で躓いたけど。
python ez_setup.py
wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
sh setuptools-0.6c11-py2.6.egg
export HTTP_PROXY=XXX.XXX.XXX:XX
easy_install pyflakes
で、 sample.py を
print "Hello World!
で用意しておき、
# pyflakes sample.py
sample.py:1: EOL while scanning string literal
print "Hello World!
^
ここまでは慣れたもんだ・・・って、PROXYの設定で躓いたけど。
2011年6月5日
NTemacs からの Python で sys.stdout.encoding [不明]
NTemacs , Python-mode で
import sys;
print sys.stdout.encoding
として、 C-c だと
None
と出て、 bash で
python
import sys;
print sys.stdout.encoding
とすると
CP932
と出る。ちなみに、 Emacs で
# coding: utf-8
test = u"日本語"
として、 C-c すると
File "<stdin>", line 2
SyntaxError: (unicode error) 'utf8' codec can't decode byte 0x93 in position 0: unexpected code byte
といわれる。やっぱ、日本語対処がうまくできてないみたい。でもでも、 bash で
python
test=u"日本語"
print test
とすると、ちゃんと「日本語」って返ってくるようになってる・・・。うー。
以下でも同じ。
# coding: utf-8
import sys
import codecs
sys.stdin = codecs.getreader ('utf_8') (sys.stdin)
sys.stdout = codecs.getwriter ('utf_8') (sys.stdout)
a=u"あ"
print a
import sys;
print sys.stdout.encoding
として、 C-c だと
None
と出て、 bash で
python
import sys;
print sys.stdout.encoding
とすると
CP932
と出る。ちなみに、 Emacs で
# coding: utf-8
test = u"日本語"
として、 C-c すると
File "<stdin>", line 2
SyntaxError: (unicode error) 'utf8' codec can't decode byte 0x93 in position 0: unexpected code byte
といわれる。やっぱ、日本語対処がうまくできてないみたい。でもでも、 bash で
python
test=u"日本語"
print test
とすると、ちゃんと「日本語」って返ってくるようになってる・・・。うー。
以下でも同じ。
# coding: utf-8
import sys
import codecs
sys.stdin = codecs.getreader ('utf_8') (sys.stdin)
sys.stdout = codecs.getwriter ('utf_8') (sys.stdout)
a=u"あ"
print a
Cygwin の Python で日本語エラー [失敗]
日本語のユニコードを使おうと .py に
ustr = u"日本語"
として、 C-c すると
File "<stdin>", line 1
SyntaxError: Non-ASCII character '\x93' in file <stdin> on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
と怒れれるので、
M-x eshell
cd ~/download
wget http://www.python.jp/pub/JapaneseCodecs/JapaneseCodecs-1.4.11.tar.gz
tar zxvf JapaneseCodecs-1.4.11.tar.gz
cd JapaneseCodecs-1.4.11/
python setup.py install
とやったが、エラーでうまくいかず
/usr/lib/python2.6/distutils/dist.py:250: UserWarning: 'licence' distribution option is deprecated; use 'license'
warnings.warn (msg)
running install
running build
running build_py
creating build
creating build/lib.cygwin-1.7.9-i686-2.6
creating build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/euc_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/iso_2022_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/iso_2022_jp_1.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/iso_2022_jp_ext.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/jis_7.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/jis_x_0201_katakana.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/jis_x_0201_roman.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/ms932.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/shift_jis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/sjis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/ujis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/windows_31j.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
creating build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/euc_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/iso_2022_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/iso_2022_jp_1.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/iso_2022_jp_ext.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/shift_jis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
creating build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/euc_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/iso_2022_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/iso_2022_jp_1.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/iso_2022_jp_ext.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/ms932.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/shift_jis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
creating build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/euc_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/jis_x_0208.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/jis_x_0212.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/shift_jis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
creating build/lib.cygwin-1.7.9-i686-2.6/japanese/aliases
copying japanese/aliases/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/aliases
running build_ext
building 'japanese.c._japanese_codecs' extension
creating build/temp.cygwin-1.7.9-i686-2.6
creating build/temp.cygwin-1.7.9-i686-2.6/src
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/python2.6 -c src/_japanese_codecs.c -o build/temp.cygwin-1.7.9-i686-2.6/src/_japanese_codecs.o
src/_japanese_codecs.c:12:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
ustr = u"日本語"
として、 C-c すると
File "<stdin>", line 1
SyntaxError: Non-ASCII character '\x93' in file <stdin> on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
と怒れれるので、
M-x eshell
cd ~/download
wget http://www.python.jp/pub/JapaneseCodecs/JapaneseCodecs-1.4.11.tar.gz
tar zxvf JapaneseCodecs-1.4.11.tar.gz
cd JapaneseCodecs-1.4.11/
python setup.py install
とやったが、エラーでうまくいかず
/usr/lib/python2.6/distutils/dist.py:250: UserWarning: 'licence' distribution option is deprecated; use 'license'
warnings.warn (msg)
running install
running build
running build_py
creating build
creating build/lib.cygwin-1.7.9-i686-2.6
creating build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/euc_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/iso_2022_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/iso_2022_jp_1.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/iso_2022_jp_ext.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/jis_7.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/jis_x_0201_katakana.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/jis_x_0201_roman.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/ms932.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/shift_jis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/sjis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/ujis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/windows_31j.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
copying japanese/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese
creating build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/euc_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/iso_2022_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/iso_2022_jp_1.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/iso_2022_jp_ext.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/shift_jis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
copying japanese/python/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/python
creating build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/euc_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/iso_2022_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/iso_2022_jp_1.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/iso_2022_jp_ext.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/ms932.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/shift_jis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
copying japanese/c/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/c
creating build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/euc_jp.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/jis_x_0208.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/jis_x_0212.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/shift_jis.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
copying japanese/mappings/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/mappings
creating build/lib.cygwin-1.7.9-i686-2.6/japanese/aliases
copying japanese/aliases/__init__.py -> build/lib.cygwin-1.7.9-i686-2.6/japanese/aliases
running build_ext
building 'japanese.c._japanese_codecs' extension
creating build/temp.cygwin-1.7.9-i686-2.6
creating build/temp.cygwin-1.7.9-i686-2.6/src
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/python2.6 -c src/_japanese_codecs.c -o build/temp.cygwin-1.7.9-i686-2.6/src/_japanese_codecs.o
src/_japanese_codecs.c:12:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
2011年6月2日
Python の パッケージ を入れる [成功?]
bash で
python
from turtle import *
とやると、そんなモジュール無いみたいなエラーが出た。 cygwin の setup.exe
でフルインストールしたやつはうまく動いたので、なんかよく分からないけど、
残りの python パッケージを全部入れてみる。
apt-cyg install libboost_python1.43
apt-cyg install postgresql-plpython
apt-cyg install python
apt-cyg install python-brlapi
apt-cyg install python-cairo
apt-cyg install python-crypto
apt-cyg install python-doc
apt-cyg install python-feedparser
apt-cyg install python-gamin
apt-cyg install python-gdata
apt-cyg install python-gobject2.0
apt-cyg install python-gobject2.0-devel
apt-cyg install python-gsf
apt-cyg install python-gtk2.0
apt-cyg install python-gtk2.0-demo
apt-cyg install python-gtk2.0-devel
apt-cyg install python-lcms
apt-cyg install python-libproxy
apt-cyg install python-libxml2
apt-cyg install python-libxslt
apt-cyg install python-ming
apt-cyg install python-numpy
apt-cyg install python-paramiko
apt-cyg install python-pygtk
apt-cyg install python-pyrex
apt-cyg install python-test
apt-cyg install python-tkinter
apt-cyg install python-xdg
apt-cyg install subversion-python
で、うまく動いた。ただ、 emacs で
from turtle import *
は flymake で、そんなの無いみたいなエラーを出している。
これは flymake 側の設定の問題だろうけど・・・うー。
[QED]
*********************************************************
python
from turtle import *
とやると、そんなモジュール無いみたいなエラーが出た。 cygwin の setup.exe
でフルインストールしたやつはうまく動いたので、なんかよく分からないけど、
残りの python パッケージを全部入れてみる。
apt-cyg install libboost_python1.43
apt-cyg install postgresql-plpython
apt-cyg install python
apt-cyg install python-brlapi
apt-cyg install python-cairo
apt-cyg install python-crypto
apt-cyg install python-doc
apt-cyg install python-feedparser
apt-cyg install python-gamin
apt-cyg install python-gdata
apt-cyg install python-gobject2.0
apt-cyg install python-gobject2.0-devel
apt-cyg install python-gsf
apt-cyg install python-gtk2.0
apt-cyg install python-gtk2.0-demo
apt-cyg install python-gtk2.0-devel
apt-cyg install python-lcms
apt-cyg install python-libproxy
apt-cyg install python-libxml2
apt-cyg install python-libxslt
apt-cyg install python-ming
apt-cyg install python-numpy
apt-cyg install python-paramiko
apt-cyg install python-pygtk
apt-cyg install python-pyrex
apt-cyg install python-test
apt-cyg install python-tkinter
apt-cyg install python-xdg
apt-cyg install subversion-python
で、うまく動いた。ただ、 emacs で
from turtle import *
は flymake で、そんなの無いみたいなエラーを出している。
これは flymake 側の設定の問題だろうけど・・・うー。
[QED]
*********************************************************
2011年6月1日
そもそも、python-mode がちゃんと動いてないし。。。[失敗]
python.el だと、run-python で以下のエラー
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named emacs
>>> File "<stdin>", line 1
emacs.eexecfile ("c:/temp/gnupack/py5560EKf")
python-mode.el だと、C-c C-c はうまくいくけど、C-c !
でやると
Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+1
File "<stdin>", line 1
1+1
^
SyntaxError: invalid syntax
だと。なんかディレクトリが違うとか何とからしいけど、わからない。。
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named emacs
>>> File "<stdin>", line 1
emacs.eexecfile ("c:/temp/gnupack/py5560EKf")
python-mode.el だと、C-c C-c はうまくいくけど、C-c !
でやると
Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+1
File "<stdin>", line 1
1+1
^
SyntaxError: invalid syntax
だと。なんかディレクトリが違うとか何とからしいけど、わからない。。
Cygwin に pyflakes がきれいに入ったけど emacs で動かない・・・ [失敗]
Cygwin python 2.6 に setuptools を入れる
http://gmt-24.net/archives/723
と
PyFlakes-Flymake for Python Programming in Emacs
http://www.ymer.org/amir/2010/01/28/pyflakes-flymake-for-python-programming-in-emacs/
を参考にしたが、うまくいかない。
# wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
--2011-06-01 15:35:58-- http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
XXX.XXX.XXX.XXX:XX に接続しています... 接続しました。
Proxy による接続要求を送信しました、応答を待っています... 200 OK
長さ: 333447 (326K) [application/octet-stream]
`setuptools-0.6c11-py2.6.egg' に保存中
100%[=================================================>] 333,447 --.-K/s 時間 0.08s
2011-06-01 15:35:58 (4.04 MB/s) - `setuptools-0.6c11-py2.6.egg' へ保存完了 [333447/333447]
# sh setuptools-0.6c11-py2.6.egg
Processing setuptools-0.6c11-py2.6.egg
Removing /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /usr/lib/python2.6/site-packages
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install script to /usr/bin
Installing easy_install-2.6 script to /usr/bin
Installed /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11
# easy_install pyflakes
Searching for pyflakes
Best match: pyflakes 0.4.0
Adding pyflakes 0.4.0 to easy-install.pth file
Using /usr/lib/python2.6/site-packages
Processing dependencies for pyflakes
Finished processing dependencies for pyflakes
で、 sample.py を
print "Hello World!
で用意しておき、
# pyflakes sample.py
sample.py:1: EOL while scanning string literal
print "Hello World!
^
とするとちゃんと動いてんだが、 init.el に
;;===== PyFlakes
;; code checking via pyflakes+flymake
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
と書いて、 sample.py を起動しても、
Flymake: Faild to lanch syntax check process 'pyflakes' with args (sample_flymake.py):
Serching for program: no such file or directory. pyflakes Flymake will be switched OFF
となって、 pyflakes を探せないみたい。
たしかに、 eshell でも、
$ pyflakes sample.py &
pyflakes: command not found
って感じ。なんでー?
http://gmt-24.net/archives/723
と
PyFlakes-Flymake for Python Programming in Emacs
http://www.ymer.org/amir/2010/01/28/pyflakes-flymake-for-python-programming-in-emacs/
を参考にしたが、うまくいかない。
# wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
--2011-06-01 15:35:58-- http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
XXX.XXX.XXX.XXX:XX に接続しています... 接続しました。
Proxy による接続要求を送信しました、応答を待っています... 200 OK
長さ: 333447 (326K) [application/octet-stream]
`setuptools-0.6c11-py2.6.egg' に保存中
100%[=================================================>] 333,447 --.-K/s 時間 0.08s
2011-06-01 15:35:58 (4.04 MB/s) - `setuptools-0.6c11-py2.6.egg' へ保存完了 [333447/333447]
# sh setuptools-0.6c11-py2.6.egg
Processing setuptools-0.6c11-py2.6.egg
Removing /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /usr/lib/python2.6/site-packages
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install script to /usr/bin
Installing easy_install-2.6 script to /usr/bin
Installed /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11
# easy_install pyflakes
Searching for pyflakes
Best match: pyflakes 0.4.0
Adding pyflakes 0.4.0 to easy-install.pth file
Using /usr/lib/python2.6/site-packages
Processing dependencies for pyflakes
Finished processing dependencies for pyflakes
で、 sample.py を
print "Hello World!
で用意しておき、
# pyflakes sample.py
sample.py:1: EOL while scanning string literal
print "Hello World!
^
とするとちゃんと動いてんだが、 init.el に
;;===== PyFlakes
;; code checking via pyflakes+flymake
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
と書いて、 sample.py を起動しても、
Flymake: Faild to lanch syntax check process 'pyflakes' with args (sample_flymake.py):
Serching for program: no such file or directory. pyflakes Flymake will be switched OFF
となって、 pyflakes を探せないみたい。
たしかに、 eshell でも、
$ pyflakes sample.py &
pyflakes: command not found
って感じ。なんでー?
pyflakes のつづき・・・ [成功]
M-x shell だと pyflakes ができて、 M-x eshell だとできなかった。
cmd でもできないから、
Cygwin でインストールした pyflakes をコマンドプロンプトや flymake で動かしてみたり
http://stickydiary.blog88.fc2.com/blog-entry-105.html
を参考に、 pyflakes.bat を
@echo off
C:\gnupack_devel-6.02\app\cygwin\cygwin\bin /usr/bin/pyflakes %*
として、
C:\gnupack_devel-6.02\app\cygwin\cygwin\bin につくったら、うまく動いたけど、
C-cd のエラーがミニバッファに出ない。 Ruby とか C++ は出るのに。
ないよう分からずコピペしてるから、限界だろう。だれかやってくれないかなぁ。
init.el
;; ------------------------------------------------------------------------
;; @ flymake で間違っているところをハイライトし、エラーとかをミニバッファへ
;; http://shnya.jp/blog/?category_name=emacs
;; http://d.hatena.ne.jp/khiker/20070630/emacs_ruby_flymake
;; http://d.hatena.ne.jp/khiker/20070720/emacs_flymake
;; http://d.hatena.ne.jp/nyaasan/20071216/p1
(require 'flymake)
;; miniBuffer にエラーを出力
(defun flymake-show-and-sit ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(progn
(let* ((line-no (flymake-current-line-no) )
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
(count (length line-err-info-list)))
(while (> count 0)
(when line-err-info-list
(let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
(full-file
(flymake-ler-full-file (nth (1- count) line-err-info-list)))
(text (flymake-ler-text (nth (1- count) line-err-info-list)))
(line (flymake-ler-line (nth (1- count) line-err-info-list))))
(message "[%s] %s" line text)))
(setq count (1- count)))))
(sit-for 60.0))
;; キー割り当て
(global-set-key "\M-gn" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-next-error)
(when (equal line (line-number-at-pos))
(next-error)))))
(global-set-key "\M-gp" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-prev-error)
(when (equal line (line-number-at-pos))
(previous-error)))))
(global-set-key "\C-cd" 'flymake-display-err-menu-for-current-line)
;; c++ での設定
(defun flymake-cc-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file))))
(push '("\\.cc$" flymake-cc-init) flymake-allowed-file-name-masks)
(add-hook 'c++-mode-hook
'(lambda ()
(flymake-mode t)))
;; ruby での設定
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns)
(add-hook
'ruby-mode-hook
'(lambda ()
;; Don't want flymake mode for ruby regions in rhtml files
(if (not (null buffer-file-name)) (flymake-mode))))
;; python での設定
;;===== PyFlakes
;; code checking via pyflakes+flymake
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
cmd でもできないから、
Cygwin でインストールした pyflakes をコマンドプロンプトや flymake で動かしてみたり
http://stickydiary.blog88.fc2.com/blog-entry-105.html
を参考に、 pyflakes.bat を
@echo off
C:\gnupack_devel-6.02\app\cygwin\cygwin\bin /usr/bin/pyflakes %*
として、
C:\gnupack_devel-6.02\app\cygwin\cygwin\bin につくったら、うまく動いたけど、
C-cd のエラーがミニバッファに出ない。 Ruby とか C++ は出るのに。
ないよう分からずコピペしてるから、限界だろう。だれかやってくれないかなぁ。
init.el
;; ------------------------------------------------------------------------
;; @ flymake で間違っているところをハイライトし、エラーとかをミニバッファへ
;; http://shnya.jp/blog/?category_name=emacs
;; http://d.hatena.ne.jp/khiker/20070630/emacs_ruby_flymake
;; http://d.hatena.ne.jp/khiker/20070720/emacs_flymake
;; http://d.hatena.ne.jp/nyaasan/20071216/p1
(require 'flymake)
;; miniBuffer にエラーを出力
(defun flymake-show-and-sit ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(progn
(let* ((line-no (flymake-current-line-no) )
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
(count (length line-err-info-list)))
(while (> count 0)
(when line-err-info-list
(let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
(full-file
(flymake-ler-full-file (nth (1- count) line-err-info-list)))
(text (flymake-ler-text (nth (1- count) line-err-info-list)))
(line (flymake-ler-line (nth (1- count) line-err-info-list))))
(message "[%s] %s" line text)))
(setq count (1- count)))))
(sit-for 60.0))
;; キー割り当て
(global-set-key "\M-gn" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-next-error)
(when (equal line (line-number-at-pos))
(next-error)))))
(global-set-key "\M-gp" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-prev-error)
(when (equal line (line-number-at-pos))
(previous-error)))))
(global-set-key "\C-cd" 'flymake-display-err-menu-for-current-line)
;; c++ での設定
(defun flymake-cc-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file))))
(push '("\\.cc$" flymake-cc-init) flymake-allowed-file-name-masks)
(add-hook 'c++-mode-hook
'(lambda ()
(flymake-mode t)))
;; ruby での設定
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns)
(add-hook
'ruby-mode-hook
'(lambda ()
;; Don't want flymake mode for ruby regions in rhtml files
(if (not (null buffer-file-name)) (flymake-mode))))
;; python での設定
;;===== PyFlakes
;; code checking via pyflakes+flymake
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
emacs で python-mode [失敗、挫折]
M-x install-elisp [RET]
http://launchpad.net/python-mode/trunk/5.2.0/+download/python-mode.el
C-c
で、文字コードのエラーうんぬん
---------------------------------------------------------------------
These default coding systems were tried to encode text
in the buffer `python-mode.el':
(undecided-unix (151727 . 31414) (151728 . 27498) (151736 . 31414)
(151737 . 4194201) (151779 . 31414) (151780 . 4194200) (151787
. 31414) (151788 . 4194201) (152162 . 31414) (152163 . 20913))
(utf-8-unix (151737 . 4194201) (151780 . 4194200) (151788
. 4194201))
However, each of them encountered characters it couldn't encode:
undecided-unix cannot encode these:
utf-8-unix cannot encode these:
Click on a character (or switch to this window by `C-x o'
and select the characters by RET) to jump to the place it appears,
where `C-u C-x =' will give information about it.
Select one of the safe coding systems listed below,
or cancel the writing with C-g and edit the buffer
to remove or modify the problematic characters,
or specify any other coding system (and risk losing
the problematic characters).
raw-text emacs-mule no-conversion
---------------------------------------------------------------------
わっかんないから、 C-g でやめて、
M-x eshell
cd ~/download
wget http://launchpad.net/python-mode/trunk/5.2.0/+download/python-mode-5.2.0.tgz
tar xzvf python-mode-5.2.0.tgz
mv python-mode ~/.emacs.d
C-x C-f ~/.emacs.d/init.el
に
;; ------------------------------------------------------------------------
;; @ Python モードを使う
;; http://sheephead.homelinux.org/2009/05/27/1281/
;; http://d.hatena.ne.jp/cou929_la/20110525/1306321857
;; ロードパスの追加
(add-to-list 'load-path "~\\.emacs.d\\python-mode")
(setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist (cons '("python" . python-mode)
interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)
と記述してもしなくても、勝手に python-mode になるじゃん・・・。 gnupack に
入っているみたい。
悔しいので、 flymake も検索してみると入っていることが分かるが、 pyflakes 、 pep8
は入ってないみたい。
ってゆーか、 python が入ってないみたい。
apt-cyg find python
で、何入れればいいか分からないし、つかれちゃった。
apt-cyg install python
としたら、 2.6.5 が入るみたい。 quit () で終了。
cd ~/download
wget http://pypi.python.org/packages/source/p/pyflakes/pyflakes-0.4.0.tar.gz
tar xzvf pyflakes-0.4.0.tar.gz
cd pypyflakes-0.4.0
python setup.py install
としてインストール。
cd ~/download
wget http://pypi.python.org/packages/source/p/pep8/pep8-0.6.1.tar.gz
tar xzvf pep8-0.6.1.tar.gz
cd pep8-0.6.1/
とするが、 pip とかいうの持ってないとインストールできないみたい。 easy_install
も分からないし。
http://atbrox.com/2009/09/21/how-to-get-pipvirtualenvfabric-working-on-cygwin/
を参考にして、
apt-cyg install python-paramiko
apt-cyg install python-crypto
をやってみるけど、その続きも分からないし。ってか、 easy_install が無いってのよ。
ってことで、
http://serverfault.com/questions/7282/how-to-run-easy-install-in-cygwin
を見て、
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
とすると入ったみたいだから、
easy_install pep8
ってしたら、なんか始まったけど、
Download error [Errno 116] hogehoge -- Some packages may not be found!
とか出てるんですけど。
その先は、もう不明なため、挫折
http://d.hatena.ne.jp/cou929_la/20110525/1306321857
http://launchpad.net/python-mode/trunk/5.2.0/+download/python-mode.el
C-c
で、文字コードのエラーうんぬん
---------------------------------------------------------------------
These default coding systems were tried to encode text
in the buffer `python-mode.el':
(undecided-unix (151727 . 31414) (151728 . 27498) (151736 . 31414)
(151737 . 4194201) (151779 . 31414) (151780 . 4194200) (151787
. 31414) (151788 . 4194201) (152162 . 31414) (152163 . 20913))
(utf-8-unix (151737 . 4194201) (151780 . 4194200) (151788
. 4194201))
However, each of them encountered characters it couldn't encode:
undecided-unix cannot encode these:
utf-8-unix cannot encode these:
Click on a character (or switch to this window by `C-x o'
and select the characters by RET) to jump to the place it appears,
where `C-u C-x =' will give information about it.
Select one of the safe coding systems listed below,
or cancel the writing with C-g and edit the buffer
to remove or modify the problematic characters,
or specify any other coding system (and risk losing
the problematic characters).
raw-text emacs-mule no-conversion
---------------------------------------------------------------------
わっかんないから、 C-g でやめて、
M-x eshell
cd ~/download
wget http://launchpad.net/python-mode/trunk/5.2.0/+download/python-mode-5.2.0.tgz
tar xzvf python-mode-5.2.0.tgz
mv python-mode ~/.emacs.d
C-x C-f ~/.emacs.d/init.el
に
;; ------------------------------------------------------------------------
;; @ Python モードを使う
;; http://sheephead.homelinux.org/2009/05/27/1281/
;; http://d.hatena.ne.jp/cou929_la/20110525/1306321857
;; ロードパスの追加
(add-to-list 'load-path "~\\.emacs.d\\python-mode")
(setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist (cons '("python" . python-mode)
interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)
と記述してもしなくても、勝手に python-mode になるじゃん・・・。 gnupack に
入っているみたい。
悔しいので、 flymake も検索してみると入っていることが分かるが、 pyflakes 、 pep8
は入ってないみたい。
ってゆーか、 python が入ってないみたい。
apt-cyg find python
で、何入れればいいか分からないし、つかれちゃった。
apt-cyg install python
としたら、 2.6.5 が入るみたい。 quit () で終了。
cd ~/download
wget http://pypi.python.org/packages/source/p/pyflakes/pyflakes-0.4.0.tar.gz
tar xzvf pyflakes-0.4.0.tar.gz
cd pypyflakes-0.4.0
python setup.py install
としてインストール。
cd ~/download
wget http://pypi.python.org/packages/source/p/pep8/pep8-0.6.1.tar.gz
tar xzvf pep8-0.6.1.tar.gz
cd pep8-0.6.1/
とするが、 pip とかいうの持ってないとインストールできないみたい。 easy_install
も分からないし。
http://atbrox.com/2009/09/21/how-to-get-pipvirtualenvfabric-working-on-cygwin/
を参考にして、
apt-cyg install python-paramiko
apt-cyg install python-crypto
をやってみるけど、その続きも分からないし。ってか、 easy_install が無いってのよ。
ってことで、
http://serverfault.com/questions/7282/how-to-run-easy-install-in-cygwin
を見て、
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
とすると入ったみたいだから、
easy_install pep8
ってしたら、なんか始まったけど、
Download error [Errno 116] hogehoge -- Some packages may not be found!
とか出てるんですけど。
その先は、もう不明なため、挫折
http://d.hatena.ne.jp/cou929_la/20110525/1306321857
2011年5月31日
flymake で間違っているところをハイライトし、エラーとかをミニバッファへ
とりあえず、 python とか難しいから、 flymake をフツーに入れてみる。
wget http://pypi.python.org/packages/source/p/pyflakes/pyflakes-0.4.0.tar.gz
tar xvzf pyflakes-0.4.0.tar.gz
cd pyflakes-0.4.0/
python setup.py install
で、 init.el は以下。よくわからないんだけど、 C とか Ruby とか一個一個書かなきゃ
いけないんだろうか。 javascript とかも難しそうだし・・・めんどくさい。
;; ------------------------------------------------------------------------
;; @ flymake で間違っているところをハイライトし、エラーとかをミニバッファへ
;; http://shnya.jp/blog/?category_name=emacs
;; http://d.hatena.ne.jp/khiker/20070630/emacs_ruby_flymake
;; http://d.hatena.ne.jp/khiker/20070720/emacs_flymake
;; http://d.hatena.ne.jp/nyaasan/20071216/p1
(require 'flymake)
;; miniBuffer にエラーを出力
(defun flymake-show-and-sit ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(progn
(let* ((line-no (flymake-current-line-no) )
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
(count (length line-err-info-list)))
(while (> count 0)
(when line-err-info-list
(let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
(full-file
(flymake-ler-full-file (nth (1- count) line-err-info-list)))
(text (flymake-ler-text (nth (1- count) line-err-info-list)))
(line (flymake-ler-line (nth (1- count) line-err-info-list))))
(message "[%s] %s" line text)))
(setq count (1- count)))))
(sit-for 60.0))
;; キー割り当て
(global-set-key "\M-gn" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-next-error)
(when (equal line (line-number-at-pos))
(next-error)))))
(global-set-key "\M-gp" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-prev-error)
(when (equal line (line-number-at-pos))
(previous-error)))))
(global-set-key "\C-cd" 'flymake-display-err-menu-for-current-line)
;; c での設定
(defun flymake-cc-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file))))
(push '("\\.cc$" flymake-cc-init) flymake-allowed-file-name-masks)
(add-hook 'c++-mode-hook
'(lambda ()
(flymake-mode t)))
;; ruby での設定
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns)
(add-hook
'ruby-mode-hook
'(lambda ()
;; Don't want flymake mode for ruby regions in rhtml files
(if (not (null buffer-file-name)) (flymake-mode))))
[QED]
*********************************************************************************
wget http://pypi.python.org/packages/source/p/pyflakes/pyflakes-0.4.0.tar.gz
tar xvzf pyflakes-0.4.0.tar.gz
cd pyflakes-0.4.0/
python setup.py install
で、 init.el は以下。よくわからないんだけど、 C とか Ruby とか一個一個書かなきゃ
いけないんだろうか。 javascript とかも難しそうだし・・・めんどくさい。
;; ------------------------------------------------------------------------
;; @ flymake で間違っているところをハイライトし、エラーとかをミニバッファへ
;; http://shnya.jp/blog/?category_name=emacs
;; http://d.hatena.ne.jp/khiker/20070630/emacs_ruby_flymake
;; http://d.hatena.ne.jp/khiker/20070720/emacs_flymake
;; http://d.hatena.ne.jp/nyaasan/20071216/p1
(require 'flymake)
;; miniBuffer にエラーを出力
(defun flymake-show-and-sit ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(progn
(let* ((line-no (flymake-current-line-no) )
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
(count (length line-err-info-list)))
(while (> count 0)
(when line-err-info-list
(let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
(full-file
(flymake-ler-full-file (nth (1- count) line-err-info-list)))
(text (flymake-ler-text (nth (1- count) line-err-info-list)))
(line (flymake-ler-line (nth (1- count) line-err-info-list))))
(message "[%s] %s" line text)))
(setq count (1- count)))))
(sit-for 60.0))
;; キー割り当て
(global-set-key "\M-gn" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-next-error)
(when (equal line (line-number-at-pos))
(next-error)))))
(global-set-key "\M-gp" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-prev-error)
(when (equal line (line-number-at-pos))
(previous-error)))))
(global-set-key "\C-cd" 'flymake-display-err-menu-for-current-line)
;; c での設定
(defun flymake-cc-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file))))
(push '("\\.cc$" flymake-cc-init) flymake-allowed-file-name-masks)
(add-hook 'c++-mode-hook
'(lambda ()
(flymake-mode t)))
;; ruby での設定
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns)
(add-hook
'ruby-mode-hook
'(lambda ()
;; Don't want flymake mode for ruby regions in rhtml files
(if (not (null buffer-file-name)) (flymake-mode))))
[QED]
*********************************************************************************
2011年5月14日
IronPython インストール
家のノートPC Windows 7 Home にインストールした。
]
何も難しいことは無かったが、とりあえず事始めなので、メモ
http://ironpython.codeplex.com/
にアクセス。Dowonloadsから、IronPython 2.7 Installer を選択。
msi 形式でくれる。バイナリもあるみたい。
そのまま、msi をインストール。
スタートメニューに登録もしてくれるので、コンソールを起動し、ハローワールド
print "Hello IronPython!"
ところで、コンソールにコピー&ペーストはできないのだろうか。
]
何も難しいことは無かったが、とりあえず事始めなので、メモ
http://ironpython.codeplex.com/
にアクセス。Dowonloadsから、IronPython 2.7 Installer を選択。
msi 形式でくれる。バイナリもあるみたい。
そのまま、msi をインストール。
スタートメニューに登録もしてくれるので、コンソールを起動し、ハローワールド
print "Hello IronPython!"
ところで、コンソールにコピー&ペーストはできないのだろうか。
登録:
投稿 (Atom)