[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eev fb09b2d7c9: Added (find-lua-tutorial-intro).
From: |
ELPA Syncer |
Subject: |
[elpa] externals/eev fb09b2d7c9: Added (find-lua-tutorial-intro). |
Date: |
Sat, 13 Jan 2024 00:59:49 -0500 (EST) |
branch: externals/eev
commit fb09b2d7c9bd67859d7fac6636318ef96d137309
Author: Eduardo Ochs <eduardoochs@gmail.com>
Commit: Eduardo Ochs <eduardoochs@gmail.com>
Added (find-lua-tutorial-intro).
---
ChangeLog | 5 ++
VERSION | 4 +-
eev-intro.el | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
eev-template0.el | 8 +--
eev-tlinks.el | 139 +++++++++++++++++++++++++++++++++++++++++++
5 files changed, 318 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cd2cf8ca57..0a1795b021 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2024-01-12 Eduardo Ochs <eduardoochs@gmail.com>
+ * eev-intro.el (find-lua-tutorial-intro): new function.
+
+ * eev-tlinks.el (find-luainit-links, find-luaso-links): new
+ functions.
+
* eev-intro.el (find-templates-intro): new section: "7. let*
macros".
(find-intro-intro): replace the `(cadr (ee-intro-sexp-here))' by
diff --git a/VERSION b/VERSION
index 103aa028b7..4b809ddbe9 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Fri Jan 12 18:15:15 GMT 2024
-Fri Jan 12 15:15:15 -03 2024
+Sat Jan 13 04:46:14 GMT 2024
+Sat Jan 13 01:46:14 -03 2024
diff --git a/eev-intro.el b/eev-intro.el
index 34d3284afd..284fb49cf1 100644
--- a/eev-intro.el
+++ b/eev-intro.el
@@ -19,7 +19,7 @@
;;
;; Author: Eduardo Ochs <eduardoochs@gmail.com>
;; Maintainer: Eduardo Ochs <eduardoochs@gmail.com>
-;; Version: 20240112
+;; Version: 20240113
;; Keywords: e-scripts
;;
;; Latest version: <http://anggtwu.net/eev-current/eev-intro.el>
@@ -100,6 +100,7 @@
;; «.find-edit-index-intro» (to "find-edit-index-intro")
;; «.find-rstdoc-intro» (to "find-rstdoc-intro")
;; «.find-show2-intro» (to "find-show2-intro")
+;; «.find-lua-tutorial-intro» (to "find-lua-tutorial-intro")
;; Videos:
;; «.find-three-main-keys-intro» (to "find-three-main-keys-intro")
@@ -2867,18 +2868,19 @@ These ones explain advanced features that require extra
setup:
33. (find-edit-index-intro)
34. (find-rstdoc-intro)
35. (find-show2-intro)
- 36. (find-prepared-intro)
- 37. (find-bounded-intro)
- 38. (find-channels-intro)
+ 36. (find-lua-tutorial-intro)
+ 37. (find-prepared-intro)
+ 38. (find-bounded-intro)
+ 39. (find-channels-intro)
This one was used in a video:
- 39. (find-three-main-keys-intro)
+ 40. (find-three-main-keys-intro)
These ones are obsolete:
- 40. (find-emacs-intro)
- 41. (find-defun-intro)
+ 41. (find-emacs-intro)
+ 42. (find-defun-intro)
For an index of the videos, run:
@@ -17275,6 +17277,165 @@ To be written! See:
+;;; _ _ _ _ _
+;;; | |_ _ __ _ | |_ _ _| |_ ___ _ __(_) __ _| |
+;;; | | | | |/ _` |_____| __| | | | __/ _ \| '__| |/ _` | |
+;;; | | |_| | (_| |_____| |_| |_| | || (_) | | | | (_| | |
+;;; |_|\__,_|\__,_| \__|\__,_|\__\___/|_| |_|\__,_|_|
+;;;
+;; «find-lua-tutorial-intro» (to ".find-lua-tutorial-intro")
+;; Skel: (find-intro-links "lua-tutorial")
+;; Test: (find-lua-tutorial-intro)
+
+(defun find-lua-tutorial-intro (&rest pos-spec-list) (interactive)
+ (let ((ee-buffer-name "*(find-lua-tutorial-intro)*"))
+ (apply 'find-eintro "\
+\(Re)generate: (find-lua-tutorial-intro)
+Source code: (find-efunction 'find-lua-tutorial-intro)
+More intros: (find-eev-quick-intro)
+ (find-eev-intro)
+ (find-eepitch-intro)
+This buffer is _temporary_ and _editable_.
+It is meant as both a tutorial and a sandbox.
+
+
+This is a work in progress that
+is in a very early stage!
+
+This intro
+
+ (find-show2-intro)
+
+explains how to install Lua and how to test the programs that I
+presented in the EmacsConf2023, but it doesn't say where someone
+who would like to learn Lua can learn the basics...
+
+
+
+1. Installation
+===============
+Run the instructions in this section:
+
+ (find-show2-intro \"2. Dependencies\")
+
+Here are the instructions - in video - for how to run them:
+
+ (find-eev2023replsbvideo \"05:23\" \"Then, to try the demo people have to\")
+ (find-eev2023replsblsubs \"05:23\" \"Then, to try the demo people have to\")
+
+and copy the `code-brappend's to your ~/.emacs (without the red stars).
+
+
+
+2. LUA_INIT
+===========
+Run this
+
+ (find-luainit-links \"/tmp/\")
+
+to download my init file for Lua in /tmp/ and test it there. Then
+run this
+
+ (find-luainit-links \"~/LUA/\")
+
+to download it in ~/LUA/ and test it there.
+Then copy these three lines to your ~/.emacs:
+
+ ;; See: (find-lua-tutorial-intro \"2. LUA_INIT\")
+ ;; (find-fline \"~/LUA/lua50init.lua\")
+ (setenv \"LUA_INIT\" (concat \"@\" (ee-expand \"~/LUA/lua50init.lua\")))
+
+
+
+
+3. The C API
+============
+This is an example of how to define Lua functions in C:
+
+ (find-angg \"CLUA/dummy2.c\")
+
+Note that its test block looks like this:
+
+/*
+ (eepitch-shell)
+ (eepitch-kill)
+ (eepitch-shell)
+gcc -g -Wall -shared -I/usr/include/lua5.1 -o dummy2.so dummy2.c
+ls -lAF dummy2*
+
+ (eepitch-lua51)
+ (eepitch-kill)
+ (eepitch-lua51)
+Path.prependtocpath \"~/CLUA/?.so\"
+require \"dummy2\"
+print(foo(42))
+
+*/
+
+Its first part compiles the .c to a .so, and the second part:
+
+ 1) runs Path.prependtocpath to add \"~/CLUA/?.so\" to the path.
+ This needs the class Path, that is defined in my init file -
+ so this will only work if you configured LUA_INIT correctly
+ using the instructions in the previous section,
+
+ 2) loads \"~/CLUA/dummy2.so\",
+
+ 3) calls `print(foo(42))' - where `foo' is a Lua function
+ defined in C in dummy2.{c,so}.
+
+Note also that the header of dummy2.c starts with these lines:
+
+ // This file:
+ // http://anggtwu.net/CLUA/dummy2.c.html
+ // http://anggtwu.net/CLUA/dummy2.c
+ // (find-angg \"CLUA/dummy2.c\")
+ // Skel: (find-luaso-links \"~/CLUA/dummy2.c\" \"foo\")
+ // Author: Eduardo Ochs <eduardoochs@gmail.com>
+ //
+ // (defun e () (interactive) (find-angg \"CLUA/dummy2.c\"))
+
+I will refer to those files as \"angg-isms\" - they only make
+sense for C files in http://anggtwu.net/.
+
+This file
+
+ (find-angg \"CLUA/dummy2.c\")
+
+was generated by this call to a template-based function:
+
+ (find-luaso-links \"~/CLUA/dummy2.c\" \"foo\")
+
+EXERCISE: run this,
+
+ (find-luaso-links \"/tmp/dummy2.c\" \"foo\")
+
+and ignore - or delete - all the lines in the temporary buffer
+that look like angg-isms; use the `ee-copy-rest' in the temporary
+buffer to create a file /tmp/dummy2.c with the correct contents;
+and run its test block. If everything goes right then the test
+block will generate a file /tmp/dummy2.so, load it from Lua, and
+test its function `foo'.
+
+
+
+4. TODO
+=======
+I have an old eev-based tutorial for Lua here:
+
+ (find-es \"lua-intro\" \"how-to-use\")
+ (find-es \"lua-intro\" \"intro:types\")
+
+I need to clean it up and explain how to use it...
+
+
+
+" pos-spec-list)))
+
+;; (find-lua-tutorial-intro)
+
+
+
diff --git a/eev-template0.el b/eev-template0.el
index 4de6e3d6be..7785ecfa2f 100644
--- a/eev-template0.el
+++ b/eev-template0.el
@@ -236,10 +236,10 @@ See the source code for examples and tests."
(cons 'concat (delete "" (nreverse exprs)))))
;; Tests:
-;; (ee-template0-lex "{<} a{(+ 2 3)} {>}")
-;; (macroexpand '(ee-template0-lex "{<} a{(+ 2 3)} {>}"))
-;; (ee-template00-lex "{<} a{(+ 2 3)} {>}")
-;; (ee-template000-lex "{<} a{(+ 2 3)} {>}")
+;; (ee-template0-lex "{<} a{(+ 2 3)} {>}")
+;; (find-eppm '(ee-template0-lex "{<} a{(+ 2 3)} {>}"))
+;; (ee-template00-lex "{<} a{(+ 2 3)} {>}")
+;; (ee-template000-lex "{<} a{(+ 2 3)} {>}")
;;
' (let ((hi "Here:") (a 22) (b 33))
(ee-template0-lex "{hi} {a} + {b} = {(+ a b)}"))
diff --git a/eev-tlinks.el b/eev-tlinks.el
index 5a66ee8e50..33d0905f1b 100644
--- a/eev-tlinks.el
+++ b/eev-tlinks.el
@@ -168,6 +168,8 @@
;; «.find-maximamsg» (to "find-maximamsg")
;; «.find-linki-links» (to "find-linki-links")
;; «.find-gitdoc-links» (to "find-gitdoc-links")
+;; «.find-luainit-links» (to "find-luainit-links")
+;; «.find-luaso-links» (to "find-luaso-links")
(require 'eev-env)
@@ -4891,6 +4893,143 @@ A \"Maxima message\" is a message in the Maxima mailing
list."
+;; «find-luainit-links» (to ".find-luainit-links")
+;; Skel: (find-find-links-links-new "luainit" "dir" "dir0")
+;; Test: (find-luainit-links)
+;;
+(defun find-luainit-links (&optional dir &rest pos-spec-list)
+"Visit a temporary buffer containing a script for testing lua50init.lua."
+ (interactive)
+ (setq dir (or dir "{dir}"))
+ (let* ((dir0 (ee-expand dir)))
+ (apply
+ 'find-elinks
+ `((find-luainit-links ,dir ,@pos-spec-list)
+ (find-luainit-links "/tmp/")
+ (find-luainit-links "~/LUA/")
+ ;; Convention: the first sexp always regenerates the buffer.
+ (find-efunction 'find-luainit-links)
+ ""
+ ,(ee-template0 "\
+ Download/update
+ (eepitch-shell)
+ (eepitch-kill)
+ (eepitch-shell)
+rm -fv {dir}lua50init.lua
+wget -P {dir} -N http://anggtwu.net/LUA/lua50init.lua
+ls -lAF {dir}lua50init.lua
+
+ Test
+ (eepitch-shell)
+ (eepitch-kill)
+ (eepitch-shell)
+export LUA_INIT=
+lua5.1
+ PP({20,\"30\"}) -- should fail
+ os.exit()
+
+export LUA_INIT=@{dir0}lua50init.lua
+lua5.1
+ PP({20,\"30\"}) -- should work
+ os.exit()
+
+ (setenv \"LUA_INIT\" nil)
+ (eepitch-lua51)
+ (eepitch-kill)
+ (eepitch-lua51)
+ PP({20,\"30\"}) -- should fail
+
+ (setenv \"LUA_INIT\" \"@{dir0}lua50init.lua\")
+ (eepitch-lua51)
+ (eepitch-kill)
+ (eepitch-lua51)
+ PP({20,\"30\"}) -- should work
+")
+ )
+ pos-spec-list)))
+
+
+
+;; «find-luaso-links» (to ".find-luaso-links")
+;; Skel: (find-find-links-links-new "luaso" "fname funname" "fname0 fname00
stem dir")
+;; Test: (find-luaso-links "/tmp/dummy2.c" "foo")
+;; See: (find-angg "CLUA/foo.c")
+;; (find-angg "LUA/CLua1.lua")
+;; (find-es "lua5" "CLua1.lua")
+;;
+(defun find-luaso-links (&optional fname funname &rest pos-spec-list)
+"Visit a temporary buffer containing hyperlinks for luaso."
+ (interactive)
+ (setq fname (or fname "{fname}"))
+ (setq funname (or funname "{funname}"))
+ (let* ((fname0 (ee-shorten-file-name fname))
+ (fname00 (ee-replace-prefix "~/" "" fname0))
+ (stem (file-name-base fname))
+ (dir (file-name-directory fname)))
+ (apply
+ 'find-elinks
+ `((find-luaso-links ,fname ,funname ,@pos-spec-list)
+ ;; Convention: the first sexp always regenerates the buffer.
+ (find-efunction 'find-luaso-links)
+ ""
+ ,(ee-template0 "\
+// (c-mode)
+// All lines with \"angg\" are angg-isms!
+// (kill-new \" {fname00}\")
+// (find-blogme3 \"anggmake.lua\" \"anggtranslate\")
+// (find-blogme3 \"anggmake.lua\" \"anggtranslate\" \"LUA/\")
+// (ee-copy-rest 2 '(find-fline \"{fname}\"))
+
+
+// This file:
+// http://anggtwu.net/{fname00}.html
+// http://anggtwu.net/{fname00}
+// (find-angg \"{fname00}\")
+// Skel: (find-luaso-links \"{fname}\" \"{funname}\")
+// Author: Eduardo Ochs <eduardoochs@gmail.com>
+//
+// (defun e () (interactive) (find-angg \"{fname00}\"))
+
+#include \"lauxlib.h\"
+#include <stdio.h>
+
+static int my_{funname}(lua_State* L) {<}
+ lua_pushnumber(L, 33);
+ lua_pushnumber(L, 333);
+ return 2;
+{>}
+
+static const struct luaL_reg {stem}_lib[] = {<}
+ {<}\"{funname}\", my_{funname}{>},
+ {<}NULL, NULL{>}
+{>};
+
+LUALIB_API int luaopen_{stem}(lua_State *L) {<}
+ lua_pushvalue(L, LUA_GLOBALSINDEX);
+ luaL_openlib(L, NULL, {stem}_lib, 0);
+ return 0;
+{>}
+
+/*
+ (eepitch-shell)
+ (eepitch-kill)
+ (eepitch-shell)
+gcc -g -Wall -shared -I/usr/include/lua5.1 -o {stem}.so {stem}.c
+ls -lAF {stem}*
+
+ (eepitch-lua51)
+ (eepitch-kill)
+ (eepitch-lua51)
+Path.prependtocpath \"{dir}?.so\"
+require \"{stem}\"
+print({funname}(42))
+
+*/\
+")
+ )
+ pos-spec-list)))
+
+
(provide 'eev-tlinks)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/eev fb09b2d7c9: Added (find-lua-tutorial-intro).,
ELPA Syncer <=