Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
;; This file: ;; http://angg.twu.net/LUA/tikz1.el.html ;; http://angg.twu.net/LUA/tikz1.el ;; (find-angg "LUA/tikz1.el") ;; Author: Eduardo Ochs <eduardoochs@gmail.com> ;; Version: 20221107 ;; Public domain. ;; ;; See: ;; http://angg.twu.net/eev-tikz.html ;; The easiest way to test this is by running: ;; (find-anggwget-elisp "LUA/tikz1.el") ;; (eval-buffer) ;; (find-tikz1-links) ;; ;; I sometimes use this: ;; (load (buffer-file-name)) ;; «.tikz-show» (to "tikz-show") ;; «.tikz-showtex» (to "tikz-showtex") ;; «.tik» (to "tik") ;; «.tib» (to "tib") ;; «.tir» (to "tir") ;; «.find-tikz1-links» (to "find-tikz1-links") ;; «.find-tikz1-exercises-links» (to "find-tikz1-exercises-links") ;; «.find-tikzsearch-links» (to "find-tikzsearch-links") ;; «.tiks» (to "tiks") ;;; _ __ _ _ ;;; ___| |__ _____ __ / / ___| |__ _____ _| |_ _____ __ ;;; / __| '_ \ / _ \ \ /\ / / / / / __| '_ \ / _ \ \ /\ / / __/ _ \ \/ / ;;; \__ \ | | | (_) \ V V / / / \__ \ | | | (_) \ V V /| || __/> < ;;; |___/_| |_|\___/ \_/\_/ /_/ |___/_| |_|\___/ \_/\_/ \__\___/_/\_\ ;;; ;; See: ;; http://angg.twu.net/eev-tikz.html#modify-compile-redisplay ;; «tikz-show» (to ".tikz-show") (defun tikz-show () (interactive) (find-3a nil '(find-ebuffer (eepitch-target-buffer)) '(find-pdftools-page "/tmp/tikz1.pdf"))) ;; «tikz-showtex» (to ".tikz-showtex") (defun tikz-showtex () (interactive) (ee-kill-buffer "tikz1.tex") (find-3a nil '(find-ebuffer (eepitch-target-buffer)) '(find-pdftools-page "/tmp/tikz1.tex"))) ;;; _ _ _ __ _ _ _ __ _ _ ;;; | |_(_) | __ / / | |_(_) |__ / / | |_(_)_ __ ;;; | __| | |/ / / / | __| | '_ \ / / | __| | '__| ;;; | |_| | < / / | |_| | |_) | / / | |_| | | ;;; \__|_|_|\_\ /_/ \__|_|_.__/ /_/ \__|_|_| ;;; ;; «tik» (to ".tik") (defun tik () "Insert an eepitch block that runs tikz1.lua." (interactive) (insert " * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) ee_dofile \"~/LUA/tikz1.lua\" -- (find-anchor \"~/LUA/tikz1.lua\") tikzbody = tikz [=[ \\draw[color=orange] (0,0)--(1,2)--(2,0)--cycle; ]=] show() * (tikz-show) ")) ;; «tib» (to ".tib") (defun tib () "Wrap the current region in a tikzbody=[=[...]=]/show() block. A `tib' block usually comes after a `tik' block." (interactive) (call-interactively 'kill-region) (insert "tikzbody = tikz [=[\n") (call-interactively 'yank) (insert "]=]\n" "show()\n" "* (tikz-show)\n\n")) ;; «tir» (to ".tir") (defun tir () "Insert a block that runs a Lua REPL in lualatex." (interactive) (insert " * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) ee_dofile \"~/LUA/tikz1.lua\" -- (find-anchor \"~/LUA/tikz1.lua\") repl = repl2 -- (find-anchor \"~/LUA/tikz1.lua\" \"repl-tests\") savetex() ** * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd /tmp/ && lualatex tikz1.tex texrun [=[ \\def\\bla{BLA} ]=] = getmeaning(\"bla\") ")) ;;; __ _ _ _ _ _ _ _ _ _ ;;; / _(_)_ __ __| | | |_(_) | __ ___/ | | (_)_ __ | | _____ ;;; | |_| | '_ \ / _` |_____| __| | |/ /|_ / |_____| | | '_ \| |/ / __| ;;; | _| | | | | (_| |_____| |_| | < / /| |_____| | | | | | <\__ \ ;;; |_| |_|_| |_|\__,_| \__|_|_|\_\/___|_| |_|_|_| |_|_|\_\___/ ;;; ;; «find-tikz1-links» (to ".find-tikz1-links") ;; Skel: (find-find-links-links-new "tikz" "" "") ;; Test: (find-tikz1-links) ;; (defun find-tikz1-links (&rest pos-spec-list) "Visit a temporary buffer containing an e-script for tikz1.lua." (interactive) (let ((ee-buffer-name "*(find-tikz1-links)*")) (apply 'find-elinks `((find-tikz1-links ,@pos-spec-list) ;; Convention: the first sexp always regenerates the buffer. (find-efunction 'find-tikz1-links) ,(ee-H "See: http://angg.twu.net/eev-tikz.html") "" "" ,(ee-template0 "\ ** 0. Basic installation ** ===================== ** Eepitch treats lines that start with two red stars as comments. ** This block downloads four files into ~/LUA/ - or updates them. ** * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) mkdir -p ~/LUA/ cd ~/LUA/ wget -N http://angg.twu.net/LUA/lua50init.lua wget -N http://angg.twu.net/LUA/tikz1.lua wget -N http://angg.twu.net/LUA/tikz1.el wget -N http://angg.twu.net/LUA/Repl2.el ** 1. Basic tests ** ============== ** This block is explained in: ** http://angg.twu.net/eev-tikz.html#modify-compile-redisplay ** ** Set the init file of Lua to ~/LUA/lua50init.lua: * (setenv \"LUA_INIT\" (format \"@%s/LUA/lua50init.lua\" (getenv \"HOME\"))) * * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) ee_dofile \"~/LUA/tikz1.lua\" -- (find-angg \"LUA/tikz1.lua\") tikzbody = tikz [=[ \\draw <<gridoptions>> (0,0) grid <<gridsize or \"(6,4)\">>; \\draw <<triangleoptions>> (0,0)--(1,2)--(2,0)--cycle; ]=] show() * (find-pdftoolsr-page \"/tmp/tikz1.pdf\") gridoptions = \"[color=gray!20]\" show() * (find-pdftoolsr-page \"/tmp/tikz1.pdf\") gridsize = \"(4,3)\" show() * (find-pdftoolsr-page \"/tmp/tikz1.pdf\") gridoptions, gridsize = nil, nil savetex() * (tikz-showtex) gridoptions = \"[color=gray!20]\" savetex() * (tikz-showtex) gridsize = \"(4,3)\" savetex() * (tikz-showtex) gridoptions, gridsize = nil, nil show() * (tikz-show) gridoptions = \"[color=gray!20]\" show() * (tikz-show) gridsize = \"(4,3)\" show() * (tikz-show) ** 2. Not-so-basic installation ** ============================ ** If you want to use this to learn TikZ, copy the following ** block of non-red star lines to your ~/.emacs. Then running ** `M-x tik' will insert an eepitch block for TikZ. ** ;; From: (find-anchor \"~/LUA/tikz1.el\") ;; See: (find-anchor \"~/LUA/tikz1.el\" \"tik\") ;; http://angg.twu.net/eev-tikz.html (setenv \"LUA_INIT\" (format \"@%s/LUA/lua50init.lua\" (getenv \"HOME\"))) (load \"~/LUA/tikz1.el\") ** ** ** ** 3. Exercises ** ============ ** They are explained here: ** http://angg.twu.net/eev-tikz.html#exercises ** If you need spoilers, run: ** (find-tikz1-exercises-links) ** ** a) [tik]: Use `M-x tik' to create an eepitch block that ** compiles and displays a drawing whose body is: ** \\draw [color=gray!20] (0,0) grid (4,3); ** \\draw [color=red] (0,0)--(1,2)--(2,0)--cycle; ** ** b) [.emacs-1]: copy the lines from the section \"2. Basic installation\" ** to your ~/.emacs. Restart Emacs. Check that `M-x find-tikz1-links' ** and `M-x tik' work. ** ** c) [.emacs-2]: if running `M-x find-es' says \"Not configured\", ** then use `M-x find-angg-es-links' to configure it. Save ** the right parts of its temporary buffer to your ~/.emacs. ** Check that this works: ** (find-es \"tikz\" \"tut-nodes\") ** ** d) [manual-pdf]: start from this URL, ** https://pgf-tikz.github.io/pgf/pgfmanual.pdf ** and produce a `code-pdf-page'/`code-pdf-text' pair ** that makes these links work: ** (find-tikzmanpage) ** (find-tikzmantext) ** ** e) [manual-git]: start from this URL, ** https://github.com/pgf-tikz/pgf ** and produce the three `code-c-d's that make these sexps work: ** (find-tikzgitfile \"\") ** (find-tikzgittgpfile \"\") ** (find-tikzmanfile \"\") ** ** f) [.emacs-3]: copy the `code-*'s from the exercises (c) and (d) ** to your ~/.emacs. Hint: use good \"From:\" lines. You can copy ** them from: ** (find-tikz1-exercises-links) ** ** g) [page]: start from this hyperlink, ** (find-tikzmantext \"(1,3.25)\") ** and produce a `find-tikzmanpage'/`find-tikzmantext' pair ** that points to the page in which that string first appears ** in the manual. ** ** h) [src]: start from this hyperlink, ** (tiks \"{<}Horizontal and Vertical Lines{>}\") ** and produce a `find-tikzmanfile' link that points to the ** source of the section \"Horizontal and Vertical Lines\" ** in the manual. ** ** i) [tiks]: start from this hyperlink, ** (tiks \"Horizontal and Vertical Lines\") ** and make sure that you know how to use all the hyperlinks ** in the temporary buffer that `tiks' generated. ** ** j) [section]: start from this hyperlink, ** (tiks \"Key Management\") ** and produce links to the section \"Key Management\" in the ** manual. ** ** k) [codeexample-1]: start from this hyperlink, ** (tiks \"Horizontal and Vertical Lines\") ** and use `M-x tik' to create an eepitch block that runs ** the first \"codeexample\" in that subsection of the manual. ** ** l) [codeexample-2]: start from this hyperlink, ** (tiks \"/a/.code=\") ** and use `M-x tik' to create an eepitch block that runs ** the first \"codeexample\" that contains that string. ** You will have to put its code in the variable \"hello\" ** instead of in \"tikzbody\". ** ** m) [codeexample-3]: start from this hyperlink, ** (tiks \"magnetic field\") ** and use `M-x tik' to create an eepitch block that runs ** the first \"codeexample\" that contains that string. ** Here you will have to use this: ** usepackages = [=[ ** \\usetikzlibrary{<}3d{>} ** ]=] ** ** n) [getmeaning]: start from any one of these links, ** (find-angg \"LUA/Repl2.lua\" \"getmeaning-tests\") ** (find-anchor \"~/LUA/Repl2.lua\" \"getmeaning-tests\") ** and make sure that you understand how to use \"printtikzkey\". ") ) pos-spec-list))) ;;; _ ;;; _____ _____ _ __ ___(_)___ ___ ___ ;;; / _ \ \/ / _ \ '__/ __| / __|/ _ \/ __| ;;; | __/> < __/ | | (__| \__ \ __/\__ \ ;;; \___/_/\_\___|_| \___|_|___/\___||___/ ;;; ;; «find-tikz1-exercises-links» (to ".find-tikz1-exercises-links") ;; Skel: (find-find-links-links-new "tikz1-exercises" "" "") ;; Test: (find-tikz1-exercises-links) ;; (defun find-tikz1-exercises-links (&rest pos-spec-list) "Visit a temporary buffer containing some spoilers." (interactive) (let ((ee-buffer-name "*(find-tikz1-exercises-links)*")) (apply 'find-elinks-elisp `((find-tikz1-exercises-links ,@pos-spec-list) ;; Convention: the first sexp always regenerates the buffer. (find-efunction 'find-tikz1-exercises-links) "" ,(ee-template0 "\ ;; Put this in your ~/.emacs: ;; From: http://angg.twu.net/eev-tikz.html ;; (find-tikz1-links) \(setenv \"LUA_INIT\" (format \"@%s/LUA/lua50init.lua\" (getenv \"HOME\"))) \(load \"~/LUA/tikz1.el\") ;; From: (find-tikz1-exercises-links) ;; (find-psne-links \"https://pgf-tikz.github.io/pgf/pgfmanual.pdf\") ;; (find-fline \"$S/https/pgf-tikz.github.io/pgf/\" \"pgfmanual.pdf\") ;; (find-extra-file-links \"$S/https/pgf-tikz.github.io/pgf/pgfmanual.pdf\" \"tikzman\") ;; \(code-pdf-page \"tikzman\" \"$S/https/pgf-tikz.github.io/pgf/pgfmanual.pdf\") \(code-pdf-text \"tikzman\" \"$S/https/pgf-tikz.github.io/pgf/pgfmanual.pdf\") ;; (find-tikzmanpage) ;; (find-tikzmantext) ;; From: (find-tikz1-exercises-links) ;; (find-git-links \"https://github.com/pgf-tikz/pgf\" \"tikzgit\") \(code-c-d \"tikzgit\" \"~/usrc/pgf/\") \(code-c-d \"tikzgittgp\" \"~/usrc/pgf/tex/generic/pgf/\") \(code-c-d \"tikzman\" \"~/usrc/pgf/doc/generic/pgf/\") ;; (find-tikzgitfile \"\") ;; (find-tikzgittgpfile \"\") ;; (find-tikzmanfile \"\") ;; TODO: ;; From: (find-eev \"eev-tlinks.el\" \"find-angg-es-links\") ;; From: (find-eev \"eev-kla.el\" \"aliases\") ") ) pos-spec-list))) ;;; _ _ _ __ _ _ _ _ ;;; | |_(_) | _____ / / | |_(_) | __ _______ ___ __ _ _ __ ___| |__ ;;; | __| | |/ / __| / / | __| | |/ /|_ / __|/ _ \/ _` | '__/ __| '_ \ ;;; | |_| | <\__ \ / / | |_| | < / /\__ \ __/ (_| | | | (__| | | | ;;; \__|_|_|\_\___/ /_/ \__|_|_|\_\/___|___/\___|\__,_|_| \___|_| |_| ;;; ;; «find-tikzsearch-links» (to ".find-tikzsearch-links") ;; «tiks» (to ".tiks") ;; Skel: (find-find-links-links-new "tikzsearch" "string" "") ;; Test: (find-tikzsearch-links "Node Coordinate System") ;; (find-tikzsearch-links) ;; (find-tikzsearch-links "rounded") ;; (defun find-tikzsearch-links (&optional string &rest pos-spec-list) "Visit a temporary buffer containing hyperlinks for tikzsearch." (interactive) (setq string (or string "{string}")) (apply 'find-elinks `((tiks ,string) (find-tikzsearch-links ,string ,@pos-spec-list) ;; Convention: the first sexp always regenerates the buffer. (find-efunction 'find-tikzsearch-links) "" ,(ee-template0 "\ # (find-angg \".emacs.papers\" \"tikz\") # (find-angg \".emacs.papers\" \"tikz\" \"{string}\") # (kill-new \"{string}\") # (find-tikzmanpage 3 \"Contents\") # (find-tikzmantext 3 \"Contents\") # (find-tikzmanpage 3 \"{string}\") # (find-tikzmantext 3 \"{string}\") # (find-tikzmanpage 1235 \"{string}\") # (find-tikzmantext 1235 \"{string}\") # (find-tikzgitfile \"\") # (find-tikzmanfile \"\") # (find-tikzgittgpfile \"\") # (find-tikzgitgrep \"grep --color=auto -nRH --null -e '{string}' *\") # (find-tikzmangrep \"grep --color=auto -nRH --null -e '{string}' *.tex\") # (find-tikzgittgpgrep \"grep --color=auto -nRH --null -e '{string}' *\") # https://github.com/pgf-tikz/pgf # https://github.com/pgf-tikz/pgf/tree/master/ ") ) pos-spec-list)) (defalias 'tiks 'find-tikzsearch-links) ;; Local Variables: ;; coding: utf-8-unix ;; End: