Python editing with emacs/wordstar key bindings.

T

Thomas Bartkus

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
 
J

John J. Lee

Thomas Bartkus said:
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
 
J

John J. Lee

Thomas Bartkus said:
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
 
C

Carl Banks

Thomas said:
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
 
T

Thomas Bartkus

Carl Banks said:
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.
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 .
In your .emacs file:

(setq indent-tabs-mode nil)

Thank you. That helps
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 ;-)
 
B

BartlebyScrivener

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
 
J

John J. Lee

Carl Banks said:
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)


[...]
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
 
C

Carl Banks

Thomas said:
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
 
S

Sergei Organov

BartlebyScrivener said:
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.
 
B

BartlebyScrivener

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 said:
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.
 
S

Sergei Organov

BartlebyScrivener said:
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.
 
B

BartlebyScrivener

Yes, thanks. I was just going to reinstall anyway. That usually fixes
it.

Rick
 
G

garylinux

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top