By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,432 Members | 795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,432 IT Pros & Developers. It's quick & easy.

Python editing with emacs/wordstar key bindings.

P: n/a
Does anyone use emacs together with both WordStar key bindings and python
mode? I'm afraid that Wordstar editing key commands are burned R/O into my
knuckles!

I would like to play with emacs for Python editing but I'm having (2)
problems.

1) When I load a .py file, emacs automatically overrides my wordstar-mode
with python-mode, forcing all the keybindings back to emacs native keys.
Why?

Why should a python-mode care what key bindings are in use?

2) We get <tab> for block indentation instead of the spaces I prefer.

Is there a better python-mode script I should be using other than the
default that came with emacs?

Any tips/hints appreciated.
Thomas Bartkus
Apr 11 '06 #1
Share this Question
Share on Google+
12 Replies


P: n/a
"Thomas Bartkus" <th***********@comcast.net> writes:
[...]

1) When I load a .py file, emacs automatically overrides my wordstar-mode
with python-mode, forcing all the keybindings back to emacs native keys.
Why?

Why should a python-mode care what key bindings are in use?
No idea. Quite odd.

2) We get <tab> for block indentation instead of the spaces I prefer.
That's odd, I get four spaces unless I'm editing an existing file that
already uses some other convention, in which case python-mode is
usuall smart enough to figure that out. I don't use wordstar-mode.

Is there a better python-mode script I should be using other than the
default that came with emacs?


I assume you're using X/Emacs, then, rather than GNU Emacs?

IIRC, there's a separate sourceforge project for python-mode now, so
you could give that version a try.
John

Apr 12 '06 #2

P: n/a
"Thomas Bartkus" <th***********@comcast.net> writes:
[...]

1) When I load a .py file, emacs automatically overrides my wordstar-mode
with python-mode, forcing all the keybindings back to emacs native keys.
Why?

Why should a python-mode care what key bindings are in use?

2) We get <tab> for block indentation instead of the spaces I prefer.

[...]

Have you tried an emacs mailing list / newsgroup re these points? You
might get more help there...
John

Apr 12 '06 #3

P: n/a
Thomas Bartkus wrote:
Does anyone use emacs together with both WordStar key bindings and python
mode? I'm afraid that Wordstar editing key commands are burned R/O into my
knuckles!
Old Borland C user?

I would like to play with emacs for Python editing but I'm having (2)
problems.

1) When I load a .py file, emacs automatically overrides my wordstar-mode
with python-mode, forcing all the keybindings back to emacs native keys.
Why?

Why should a python-mode care what key bindings are in use?
Python and wordstar are both major modes. When python-mode is loaded,
it replaces (not sits atop of) wordstar-mode; you can't have two major
modes loaded at the same time.

If you want just want to use wordstar mode, you can prevent Emacs from
loading python mode by putting -*- mode: wordstar -*- on the first line
of the Python file (or second line if it uses a #!). Or, you could
remove python mode from the auto-mode-alist and interpreter-mode-alists
in your .emacs file, which I leave as an exercise.

2) We get <tab> for block indentation instead of the spaces I prefer.
In your .emacs file:

(setq indent-tabs-mode nil)

Is there a better python-mode script I should be using other than the
default that came with emacs?


I doubt there's one that solves your problem.
Carl Banks

Apr 13 '06 #4

P: n/a
"Carl Banks" <in**********@aerojockey.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Thomas Bartkus wrote:
Does anyone use emacs together with both WordStar key bindings and python mode? I'm afraid that Wordstar editing key commands are burned R/O into my knuckles!
Old Borland C user?


Worse than that! It starts with Wordstar itself on a terminal to cp/m.
It continued with Borland Pascal -> Delphi.

Wordstar key controls are the only key bindings that are ergonometric on a
qwerty keyboard. If you do serious typing, you don't break stride to issue
editing commands.
I would like to play with emacs for Python editing but I'm having (2)
problems.

1) When I load a .py file, emacs automatically overrides my wordstar-mode with python-mode, forcing all the keybindings back to emacs native keys.
Why?

Why should a python-mode care what key bindings are in use?


Python and wordstar are both major modes. When python-mode is loaded,
it replaces (not sits atop of) wordstar-mode; you can't have two major
modes loaded at the same time.

If you want just want to use wordstar mode, you can prevent Emacs from
loading python mode by putting -*- mode: wordstar -*- on the first line
of the Python file (or second line if it uses a #!). Or, you could
remove python mode from the auto-mode-alist and interpreter-mode-alists
in your .emacs file, which I leave as an exercise.


I do notice that I can invoke wordstar-mode *after* loading the .py file and
get the whole enchilada. The Wordstar key bindings with the syntax
highlighting.
It just strikes me as odd that key bindings should be reasserted by invoking
python-mode.

Perhaps python-mode shouldn't be an emacs "major mode".
We just want syntax highlighting and some minor formatting assist. Key
bindings have nothing to do with the language. I need to learn how to edit
the key re-assignment out of python-mode.el .
2) We get <tab> for block indentation instead of the spaces I prefer.


In your .emacs file:

(setq indent-tabs-mode nil)


Thank you. That helps
Is there a better python-mode script I should be using other than the
default that came with emacs?


I doubt there's one that solves your problem.


Yes.
The *real* problem here is that I need to get down and dirty with emacs/lisp
when all I started looking for was a more robust editor for Python ;-)
Carl Banks

Apr 13 '06 #5

P: n/a
>> When all I started looking for was a more robust editor for Python ;-)

Both WingIDE and Komodo Dragon allow for customization of keyboard
bindings. They aren't free, but they cost only $30.00 or so. Cheap for
what you get, especially in the case of Komodo because it makes a nice
editor for many languages--Perl, PHP, HTML etc.

I tried Xemacs several times over the years on Win XP. Something
usually breaks, and then--yes--you have to learn Lisp to fix it.

rpd

Apr 13 '06 #6

P: n/a
Thomas Bartkus wrote:
I do notice that I can invoke wordstar-mode *after* loading the .py file and
get the whole enchilada. The Wordstar key bindings with the syntax
highlighting.
It just strikes me as odd that key bindings should be reasserted by invoking
python-mode.


Ah--you're only thinking of syntax highlighting. Now it makes sense.

Try putting these lines in your .emacs:

(defun use-wordstar-for-python () (wordstar-mode))
(add-hook 'python-mode-hook 'use-wordstar-for-python)

There might be a "right" way to get syntax highlighting without setting
the major mode (if not, there ought to be), but this should do the
trick for you.
Carl Banks

Apr 13 '06 #7

P: n/a
"Carl Banks" <in**********@aerojockey.com> writes:
[...]
1) When I load a .py file, emacs automatically overrides my wordstar-mode
with python-mode, forcing all the keybindings back to emacs native keys.
Why? [...]
Python and wordstar are both major modes. When python-mode is loaded,
it replaces (not sits atop of) wordstar-mode; you can't have two major
modes loaded at the same time.


Oh, of course -- didn't occur to me that wordstar-mode might be a
major mode.

Thomas, why not simply use the standard emacs provisions for key
rebinding? Or are the wordstar keys modal or otherwise difficult to
implement that way, as is the case with vi bindings? (but viper does a
great job of that -- I'm using it right now)
[...] Is there a better python-mode script I should be using other than the
default that came with emacs?


I doubt there's one that solves your problem.


Carl is right: changing python-mode is the wrong end to approach this
problem. Change the keybindings instead.

Like I said, if you're stuck rebinding the keys, try one of the emacs
mailing lists / newsgroups. Thanks to the kind help of such people
I've been getting away with scandalously little knowledge of my own
..emacs for years, and only just now learning a little elisp. :-)
John

Apr 13 '06 #8

P: n/a
"BartlebyScrivener" <rp*******@gmail.com> writes:
When all I started looking for was a more robust editor for Python ;-)


Both WingIDE and Komodo Dragon allow for customization of keyboard
bindings. They aren't free, but they cost only $30.00 or so. Cheap for
what you get, especially in the case of Komodo because it makes a nice
editor for many languages--Perl, PHP, HTML etc.

I tried Xemacs several times over the years on Win XP. Something
usually breaks, and then--yes--you have to learn Lisp to fix it.


No, usually you just need to ask in one of (X)emacs groups/mailing
lists, and get a recipe in about a day, making it similar to learning to
use Python. And that drastically differs from trying to convince those $
companies to fix something for you ;)

-- Sergei.

Apr 14 '06 #9

P: n/a
Yes, but for some reason, I get more and better help here with Python
than on xemacs. Or maybe I've just had bad luck. Something like the
following just leaves me scratching my head. I'm on Windows XP and
never compiled anything that I know of. I'd rather pay $30 and have
the editor work.

"BartlebyScrivener" <rpdool...@gmail.com> writes:
I tried searching on this but I don't see exactly my error message.
When I open a php file for editing, I get: "file mode specification
error: (void-function run-mode-hooks)" What line do I need to add to my .init file to make this stop?


You are using .elc files compiled with a different version of Emacs.
Recompile them.

Apr 14 '06 #10

P: n/a
"BartlebyScrivener" <rp*******@gmail.com> writes:
Yes, but for some reason, I get more and better help here with Python
than on xemacs. Or maybe I've just had bad luck. Something like the
following just leaves me scratching my head. I'm on Windows XP and
never compiled anything that I know of. I'd rather pay $30 and have
the editor work.
Well, I'd pay too, but my experience is that no editor *always* works
for me, and ability to fix it (or fine-tune for my own needs) is indeed
essential for me. To the extreme that I'd rather learn some lisp to be
able to (and besides lisp being fun to learn) ;) That said, I do think
(X)emacs is not very suitable for casual user, but it starts to pay back
for investments put into it pretty soon.

BTW, what you've cited below sounds just like messed/broken Emacs
installation (maybe installing one version on top of another, or mixing
Emacs and XEmacs installations, or borrowing some files from separate
archives -- difficult to say exactly), as you normally don't need to
compile anything. Not to mention the fact that Windows is rather new
platform for emacsen, so quite a few OS-specific issues could well be
unresolved or simply be buggy indeed.

Well, I think we should better stop this as an OT anyway.

-- Sergei.

"BartlebyScrivener" <rpdool...@gmail.com> writes:
I tried searching on this but I don't see exactly my error message.
When I open a php file for editing, I get: "file mode specification
error: (void-function run-mode-hooks)"

What line do I need to add to my .init file to make this stop?


You are using .elc files compiled with a different version of Emacs.
Recompile them.

--
http://mail.python.org/mailman/listinfo/python-list


Apr 14 '06 #11

P: n/a
Yes, thanks. I was just going to reinstall anyway. That usually fixes
it.

Rick

Apr 14 '06 #12

P: n/a
This is new to me. I did not know that emacs HAD a word star mode.....
I may have to look at emacs again (last time was 1995).

I am still looking for a python editor I like. Yes I used to write asm
code in
wordstar in nondocument mode. And yes all of the old dos editors used
the wordstar keys. Everything by Borland used them.
Because of this I still use the 'joe' editor when I am on the command
line
and cooledit(with wstar like bindings) on X.
I like the features on other editors but I need my wstar keys.

Apr 14 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.