newLisp Mode for emacs

Q&A's, tips, howto's
Locked
Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

newLisp Mode for emacs

Post by Tim Johnson »

I'm new to newLisp, also new to emacs. A search on 'emacs' indicates that some
members have hacked scheme.el for newLisp. I'd like to do the same. I've parsed
keywords from newlisp_manual.html, and will attempt to hack a copy of
scheme.el myself, but I would appreciate a working copy if one is available, so
I have something to fall back on when I get totally screwed up.

Comments, docs, pointers to relevant topics are welcome.
tim

Sammo
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

Post by Sammo »

Hi Tim,

In this thread, Lutz describes a three-line technique for asking newLisp itself for a list of keywords. In the future, that might be an easier way to get that list.

-- Sam

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Here is a simple way to get a complete list of keywords without using the manual:

(dolist (s (symbols)) (if (primitive? (eval s)) (println s)))

Just add 'nil' and 'true' and you are done.

There is also a file 'keywords.txt' in the doc directory in the source distribuition and also in the Win32 distribution. But they still lack the new 'share' and 'semaphore', which are in development.

'newlisp.el' would be a great contribution,

thanks and welcome to the discussion board,

Lutz

eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Post by eddier »

I've added the keywords to the scheme.el file before. I tried to get the {} and [text][/text] for strings with no luck. If you could get those to work, please have Lutz post it as I would love to have the newlisp.el.

For highlighting to work, I have to name my files with a .scm extension unfortunately.

Steps to take.
Log in as root.
"cd /usr/share/emacs/21.3/lisp/progmodes" (assuming your emacs and mine are the same and in the same place).
Make a BACKUP of scheme.el (I messed mine up several times playing with it).
Then edit the file "emacs scheme.el" (if you don't have scheme.el in this location, You will have to down load it. You will have to be root to copy the file to the proper location "cp scheme.el /usr/share/emacs/21.3/lisp/progmodes")
Do an emacs search "Ctrl + s" and type in "defconst scheme-font-lock-keywords-2"
(This will take you down to line 317 in my version)
You will see a list of keywords. Start replacing with newLISP keywords and you are set.

It would also be nice to have it to highlight javascript keywords inside strings with <script></script> tabgs for CGI programming!

Welcome abord.

Eddie

eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Post by eddier »

Oh, I forgot one thing. Before the highlighting will work, you must byte compile the file from within emacs. That is, after changing the scheme.el file, click on "Emacs-Lisp" and click on "Byte-compile this file"

Good luck!

Eddie

Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Post by Tim Johnson »

Thanks for the good wishes and advice. I'm excited about digging into newLisp.
Actually, I'm currently using Xemacs, not gnu Emacs.
Took one look at the xemacs version of scheme.el and since it looked very
different, I copied the emacs version into my Xemacs load-path.

Xemacs barfed on 'lisp-mode-shared-map. A quick and preliminary google seems to suggest
that I should replace 'lisp-mode-shared-map with 'shared-lisp-mode-map.
(Forks are fun ain't they?) I did a load-library from xemacs and got no further compaints.

I will follow eddier's advice on the key words and report back.

-tim-

Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Post by Tim Johnson »

I had problems using scheme.el with both lucid and GNU emacs.
My solution was quack.el, which is a very nice piece of work. The
original is available at http://www.neilvandyke.org/quack/.
I did a quick "hack" of quack.el viewable at
http://www.johnsons-web.com/demo/newlisp/ where I simply cleared
'quack-pltish-keywords-to-fontify, and dropped in keywords from
keywords.txt. The inferior process worked right "out of the box", quack
presumes a default interpreter, accepts any interprerter name and
then "remembers" it.

It appears that quack.el is equally compatible with both emacs
forks. However the author suggests that it functions better with
GNU emacs. Sadly, GNU emacs does not preform well for me
on my system Xemacs loads much faster and many functions are
also far faster. Dunno why!

TODO: What I'd like to do is hand-roll and install my own font faces.
See font-lock-more.el at the URL above and examples of how I did
it for rebol at sample.el. If continuing the topic of customizing emacs
for newlisp is considered outside of the forum parameters, I've got an
ML that could be used for it.

I'm also an emacs newbie so any contributions would be hugely
welcomed.

thanks
tim

Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Post by Tim Johnson »

I just went thru jsmal's first chapter. Good tutorial!
I used three different ways of testing the code:

1)Newlisp from shell command line
2)As an emacs inferior process command line.
3)From a .lsp file buffer, piping to the inferior process.

Seems to be a problem with the inferior process:
Multiple line forms give an error message:
"missing parenthesis"
when evaluated either from the buffer or the command line
of the process. It looks like the process is being blocked
from evaluating more than one line at a time.....

No biggie. Am writing an inferior process from scratch from rebol.
Should give some clues, might have to write a from-scratch process
for newlisp also. Or I've missed something in my emacs understanding...

eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Post by eddier »

I've only played with the scheme.el in emacs. I've used emacs for about 8 years but to be honest, I don't know anything about its inner workings. I discovered a few things by hunting them down on the Internet.

I used the M[ key sequence and ran newLISP from the shell command line.

I've never tried xemacs. Sounds like that might be a better way to go.

Maybe we should try working with Lutz's newlisp-tk? Add keyword highlighting and better indention and stuff?

Maybe even as a group we might write our own newLISP editor in newLISP. I would to be able to switch key-bindings to one of the standards however. The thought of an editor in newLISP has crossed my mind several times and would be a real test for newLISP. I've just never had the time to devote to such a big programming project to do alone. If you wanted to take the lead, I would be willing to devote an hour a day to such a project. If we could start with a nice overall structure and spec, we work our way towards that end.

What do you think Tim?

Eddie

Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Post by Tim Johnson »

Legend: emacs=(collectively, both forks of emacs)
lispish=(variant, descendent or "dialect" of lisp)
<Eddie>
I've only played with the scheme.el in emacs. I've used emacs for about 8 years
but to be honest, I don't know anything about its inner workings. I discovered
a few things by hunting them down on the Internet.
</Eddie>
I find emacs very hard to learn and finding a good support community more
difficult than with vim. But worth the effort. I like to think that the emacs
"internals" are an elisp programming environment. (elisp = another lispish
language). A newlisp progammer may find much familiar territory in the emacs
internals.
<Eddie>
I used the M[ key sequence and ran newLISP from the shell command line.
</Eddie>
I've written a crude emacs inferior process for rebol, seems to work, and
it wouldn't take much to make a similar one for newlisp. However, I'm inclined
to contact the quack author first and see if he has the time or interest to
modify quack to better accomodate newlisp. His code demostrates the intent
to adapt to any number of lispish languages.
<Eddie>
I've never tried xemacs. Sounds like that might be a better way to go.
</Eddie>
My experience is that xemacs is more user friendly and has additional features
from GNU emacs. But that could be specific to my system and my situation
<Eddie>
Maybe we should try working with Lutz's newlisp-tk? Add keyword highlighting
and better indention and stuff?
</Eddie>
I intend to check that out when I have more time.
I would hope that Lutz would have some comments to contribute here...
read on:
<Eddie>
Maybe even as a group we might write our own newLISP editor in newLISP. I would
to be able to switch key-bindings to one of the standards however. The thought
of an editor in newLISP has crossed my mind several times and would be a real
test for newLISP. I've just never had the time to devote to such a big
programming project to do alone. If you wanted to take the lead, I would be
willing to devote an hour a day to such a project. If we could start with a
nice overall structure and spec, we work our way towards that end.
</Eddie>
To be clear about my professional goals and specific situation:
I have many obligations in my business that limit my R&D time, and being self-employed,
I have no R&D budget. My R&D goal is to =>
1)Learn emacs
2)Learn a lispish language (and newlisp fits the bill better than any other, to make
a long story short).
In short such a contribution may be beyond my time constraints *and* ability,
but :-) read on:
<Eddie>
What do you think Tim?
</Eddie>
Here's some thoughts (and these thoughts are spinoffs of some of my R&D
goals) I have a need to customize emacs to allow a perl programmer used to
KEdit to make a transition without learning much new, and then add
functionality incrementally. Similarly with emacs, given the similarity
between newlisp and elisp perhaps one could customize a "newlisp-friendly"
emacs that could even be bundled with newlisp. With an assortment of keybinding
modules that could allow transitions from other editors. And maybe there is a
tie-in with newlisp-tk?

And for anyone reading this that just hates emacs - here's another thought.
Vim offers hooks to compile in perl, python, and ruby interpreters. I believe
that it is doable for Lutz to work with Bram Moolenar to make newLisp compilable
into vim. I currently use vim with python compiled in for my coding in C/CC+,
rebol and python.
-Tim-

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Offtopic, But do i smell Rebol here ;-) ..
-- (define? (Cornflakes))

eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Post by eddier »

Ok, tommorrow I'll take a hack at your hack at quack and see what we can do.

Eddie

Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Post by Tim Johnson »

Code for the inferior process is at:
http://www.johnsons-web.com/demo/newlis ... -comint.el

Locked