Python editing with emacs/wordstar key bindings.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Bartkus

    #1

    Python editing with emacs/wordstar key bindings.

    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


  • John J. Lee

    #2
    Re: Python editing with emacs/wordstar key bindings.

    "Thomas Bartkus" <thomasbartkus@ comcast.net> writes:
    [...][color=blue]
    >
    > 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?[/color]

    No idea. Quite odd.

    [color=blue]
    > 2) We get <tab> for block indentation instead of the spaces I prefer.[/color]

    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.

    [color=blue]
    > Is there a better python-mode script I should be using other than the
    > default that came with emacs?[/color]

    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

    Comment

    • John J. Lee

      #3
      Re: Python editing with emacs/wordstar key bindings.

      "Thomas Bartkus" <thomasbartkus@ comcast.net> writes:
      [...][color=blue]
      >
      > 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.[/color]
      [...]

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


      John

      Comment

      • Carl Banks

        #4
        Re: Python editing with emacs/wordstar key bindings.

        Thomas Bartkus wrote:[color=blue]
        > 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![/color]

        Old Borland C user?

        [color=blue]
        > 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?[/color]

        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.

        [color=blue]
        > 2) We get <tab> for block indentation instead of the spaces I prefer.[/color]

        In your .emacs file:

        (setq indent-tabs-mode nil)

        [color=blue]
        > Is there a better python-mode script I should be using other than the
        > default that came with emacs?[/color]

        I doubt there's one that solves your problem.


        Carl Banks

        Comment

        • Thomas Bartkus

          #5
          Re: Python editing with emacs/wordstar key bindings.

          "Carl Banks" <invalidemail@a erojockey.com> wrote in message
          news:1144887253 .027194.198750@ i39g2000cwa.goo glegroups.com.. .[color=blue]
          > Thomas Bartkus wrote:[color=green]
          > > Does anyone use emacs together with both WordStar key bindings and[/color][/color]
          python[color=blue][color=green]
          > > mode? I'm afraid that Wordstar editing key commands are burned R/O into[/color][/color]
          my[color=blue][color=green]
          > > knuckles![/color]
          >
          > Old Borland C user?[/color]

          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.
          [color=blue][color=green]
          > > 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[/color][/color]
          wordstar-mode[color=blue][color=green]
          > > 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?[/color]
          >
          > 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.[/color]

          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 .
          [color=blue][color=green]
          > > 2) We get <tab> for block indentation instead of the spaces I prefer.[/color]
          >
          > In your .emacs file:
          >
          > (setq indent-tabs-mode nil)[/color]

          Thank you. That helps
          [color=blue][color=green]
          > > Is there a better python-mode script I should be using other than the
          > > default that came with emacs?[/color]
          >
          > I doubt there's one that solves your problem.[/color]

          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 ;-)
          [color=blue]
          > Carl Banks
          >[/color]


          Comment

          • BartlebyScrivener

            #6
            Re: Python editing with emacs/wordstar key bindings.

            >> 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

            Comment

            • Carl Banks

              #7
              Re: Python editing with emacs/wordstar key bindings.

              Thomas Bartkus wrote:[color=blue]
              > 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.[/color]

              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

              Comment

              • John J. Lee

                #8
                Re: Python editing with emacs/wordstar key bindings.

                "Carl Banks" <invalidemail@a erojockey.com> writes:
                [...][color=blue][color=green]
                > > 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?[/color][/color]
                [...][color=blue]
                > 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.[/color]

                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)


                [...][color=blue][color=green]
                > > Is there a better python-mode script I should be using other than the
                > > default that came with emacs?[/color]
                >
                > I doubt there's one that solves your problem.[/color]

                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

                Comment

                • Sergei Organov

                  #9
                  Re: Python editing with emacs/wordstar key bindings.

                  "BartlebyScrive ner" <rpdooling@gmai l.com> writes:[color=blue][color=green][color=darkred]
                  >>> When all I started looking for was a more robust editor for Python ;-)[/color][/color]
                  >
                  > 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.[/color]

                  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.

                  Comment

                  • BartlebyScrivener

                    #10
                    Re: Python editing with emacs/wordstar key bindings.

                    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.

                    "BartlebyScrive ner" <rpdool...@gmai l.com> writes:[color=blue]
                    > 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)"[/color]
                    [color=blue]
                    > What line do I need to add to my .init file to make this stop?[/color]

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

                    Comment

                    • Sergei Organov

                      #11
                      Re: Python editing with emacs/wordstar key bindings.

                      "BartlebyScrive ner" <rpdooling@gmai l.com> writes:[color=blue]
                      > 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.[/color]

                      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.
                      [color=blue]
                      >
                      > "BartlebyScrive ner" <rpdool...@gmai l.com> writes:[color=green]
                      >> 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)"[/color]
                      >[color=green]
                      >> What line do I need to add to my .init file to make this stop?[/color]
                      >
                      > You are using .elc files compiled with a different version of Emacs.
                      > Recompile them.
                      >
                      > --
                      > http://mail.python.org/mailman/listinfo/python-list[/color]

                      Comment

                      • BartlebyScrivener

                        #12
                        Re: Python editing with emacs/wordstar key bindings.

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

                        Rick

                        Comment

                        • garylinux@gmail.com

                          #13
                          Re: Python editing with emacs/wordstar key bindings.

                          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.

                          Comment

                          Working...