[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eev dc4b212 2/4: New file: "eev-tla.el".
From: |
ELPA Syncer |
Subject: |
[elpa] externals/eev dc4b212 2/4: New file: "eev-tla.el". |
Date: |
Sat, 29 May 2021 08:57:09 -0400 (EDT) |
branch: externals/eev
commit dc4b212f840de2b2352c57042dbb3f20992689c0
Author: Eduardo Ochs <eduardoochs@gmail.com>
Commit: Eduardo Ochs <eduardoochs@gmail.com>
New file: "eev-tla.el".
---
VERSION | 4 +-
eev-elinks.el | 2 +
eev-hydras.el | 160 ++++++++++++++++++++++---
eev-intro.el | 3 +-
eev-tla.el | 367 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 515 insertions(+), 21 deletions(-)
diff --git a/VERSION b/VERSION
index b05a4ac..70ea30e 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Sun May 16 07:50:08 GMT 2021
-Sun May 16 04:50:08 -03 2021
+Sat May 22 19:31:36 GMT 2021
+Sat May 22 16:31:36 -03 2021
diff --git a/eev-elinks.el b/eev-elinks.el
index c0c027d..e7d091a 100644
--- a/eev-elinks.el
+++ b/eev-elinks.el
@@ -1297,6 +1297,8 @@ Convert PKG - a symbol - to a package-desc structure (or
to nil)."
;; «find-esetkey-links» (to ".find-esetkey-links")
;; Skel: (find-find-links-links-new "esetkey" "key command" "longkey")
;; Test: (find-esetkey-links (kbd "M-o") 'other-window)
+;; See: (find-eevtemplvideo "14:20" "4. `find-esetkey-links'")
+;; (find-eevtemplvideo "14:45" "if we just run M-x find-esetkey-links")
;;
(defun find-esetkey-links (&optional key command &rest pos-spec-list)
"Visit a temporary buffer containing sexps for setting a key."
diff --git a/eev-hydras.el b/eev-hydras.el
index ef62147..fef9ffc 100644
--- a/eev-hydras.el
+++ b/eev-hydras.el
@@ -19,7 +19,7 @@
;;
;; Author: Eduardo Ochs <eduardoochs@gmail.com>
;; Maintainer: Eduardo Ochs <eduardoochs@gmail.com>
-;; Version: 20210511
+;; Version: 20210521
;; Keywords: e-scripts
;;
;; Latest version: <http://angg.twu.net/eev-current/eev-hydras.el>
@@ -41,6 +41,16 @@
;; It depends on the package "hydra".
;; I need to record a short video about this.
;; This code will probably change a LOT in the next months.
+;; Update: I recorded a video, it's here:
+;;
+;; http://angg.twu.net/eev-videos/2021-05-20_hydra_ei.mp4
+;; (find-eevvideo-links "hydraei" "2021-05-20_hydra_ei")
+
+
+
+;; «.hydra-eev-index-edit» (to "hydra-eev-index-edit")
+;; «.find-eev-index-edit-intro» (to "find-eev-index-edit-intro")
+
;; See: https://github.com/abo-abo/hydra
@@ -51,22 +61,27 @@
+(defalias 'ei 'eev-index-edit)
+
+(defun eev-index-edit ()
+ "Call `eev-index-edit/body' to edit the index."
+ (interactive)
+ (hydra-eev-index-edit/body))
+
(defun eev-index-replace (from-string to-string)
"Replace FROM-STRING to TO-STRING in the current line."
(search-forward from-string (ee-eol))
(replace-match to-string)
(eek "C-a"))
-(defun eev-index-edit ()
- "Call `eev-index-edit/body' to edit the index."
- (interactive)
- ;;
- ;; Definition of the hydra:
- ;;
- (defhydra hydra-eev-index-edit (:color green :hint nil)
+
+
+;; «hydra-eev-index-edit» (to ".hydra-eev-index-edit")
+;;
+(defhydra hydra-eev-index-edit (:color green :hint nil)
"
-_q_:quit ^^^^ _0_: delthiswindow
- werty: _u_:prev _i_:insert _o_:other window _p_:prev
+_q_:quit ^^^^ _0_: delthiswindow
+ werty: _u_:prev _i_:insert _o_:second window _p_:prev
asdfgh: _j_:next _k_:kill _l_:eval
^ ^ _,_:adj<- _._:adj->
Standard usage: _k__o__p__l__i__0_q
@@ -92,14 +107,125 @@ Use `_,_'s and `_._'s between the `_i_' and the `_0_' to
adjust the `(to ...)'.\
("<" (eek "M-<"))
("M-<" (eek "M-<"))
("q" nil))
- ;;
- ;; End of the definition of the hydra.
- ;;
- ;; Call the hydra:
- (hydra-eev-index-edit/body)
- )
-(defalias 'ei 'eev-index-edit)
+
+
+
+
+;; «find-eev-index-edit-intro» (to ".find-eev-index-edit-intro")
+;; Skel: (find-intro-links "eev-index-edit")
+
+(defun find-eev-index-edit-intro (&rest pos-spec-list) (interactive)
+ (let ((ee-buffer-name "*(find-eev-index-edit-intro)*"))
+ (apply 'find-eintro "\
+\(Re)generate: (find-eev-index-edit-intro)
+Source code: (find-efunction 'find-eev-index-edit-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 \"intro\" is a sandboxed tutorial for:
+
+ (find-eev \"eev-hydras.el\")
+ (find-refining-intro \"5. Pointing to anchors\")
+ (find-refining-intro \"5. Pointing to anchors\" \"but I don't touch-type\")
+
+In these sections about anchors in the main tutorial - see:
+
+ (find-eev-quick-intro \"8.3. Creating index/section anchor pairs\")
+ (find-eev-quick-intro \"8.4. Creating e-script blocks\")
+
+I said that I organize the indexes of my e-script files - like:
+
+ (find-wget \"http://angg.twu.net/e/youtube.e\")
+ http://angg.twu.net/e/youtube.e.html
+
+by hand. This was true until april 2021, when I wrote a hydra for
+that and started to play with it.
+
+Remember that many functions in eev create temporary buffers that
+have many lines, or blocks of lines, that can be used to perform
+different actions; they act as visual interfaces in which the
+actions are spread vertically, with at most one action per line.
+Hydra.el lets us create interfaces in which each action is bound
+to a key, and the minibuffer/echo area is used to display a
+reminder of what each key does.
+
+This is an index, followed by two e-script blocks, and by a
+\"plic\" and a \"bletch\" that you will use to create new
+e-script blocks.
+
+
+
+# «.foo» (to \"foo\")
+# «.bar» (to \"bar\")
+
+
+
+#####
+#
+# foo
+# 2021may20
+#
+#####
+
+# «foo» (to \".foo\")
+
+
+
+#####
+#
+# bar
+# 2021may20
+#
+#####
+
+# «bar» (to \".bar\")
+
+
+plic
+bletch
+
+
+
+
+Here is the exercise.
+1) Use `M-B' to convert the line with \"plic\" above into an
+ e-script block, as explained here:
+
+ (find-eev-quick-intro \"8.4. Creating e-script blocks\")
+
+2) Put the point on the line that should be moved to the index -
+ the one whose anchor is <.plic> with double angle brackets -
+ and type:
+
+ C-l M-x ei RET kopli0q
+
+ The actions associated to \"kopli0q\" are:
+
+ (k)ill the current line
+ switch to the sec(o)nd window
+ move backwards to the line of the (p)revious anchor
+ eva(l) the current line - that has a `to' pointing to the index
+ (i)nsert, i.e., yank, the last kill after this line
+ (0): run `C-x 0' to delete the window that shows the index
+ (q)uit the `hydra-eev-index-edit' mode
+
+3) Do the same for the \"bletch\".
+
+4) Take a look at the source code and figure out how to use the
+ keys `1', ',', '.', <up>, and <down> in `hydra-eev-index-edit'
+ mode.
+
+" pos-spec-list)))
+
+;; (find-eev-index-edit-intro)
+
+
(provide 'eev-hydras)
diff --git a/eev-intro.el b/eev-intro.el
index 3f0db7c..31a72be 100644
--- a/eev-intro.el
+++ b/eev-intro.el
@@ -7623,8 +7623,7 @@ the URL to the end of a log file. So \"p-sn-e\".
Source code: (find-eev \"eev-intro.el\" \"find-audiovideo-intro\")
More intros: (find-eev-quick-intro)
(find-eev-intro)
- (find-eval-intro)
- (find-eepitch-intro)
+ (find-videos-intro)
This buffer is _temporary_ and _editable_.
It is meant as both a tutorial and a sandbox.
diff --git a/eev-tla.el b/eev-tla.el
new file mode 100644
index 0000000..0a1b895
--- /dev/null
+++ b/eev-tla.el
@@ -0,0 +1,367 @@
+;;; eev-tla.el --- eev links based on TLAs, i.e., three-letter acronyms.
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+;;
+;; This file is part of GNU eev.
+;;
+;; GNU eev is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GNU eev is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+;;
+;; Author: Eduardo Ochs <eduardoochs@gmail.com>
+;; Maintainer: Eduardo Ochs <eduardoochs@gmail.com>
+;; Version: 20210522
+;; Keywords: e-scripts
+;;
+;; Latest version: <http://angg.twu.net/eev-current/eev-tla.el>
+;; htmlized: <http://angg.twu.net/eev-current/eev-tla.el.html>
+;; See also: <http://angg.twu.net/eev-current/eev-readme.el.html>
+;; <http://angg.twu.net/eev-intros/find-eev-intro.html>
+;; <http://angg.twu.net/eev-intros/find-here-links-intro.html>
+;; (find-eev-intro)
+;; (find-here-links-intro)
+
+;;; Commentary:
+
+;; This is a new, experimental feature that is not loaded by default.
+;; It is a better version of a tool that I've used for some years to
+;; index both the sources and the PDFs of my LaTeX files.
+;;
+;; In 2018 I extended the idea of "very short names" to "three letter
+;; acronyms" (TLAs), and I started to use TLAs to point to my .tex
+;; files; for example, the `M-x lod' would open the file
+;; ~/LATEX/2019logicday.tex, `M-x lodp' would display its PDF, and
+;; these two sexps
+;;
+;; (lodp 6 "set-comprehensions")
+;; (lod "set-comprehensions")
+;;
+;; would point to a) the page 6 of the PDF and b) to the anchor
+;; "<<set-comprehensions>>" in the .tex file... after each section
+;; anchor in the .tex I had a pair of sexps like those two above, that
+;; I could copy to other files to use as hyperlinks to both the output
+;; and the source of that section. With this my LaTeXing life became
+;; much better - because with this I had a very good way to point to
+;; my LaTeX tricks!...
+;;
+;; In 2021 I sent an e-mail to Erich Ruff after seeing this e-mail
+;; that he sent to the Hyperbole mailing list:
+;;
+;; https://lists.gnu.org/archive/html/hyperbole-users/2021-05/msg00042.html
+;;
+;; we exchanged ideas in a series of private e-mails, and I wrote this
+;; prototype to see if it could be a convenient way to make his long
+;; sexp hyperlinks shorter.
+;;
+;; This version supposes that we have a bijection between TLAs
+;; (symbols) and file names (strings). In my other, older,
+;; implementation I sometimes had two TLAs associated to the same file
+;; name, like this:
+;;
+;; c2m202fp -> "~/LATEX/2020-2-C2-fracs-parcs.pdf"
+;; c2fp -> "~/LATEX/2020-2-C2-fracs-parcs.pdf"
+;;
+;; note that both `c2fp' and `c2m202fp' are symbols longer than three
+;; characters, but I'd refer to both of them as "TLA"s anyway.
+;;
+;; Here are the design principles that I used:
+;;
+;; 1. We may have hundreds of files that we want to create TLA-links
+;; for. A "TLA" - a "three-letter acronym" may be longer than
+;; three characters.
+;;
+;; 2. It should be easy to create a TLA, and a `code-tla', for a new
+;; file.
+;;
+;; 3. Some of the files that we may want to access with TLAs may be
+;; read-only in some sense - so it's not feasible to define the
+;; TLAs associated to them in their "Local Variables:" sections,
+;; because we do not want to change them to add local variables.
+;; See:
+;;
+;; (find-enode "File Variables" ";;; Local Variables:")
+;;
+;; 4. Creating links to a file that has a TLA associated to it has
+;; to be very fast. If we are in
+;;
+;; /mnt/fichte/fuchs_erich-fichte_im_gespraech_1_1762-1798.txt
+;;
+;; and we are after the anchor "<<Fichte Charakter>>", with the
+;; region being the string "some text that is not an anchor",
+;; then there must be a short sequence of keystrokes that
+;; produces a temporary buffer containing these lines, among
+;; other stuff:
+;;
+;; (fim1a "Fichte Charakter")
+;; (fim1 "some text that is not an anchor")
+;;
+;; The conversion from the file name and the `fim1' is done using
+;; a hash table.
+;;
+;; 5. If we create a TLA for a file whose name ends in .tex, like this,
+;;
+;; (code-tla "lod" "~/LATEX/2019logicday.tex")
+;;
+;; then the `code-tla' should also create functions `lodp' and
+;; `lodt' such that
+;;
+;; (lodp 6 "set-comprehensions")
+;; (loda "set-comprehensions")
+;; (lodt "calculate")
+;;
+;; are equivalent to:
+;;
+;; (find-pdf-page "~/LATEX/2019logicday.tex" 6)
+;; (find-anchor "~/LATEX/2019logicday.tex" "set-comprehensions")
+;; (find-pdf-text "~/LATEX/2019logicday.tex" "calculate")
+
+
+;; To try this, do:
+;; (load "eev-tla.el")
+;; and then use `M-3 M-j' to generate the temporary buffers,
+;; and `M-3 M-3 M-j' to insert a {tla}p/{tla}a pair.
+
+
+
+;; «.hash-table» (to "hash-table")
+;; «.code-tla» (to "code-tla")
+;; «.find-tla-def-links» (to "find-tla-def-links")
+;; «.find-tla-links» (to "find-tla-links")
+
+
+
+;; «hash-table» (to ".hash-table")
+
+(setq ee-tla-table (make-hash-table :test 'equal))
+
+;; Tests: (ee-tla-canonicalize nil)
+;; (ee-tla-canonicalize "/home/edrx/foo")
+(defun ee-tla-canonicalize (o)
+ (if (stringp o) (ee-shorten-file-name (ee-expand o)) o))
+
+(defun ee-tla-set (tla fname)
+ (setq fname (ee-tla-canonicalize fname))
+ (puthash fname tla ee-tla-table)
+ (puthash tla fname ee-tla-table))
+
+(defun ee-tla-get (o) (gethash o ee-tla-table))
+(defun ee-tla-remove (o) (remhash o ee-tla-table))
+(defun ee-tla-fname () (ee-tla-canonicalize (buffer-file-name)))
+(defun ee-tla-tla () (ee-tla-get (ee-tla-fname)))
+
+;; Based on: (find-eev "eev-edit.el" "ee-copy-this-line-to-kill-ring")
+(defun ee-tla-tag ()
+ (save-excursion
+ (if (re-search-backward (ee-tag-re) nil 'no-error)
+ (ee-no-properties (match-string 1)))))
+
+
+
+;; Test: (find-estring (ee-tla-table-to-string))
+;;
+(defun ee-tla-table-to-string ()
+ (let ((lines (cl-loop for k being the hash-keys of ee-tla-table
+ collect (format "%S -> %S\n" k (ee-tla-get k)))))
+ (apply 'concat (sort lines 'string<))))
+
+;; (code-tla "ats" "~/LATEX/2020ats.tex")
+;; (code-tla "pyt" "~/LATEX/2020pythontex.tex")
+;; (code-tla "dnv" "~/LATEX/2020dednat6-video.tex")
+;; (code-tla "qui" "~/LATEX/2020quiver.tex")
+;; (code-tla "grt" "~/LATEX/2020groth-tops.tex")
+;; (code-tla "grd" "~/LATEX/2021groth-tops-defs.tex")
+;; (code-tla "grc" "~/LATEX/2021groth-tops-children.tex")
+;; (code-tla "grs" "~/LATEX/2021groth-tops-children-slides.tex")
+;; (code-tla "has" "~/LATEX/2021haskell.tex")
+;; (code-tla "exc" "~/LATEX/2021excuse.tex")
+;; (grt)
+;; (grta "grotop-J")
+;; (grta "grotop-J" "first")
+;; (grtp 11 "grotop-J" "first")
+
+
+;;; _ _ _
+;;; ___ ___ __| | ___ | |_| | __ _
+;;; / __/ _ \ / _` |/ _ \_____| __| |/ _` |
+;;; | (_| (_) | (_| | __/_____| |_| | (_| |
+;;; \___\___/ \__,_|\___| \__|_|\__,_|
+;;;
+;; «code-tla» (to ".code-tla")
+;; Skel: (find-code-xxx-links "tla" "tla fname" "")
+;; Tests: (find-code-tla "qux" "~/LATEX/2019J-ops-algebra.tex")
+;; (find-code-tla "qux" "~/LATEX/2019J-ops-algebra.txt")
+
+(defun code-tla (tla fname)
+ (eval (ee-read (ee-code-tla tla fname))))
+(defun find-code-tla (tla fname)
+ (find-estring-elisp (ee-code-tla tla fname)))
+(defun ee-code-tla (tla fname)
+ (let* ((fnamepdf (ee-tla-tex-to-pdf fname))
+ (haspdf (stringp fnamepdf)))
+ (concat
+ (ee-template0 "\
+;; (find-code-tla \"{tla}\" \"{fname}\")
+;; (code-tla \"{tla}\" \"{fname}\")
+
+(ee-tla-set '{tla} \"{fname}\")
+
+(defun {tla} (&rest pos-spec-list)
+ (interactive)
+ (apply 'find-fline \"{fname}\" pos-spec-list))
+(defun {tla}a (&rest pos-spec-list)
+ (apply 'find-anchor \"{fname}\" pos-spec-list))
+")
+ (if haspdf
+ (ee-template0 "
+(defun {tla}p (&optional page &rest rest)
+ (interactive)
+ (find-pdf-page \"{fnamepdf}\" page))
+(defun {tla}t (&optional page &rest rest)
+ (interactive)
+ (apply 'find-pdf-text \"{fnamepdf}\" page rest))
+") "")
+ )))
+
+;; Tests: (ee-tla-tex-to-pdf "~/LATEX/2019J-ops-algebra.foo")
+;; (ee-tla-tex-to-pdf "~/LATEX/2019J-ops-algebra.tex")
+;;
+(defun ee-tla-tex-to-pdf (fname)
+ (if (string-match ".tex$" fname)
+ (replace-regexp-in-string ".tex$" ".pdf" fname)))
+
+
+
+
+;; «find-tla-def-links» (to ".find-tla-def-links")
+;; Skel: (find-find-links-links-new "tla-def" "fname tla" "haspdf")
+;;
+(defun find-tla-def-links (&optional fname tla &rest pos-spec-list)
+"Visit a temporary buffer containing hyperlinks for tla-def."
+ (interactive)
+ (setq fname (or fname "{fname}"))
+ (setq tla (or tla "{tla}"))
+ (let* ((haspdf "{haspdf}"))
+ (apply
+ 'find-elinks-elisp
+ `((find-tla-def-links ,fname ,tla ,@pos-spec-list)
+ ;; Convention: the first sexp always regenerates the buffer.
+ (find-efunction 'find-tla-def-links)
+ ,(ee-template0 "\
+;; This file doesn't have a TLA. Change the last argument above...
+
+;; (find-estring (ee-tla-table-to-string))
+;; (find-fline \"~/.emacs\" \"(code-tla '{tla} \")
+;; (find-fline \"~/.emacs.tlas\" \"(code-tla '{tla} \")
+;; (ee-copy-rest 2 '(find-fline \"~/.emacs\"))
+;; (ee-copy-rest 1 '(find-fline \"~/.emacs.tlas\"))
+;; (find-code-tla '{tla} \"{fname}\")
+(code-tla '{tla} \"{fname}\")\
+")
+ )
+ pos-spec-list)))
+
+
+
+;; «find-tla-links» (to ".find-tla-links")
+;; Skel: (find-find-links-links-new "tla" "tla fname tag" "haspdf")
+;; Test: (find-tla-links)
+;;
+(defun find-tla-links (&optional tla fname tag &rest pos-spec-list)
+"Visit a temporary buffer containing hyperlinks for tla."
+ (interactive)
+ (setq tla (or tla "{tla}"))
+ (setq fname (or fname "{fname}"))
+ (setq tag (or tag "{tag}"))
+ (let* ((haspdf "{haspdf}"))
+ (apply
+ 'find-elinks-elisp
+ `((find-tla-links ',tla ,fname ,tag ,@pos-spec-list)
+ ;; Convention: the first sexp always regenerates the buffer.
+ (find-efunction 'find-tla-links)
+ ""
+ ,(ee-template0 "\
+;; Links to here:
+({tla})
+({tla}a \"{tag}\")
+
+({tla}p 1 \"{tag}\")
+({tla}a \"{tag}\")
+({tla}t 1)
+
+;; Inspect or remove the current association:
+;; (find-estring (ee-tla-table-to-string) \"{tla} ->\")
+;; (find-estring (ee-tla-table-to-string) \"-> {tla}\")
+;; (ee-tla-remove '{tla})
+;; (ee-tla-remove \"{fname}\")
+
+;; Save the current association:
+;; (find-fline \"~/.emacs\" \"(code-tla '{tla} \")
+;; (find-fline \"~/.emacs.tlas\" \"(code-tla '{tla} \")
+;; (ee-copy-rest 1 '(find-fline \"~/.emacs\"))
+;; (ee-copy-rest 0 '(find-fline \"~/.emacs.tlas\"))
+(code-tla '{tla} \"{fname}\")\
+")
+ )
+ pos-spec-list)))
+
+
+
+
+
+;; (ee-tla-remove 'etl)
+;; (ee-tla-remove (ee-tla-fname))
+;; (find-estring (ee-tla-table-to-string))
+;; (eejump-3)
+
+(defun find-tla-here-links ()
+ "Visit a temporary buffer containing hyperlinks for TLAs.
+If the current file has a TLA associated to it, run `find-tla-links';
+if it doesn't, run `find-tla-def-links'.\n
+See: (find-eevfile \"eev-tla.el\" \";; Commentary:\")"
+ (interactive)
+ (let* ((fname (ee-tla-fname))
+ (tla (ee-tla-tla))
+ (tag (ee-tla-tag)))
+ (if tla (find-tla-links tla fname tag)
+ (find-tla-def-links fname))))
+
+(defun eejump-3 () (find-tla-here-links))
+
+
+;; Tests: (find-estring (ee-tla-link 'foo 99 "TaG"))
+;; (find-estring (ee-tla-link 'foo 9 "TaG"))
+;; (find-estring (ee-tla-link))
+;;
+(defun ee-tla-link (&optional tla n tag)
+ (setq tla (or tla "{tla}"))
+ (setq n (format "%s" (or n 1)))
+ (setq tag (or tag "{tag}"))
+ (let ((s (replace-regexp-in-string "." " " n)))
+ (ee-template0 "\
+% ({tla}p {n} \"{tag}\")
+% ({tla}a {s} \"{tag}\")
+")))
+
+(defun eejump-33 ()
+ (eek "C-a")
+ (insert (ee-tla-link (ee-tla-tla) 99 (ee-tla-tag))))
+
+
+
+
+(provide 'eev-tla)
+
+
+;; Local Variables:
+;; coding: utf-8-unix
+;; no-byte-compile: t
+;; End: