[Python-mode] bug with shipped pymacs? was: what to (not) use with python-mode?
Tom Roche
Tom_Roche at pobox.com
Sun Oct 9 23:21:33 CEST 2011
summary: something is wrong with the pymacs I installed with
python-mode=6.0.3, or with my installation or use of it. Let me know if
I need to do something different, or file a bug, or both, or neither.
details:
Andreas Röhler Sun, 09 Oct 2011 08:23:07 +0200
> [does] Pymacs work still?
Doh! Obviously I should have tested that. For instructions in testing
pymacs, I went to
http://pymacs.progiciels-bpi.ca/pymacs.html#installation
>> 2.5 Prepare your .emacs file
>> The .emacs file [needs] these lines:
>> (autoload 'pymacs-apply "pymacs")
>> (autoload 'pymacs-call "pymacs")
>> (autoload 'pymacs-eval "pymacs" nil t)
>> (autoload 'pymacs-exec "pymacs" nil t)
>> (autoload 'pymacs-load "pymacs" nil t)
>> ;;(eval-after-load "pymacs"
>> ;; '(add-to-list 'pymacs-load-path YOUR-PYMACS-DIRECTORY"))
>> If you plan to use a special directory to hold your own Pymacs code
>> in Python, which should be searched prior to the usual Python
>> import search path, then uncomment the last two lines (by removing
>> the semi-colons) and replace YOUR-PYMACS-DIRECTORY by the name of
>> your special directory. [...]
>> To check [your install], start a fresh Emacs session, and type
>> M-x pymacs-eval
>> Emacs should prompt you for a Python expression.
It did not. So I restored some lines to my tlrPython.el (which is
loaded by my init.el), producing
tlrPython.el
> (defconst LOCAL-PYTHON-LISP-DIR (concat LOCAL-EMACS-LISP-DIR "/python"))
> (defconst PYTHON-MODE-DIR (concat LOCAL-PYTHON-LISP-DIR "/python-mode"))
> (defconst PYMACS-DIR (concat PYTHON-MODE-DIR "/pymacs"))
> (defconst PYLOOKUP-DIR (concat LOCAL-PYTHON-LISP-DIR "/pylookup"))
> (setq load-path
> (append
> (list
> LOCAL-PYTHON-LISP-DIR
> PYTHON-MODE-DIR
> PYMACS-DIR
> PYLOOKUP-DIR
> )
> load-path)
> ) ; end (setq load-path
>
> ;;; python-mode: https://launchpad.net/python-mode
> (require 'python-mode)
> (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
>
> ; no longer needed with python-mode >= 6.0.3
> ; (require 'ipython)
>
> ;; pymacs
> (autoload 'pymacs-apply "pymacs")
> (autoload 'pymacs-call "pymacs")
> (autoload 'pymacs-eval "pymacs" nil t)
> (autoload 'pymacs-exec "pymacs" nil t)
> (autoload 'pymacs-load "pymacs" nil t)
> ;; (pymacs-load "ropemacs" "rope-")
> ;; (setq ropemacs-enable-autoimport t)
>
> (require 'comint)
> (define-key comint-mode-map (kbd "M-") 'comint-next-input)
> (define-key comint-mode-map (kbd "M-") 'comint-previous-input)
> (define-key comint-mode-map [down] 'comint-next-matching-input-from-input)
> (define-key comint-mode-map [up] 'comint-previous-matching-input-from-input)
>
> ;;; pylookup: http://taesoo.org/Opensource/Pylookup
> ;;; following from pylookup-dir/README
> (setq pylookup-dir (concat LOCAL-PYTHON-LISP-DIR "/pylookup"))
> ; (add-to-list 'load-path pylookup-dir) ; done above
> ;; load pylookup @ compile time
> (eval-when-compile (require 'pylookup))
> ;; set executable file and db file
> (setq pylookup-program (concat pylookup-dir "/pylookup.py"))
> (setq pylookup-db-file (concat pylookup-dir "/pylookup.db"))
> ;; to speedup, just load it on demand
> (autoload 'pylookup-lookup "pylookup"
> "Lookup SEARCH-TERM in the Python HTML indexes." t)
> (autoload 'pylookup-update "pylookup"
> "Run pylookup-update and create the database at `pylookup-db-file'." t)
> (global-set-key "\C-ch" 'pylookup-lookup)
> ;;; to update offline, see pylookup-dir/README)
>
> ;;; autopair: http://code.google.com/p/autopair/
> (autoload 'autopair-global-mode "autopair" nil t)
> (autopair-global-mode)
> (add-hook 'lisp-mode-hook
> #'(lambda () (setq autopair-dont-activate t)))
> (add-hook 'python-mode-hook
> #'(lambda ()
> (push '(?' . ?')
> (getf autopair-extra-pairs :code))
> (setq autopair-handle-action-fns
> (list #'autopair-default-handle-action
> #'autopair-python-triple-quote-action))))
>
> ;; $ sudo aptitude install pylint pep8
> (require 'python-pep8)
> (require 'python-pylint)
>
> ;;; yasnippet: http://code.google.com/p/yasnippet/
> (require 'yasnippet-bundle)
> (yas/initialize)
> (yas/load-directory (concat LOCAL-PYTHON-LISP-DIR "/my-snippets/"))
>
> ;;; nose support (for testing): see
> ;;; LOCAL-PYTHON-LISP-DIR/nose.el
> ;;; from
> ;;; https://bitbucket.org/jpellerin/nosemacs/src/0192bf439dc9/nose.el
> (require 'nose)
> ;;; to enable searching for test cases in current directory, `touch setup.py` there (e.g. with `M-x eshell`)
> ;;; following fails as of 29 Jul 11 01:17:03 PM: see
> ;;; https://bitbucket.org/jpellerin/nosemacs/issue/2/adding-py-to-nose-project-root-files-fails
> ;(add-to-list 'nose-project-root-files ".py")
> ;;; default keybindings from nose.el
> (add-hook 'python-mode-hook
> (lambda ()
> (local-set-key "\C-ca" 'nosetests-all)
> (local-set-key "\C-cm" 'nosetests-module)
> (local-set-key "\C-c." 'nosetests-one)
> (local-set-key "\C-cpa" 'nosetests-pdb-all)
> (local-set-key "\C-cpm" 'nosetests-pdb-module)
> (local-set-key "\C-cp." 'nosetests-pdb-one)))
byte-compile-file, and restarted emacs. I then was able to do
M-x pymacs-eval
and got prompt="Python expression?" at which I tried
>> repr(2L**111) RET ([or] repr(2**111) RET if you are using Python 3).
>> The mini buffer should display
>> "2596148429267413814265248164610048L"
>> ([or 2596148429267413814265248164610048] in Python 3).
It did not. Instead I got
*Backtrace*
> Debugger entered--Lisp error: (error "Pymacs Lisp version is @VERSION@, Python is 0.24-beta2")
> signal(error ("Pymacs Lisp version is @VERSION@, Python is 0.24-beta2"))
> pymacs-report-error("Pymacs Lisp version is @VERSION@, Python is %s" "0.24-beta2")
> pymacs-start-services()
> pymacs-serve-until-reply("eval" (princ "repr(2L**111)"))
> pymacs-eval("repr(2L**111)")
> call-interactively(pymacs-eval t nil)
> execute-extended-command(nil)
> call-interactively(execute-extended-command nil nil)
Note that error message is broken in at least 2 ways, since
$ python --version
Python 2.7.2 -- EPD 7.1-2 (64-bit)
and it is pymacs that has version=0.24-beta2. Fortunately I still have
a previously-installed working pymacs, so I changed one line in my
tlrPython.el to point to that
- (defconst PYMACS-DIR (concat PYTHON-MODE-DIR "/pymacs"))
+ (defconst PYMACS-DIR (concat LOCAL-PYTHON-LISP-DIR "/pymacs"))
byte-compile-file, and restarted emacs. I then was able to do
M-x pymacs-eval
and got prompt="Python expression?" at which I entered
repr(2L**111)
and got the expected result
"2596148429267413814265248164610048L"
in the minibuffer. So ISTM something is wrong; please advise.
HTH, Tom Roche <Tom_Roche at pobox.com>
More information about the Python-mode
mailing list