[PYTHONMAC-SIG] New Python Mode for Alpha Editor

Tom Fetherston tomf59@sgi.net
Sun, 3 Nov 1996 03:31:06 -0500


Hello all!

I just downloaded the Python app and joined this list last week.  One of
the things I was interested to see was if anyone was using Alpha to edit
code and interact with Python.

I saw from the mailing-list archives that a few of you did but that no one
really knew Alpha well enough to write a good, customized mode for Python.

Well, I have been writing a Alpha mode for SuperCard, so I thought I
would take a crack at this.

I'am hoping to release a first version of this early this week.  If you are
interested, send me email and I will give you a copy of this when it is
ready.  Enclose any features that you might like to have and I'll see what
I can do.

Now, I still know practically no Python (most of the time has gone into
writing this mode :) ), and I may have some of the stuff wrong, so your
comments would be appreciated.

There is still a lot of enhancements that can be added once I know a little
more about Python.

Thanks to Rob Managan for providing the existing version of the Python mode
for Alpha that I used as a base.

Thanks also to Just van Rossum for his Python slave that allows python code
to be run via appleEvents.

To use this mode, you will need a copy of Alpha (current released version
is 6.5).  This is a shareware editor ($30).  A fully functional version of
it can be retrieved via links off Alpha's home page:

http://www.cs.umd.edu/~keleher/alpha.html

Below are some excerpts from the Python Mode Help File.  It lists most of
what I've got working (or hope to have working) in this first release.

Note: The Python mode will be freeware.

Sincerely,
Tom Fetherston
Pittsburgh, PA (USA)



########################
Python Support in Alpha
########################

Introduction
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

This document describes the use of the Python menu in Alpha.  The Python
menu was written to allow Alpha to act as a front end for Just's slave
Python application and to make it possible to "attach" Python scripts to
Alpha.  It provides a number of features designed to make the use and
development of Python scripts on the Mac more convenient.  These are
detailed in the rest of this document (most easily navigated using the "M"
menu on the sidebar), but here's a quick overview:

Editing Python scripts...

* Python keywords and special variables are colorized in Python mode.

* For entering code, this mode automatically detects colons that require
  indentation of the next line of code and does the indentation for you
  when you enter a return.  To facilitate "dedenting", "cmd-<return>" puts
  the next line out one level, while "opt->return>" brings you flush to
  the left margin.

* A Python "man page" is provided as an on-line reference, available as the
  file "Python Commands" in Alpha's Help menu; it has been colorized and
  indexed to make it easy to read and navigate.

* The man page can be referenced by command-double-clicking a highlighted
  Python keyword or other special words in your Python script.

Running Python Scripts...

* Python scripts can be run directly from Alpha - a script can be
  a text window in Alpha, a highlighted selection from a window, or a
  disk file.

Python Mode
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Python mode is entered automatically whenever you open a file with a ".py"
or ".pyc" suffix; you can also invoke it explicitly using the modes menu
pop-up in the status bar at the bottom of the screen.  Python mode offers a
number of features supporting the editing and debugging of Python scripts:

Basic language support
----------------------

* Python keywords are colored blue in Python mode.

* Comments are colored in a light brown.

* To enhance visibility, certain punctuation is shown in red.

* Double-quote enclosed strings are colored green. (note: Alpha is
  not able to detect and color the other types of strings)

* Whenever you save a python script with the keyboard shortcut, "cmnd-s",
  its end-of-line characters will be changed to those used on the Mac, and
  its creator will be set to "Pyth".

  Saving via the save command in the "File" menu does not apply the above
  changes.

* A single line or a selected block of lines may be commented out by
  using the "Comment Line" command under the "Text" menu.  Lines
  are uncommented using "Uncomment Line", which appears in the "Text"
  menu when the option key is held down.

* Alpha will create an index of all classes and def's in your Python script
  when you click the "{}" button on the sidebar.  This index is re-computed
  whenever you have made changes and click on the "{}" button.  The index
  is maintained in alphabetical order.

* Alpha will create an index of all classes and def's in your Python script
  when you select "Mark File" from the Marks menu on the sidebar (the "M"
  button).  The index is in the order of appearance.  Once created,
  whenever you save your file, this index is saved with it.

  When you open a Python script that hasn't already been "Mark-indexed", an
  index is automatically created.

* Both of the above indices indicate the number and kind of parameters
  that each "def" takes. These are shown within paren's, the symbols and
  what they represent are:
    "*" - regular parameter
    "=BF" - optional parameter that has a default value
    "=8A" - parameter that will "absorb" any additional arguments


Command-double-clicking (almost)
-----------------------

A simple form of hypertext help is invoked by double-clicking on
certain pieces of text while the command key is held down:

* The online man page can be referenced by command-double-clicking a
  highlighted Python keyword or special variable in your Python script.

  Most of the clickable keywords and variables will be colored blue.
  Special variables containing alphabetic characters, .e.g. @ARGV,
  are also clickable but are not colored.




=================
PYTHONMAC-SIG  - SIG on Python for the Apple Macintosh

send messages to: pythonmac-sig@python.org
administrivia to: pythonmac-sig-request@python.org
=================