Re: [Python-mode] code/macros to reformat code
On Wed, May 11, 2011 at 12:20 AM, Andreas Röhler andreas.roeh...@online.de wrote: Am 11.05.2011 00:44, schrieb m h: Folks- I was wondering if anyone has some code floating around to reformat code after the code passes a certain column (say 79 or 80). What I'm looking for is reformatting long lines. I'd like to convert something like (assume the k of junk is around 78): my_string = foo bar baz ... junk stuff etc to: my_string = foo bar baz ... junk stuff etc Hi, assume your result must read: my_string = foo bar baz ... junk stuff etc The only way I see is transferring quotes into triple-quotes, in case py-fill-string takes action. Nope, my example meant what I wrote. I don't want the newlines that triple quoted strings would bring with it. I want to split up a longer than 80 (or what have you) string into multiple lines. cheers, -matt ___ Python-mode mailing list Python-mode@python.org http://mail.python.org/mailman/listinfo/python-mode
[Python-mode] code/macros to reformat code
Folks- I was wondering if anyone has some code floating around to reformat code after the code passes a certain column (say 79 or 80). What I'm looking for is reformatting long lines. I'd like to convert something like (assume the k of junk is around 78): my_string = foo bar baz ... junk stuff etc to: my_string = foo bar baz ... junk stuff etc My searches have turned up nothing, but I'm assuming someone has something. cheers, -matt ___ Python-mode mailing list Python-mode@python.org http://mail.python.org/mailman/listinfo/python-mode
Re: [Python-mode] running Python tests
On Tue, Mar 15, 2011 at 6:48 AM, Yaroslav Halchenko li...@onerussian.com wrote: Hi Andreas, Thank you for the invitation -- unfortunately I am already overloaded with other projects so would not be able to provide adequate time to python-mode. Moreover my elisp knowledge is quite basic :-/ FWIW I use python-mode together with rope to get me some quick navigation facilities (haven't actually used it for refactoring ;) ) Pymacs seems broken. The emacs-for-python and emacs-starter-kit at https://github.com/gabrielelanaro/ both seem to have good rope support out of the box and were working with python-mode.el. (I'm trying out the new python.el and it works that too). -matt ___ Python-mode mailing list Python-mode@python.org http://mail.python.org/mailman/listinfo/python-mode
Re: [Python-mode] Hey
On Tue, Mar 16, 2010 at 2:55 PM, Barry Warsaw ba...@python.org wrote: On Mar 16, 2010, at 09:39 AM, m h wrote: On this note, it might be nice to create a wiki page (python.el vs python-mode.el) elaborating the different features found in each Like this one: http://www.emacswiki.org/emacs/PythonMode Could use lots of clean up though. Well, that one could use some work too. My thought was to have a page that just lists a table with rows for features and 2 columns, python.el and python-mode.el. Then below perhaps some discussion about why one would use one versus the other. When new people come to the python/emacs world it is confusing (to say the least that there are two modes), and there isn't anywhere that explains the features of both. The page you point isn't really python mode specific anymore. It is more of using Python and emacs together for various features (some of which are in python(-mode).el, and some aren't). -matt ___ Python-mode mailing list Python-mode@python.org http://mail.python.org/mailman/listinfo/python-mode
Re: [Python-mode] making stack traces clickable in gud.el pdb output.
Hey all- I got my original wish, compile-mode error navigation through the python stack trace of a unittest failure. Thanks to Gerard B for the hint. I'm doing this from pdbtrack (shell) instead of pure pdb, but it should work in both I believe. You need to enable compilation-shell-minor-mode. And have the following code in your .emacs: ;; if compilation-shell-minor-mode is on, then these regexes ;; will make errors linkable (defun matt-add-global-compilation-errors (list) (dolist (x list) (add-to-list 'compilation-error-regexp-alist (car x)) (setq compilation-error-regexp-alist-alist (cons x (assq-delete-all (car x) compilation-error-regexp-alist-alist) (matt-add-global-compilation-errors `( (matt-python ,(concat ^ *File \\(\?\\)\\([^,\ \n]+\\)\\1 , lines? \\([0-9]+\\)-?\\([0-9]+\\)?) 2 (3 . 4) nil 2 2) (matt-pdb-stack ,(concat ^?[[:space:]]*\\(\\([-_./a-zA-Z0-9 ]+\\) (\\([0-9]+\\))\\) [_a-zA-Z0-9]+()[[:space:]]*-) 2 3 nil 0 1) (matt-python-unittest-err ^ File \\\([-_./a-zA-Z0-9 ]+\\)\, line \\([0-9]+\\).* 1 2) ) ) (defun matt-set-local-compilation-errors (errors) Set the buffer local compilation errors. Ensures than any symbols given are defined in compilation-error-regexp-alist-alist. (dolist (e errors) (when (symbolp e) (unless (assoc e compilation-error-regexp-alist-alist) (error (concat Error %s is not listed in compilation-error-regexp-alist-alist) e (set (make-local-variable 'compilation-error-regexp-alist) errors)) Then you can use standard compile mode navigation to zip through the error stack trace. cheers, -matt ___ Python-mode mailing list Python-mode@python.org http://mail.python.org/mailman/listinfo/python-mode
Re: [Python-mode] making stack traces clickable in gud.el pdb output.
On Tue, Jan 19, 2010 at 7:28 AM, Barry Warsaw ba...@python.org wrote: On Jan 18, 2010, at 06:27 PM, m h wrote: I'm using pdb (from gud.el) with emacs, which is working pretty good. I've got two gripes. * After I run pdb on a testfile, the point goes to the top of the buffer * I'd like to be able to click on files in the stacktrace (on unittest failures) and have emacs open the buffer to the correct line I figure if I can fix the later 80% of the other issues are covered. Any pointers or tips are greatly appreciated. I've searched gud.el for alist and find-file, but alas my elisp is not quite up to snuff to tell if this is actually supported. I'm afraid I can't help much. I generally use pdb-track instead of gud, and haven't really noticed any problems. Wow, didn't you add python support to gud? Would you (or anyone else) care to mention their workflow? I've just been trying to get python-mode C-c C-c to allow me to use pdb. But I get an error: stdin(181)_test() (Pdb) Traceback (most recent call last): File stdin, line 186, in module File stdin, line 181, in _test File stdin, line 181, in _test File /usr/lib64/python2.6/bdb.py, line 46, in trace_dispatch return self.dispatch_line(frame) File /usr/lib64/python2.6/bdb.py, line 65, in dispatch_line if self.quitting: raise BdbQuit bdb.BdbQuit How do I invoke pdbtrack from python-mode? I usually have unittests or doctests for my modules, when I've got problems I like to step through, so I insert a 'import pdb; pdb.set_trace' and run through M-x pdb. I'd be interested in what others are doing. -matt ___ Python-mode mailing list Python-mode@python.org http://mail.python.org/mailman/listinfo/python-mode
Re: [Python-mode] making stack traces clickable in gud.el pdb output.
Thanks much for the responses! On Tue, Jan 19, 2010 at 2:25 PM, Barry Warsaw ba...@python.org wrote: On Jan 19, 2010, at 12:18 PM, m h wrote: Wow, didn't you add python support to gud? If I did, it was a million years ago and I don't remember it ;). :) Would you (or anyone else) care to mention their workflow? I've just been trying to get python-mode C-c C-c to allow me to use pdb. But I get an error: stdin(181)_test() (Pdb) Traceback (most recent call last): File stdin, line 186, in module File stdin, line 181, in _test File stdin, line 181, in _test File /usr/lib64/python2.6/bdb.py, line 46, in trace_dispatch return self.dispatch_line(frame) File /usr/lib64/python2.6/bdb.py, line 65, in dispatch_line if self.quitting: raise BdbQuit bdb.BdbQuit How do I invoke pdbtrack from python-mode? It's really easy. You still insert 'import pdb; pdb.set_trace()' at the spot in your code where you want to break. Then run your code from a shell buffer. When you hit the break point, you'll drop into pdb. pdb-track will notice the new prompt and you'll be able to interact with it right there. You'll use pdb commands but you'll get the nice two-screen view with code tracking. So just to be explicit about what 'run your code from a shell buffer'. I tried: 1- C-c ! 2- type `execfile('filename.py')` into python shell 3- hit breakpoint/nirvana Is that how you do it, or is there another way? It'd be nice not to have to type out part 2. Right now I have a macro bound to f-11 that re-runs my last pdb command. I guess M-p (like ctr-p in terminal) works ok too in that it scrolls through the command histories. So that get's rid of one of my problems (gud/pdb scrolls buffer to top). Anyway to make it recognize files and make them clickable in the python shell? cheers- -matt -matt ___ Python-mode mailing list Python-mode@python.org http://mail.python.org/mailman/listinfo/python-mode
Re: [Python-mode] making stack traces clickable in gud.el pdb output.
(forgot to reply to list) On Tue, Jan 19, 2010 at 4:36 PM, Barry Warsaw ba...@python.org wrote: On Jan 19, 2010, at 03:06 PM, m h wrote: So just to be explicit about what 'run your code from a shell buffer'. I tried: 1- C-c ! 2- type `execfile('filename.py')` into python shell 3- hit breakpoint/nirvana Actually, no! Seriously, run it in a shell buffer. :) M-x shell RET % python filename.py hit breakpoint/nirvana I was using M-x ansi-shell It worked in M-x shell. Thanks. :) Is that how you do it, or is there another way? It'd be nice not to have to type out part 2. Right now I have a macro bound to f-11 that re-runs my last pdb command. I guess M-p (like ctr-p in terminal) works ok too in that it scrolls through the command histories. So that get's rid of one of my problems (gud/pdb scrolls buffer to top). Anyway to make it recognize files and make them clickable in the python shell? clickable? Is that like using that mouse thing? To paraphrase a wise man, There's no clicking in Emacs! :) ;) Yeah, I'm trying to avoid that bad habit of 'clicking'. ok, how about 'hyperlinkable'? I've got an ack.el extension that searches for files, in it's buffer you can move the cursor over the file (with the keyboard!) and hit enter and it will pop you to that file/linum. -matt ___ Python-mode mailing list Python-mode@python.org http://mail.python.org/mailman/listinfo/python-mode