Shop OBEX P1 Docs P2 Docs Learn Events
Emacs Propeller mode available — Parallax Forums

Emacs Propeller mode available

proplemproplem Posts: 233
edited 2011-06-15 13:02 in Propeller 1
Hello every one,

after hours of hacking i may proudly present:

prop-mode.el.7z

my contribution to the propeller and Emacs community.

Bildschirmfoto-feuerwehr.spin-1.png


Certainly not ready for sale (it's GPL, and i copied and stole the knowledge in the internet) but already useful. I don't use another IDE as i don't use another microcontroller.

0. preconditions

  • use Emacs 23 because of the Parallax Truetype font and the newly integrated function serial-term which i'm planning to use in future
  • the Parallax font should be installed (HOWTO: google for it)
  • prop-mode depends on BradC's bstc.linux. Without his work this mode wouldn't be useful! Thanks BradC.
  • I made the following symbolic links in /usr/local/bin
    bstc -> bstc.linux
    bstl -> bstl.linux (currently not used)
  • prop-mode.el was developed and tested under Debian Squeeze (6.0)


1. put prop-mode.el in a path so that emacs may find it
C-x C-f prop-mode.el <enter>
M-x emacs-lisp-byte-compile-and-load <enter>
2. Put this in your .emacs:
(load "prop-mode")
3. within emacs
 C-x C-f <any spin file you like>
4. now prop-mode should be activated and you see a relatively poor syntax highlighting

5. useful prop-mode/Emacs commands
C-c c prop-compile
C-c e prop-compile-and-load-EEPROM
C-c r prop-compile-and-load-RAM

With C-h f <command-name> you get a little help

C-h m shows additional help to prop-mode
6. important hints

  • There is an automatically created buffer "*Propeller Compile*" with compilation output of bstc.
    I prefer to open a new frame with C-x 5 2 in which i select (C-x b *Prop<tab>) to permanently view what's happening in that buffer.
  • one has to save (C-x C-s) before compiling. I didn't automate that yet.
  • /dev/ttyUSB0 is currently hardcoded in prop-mode.el
  • i didn't test prop-mode.el on Windows yet.


7. Thanks

  • Without his knowledge BradC delivered an important contribution to prop-mode.el. I hope he is not angry for this new propeller-IDE offending his cool bst. I love Emacs and i wanted bring together what is belonging together: Propeller and Emacs.
    BradC: RESPECT for your work and many, many thanks. I admire your productivity.
  • Thanks to all the anonymous people in the internet which contributed the foundation for prop-mode.el
  • Thanks to the Emacs community
  • Thanks to Ariba for posting PropTerminal_Linux which works fine on Debian squeeze
  • Thanks to ErNa who led me to propeller, software, electronics and many other things that enriched my life in the last 22 years.

Comments

  • johnfosjohnfos Posts: 59
    edited 2011-04-27 13:19
    proplem:

    Well, for your first post here you've certainly hit the ground running!

    HUGE thanks for that. It's exactly what I've been looking for. I spent some time trying to produce such a thing myself, but my lisp/emacs skills are much too low and I didn't get very far at all.

    Your version works fine in my setup (Fedora 11 with emacs 23.1.1) and your instructions led to a flawless installation. The lengthiest part was finding a 7-zip decoder :-)

    I did get one warning when building the file:

    Compiling file /home/john/elisp/prop-mode.el at Wed Apr 27 20:30:07 2011
    Entering directory `/home/john/elisp/'

    In prop-mode-face-activate:
    prop-mode.el:358:10:Warning: assignment to free variable
    `buffer-face-mode-face'

    Doesn't seem to have done any harm though.

    Of course, there's always a downside to posting things like this: people like me come straight back with wish lists :-(

    1. I'd like to adjust the font size to be a little larger. I can't see anything in the .el file that explicitly sets the size - do you have any suggestions as to how to do that?

    2. Using the tab key, the indentation seems to increase by steps that are not of equal size. It'd be very convenient if the steps could be made equal.

    Thanks again for a brilliant piece of work. It's now part of my standard setup.
  • Heater.Heater. Posts: 21,230
    edited 2011-04-27 22:15
    Brilliant!

    Welcome to the forum and a big thank you for that.

    Just so that no one is left out don't forget there is Spin syntax highlighting for vim here http://forums.parallax.com/showthread.php?118328-Spin-syntax-definition-for-Vim:)
  • proplemproplem Posts: 233
    edited 2011-04-28 13:12
    johnfos wrote: »
    proplem:

    Well, for your first post here you've certainly hit the ground running!

    HUGE thanks for that. It's exactly what I've been looking for. I spent some time trying to produce such a thing myself, but my lisp/emacs skills are much too low and I didn't get very far at all.

    Your version works fine in my setup (Fedora 11 with emacs 23.1.1) and your instructions led to a flawless installation. The lengthiest part was finding a 7-zip decoder :-)

    I did get one warning when building the file:

    Compiling file /home/john/elisp/prop-mode.el at Wed Apr 27 20:30:07 2011
    Entering directory `/home/john/elisp/'

    In prop-mode-face-activate:
    prop-mode.el:358:10:Warning: assignment to free variable
    `buffer-face-mode-face'

    Doesn't seem to have done any harm though.

    Of course, there's always a downside to posting things like this: people like me come straight back with wish lists :-(

    1. I'd like to adjust the font size to be a little larger. I can't see anything in the .el file that explicitly sets the size - do you have any suggestions as to how to do that?

    2. Using the tab key, the indentation seems to increase by steps that are not of equal size. It'd be very convenient if the steps could be made equal.

    Thanks again for a brilliant piece of work. It's now part of my standard setup.

    johnfos,

    i am happy to hear that you're going to add it to your standard setup. That's what i wanted.

    Though your wish list isn't very long, i can't improve prop-mode as i would like to do - job, family and so on, but my goal is continuous improvement of prop-mode in longer terms.

    Some words to your issues:

    The warning is reproducable, i know of it, a fix will follow.

    To 1:
    In emacs23 you can increase and decrease font size with S-<left mouse button> or C-x C-+? Try both. There'll appear a popup menu with appropriate selections.
    In prop-mode.el search C-s Parallax. At some place the fontset is selected in a line similar to
    ... :family "Parallax" 
    
    Here is the right place to insert a font size, i don't know it either. I do not have the code in front of me. In future may be this will be a customizable setting. You might find some hints in the internet how this is to be done.

    I'm no native lisp speaker, and it was a lot of try and error necessary to implement prop-mode :-)

    To 2:
    Yes indentation is currently problematic. It will be solved as fast as possible. Patience:-)
    There's is workaround: If i was confused about indentation, i marked tho whole buffer C-x h and M-x untabify. So any tabs are replaced by spaces. Another way is using whitespace.el. It works quite sufficient.

    A tip aside:
    There is one function i found out by accident after years of using emacs: M-/ it's auto completion. Mode independent, it tries to complete by accessing possibilities in all open buffers.

    Regards,
    proplem
  • johnfosjohnfos Posts: 59
    edited 2011-04-29 11:49
    proplem,

    Many thanks for that helpful reply.

    I promise to be patient :-)

    Meanwhile, exploring your tip on the font size, I added one line to the prop-mode-face-activate function (the text-scale-adjust line, which is what the command C-X C-+ translates to):
    (defun prop-mode-face-activate ()
       "Set font to a variable width (proportional) fonts in current buffer"
       (interactive)
       (setq buffer-face-mode-face '(:family "Parallax"))
       (text-scale-adjust 1)
       (buffer-face-mode))
    
    Probably not the best way to do it, but for me it gives a much more readable size.
  • RS_JimRS_Jim Posts: 1,751
    edited 2011-04-30 07:55
    Great! I would like to try it. How do I get EMACS23 for windows?
    Jim
  • johnfosjohnfos Posts: 59
    edited 2011-04-30 08:39
    RS_Jim wrote: »
    Great! I would like to try it. How do I get EMACS23 for windows?
    Jim
    Googling for "emacs windows download" (without the quotes) seems to yeld quite a few results...
  • proplemproplem Posts: 233
    edited 2011-05-02 11:38
    Hello together,

    i did not try prop-mode.el with Windows. AFAIK bstc is not available for Windows though you have to use propellent.exe which i didn't ever try.

    I think the wish list is getting longer ... :-)

    regards, proplem
  • johnfosjohnfos Posts: 59
    edited 2011-05-02 12:56
    bstc works under Linux, Mac and Windows. So there's one item off the todo list :-)
  • proplemproplem Posts: 233
    edited 2011-05-02 14:09
    hello out there,

    good news johnfos! bstc is a platform independent tool. I didn't know that.

    But there are some further news:

    prop-mode-0.1.7z

    It is now possible to customize variables:

    use M-x customize-group prop-mode<return>

    @johnfos: handling of fonts in emacs lisp requires at least a PHD or Prof title, but with prop-mode-std-fontsize you can adjust the size to your needs. Try values about 150, 125 i think you'll be happy.

    There is another important feature:

    prop-mode-serial-interface is also customizable aiming at platform independency (without knowing of bstc's ability to do that). I thought of people working on windows (and me also;-). Furter more prop-mode-serial-interface is buffer-local. So one can M-x set-variable COM1 or /dev/ttyUSB1 and so on for a specific buffer and compilation will compile into that device. Great isn't it? A Multi-Propeller-Interface IDE with one additional line of code.

    Did anybody work on windows with prop-mode? Maybe successful? I didn't have the time yet.

    regards, proplem
  • Mark_TMark_T Posts: 1,981
    edited 2011-05-04 09:30
    I had to fix a bug in prop-font-lock-keywords where there were some quotes left inside the backquoted expression (this prevented printing the buffer):

    Replace this:
    (defvar prop-font-lock-keywords
        `(
         (,(regexp-opt prop-block-designators-keywords 'words) .   font-lock-keyword-face)
         (,(regexp-opt prop-configuration-keywords 'words) .       font-lock-constant-face)
         (,(regexp-opt prop-types-keywords 'words) .               font-lock-type-face)
         (,(regexp-opt prop-cog-control-keywords 'words) .         font-lock-keyword-face)
         (,(regexp-opt prop-process-control-keywords 'words) .     font-lock-keyword-face)
         (,(regexp-opt prop-flow-control-keywords 'words) .        font-lock-keyword-face)
         (,(regexp-opt prop-memory-keywords 'words) .              font-lock-keyword-face)
         (,(regexp-opt prop-directives-keywords 'words) .          font-lock-keyword-face)
         (,(regexp-opt prop-registers-keywords 'words) .           font-lock-constant-face)
         (,(regexp-opt prop-constants-keywords 'words) .           font-lock-constant-face)
         (,(regexp-opt prop-variables-keywords 'words) .           font-lock-variable-name-face)
    
    
        ;; note: order above matters. ''mylsl-keywords-regexp'' goes last because
        ;; otherwise the keyword ''state'' in the function ''state_entry''
        ;; would be highlighted.
         '("\"[^\"]*\"" 0 font-lock-string-face t)
         '(":=" 0 font-lock-keyword-face t)
         '("'.*$" 0 font-lock-comment-face t)
    ;;         '(font-lock-syntactic-keywords . prop-font-lock-syntactic-keywords)
            ))
    
    with:
    (defvar prop-font-lock-keywords
        `(
         (,(regexp-opt prop-block-designators-keywords 'words) .   font-lock-keyword-face)
         (,(regexp-opt prop-configuration-keywords 'words) .       font-lock-constant-face)
         (,(regexp-opt prop-types-keywords 'words) .               font-lock-type-face)
         (,(regexp-opt prop-cog-control-keywords 'words) .         font-lock-keyword-face)
         (,(regexp-opt prop-process-control-keywords 'words) .     font-lock-keyword-face)
         (,(regexp-opt prop-flow-control-keywords 'words) .        font-lock-keyword-face)
         (,(regexp-opt prop-memory-keywords 'words) .              font-lock-keyword-face)
         (,(regexp-opt prop-directives-keywords 'words) .          font-lock-keyword-face)
         (,(regexp-opt prop-registers-keywords 'words) .           font-lock-constant-face)
         (,(regexp-opt prop-constants-keywords 'words) .           font-lock-constant-face)
         (,(regexp-opt prop-variables-keywords 'words) .           font-lock-variable-name-face)
    
    
        ;; note: order above matters. ''mylsl-keywords-regexp'' goes last because
        ;; otherwise the keyword ''state'' in the function ''state_entry''
        ;; would be highlighted.
         ("\"[^\"]*\"" 0 font-lock-string-face t)
         (":=" 0 font-lock-keyword-face t)
         ("'.*$" 0 font-lock-comment-face t)
    ;;         (font-lock-syntactic-keywords . prop-font-lock-syntactic-keywords)
         ))
    

    (The change is removing ' marks from the last three lines)
  • proplemproplem Posts: 233
    edited 2011-05-04 13:54
    Mark_T,

    it's funny that you fixed a bug in that lines. It's funny because i wanted to comment these lines with the comment sign of spin forgetting to be talking lisp. I understand you really fixed another bug - strange.

    So far it was a bugbug :-))

    I can't understand what you are meaning with
    (this prevented printing the buffer):
    can you explain?

    I would suggest you leave these lines commented or better you comment them in the following manner:
         ;;("\"[^\"]*\"" 0 font-lock-string-face t)
         ;;(":=" 0 font-lock-keyword-face t)
         ;;("'.*$" 0 font-lock-comment-face t)
    
    Strings and comments are already fontified by other means. Only the operator := is not yet fontified.

    Better fontification is one of the obvious open issues.

    sorry for the inconvenience, best regards,
    proplem
  • Mark_TMark_T Posts: 1,981
    edited 2011-05-04 16:16
    proplem wrote: »
    Mark_T,

    it's funny that you fixed a bug in that lines. It's funny because i wanted to comment these lines with the comment sign of spin forgetting to be talking lisp. I understand you really fixed another bug - strange.

    So far it was a bugbug :-))

    I can't understand what you are meaning with
    (this prevented printing the buffer):
    can you explain?

    proplem

    Well I only encountered the problem on a Mac I have connected to a printer - using print-buffer in emacs on a buffer in propellor mode failed with an error about 'QUOTE'.

    So I hunted in the source for the likely cause - I know several Lisp dialects so that backquoted expression stood out as wrong (not everyone can read Lisp fluenty, I know ;)

    And if you know Lisp you know that 'expr is a macro for (QUOTE expr)

    I presume printing the buffer exercises more parts of the mode definition than simply setting the mode on the buffer.

    PS Thanks for the mode, its looking good (and saving me some black ink!)
  • proplemproplem Posts: 233
    edited 2011-06-15 13:02
    Hi everyone,

    prop-mode-110615.7z

    Many improvements have been done:

    • customizable list of paths to spin libs
      M-x customize-group prop-mode
    • better wrapper for bstc
    • (minor) compilation mode is used
    • fontification is much better
    • PropTerminal_Linux is toggable via C-c t

    If there are any wishes feel free to reply to this post.

    regards, proplem
Sign In or Register to comment.