# Christmas wish: Literate Elisp

44 messages
123
Open this post in threaded view
|

## Christmas wish: Literate Elisp

Open this post in threaded view
|

## Re: Christmas wish: Literate Elisp

 > My proposal is to slightly change Elisp parser to treat lines that start > with any other printable character but '(' as a start of comment and to > simply ignore the line, just as it treats ';' as a comment. The sexpresso Haskell package follows the same idea ;-) As for using it in Elisp: I don't think there's anything stopping anyone from making such a literate-elisp-mode and even arrange for load to handle such a file (just like there is already a package that lets load work directly on .org files). I'd welcome such a package in GNU ELPA.         Stefan
Open this post in threaded view
|

## Re: Christmas wish: Literate Elisp

Open this post in threaded view
|

## Sv: Christmas wish: Literate Elisp

 In reply to this post by Stefan Monnier To be honest my contact with Haskell broke once the university course, some 20 yrs ago was over, so I am a little bit illiterate about Haskells sexy packages. I just recalled that it was possible to invert text and code in Haskell. But cool. Didn't know there is a package to let load org files directly either. What I do in init is use org-babel to entangle my init file (org-babel-load-file (expand-file-name "~/.emacs.d/lisp/init.org")). What is the name of the package? I have tried to google it and looked into elpa packages with list-package but I don't see it. I am just curious how is it done, as I was thinking or they refactor the code as in org-babel into corresponding lisp file. Thanks for the answers. Från: Stefan Monnier <[hidden email]> Skickat: den 12 december 2019 18:29 Till: arthur miller <[hidden email]> Kopia: emacs-devel <[hidden email]>; [hidden email] <[hidden email]> Ämne: Re: Christmas wish: Literate Elisp   > My proposal is to slightly change Elisp parser to treat lines that start > with any other printable character but '(' as a start of comment and to > simply ignore the line, just as it treats ';' as a comment. The sexpresso Haskell package follows the same idea ;-) As for using it in Elisp: I don't think there's anything stopping anyone from making such a literate-elisp-mode and even arrange for load to handle such a file (just like there is already a package that lets load work directly on .org files). I'd welcome such a package in GNU ELPA.         Stefan
Open this post in threaded view
|

## Sv: Christmas wish: Literate Elisp

Open this post in threaded view
|

## Re: Sv: Christmas wish: Literate Elisp

 In reply to this post by arthur miller arthur miller [2019-12-14 04:40:30] wrote: > To be honest my contact with Haskell broke once the university course, some > 20 yrs ago was over, so I am a little bit illiterate about Haskells sexy > packages.  I just recalled that it was possible to invert text and code in > Haskell.  But cool. The fact that it's written is Haskell is just incidental. > Didn't know there is a package to let load org files directly either. Hmm... The closest I can find is https://github.com/jingtaozf/literate-elisp/but it doesn't quite match what I think I was referring to.         Stefan > Thanks for the answers. > ________________________________ > Från: Stefan Monnier <[hidden email]> > Skickat: den 12 december 2019 18:29 > Till: arthur miller <[hidden email]> > Kopia: emacs-devel <[hidden email]>; [hidden email] <[hidden email]> > Ämne: Re: Christmas wish: Literate Elisp > >> My proposal is to slightly change Elisp parser to treat lines that start >> with any other printable character but '(' as a start of comment and to >> simply ignore the line, just as it treats ';' as a comment. > > The sexpresso Haskell package follows the same idea ;-) > > As for using it in Elisp: I don't think there's anything stopping anyone > from making such a literate-elisp-mode and even arrange for load to > handle such a file (just like there is already a package that lets > load work directly on .org files). > > I'd welcome such a package in GNU ELPA. > > >         Stefan
Open this post in threaded view
|

## RE: Sv: Christmas wish: Literate Elisp

 Thanks, I have also found literste-li when I searched, but thought it didn't looked  as suggested . I have played a bit yesterday,  for about an hour and managed to find readevalloop in lread.c in sources. I managed to get a partial hack to work in some cases, but in other I get parse errors. I am not sure I understand exactly how the parser hangs together yet, if I can do everything in that function or I have to change some of other functions too. I will have more time tonight evening. Skickat från min Samsung Galaxy-smartphone. -------- Originalmeddelande -------- Från: Stefan Monnier <[hidden email]> Datum: 2019-12-14 15:08 (GMT+01:00) Till: arthur miller <[hidden email]> Kopia: emacs-devel <[hidden email]>, [hidden email] Ämne: Re: Sv: Christmas wish: Literate Elisp arthur miller [2019-12-14 04:40:30] wrote: > To be honest my contact with Haskell broke once the university course, some > 20 yrs ago was over, so I am a little bit illiterate about Haskells sexy > packages.  I just recalled that it was possible to invert text and code in > Haskell.  But cool. The fact that it's written is Haskell is just incidental. > Didn't know there is a package to let load org files directly either. Hmm... The closest I can find is https://github.com/jingtaozf/literate-elisp/ but it doesn't quite match what I think I was referring to.         Stefan > Thanks for the answers. > ________________________________ > Från: Stefan Monnier <[hidden email]> > Skickat: den 12 december 2019 18:29 > Till: arthur miller <[hidden email]> > Kopia: emacs-devel <[hidden email]>; [hidden email] <[hidden email]> > Ämne: Re: Christmas wish: Literate Elisp > >> My proposal is to slightly change Elisp parser to treat lines that start >> with any other printable character but '(' as a start of comment and to >> simply ignore the line, just as it treats ';' as a comment. > > The sexpresso Haskell package follows the same idea ;-) > > As for using it in Elisp: I don't think there's anything stopping anyone > from making such a literate-elisp-mode and even arrange for load to > handle such a file (just like there is already a package that lets > load work directly on .org files). > > I'd welcome such a package in GNU ELPA. > > >         Stefan
Open this post in threaded view
|

## Sv: Sv: Christmas wish: Literate Elisp

 In reply to this post by Stefan Monnier Hello again, I was able to make readevalloop do what I want. It was rather trivial to implement this (once I realized how it works 🙂). Emacs built fine and I was able to test wtih eval-buffer and eval-regionwhich worked as intended. It was just 4 code lines, I just copied codeto parse comment and change the condition in if-statement: (message "Hello, World!") (message "Hello Again!") In code blocs the ';' is still a comment delimiter: (message  ;; Here is a line comment  "I am a bit chatty today!") That's it for today folks! (message "Bye bye cruel world!") This email was composed in scratch buffer and executed during writing with eval-buffer for testing. However, byte compiler is not happy about this. It emits warnings for every word out of code blocks as references to free variables. I am not sure where to look to patch it, maybe another day. Från: Stefan Monnier <[hidden email]> Skickat: den 14 december 2019 15:08 Till: arthur miller <[hidden email]> Kopia: emacs-devel <[hidden email]>; [hidden email] <[hidden email]> Ämne: Re: Sv: Christmas wish: Literate Elisp   arthur miller [2019-12-14 04:40:30] wrote: > To be honest my contact with Haskell broke once the university course, some > 20 yrs ago was over, so I am a little bit illiterate about Haskells sexy > packages.  I just recalled that it was possible to invert text and code in > Haskell.  But cool. The fact that it's written is Haskell is just incidental. > Didn't know there is a package to let load org files directly either. Hmm... The closest I can find is https://github.com/jingtaozf/literate-elisp/ but it doesn't quite match what I think I was referring to.         Stefan > Thanks for the answers. > ________________________________ > Från: Stefan Monnier <[hidden email]> > Skickat: den 12 december 2019 18:29 > Till: arthur miller <[hidden email]> > Kopia: emacs-devel <[hidden email]>; [hidden email] <[hidden email]> > Ämne: Re: Christmas wish: Literate Elisp > >> My proposal is to slightly change Elisp parser to treat lines that start >> with any other printable character but '(' as a start of comment and to >> simply ignore the line, just as it treats ';' as a comment. > > The sexpresso Haskell package follows the same idea ;-) > > As for using it in Elisp: I don't think there's anything stopping anyone > from making such a literate-elisp-mode and even arrange for load to > handle such a file (just like there is already a package that lets > load work directly on .org files). > > I'd welcome such a package in GNU ELPA. > > >         Stefan lread.patch (534 bytes) Download Attachment
Open this post in threaded view
|

## Re: Sv: Sv: Christmas wish: Literate Elisp

 >> As for using it in Elisp: I don't think there's anything stopping anyone >> from making such a literate-elisp-mode and even arrange for load to >> handle such a file (just like there is already a package that lets >> load work directly on .org files). > I was able to make readevalloop do what I want. It was rather trivial to Note that in my comment above I meant it in existing Emacsen, i.e. without any modification to the C code. The idea is to make use of existing hooks such as load-source-file-function or file-name-handler-alist. I'm not sure what hook could be used to do the same with byte-compilation, but in the worst case, an advice should do the trick.         Stefan
Open this post in threaded view
|

## Sv: Sv: Sv: Christmas wish: Literate Elisp

 Aha 😊 Sorry, I didn’t realized what you ment. I am not sure I know that much of elisp, but I may try to look at, would be lots of learning for me 😊.   Skickades från E-post för Windows 10   Från: [hidden email] Skickat: den 16 december 2019 14:41 Till: [hidden email] Kopia: [hidden email]; [hidden email] Ämne: Re: Sv: Sv: Christmas wish: Literate Elisp   >> As for using it in Elisp: I don't think there's anything stopping anyone >> from making such a literate-elisp-mode and even arrange for load to >> handle such a file (just like there is already a package that lets >> load work directly on .org files). > I was able to make readevalloop do what I want. It was rather trivial to Note that in my comment above I meant it in existing Emacsen, i.e. without any modification to the C code. The idea is to make use of existing hooks such as load-source-file-function or file-name-handler-alist. I'm not sure what hook could be used to do the same with byte-compilation, but in the worst case, an advice should do the trick.         Stefan
Open this post in threaded view
|

## Re: Sv: Sv: Christmas wish: Literate Elisp

 Arthur,Have you happened to have looked at Outshine (https://github.com/alphapapa/outshine)?It enhances outline-minor-mode and lets it work with standard org-syntax while in comment blocks (and defines hotkeys to swap into an edit buffer that makes it look like a normal Org-Mode buffer).By keeping the literate syntax in comments you don't break the existing parser.Regards,JonOn Mon, Dec 16, 2019 at 9:03 AM arthur miller <[hidden email]> wrote: Aha 😊 Sorry, I didn’t realized what you ment. I am not sure I know that much of elisp, but I may try to look at, would be lots of learning for me 😊.   Skickades från E-post för Windows 10   Från: [hidden email] Skickat: den 16 december 2019 14:41 Till: [hidden email] Kopia: [hidden email]; [hidden email] Ämne: Re: Sv: Sv: Christmas wish: Literate Elisp   >> As for using it in Elisp: I don't think there's anything stopping anyone >> from making such a literate-elisp-mode and even arrange for load to >> handle such a file (just like there is already a package that lets >> load work directly on .org files). > I was able to make readevalloop do what I want. It was rather trivial to Note that in my comment above I meant it in existing Emacsen, i.e. without any modification to the C code. The idea is to make use of existing hooks such as load-source-file-function or file-name-handler-alist. I'm not sure what hook could be used to do the same with byte-compilation, but in the worst case, an advice should do the trick.         Stefan
Open this post in threaded view
|

## RE: Sv: Sv: Christmas wish: Literate Elisp

 Of course, I am aware of outline modes, but my proposal is more about literate programming then outlining. Being able to use org outlining in elisp is just an extra icing on the cake that comes out implicitly as a bi product for free. Otherwise of course one can use outline code for folding.  It is true, that keeping directives in comments does not break the existing parser, but then it is not so much of literate programming, is it? If we would just use directives in comments then we already have org + babel. But I think 4 extra lines of C code to enable this feature in eval-loop was a trivial price to pay :-).  Now I just wonder how to change the bytecode compiler. Unfortunately it seems to be much more involved process. I don't know  if I can do it, since I am  not so acquainted with Emacs internals, so it would be cool if someone more knowledgeable can at least hint me if not help. Skickat från min Samsung Galaxy-smartphone. -------- Originalmeddelande -------- Från: Jonathan Leech-Pepin <[hidden email]> Datum: 2019-12-16 17:07 (GMT+01:00) Till: arthur miller <[hidden email]> Kopia: Stefan Monnier <[hidden email]>, [hidden email], emacs-devel <[hidden email]> Ämne: Re: Sv: Sv: Christmas wish: Literate Elisp Arthur, Have you happened to have looked at Outshine (https://github.com/alphapapa/outshine)? It enhances outline-minor-mode and lets it work with standard org-syntax while in comment blocks (and defines hotkeys to swap into an edit buffer that makes it look like a normal Org-Mode buffer). By keeping the literate syntax in comments you don't break the existing parser. Regards, Jon On Mon, Dec 16, 2019 at 9:03 AM arthur miller <[hidden email]> wrote: Aha 😊 Sorry, I didn’t realized what you ment. I am not sure I know that much of elisp, but I may try to look at, would be lots of learning for me 😊.   Skickades från E-post för Windows 10   Från: [hidden email] Skickat: den 16 december 2019 14:41 Till: [hidden email] Kopia: [hidden email]; [hidden email] Ämne: Re: Sv: Sv: Christmas wish: Literate Elisp   >> As for using it in Elisp: I don't think there's anything stopping anyone >> from making such a literate-elisp-mode and even arrange for load to >> handle such a file (just like there is already a package that lets >> load work directly on .org files). > I was able to make readevalloop do what I want. It was rather trivial to Note that in my comment above I meant it in existing Emacsen, i.e. without any modification to the C code. The idea is to make use of existing hooks such as load-source-file-function or file-name-handler-alist. I'm not sure what hook could be used to do the same with byte-compilation, but in the worst case, an advice should do the trick.         Stefan
Open this post in threaded view
|

## Re: Sv: Sv: Christmas wish: Literate Elisp

Open this post in threaded view
|

## Sv: Sv: Sv: Christmas wish: Literate Elisp

Open this post in threaded view
|

## Re: Sv: Sv: Sv: Christmas wish: Literate Elisp

Open this post in threaded view
|

## Sv: Sv: Sv: Sv: Christmas wish: Literate Elisp

Open this post in threaded view
|

## Re: Sv: Sv: Sv: Christmas wish: Literate Elisp

 In reply to this post by Adam Porter > ; I am not more distracted while reading this line of text > than I am while reading this one. Thre is no discussion of changing the existing syntax/semantic of Elisp here.  Arthur is proposing a new file format/syntax as an alternative to the use of weave/tangle or Org-mode. You don't have to agree with each other.         Stefan
Open this post in threaded view
|

## Christmas wish: Literate Elisp (Intro)

 >> ; I am not more distracted while reading this line of text >> than I am while reading this one. > > Thre is no discussion of changing the existing syntax/semantic of > Elisp here.  Arthur is proposing a new file format/syntax as an > alternative to the use of weave/tangle or Org-mode. > > You don't have to agree with each other. Arthur's vision is a beautiful thing to my eyes.  Lawyers and programmers can read and write, thoughtfully and clearly, together collaboratively, at the Creation before the two crashs. (message         "Before you go, have you heard the comedian tell the joke about          the lawyer, the scientist, and the engineer going to Mars?") -- VanL., 🐞   əə0@ 一 二 三 言 語 𝔖 元 示 証 明 海 自 己 漢 本 人 Gnus/Emacs (berkeley-unix)
Open this post in threaded view
|

## Re: Sv: Sv: Sv: Christmas wish: Literate Elisp

 In reply to this post by Stefan Monnier Stefan Monnier <[hidden email]> writes: > Thre is no discussion of changing the existing syntax/semantic of > Elisp here.  Arthur is proposing a new file format/syntax as an > alternative to the use of weave/tangle or Org-mode. That's not my understanding of what Arthur is proposing.  You did propose an alternative file format in earlier messages when you wrote: > As for using it in Elisp: I don't think there's anything stopping > anyone from making such a literate-elisp-mode and even arrange for > load to handle such a file (just like there is already a package > that lets load work directly on .org files).  I'd welcome such a > package in GNU ELPA. And: > Note that in my comment above I meant it in existing Emacsen, > i.e. without any modification to the C code.  The idea is to make use > of existing hooks such as load-source-file-function or > file-name-handler-alist.  I'm not sure what hook could be used to do > the same with byte-compilation, but in the worst case, an advice > should do the trick. But Arthur has been proposing to alter the Emacs Elisp parser itself, e.g. when he wrote: > My proposal is to slightly change Elisp parser to treat lines that > start with any other printable character but '(' as a start of comment > and to simply ignore the line, just as it treats ';' as a comment And: > I was able to make readevalloop do what I want. It was rather trivial > to implement this (once I realized how it works 🙂). Emacs built fine > and I was able to test wtih eval-buffer and eval-regionwhich worked as > intended. > It was just 4 code lines, I just copied codeto parse comment and > change the condition in if-statement: > However, byte compiler is not happy about this. It emits warnings for > every word out of code blocks as references to free variables. I am > not sure where to look to patch it, maybe another day. And: > If we would just use directives in comments then we already have org + > babel. But I think 4 extra lines of C code to enable this feature in > eval-loop was a trivial price to pay :-). > Now I just wonder how to change the bytecode compiler. Unfortunately > it seems to be much more involved process. I don't know if I can do > it, since I am not so acquainted with Emacs internals, so it would be > cool if someone more knowledgeable can at least hint me if not help. I've looked again at all messages in the thread.  Am I missing something?