Meta characters in PicoLisp
Hi List, citing from the Reference , | Internal symbol names can consist of any printable (non-whitespace) | charac-ter, except for the following meta characters: | | ’ ( ) , [ ] ‘ ~ { } ` I forgot what the ~ is about (e.g. in ~( ... )), and could not find the explanation. And isn't ^ another meta character (with what meaning in PicoLisp)? -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta characters in PicoLisp
Hi Thorsten, I forgot what the ~ is about (e.g. in ~( ... )), and could not find the explanation. It is described in doc/ref.html#macro-io. The tilde is similar to the backquote, in that both evaluate the following expression, and put the result into the currently read list. While the backquote inserts the result as it is, the tilde expects that the result is a list which is then spliced into the read list. : (1 2 `(chop abc) 3 4) - (1 2 (a b c) 3 4) : (1 2 ~(chop abc) 3 4) - (1 2 a b c 3 4) Besides this, the tilde has a special meaning when separating a namespace and a symbol name, e.g. myPackage~mySymbol And isn't ^ another meta character (with what meaning in PicoLisp)? Not in internal symbols. In transient symbols (strings), however, it denotes a control character. e.g. ^I is TAB and ^M is carriage return . abc^Jdef^Jghi^J is a text of three lines. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta characters in PicoLisp
Alexander Burger a...@software-lab.de writes: Hi Alex, I forgot what the ~ is about (e.g. in ~( ... )), and could not find the explanation. It is described in doc/ref.html#macro-io. The tilde is similar to the backquote, in that both evaluate the following expression, and put the result into the currently read list. While the backquote inserts the result as it is, the tilde expects that the result is a list which is then spliced into the read list. : (1 2 `(chop abc) 3 4) - (1 2 (a b c) 3 4) : (1 2 ~(chop abc) 3 4) - (1 2 a b c 3 4) I knew I read about it, but forgot where. Searching in 'PicoLisp Works' did not help, since the tilde character is not found (on scribd at least). Besides this, the tilde has a special meaning when separating a namespace and a symbol name, e.g. myPackage~mySymbol And isn't ^ another meta character (with what meaning in PicoLisp)? Not in internal symbols. In transient symbols (strings), however, it denotes a control character. e.g. ^I is TAB and ^M is carriage return . abc^Jdef^Jghi^J is a text of three lines. I see, thanks! -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: epil - PicoLisp with Emacs-like command-line (was: Meta key in
Hi Thorsten, Maybe there could be a 1. global switch '*Vi' that is true by default, and 2. a function '(de Toggle-Vi...)' that toggles that switch, and 3. three modes: Command, Insert, EInsert or 3. two modes Command and Insert, with much Command functionality duplicated in Insert Perhaps it is better to keep the two editors separate? This would make changes and extensions more modular. maybe one could actually have two additional library files 'eled.l' and 'eedit.l', not change anything in 'led.l' and 'edit.l', and simply Yes. insert conditional statements in the startscripts and the functions that load the libraries? I.e., add 'eled.l' and 'eedit.l' to the PicoLisp I would use the names vled.l and eled.l, and have a symbolic link led.l to one of those. In that way, no changes to the rest of the system are necessary. Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: epil - PicoLisp with Emacs-like command-line (was: Meta key in
Hi Thorsten, I managed to produce a first experimental version of 'epil', i.e. a new version of led.l (eled.l) and some small changes in libraries that are called at PicoLisp startup. If you clone this github repo: ,- | https://github.com/tj64/epil `- Thanks! I think this might make the PicoLisp REPL more usable for many people, as most are not used to a VI-style command line, and probably are not even aware of it. In the long term, the Emacs-interface should be available without explicit installation, and possibly even co-exist with the VI version (switchable at runtime). Would this be difficult? Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: epil - PicoLisp with Emacs-like command-line (was: Meta key in
Alexander Burger a...@software-lab.de writes: Hi Alex, I managed to produce a first experimental version of 'epil', i.e. a new version of led.l (eled.l) and some small changes in libraries that are called at PicoLisp startup. If you clone this github repo: ,- | https://github.com/tj64/epil `- Thanks! I think this might make the PicoLisp REPL more usable for many people, as most are not used to a VI-style command line, and probably are not even aware of it. Although it seems very efficient, and there are not too many keybindings to remember, the VI-style command line requieres a completely different way a thinking for somebody who uses Emacs all the time. In the long term, the Emacs-interface should be available without explicit installation, and possibly even co-exist with the VI version (switchable at runtime). Would this be difficult? Since now I know how to assign (almost) all kinds of Emacs keybindings in PicoLisp, I can try to better understand the 'commandline' implementation. What I did for 'epil' is simply eliminating 'Command mode' and shifting the commands into 'Insert mode' with new keybindings. Maybe there could be a 1. global switch '*Vi' that is true by default, and 2. a function '(de Toggle-Vi...)' that toggles that switch, and 3. three modes: Command, Insert, EInsert or 3. two modes Command and Insert, with much Command functionality duplicated in Insert where Command and Insert are the Vi-Style modes and EInsert is the Emacs-style mode. Since there are conflicting keybindings, one would call the functions for many keys conditional on the value of '*Vi*'. Does that sound like a reasonable approach, or is there a simpler/more elegant solution? As an alternative approach: maybe one could actually have two additional library files 'eled.l' and 'eedit.l', not change anything in 'led.l' and 'edit.l', and simply insert conditional statements in the startscripts and the functions that load the libraries? I.e., add 'eled.l' and 'eedit.l' to the PicoLisp distribution, and offer the 'epil' shell-command too? For development, at the moment I rather prefer to have 'epil' separated from standard PicoLisp, so I can mess up things ;) -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta key in PicoLisp program
Alexander Burger a...@software-lab.de writes: Hi Alex, thanks for your explanations. So Ctrl and Shift are the only 'meta-keys' that can be used (and Yes, they cause the generation of different ASCII characters by the keyboard when they are pressed. For example, if you press the 'A' key you get the character 97 ('a'), if you press shift, you get 65 ('A'), and if you press control, you get 1 ('^A'). my idea is to add an Emacs-like command line to PicoLisp. I thought this would be about: 1. move all commands from command-mode to insertion-mode (the only Emacs-mode) 2. eliminate command-mode 3. replace the vi 1-key bindings with Emacs keychords (with Control and Meta prefix-keys) for all commands that have equal or similar semantics to Emacs commands 4. eliminate/replace the commands that do not fit into the non-modal Emacs concept 5. write some new commands to give PicoLisp commandline editing the authentic Emacs feeling. but there is no way to emulate Emacs without the Meta/Alt-key, and e.g. C-d (Ctrld) is 'delete-char' in Emacs, just like C-c (Ctrlc) is a very common prefix-key. combined)? What about F1 to F12 or any other keys not used for 'self-insertion''? The function keys are usually generated as escape sequences (system dependent). You may take a look into lib/term.l in the PicoLisp distribution. It defines some keys from the terminfo database (using 'tput'). this looks easy enough, but I'm still looking for a document that explains what you are doing there. I found lots of material about changing colors and positioning text with tput, but nothing yet about how define keys. Do you have a link or so where this is explained in a basic way? Do the definitions in lib/term.l only work in xterm (X11 session) or in a console session (without X11) too? Would Emacs-like key-chords be possible? E.g. 'C-x u', i.e. type first 'Ctrlx' and then 'u', using 'C-x' as a kind of prefix that can be combined with e.g. [a-zA-Z0-9]. Yes, all this must be handled as events (or sequences of events). Same goes for mouse-clicks and -buttons. Do you have an example of this kind of event-handling in the PicoLisp sources? BTW - where are Ctrl-d and Ctrl-c defined? Could they be redefined to something else in one single place? No, they are ASCII values. In general, a control character is the corresponding uppercase character minus 64. For example, Ctrl-A is 1, Ctrl-B is 2, Ctrl-C is 3 and so on. But would it be possible to make PicoLisp call 'delete-char' when the Ctrl-d ASCII is send, and use another (less common) ASCII value to exit the program? -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta key in PicoLisp program
Hi Thorsten, my idea is to add an Emacs-like command line to PicoLisp. I thought this Good idea :) 1. move all commands from command-mode to insertion-mode (the only Emacs-mode) 2. eliminate command-mode 3. replace the vi 1-key bindings with Emacs keychords (with Control and Meta prefix-keys) for all commands that have equal or similar semantics to Emacs commands 4. eliminate/replace the commands that do not fit into the non-modal Emacs concept 5. write some new commands to give PicoLisp commandline editing the authentic Emacs feeling. Yes. Quite a lot of stuff, though. Do the definitions in lib/term.l only work in xterm (X11 session) or in a console session (without X11) too? They should work where 'tput' and 'terminfo' is available. Would Emacs-like key-chords be possible? E.g. 'C-x u', i.e. type first 'Ctrlx' and then 'u', using 'C-x' as a kind of prefix that can be combined with e.g. [a-zA-Z0-9]. Yes, I think so. By handling sequences of key events, collecting them as necessary, and then deciding what action to perform. Do you have an example of this kind of event-handling in the PicoLisp sources? As a central entry point the 'fkey' function from lib/led.l can be used. An example usage is in http://rosettacode.org/wiki/Keyboard_macros#PicoLisp The flight simulator in rcsim/main.l uses it too, defining some function keys to control the airplane. But these examples don't handle sequences of multiple-key events. For those, a given key like Ctrl-X might then wait for a short timeout period (e.g. with (key 200)) for further keys to arrive. No, they are ASCII values. In general, a control character is the corresponding uppercase character minus 64. For example, Ctrl-A is 1, Ctrl-B is 2, Ctrl-C is 3 and so on. But would it be possible to make PicoLisp call 'delete-char' when the Ctrl-d ASCII is send, and use another (less common) ASCII value to exit the program? Yes. Exiting upon Ctrl-D is explicitly coded into the line editor. So any other key (or none at all) might be used. Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta key in PicoLisp program
On Fri, Oct 26, 2012 at 11:57:34AM +0200, Axel Svensson wrote: my idea is to add an Emacs-like command line to PicoLisp. I thought this Is there anything you want that's not supported by the GNU readline library? Since this library is so popular, it's been well tested during the years. Maybe it be possible to create picolisp bindings for it? In fact, there is already a simple version in the PicoLisp distribution, in lib/readline.l. It is for pil32. In pil64, 'readline' can be directly called via 'native': (de *Led (native /lib64/libreadline.so.5 readline 'S NIL)) but this has a memory leak iirc. I haven't investigated closely. The problem with both solutions is that they don't integrate as well as lib/led.l with the PicoLisp runtime environment (e.g. tab completion on the currently existing internal symbols, locking of the history file), but this can probably be improved upon. Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta key in PicoLisp program
On Fri, Oct 26, 2012 at 12:27:21PM +0200, Alexander Burger wrote: The problem with both solutions is that they don't integrate as well as lib/led.l with the PicoLisp runtime environment (e.g. tab completion BTW, the historic reason for PicoLisp's simple line editor is that the GNU readline library is bigger than the whole PicoLisp interpreter. So it didn't feel right to link with it. -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta key in PicoLisp program
GNU readline library is bigger than the whole PicoLisp interpreter. So it didn't feel right to link with it. Probably right feeling there. In production, command line interaction might not even be used at all. But the option is nice, so if someone's willing to tweak readline.l it would be a welcomed contribution. -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta key in PicoLisp program
Alexander Burger a...@software-lab.de writes: Hi Alex, my idea is to add an Emacs-like command line to PicoLisp. I thought this Yes. Quite a lot of stuff, though. I already have a basic emacs commandline version running, the most basic Emacs 'movement, deletion and paste' commands, just by changing the keybinding of existing functions to Emacs bindings with Ctrlprefix. But there are still several things I don't really understand: Would Emacs-like key-chords be possible? E.g. 'C-x u', i.e. type first 'Ctrlx' and then 'u', using 'C-x' as a kind of prefix that can be combined with e.g. [a-zA-Z0-9]. Yes, I think so. By handling sequences of key events, collecting them as necessary, and then deciding what action to perform. Do you have an example of this kind of event-handling in the PicoLisp sources? As a central entry point the 'fkey' function from lib/led.l can be used. An example usage is in http://rosettacode.org/wiki/Keyboard_macros#PicoLisp in lib/term.l I find: ,-- | (setq |*XtF1(in '(tput kf1) (line T)) |*XtF2(in '(tput kf2) (line T)) `-- but in the web I still did not find a list of all the keys like kf1 and kf2 that 'tput' knows about - where can I look them up? I would e.g. need to know how to adress the Alt key - kalt? I guess not... and what about this notation: , | *XtMenu ^[[29~#? ` where do I find the explanation for ^[[29~? In http://rosettacode.org/wiki/Keyboard_macros#PicoLisp I find: ,-- | (load @lib/term.l) | | (fkey *XtF1 |(prinl Initialized value to (setq *Number 1)) ) | | (fkey *XtUp |(prinl Incremented to (inc '*Number)) ) `-- thats easy enough. The flight simulator in rcsim/main.l uses it too, defining some function keys to control the airplane. same thing here: , | (fkey *XtUp |(down *Model) ) ` But these examples don't handle sequences of multiple-key events. For those, a given key like Ctrl-X might then wait for a short timeout period (e.g. with (key 200)) for further keys to arrive. could you give a little example how this would look like, e.g. if I want to define the Emacs binding 'C-x u' ('Ctrl-x u'), i.e. press C-x first (as a prefix) and then u? Yes. Exiting upon Ctrl-D is explicitly coded into the line editor. So any other key (or none at all) might be used. I redefined CtrlD to CtrlQ, that was easy. (What about CtrlC - where is that defined?) -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta key in PicoLisp program
Thorsten Jolitz tjol...@googlemail.com writes: but in the web I still did not find a list of all the keys like kf1 and kf2 that 'tput' knows about - where can I look them up? I would e.g. need to know how to adress the Alt key - kalt? I guess not... ok, I found the list of keys in the terminfo man-page (I should have looked first there), so this part of the question is obsolete... -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta key in PicoLisp program
Alexander Burger a...@software-lab.de writes: Hi Alex, AltV (M-V or M-S-v in Emacs) CtrlALTV (C-M-V or C-M-S-v in Emacs) instead of something like this (CtrlV): Unfortunately, this is not directly possible. Alt/Meta key combinations have no representation in ASCII or UTF-8. Instead, they are generated as events by the runtime system, where key events may have certain bits set for modifier keys. As such, they are very system-dependent. External libraries like 'termcap/terminfo' or 'curses' can be used to handle them. BTW, this is one of the reasons why the PicoLisp line editor uses a 'vi'-style user interface. It needs only ASCII-keys. So Ctrl and Shift are the only 'meta-keys' that can be used (and combined)? What about F1 to F12 or any other keys not used for 'self-insertion''? Would Emacs-like key-chords be possible? E.g. 'C-x u', i.e. type first 'Ctrlx' and then 'u', using 'C-x' as a kind of prefix that can be combined with e.g. [a-zA-Z0-9]. PS BTW - where are Ctrl-d and Ctrl-c defined? Could they be redefined to something else in one single place? -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Meta key in PicoLisp program
Hi List, how would I write a - Meta/Alt key - AltGr key in a PicoLisp program? E.g. if I want to write AltV (M-V or M-S-v in Emacs) CtrlALTV (C-M-V or C-M-S-v in Emacs) instead of something like this (CtrlV): ,--- | (^V (insChar (key))) `--- -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Meta key in PicoLisp program
Hi Thorsten, AltV (M-V or M-S-v in Emacs) CtrlALTV (C-M-V or C-M-S-v in Emacs) instead of something like this (CtrlV): Unfortunately, this is not directly possible. Alt/Meta key combinations have no representation in ASCII or UTF-8. Instead, they are generated as events by the runtime system, where key events may have certain bits set for modifier keys. As such, they are very system-dependent. External libraries like 'termcap/terminfo' or 'curses' can be used to handle them. BTW, this is one of the reasons why the PicoLisp line editor uses a 'vi'-style user interface. It needs only ASCII-keys. Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: meta!
Hi Dexen, could we please have the ``Content-Transfer-Encoding: quoted-printable''=20 handling fixed? :) I.e., the stuff that currently creates the endless =3D20 etc. Hmm, OK. But how? The source is in the PicoLisp distribution in misc/mailing, it doesn't do anything with the encoding. Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: meta!
Hi Alex, On Monday 14 of March 2011 19:13:54 you wrote: could we please have the ``Content-Transfer-Encoding: quoted-printable''=3D20 handling fixed? :) =20 I.e., the stuff that currently creates the endless =3D3D20 etc. =20 Hmm, OK. But how? The source is in the PicoLisp distribution in misc/mailing, it doesn't do anything with the encoding. Let's see :-) Cheers, =2D-=20 dexen deVries [[[=E2=86=93][=E2=86=92]]] ``In other news, STFU and hack.'' mahmud, in response to Erann Gat's ``How I lost my faith in Lisp'' http://news.ycombinator.com/item?id=3D2308816 -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: meta!
On Monday 14 of March 2011 19:13:54 you wrote: could we please have the ``Content-Transfer-Encoding: quoted-printable''=20 handling fixed? :) I.e., the stuff that currently creates the endless =3D20 etc. Hmm, OK. But how? The source is in the PicoLisp distribution in misc/mailing, it doesn't do anything with the encoding. And it didn't work. In short, the messages I receive don't have the ``Content-Transfer-Encoding'' header (which is a companion to ``Content-Type''), even the ones I sent with that header for sure. Without this header, the mail client doesn't know to interpret the escape codes starting with the ``equals'' sign. Now I dont' understand the code too well, but it seems only fields indicated by a shortlist are copied from incomming message to the outgoing message. Perhaps if you added the ``Content-Transfer-Encoding'' field to this list (to be just copied), it would work? Attached patch attempts to fir it~ Cheers, -- dexen deVries [[[↓][→]]] ``In other news, STFU and hack.'' mahmud, in response to Erann Gat's ``How I lost my faith in Lisp'' http://news.ycombinator.com/item?id=2308816 --Boundary-00=_xLmfN70LoP+89EH Content-Type: text/x-patch; charset=UTF-8; name=0001-attempt-to-fix-Content-Transfer-Encoding-header-not-.patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=0001-attempt-to-fix-Content-Transfer-Encoding-header-not-.patch From e17e05b34cbbbe342d4350cdce8a16fa3b180ea8 Mon Sep 17 00:00:00 2001 From: dexen deVries dexen.devr...@gmail.com Date: Mon, 14 Mar 2011 19:47:16 +0100 Subject: [PATCH] attempt to fix Content-Transfer-Encoding header not being forwarded X-Face: 1TH%]0KlR_DQ/V9+m_neC|Yj3$MU@B/vVI\}^j`G/[9JKe=5`p[$l|z^\MRO%k:9xXL[_!jEZo8$[]yo{7O-]t_@Qj`v5H@L[YyU#j7(H)P\{pMs))9$@Vww1ni-{+{5olk=XYG,}|UHQMC08506\0=+p|75ucH!S!1UcXoC1vgpN_{lOMt_54_N5;)ngh6=D^uZN,}ZI9-k9v!}`jpCUMM,//`H6w{KgeM^bS]jwD8'lAEX9F[ScIHig1.r%65; --- misc/mailing |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/misc/mailing b/misc/mailing index 1c7087a..aae2dc5 100755 --- a/misc/mailing +++ b/misc/mailing @@ -22,7 +22,7 @@ (while (setq *From (lowc (till T))) (off *Name *Subject *Date *MessageID *InReplyTo *MimeVersion - *ContentType *ContentDisposition *UserAgent ) + *ContentType *ContentTransferEncoding *ContentDisposition *UserAgent ) (while (split (line) ) (setq *Line (glue (cdr @))) (case (pack (car @)) @@ -33,6 +33,7 @@ (In-Reply-To: (setq *InReplyTo *Line)) (MIME-Version: (setq *MimeVersion *Line)) (Content-Type: (setq *ContentType *Line)) + (Content-Transfer-Encoding: (setq *ContentTransferEncoding *Line)) (Content-Disposition: (setq *ContentDisposition *Line)) (User-Agent: (setq *UserAgent *Line)) ) ) (if (nor (member *From *Mailings) (= subscribe (lowc *Subject))) @@ -66,6 +67,7 @@ (and *InReplyTo (prinl In-Reply-To: @ ^M)) (and *MimeVersion (prinl MIME-Version: @ ^M)) (and *ContentType (prinl Content-Type: @ ^M)) +(and *ContentTransferEncoding (prinl Content-Transfer-Encoding: @ ^M)) (and *ContentDisposition (prinl Content-Disposition: @ ^M)) (and *UserAgent (prinl User-Agent: @ ^M)) (prinl ^M) -- 1.7.4.1 --Boundary-00=_xLmfN70LoP+89EH-- -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: meta!
Hi Dexen, In short, the messages I receive don't have the ``Content-Transfer-Encoding= header (which is a companion to ``Content-Type''), even the ones I sent wit= that header for sure. Without this header, the mail client doesn't know to interpret the escape=20 codes starting with the ``equals'' sign. This sounds very reasonable! I wasn't aware of that. Attached patch attempts to fir it~ Thanks a lot! I installed a patched version. This mail is already sent via the new version :) Let's see. Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: meta!
Great! On Mon, Mar 14, 2011 at 10:05:28PM +0100, dexen deVries wrote: testin-testin' :D foo == bar? BINGO! :D Thanks again! -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe