Quantcast

what to (not) use with python-mode?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

what to (not) use with python-mode?

Tom Roche

python-mode now

* contains pymacs
* does what helpers like the 'ipython' package did (i.e., run `ipython` in an emacs buffer)

and probably more of which I'm not aware. So it's time to clean up my emacs-python configuration, i.e., the file I load from my init.el containing python-related instructions. It now has

tlrPython.el

> (defconst LOCAL-PYTHON-LISP-DIR (concat LOCAL-EMACS-LISP-DIR "/python"))
> (defconst PYTHON-MODE-DIR (concat LOCAL-PYTHON-LISP-DIR "/python-mode"))
> (setq load-path
>   (append
>     (list
>       LOCAL-PYTHON-LISP-DIR
>       PYTHON-MODE-DIR
> ; no longer needed with python-mode >= 6.0.3
> ;      (concat LOCAL-PYTHON-LISP-DIR "/pymacs")
>       (concat LOCAL-PYTHON-LISP-DIR "/pylookup")
>     )
>   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)

> ; no longer needed with python-mode >= 6.0.3
> ; ;; 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
> ;; The following NEW packages will be installed:
> ;; blt{a} pep8 pylint python-logilab-astng{a} python-logilab-common{a} python-tk{a} tcl8.5{a} tk8.5{a}
> ;; 0 packages upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
> ;; Need to get 5,797kB of archives. After unpacking 28.0MB will be used.
> (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)))

Has python-mode made any of the above superfluous?

Are there better settings for any of the above?

Also, if there's anything you currently use with emacs when writing python that you'd care to recommend, please do.

TIA, Tom Roche <[hidden email]>
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: what to (not) use with python-mode?

Andreas Röhler-2
[ ... ]

Hi Tom,

pasted your questions onto the Blueprint
https://blueprints.launchpad.net/python-mode/+spec/python-mode-pymacs

so it don't get lost.

BTW we just started delivering Pymacs.

It might help if you check one by one how far the requirements are
served already resp. not - please send bug-reports in the latter case.

Thanks,

Andreas
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: what to (not) use with python-mode?

Tom Roche

Andreas Röhler Fri, 07 Oct 2011 19:53:00 +0200
> BTW we just started delivering Pymacs.

This is good. (Hoffentlich :-)

> It might help if you check one by one how far the requirements are
> served already

Perhaps I should know this, but, since I don't: where are the requirements listed?
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: what to (not) use with python-mode?

Andreas Röhler-2
Am 09.10.2011 05:27, schrieb Tom Roche:

>
> Andreas Röhler Fri, 07 Oct 2011 19:53:00 +0200
>> BTW we just started delivering Pymacs.
>
> This is good. (Hoffentlich :-)
>
>> It might help if you check one by one how far the requirements are
>> served already
>
> Perhaps I should know this, but, since I don't: where are the requirements listed?
> _______________________________________________

meant: if you remove your init done so far, will Pymacs work still?

Andreas
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bug with shipped pymacs? was: what to (not) use with python-mode?

Tom Roche

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 <[hidden email]>
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: bug with shipped pymacs?

François Pinard
Tom Roche <[hidden email]> writes:

> summary: something is wrong with the pymacs I installed with
> python-mode=6.0.3, or with my installation or use of it.

>> Debugger entered--Lisp error: (error "Pymacs Lisp version is
>> @VERSION@, Python is 0.24-beta2")

Hi, Tom.

The pymacs.el file was likely copied verbatim, out of pymacs.el.in from
the Pymacs distribution.  The ".in" suffix is a hint that the file needs
processing before "becoming" the usable file.  The problem may be there!

There is a Makefile in the distribution that takes care of these things,
and the installation documentation tries to stress that one should
either run "make" or at least do the equivalent by other means.

I would surely like that python-mode use Pymacs in a more solid way, and
just not try to "patch it" in.  Don't hesitate to use me, if I can
help.  If you do not thrown bug trackers at me, I'm quite speakable! :-)

François

P.S. - Who should nevertheless warn you that I may be a bit slow at
replying, surely not because of bad will, but as I miss free time.
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Loading...