emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eev 1679adb48e: New intro: (find-kla-intro)


From: ELPA Syncer
Subject: [elpa] externals/eev 1679adb48e: New intro: (find-kla-intro)
Date: Tue, 15 Nov 2022 13:58:53 -0500 (EST)

branch: externals/eev
commit 1679adb48e929631f69f8d82554eb4f5078b9523
Author: Eduardo Ochs <eduardoochs@gmail.com>
Commit: Eduardo Ochs <eduardoochs@gmail.com>

    New intro: (find-kla-intro)
---
 ChangeLog     |  14 ++-
 VERSION       |   9 +-
 eev-intro.el  | 370 ++++++++++++++++++++++++++++++++++++++++++++++------------
 eev-kla.el    | 110 +++++++++++++----
 eev-tlinks.el |   4 +
 5 files changed, 399 insertions(+), 108 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ea8b8c7c25..71f3bf3253 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
-<<<<<<< HEAD
-=======
+2022-11-15  Eduardo Ochs  <eduardoochs@gmail.com>
+
+       * eev-kla.el (ee-kl-expand, ee-kl-prefixp, ee-kl-cds)
+       (ee-kl-lrcds, ee-kl-lrcd): new functions.
+
+       * eev-intro.el (find-kla-intro): rewritten completely.
+
+2022-11-12  Eduardo Ochs  <eduardoochs@gmail.com>
+
+       * eev-intro.el (find-kla-test-intro): renamed to find-kla-intro.
+
 2022-11-08  Eduardo Ochs  <eduardoochs@gmail.com>
 
        * eev-videolinks.el (ee-1stclassvideos-info): added an indication
@@ -20,7 +29,6 @@
        * eev-rstdoc.el (ee-code-rstdoc): made some functions interactive.
        (ee-rstdoc-rst): fixed the behavior when str is nil.
 
->>>>>>> UTF-8
 2022-11-01  Eduardo Ochs  <eduardoochs@gmail.com>
 
        * eepitch.el (eepitch-php): new function.
diff --git a/VERSION b/VERSION
index 391d20a743..5fd48655ac 100644
--- a/VERSION
+++ b/VERSION
@@ -1,7 +1,2 @@
-<<<<<<< HEAD
-Tue Nov  1 07:32:45 GMT 2022
-Tue Nov  1 04:32:45 -03 2022
-=======
-Tue Nov  8 04:36:40 GMT 2022
-Tue Nov  8 01:36:40 -03 2022
->>>>>>> UTF-8
+Tue Nov 15 18:53:00 GMT 2022
+Tue Nov 15 15:53:00 -03 2022
diff --git a/eev-intro.el b/eev-intro.el
index 5df4538995..224b0b6320 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:    20220920
+;; Version:    20221115
 ;; Keywords:   e-scripts
 ;;
 ;; Latest version: <http://angg.twu.net/eev-current/eev-intro.el>
@@ -94,7 +94,7 @@
 ;; «.find-git-intro»                   (to "find-git-intro")
 ;; «.find-windows-beginner-intro»      (to "find-windows-beginner-intro")
 ;; «.find-eev-exercises-intro»         (to "find-eev-exercises-intro")
-;; «.find-kla-test-intro»              (to "find-kla-test-intro")
+;; «.find-kla-intro»                   (to "find-kla-intro")
 
 ;; Videos:
 ;; «.find-three-main-keys-intro»       (to "find-three-main-keys-intro")
@@ -2755,7 +2755,7 @@ These are etcs:
 
 These ones explain advanced features that require extra setup:
 
-  31. (find-kla-test-intro)
+  31. (find-kla-intro)
   32. (find-prepared-intro)
   33. (find-bounded-intro)
   34. (find-channels-intro)
@@ -14457,15 +14457,15 @@ see:
 ;;; |   <| | (_| |
 ;;; |_|\_\_|\__,_|
 ;;;               
-;; «find-kla-test-intro»  (to ".find-kla-test-intro")
-;; Skel: (find-intro-links "kla-test")
-;; Test: (find-kla-test-intro)
+;; «find-kla-intro»  (to ".find-kla-intro")
+;; Skel: (find-intro-links "kla")
+;; Test: (find-kla-intro)
 
-(defun find-kla-test-intro (&rest pos-spec-list) (interactive)
-  (let ((ee-buffer-name "*(find-kla-test-intro)*"))
+(defun find-kla-intro (&rest pos-spec-list) (interactive)
+  (let ((ee-buffer-name "*(find-kla-intro)*"))
     (apply 'find-eintro "\
-\(Re)generate: (find-kla-test-intro)
-Source code:  (find-efunction 'find-kla-test-intro)
+\(Re)generate: (find-kla-intro)
+Source code:  (find-efunction 'find-kla-intro)
 More intros:  (find-eev-quick-intro)
               (find-eev-intro)
               (find-eepitch-intro)
@@ -14474,109 +14474,329 @@ It is meant as both a tutorial and a sandbox.
 
 
 
-Pre-requisites:
-  (find-saving-links-intro)
-  (find-saving-links-intro \"2.3. The base case 3\")
 WARNING:
-  In sep/2022 I rewrote eev-kla.el completely...
-  This hands-on tutorial is currently broken.
-  TODO: FIX IT!!!
+  This is being rewritten!
   See: http://angg.twu.net/emacsconf2022-kla.html
        (find-eev \"eev-kla.el\")
+  The prerequisites for this tutorial are:
+    (find-eev-quick-intro \"8. Anchors\")
+    (find-eev-quick-intro \"9.1. `code-c-d'\")
+    (find-eev-quick-intro \"9.2. Extra arguments to `code-c-d'\")
+    (find-eev-quick-intro \"9.2. Extra arguments to `code-c-d'\" \"to 
anchors\")
+    (find-eev-quick-intro \"4. Creating Elisp Hyperlinks\")
+    (find-eev-quick-intro \"4.1. `find-here-links'\")
+
+
 
 
 1. Introduction
 ===============
-THIS IS AN ADVANCED FEATURE!!!
+In this section of the main tutorial
+
+  (find-eev-quick-intro \"10.1. Generating short hyperlinks to files\")
+
+we saw that after running these three `code-c-d's,
+
+  (code-c-d \"foo\"  \"/tmp/FOO/\"          :anchor)
+  (code-c-d \"bar\"  \"/tmp/FOO/BAR/\"      :anchor)
+  (code-c-d \"plic\" \"/tmp/FOO/BAR/PLIC/\" :anchor)
+
+all these links will point to the same file:
+
+  (find-file  \"/tmp/FOO/BAR/PLIC/bletch\")
+  (find-fline \"/tmp/FOO/BAR/PLIC/bletch\")
+  (find-foofile        \"BAR/PLIC/bletch\")
+  (find-barfile            \"PLIC/bletch\")
+  (find-plicfile                \"bletch\")
 
-The function `eekla' implements a way to create links to anchors
-that requires fewer keystrokes than the way described here,
+If we visit the file \"/tmp/FOO/BAR/PLIC/bletch\" and we type
+`M-h M-h' - i.e., `find-here-links' - there, we well get a
+temporary buffer whose \"core\" will be those five hyperlinks
+above... `find-here-links' doesn't know how to choose the
+\"best\" hyperlink to \"/tmp/FOO/BAR/PLIC/bletch\", so it shows
+all the options. Usually at that point we choose the best
+hyperlink ourselves, we refine it with these keys,
+
+  (find-emacs-keys-intro \"1. Basic keys (eev)\")
+  (find-emacs-keys-intro \"1. Basic keys (eev)\" \"refining hyperlinks\")
+
+and we copy it to our notes.
+
+This takes many keystrokes. For example, suppose that we have
+anchors in /tmp/FOO/BAR/PLIC/bletch, and we want create a
+hyperlink to the anchor just before point and put that link in
+the kill ring. One sequence of keystrokes that does that is:
+
+  M-1 M-h M-w    ;; ee-copy-preceding-tag-to-kill-ring
+      M-h M-h    ;; find-here-links
+   8*<down>      ;; go to the line with the `(find-plicfile ...)'
+      M-h M-2    ;; ee-duplicate-this-line
+      M-h M-y    ;; ee-yank-pos-spec
+      M-h M--    ;; ee-shrink-hyperlink-at-eol
+      C-a        ;; move-beginning-of-line
+      C-SPC      ;; set-mark-command
+      <down>     ;; next-line
+      M-w        ;; kill-ring-save
+      M-k        ;; ee-kill-this-buffer
+
+The file eev-kla.el implements a way to do that with fewer
+keystrokes. If we are in /tmp/FOO/BAR/PLIC/bletch and we type
+`M-x eekla' - or `M-x kla', if we have defined certain aliases -
+then this will \"kill link to anchor\", which is a mnemonic for
+\"create the best link to the anchor before point and put in the
+kill ring\".
+
+The algorithm that chooses the \"best link\" sometimes needs some
+tinkering to work correctly, so here in this tutorial I will
+explain in details how it works, and how to replace its pieces
+when needed.
+
+The old way of producing these hyperlinks - the one that uses the
+sequence `M-1 M-h M-w ... M-k' - is explained here:
 
   (find-saving-links-intro)
   (find-saving-links-intro \"2.3. The base case 3\")
 
-but to understand this new way you will need to understand all
-the pre-requisites of the \"Base case 3\" - see the link above -
-and also file-local, or dir-local, variables, that are explained
-in these pages of the Emacs manual:
 
-      (find-enode \"Specifying File Variables\")
-  or: (find-enode \"Directory Variables\")
 
-The code for `eekla', `eeklf', `eekl2' and friends is here:
 
-  (find-eev \"eev-kla.el\")
-  (find-eev \"eev-kla.el\" \"aliases\")
+2. `ee-code-c-d-pairs'
+======================
+A call to
+
+       (code-c-d \"foo\" \"/tmp/FOO/\" :anchor)
 
+does a bit more than just running the code shown by this sexp:
 
+  (find-code-c-d \"foo\" \"/tmp/FOO/\" :anchor)
 
-2. Setup for a demo
-===================
-We need to create some test directories in /tmp/eev-kla-test/.
-Run this eepitch block:
+It also runs this,
 
- (eepitch-shell)
- (eepitch-kill)
- (eepitch-shell)
-  rm -Rfv /tmp/eev-kla-test/
-  mkdir   /tmp/eev-kla-test/
-  mkdir   /tmp/eev-kla-test/dira/
-  mkdir   /tmp/eev-kla-test/dirb/
+  (ee-code-c-d-add-pair \"foo\" \"/tmp/FOO/\")
 
-We need to create some files there. Take a look at the source of
-`ee-kla-demo-write-three-files' here,
+that modifies the variable `ee-code-c-d-pairs' in two steps: it
+first deletes all the elements of `ee-code-c-d-pairs' that are of
+the form (\"foo\" ...), and then it adds the pair
 
-  (find-eev \"eev-kla.el\" \"demo\")
+  (\"foo\" \"/tmp/FOO/\")
 
-and after understanding it, run this:
+to the front of the list. If you want to look at the code that
+does that, it is here:
 
-  (code-c-d \"klat\"  \"/tmp/eev-kla-test/\")
-  (code-c-d \"klata\" \"/tmp/eev-kla-test/dira/\")
-  (code-c-d \"klatb\" \"/tmp/eev-kla-test/dirb/\")
-  (ee-kla-demo-write-three-files)
+  (find-eev \"eev-code.el\" \"code-c-d\")
+  (find-eev \"eev-code.el\" \"code-c-d-pairs\")
 
-and inspect that directory with:
+and you can inspect the variable `ee-code-c-d-pairs' with:
 
-  (find-fline \"/tmp/eev-kla-test/\")
-  (find-fline \"/tmp/eev-kla-test/dira/\")
-  (find-fline \"/tmp/eev-kla-test/dirb/\")
-  (find-fline \"/tmp/eev-kla-test/dira/foo\")
-  (find-fline \"/tmp/eev-kla-test/dirb/bar\")
-  (find-fline \"/tmp/eev-kla-test/.dir-locals.el\")
+  (find-eppp ee-code-c-d-pairs)
 
+We will refer to the elements of `ee-code-c-d-pairs' as `c-d's. A
+`c-d' is a pair made of a `c' and a `d', where these `c' and `d'
+were the arguments given to a `code-c-d'.
 
 
-3. Run some tests
+
+3. The components
 =================
-Run this 4-line sexp
+In order to convert a filename like
 
-  (find-3a nil
-   ' (find-fline \"/tmp/eev-kla-test/dira/foo\")
-   ' (find-fline \"/tmp/eev-kla-test/dirb/bar\")
-   )
+  \"/tmp/FOO/BAR/PLIC/bletch\"
+
+to a sexp like
+
+       (find-plicfile \"bletch\")
+  or:  (find-plic     \"bletch\")
+
+eev needs to:
+
+  1. select all the `c-d's in `ee-code-c-d-pairs' whose `d's are
+     initial substrings of \"/tmp/FOO/BAR/PLIC/bletch\",
+
+  2. select the \"best one\" among these `c-d's; in our example
+     it will be
+
+       (\"plic\" \"/tmp/FOO/BAR/PLIC/\")
+
+  3. remove the prefix \"/tmp/FOO/BAR/PLIC/\" from
+     \"/tmp/FOO/BAR/PLIC/bletch\" to obtain \"bletch\"; we will
+     refer to \"/tmp/FOO/BAR/PLIC/bletch\" as the `fname', and to
+     the \"bletch\" as the \"rest\". We will abbreviate the
+     \"rest\" as `r', and we will refer to the length of `r' as
+     `l'. So in this case we have:
+
+       /tmp/FOO/BAR/PLIC/bletch
+       \\----------------/\\----/
+               d           r
+       \\----------------------/
+                 fname
+
+     and \"bletch\" has 6 characters, so `l' is 6.
+
+  4. build the sexp. We will refer to its components as:
+
+       (find-plicfile \"bletch\")
+             \\--/      \\----/
+              c        shortfname
+        \\-----------/
+         find-cfile
+
+       (find-plic     \"bletch\")
+             \\--/      \\----/
+              c        shorterfname
+        \\-------/
+         find-c
+
+     `shortfname' and `shortfname' will usually be equal to `r',
+     but not always. The differences will be explained in section
+     ___.
+
+
+
+4. The best `l-r-c-d'
+=====================
+The algorithm that chooses the \"best\" `c-d' is here:
+
+  (find-eev \"eev-kla.el\" \"best-lrcd\")
+
+If `fname' is \"/tmp/FOO/BAR/PLIC/bletch\" and
+`ee-code-c-d-pairs' is this list,
+
+  ((\"plic\" \"/tmp/FOO/BAR/PLIC/\")
+   (\"bar\"  \"/tmp/FOO/BAR/\")
+   (\"foo\"  \"/tmp/FOO/\")
+   (\"eev\"  \"/home/edrx/eev-current/\")
+   (\"e\"    \"/usr/share/emacs/27.1/lisp/\"))
+
+then the `c-d's in `ee-code-c-d-pairs' that \"match\" `fname', in
+the sense their `d's are initial substrings of
 
-to create a window setting like this:
-   _________________
-  |         |       |
-  |         |  foo  |
-  |  intro  |_______|
-  |         |       |
-  |         |  bar  |
-  |_________|_______|
+           \"/tmp/FOO/BAR/PLIC/bletch\"
 
-Go to the window showing the file \"foo\", run `M-x eekla' in
-several positions of that file - after each anchor and in the
-beginning - and understand the messages in the echo area. Then do
-the same in the window with the file \"bar\".
+will be these ones:
 
+  ((\"plic\" \"/tmp/FOO/BAR/PLIC/\")
+   (\"bar\"  \"/tmp/FOO/BAR/\")
+   (\"foo\"  \"/tmp/FOO/\"))
 
-\[TODO]: Explain how to test eekla2. See:
-  (find-eev \"eev-kla.el\" \"eekla2\")
+Try this:
+
+  (find-eppp (ee-kl-lrcds \"/tmp/FOO/BAR/PLIC/bletch\"))
+
+It will show something like this:
+
+  ((6           \"bletch\" \"plic\" \"/tmp/FOO/BAR/PLIC/\")
+   (11     \"PLIC/bletch\" \"bar\"  \"/tmp/FOO/BAR/\")
+   (15 \"BAR/PLIC/bletch\" \"foo\"  \"/tmp/FOO/\"))
+
+note that each `c-d' that matched `fname' was converted to an
+`l-r-c-d'; the `r' is the \"rest\" that remains of `fname' after
+the deleting the initial `d', and the `l' is the length of the
+\"rest\".
+
+This sexp
+
+  (ee-kl-lrcds \"/tmp/FOO/BAR/PLIC/bletch\")
+
+returns _all_ the `l-r-c-d's that match that filename; this sexp
+
+  (ee-kl-lrcd  \"/tmp/FOO/BAR/PLIC/bletch\")
+
+returns _the_ `l-r-c-d' that matches that filename - i.e., the
+\"best\" `l-r-c-d' that matches that filename. The best one is
+chosen by sorting the `l-r-c-d's by their `l's and then returning
+the first `l-r-c-d' in the sorted list. In that example the best
+`l-r-c-d' will be this one:
+
+  (6 \"bletch\" \"plic\" \"/tmp/FOO/BAR/PLIC/\")
+   
+Note that its `r' is as short as possible. When there are no
+`c-d's matching the filename the function `ee-kl-lrcd' returns
+nil.
+
+
+
+
+5. `cl-loop'
+============
+The functions that produce the best `l-r-c-d' are implemented
+using `cl-loop'. I didn't explain `cl-loop' in
+
+  (find-elisp-intro)
+
+because it was too complex, but let's see it now. The features of
+`cl-loop' that we will need are explained here:
+
+  (find-clnode \"Loop Basics\")
+  (find-clnode \"Accumulation Clauses\" \"collect FORM\")
+  (find-clnode \"Accumulation Clauses\" \"append FORM\")
+  (find-clnode \"For Clauses\" \"for VAR in LIST by FUNCTION\")
+  (find-clnode \"For Clauses\" \"for VAR on LIST by FUNCTION\")
+  (find-clnode \"For Clauses\" \"for VAR = EXPR1 then EXPR2\")
+  (find-clnode \"For Clauses\" \"destructuring\")
+  (find-clnode \"Other Clauses\" \"if CONDITION CLAUSE\")
+
+Try to understand these examples:
+
+  (cl-loop for x in '(1 2 3 4 5 6)
+           collect (* 10 x))
+
+  (cl-loop for sublist on '(a b c d e f)
+           collect sublist)
+
+  (cl-loop for sublist on '(a b c d e f) by 'cddr
+           collect sublist)
+
+  (cl-loop for (x y . rest) on '(a b c d e f) by 'cddr
+           collect (list x y rest))
+
+  (cl-loop for (x y) on '(a b c d e f) by 'cddr
+           collect (list x y))
+
+  (cl-loop for a in '(-3 -2 -1 0 1 2 3)
+           for sq = (* a a)
+           if (>= sq 4)
+           collect (list a sq))
+
+Note that this
+
+  (cl-loop for a in '(1 2 3)
+           for b in '(4 5 6)
+           collect (list a b))
+
+returns ((1 4) (2 5) (3 6)) - `cl-loop' runs the two `for's \"in
+parallel\" instead of treating them as nested. This is explained
+here:
+
+  (find-clnode \"For Clauses\" \"several\" \"for\" \"clauses in a row\")
+
+One way to make the `for's of the example above behave as nested
+is by nesting `cl-loop's and using `append' in the outer one
+instead of `collect', like this:
+
+  (cl-loop for a in '(1 2 3)
+           append (cl-loop for b in '(4 5 6)
+                           collect (list a b)))
+
+
+
+
+
+
+6. `cl-defun'
+=============
+See:
+
+  (find-clnode \"Argument Lists\" \"cl-defun\")
+  (find-clnode \"Argument Lists\" \"&key ((KEYWORD VAR) INITFORM SVAR)\")
+  (find-eev \"eev-kla.el\" \"other-defaults\")
+
+  (find-here-links-intro \"8. Debugging\")
+  (find-eevfile \"eev-hlinks.el\" \"Debug mode\")
 
 
 " pos-spec-list)))
 
-;; (find-kla-test-intro)
+;; (find-kla-intro)
 
 
 
diff --git a/eev-kla.el b/eev-kla.el
index 7d3fafda8f..9386387c49 100644
--- a/eev-kla.el
+++ b/eev-kla.el
@@ -19,7 +19,7 @@
 ;;
 ;; Author:     Eduardo Ochs <eduardoochs@gmail.com>
 ;; Maintainer: Eduardo Ochs <eduardoochs@gmail.com>
-;; Version:    20221018
+;; Version:    20221115
 ;; Keywords:   e-scripts
 ;;
 ;; Latest version: <http://angg.twu.net/eev-current/eev-kla.el>
@@ -28,7 +28,6 @@
 ;;                 <http://angg.twu.net/eev-intros/find-eev-intro.html>
 ;;                                                (find-eev-intro)
 
-;; «.prerequisites»            (to "prerequisites")
 ;; «.intro»                    (to "intro")
 ;;  «.test»                    (to "test")
 ;;
@@ -37,6 +36,7 @@
 ;; «.ee-kl-kill»               (to "ee-kl-kill")
 ;; «.ee-kl-format2»            (to "ee-kl-format2")
 ;; «.ee-kl-insert»             (to "ee-kl-insert")
+;; «.best-lrcd»                        (to "best-lrcd")
 ;; «.guess»                    (to "guess")
 ;; «.simple-defaults»          (to "simple-defaults")
 ;; «.other-defaults»           (to "other-defaults")
@@ -51,20 +51,34 @@
 
 ;;; Commentary:
 
-;;   «prerequisites»  (to ".prerequisites")
-;; 0. Prerequisites
-;; ================
-;; This tool will only make sense to people who understand anchors,
-;; `code-c-d', and `find-here-links' very well. See:
+;; WARNING (2022nov15): This is being rewritten!
+;; One of my presentations at the EmacsConf2022 will be about
+;; eev-kla.el. Its page is:
+;;
+;;   http://angg.twu.net/emacsconf2022-kla.html
+;;
+;; Right now - 2022nov15 - I am in the middle of rewriting both and
+;; the code and the docs of eev-kla.el almost completely. The docs are
+;; being moved to:
+;;
+;;   (find-kla-intro)
+;;
+;; And some concepts are changing. In my first versions of eev-kla.el
+;; the "preferred `c'" for a file was always obtained by reading the
+;; variable `ee-preferred-c', that was usually set using this:
 ;;
-;;   (find-eev-quick-intro "8. Anchors")
-;;   (find-eev-quick-intro "9.1. `code-c-d'")
-;;   (find-eev-quick-intro "9.2. Extra arguments to `code-c-d'")
-;;   (find-eev-quick-intro "9.2. Extra arguments to `code-c-d'" "to anchors")
-;;   (find-eev-quick-intro "4. Creating Elisp Hyperlinks")
-;;   (find-eev-quick-intro "4.1. `find-here-links'")
+;;   (find-enode "Directory Variables")
 ;;
+;; Then I added a way to guess the best `c' for a filename; then I
+;; made guessing the default way, and `ee-preferred-c' secondary; then
+;; I rewrote the algorithm for guessing, made it use this,
 ;;
+;;   (find-kla-intro "4. The best `l-r-c-d'")
+;;   (find-kla-intro "5. `cl-loop'")
+;;
+;; and started to move all the docs to `(find-kla-intro)'.
+
+
 ;;
 ;;   «intro»  (to ".intro")
 ;; 1. Very short introduction
@@ -571,6 +585,56 @@
 
 
 
+
+;;;  ____            _     _                               _ 
+;;; | __ )  ___  ___| |_  | |      _ __       ___       __| |
+;;; |  _ \ / _ \/ __| __| | |_____| '__|____ / __|____ / _` |
+;;; | |_) |  __/\__ \ |_  | |_____| | |_____| (_|_____| (_| |
+;;; |____/ \___||___/\__| |_|     |_|        \___|     \__,_|
+;;;                                                          
+;; «best-lrcd»  (to ".best-lrcd")
+;; These functions try to choose the "best" `c-d' for a filename. They
+;; filter `ee-code-c-d-pairs' to find all the `c-d's that "match" that
+;; filename, then they choose the best one, and they return it
+;; converted to an `l-r-c-d'. The ideas and the terminology are
+;; explained here:
+;;   (find-kla-intro "4. The best `l-r-c-d'")
+
+(defun ee-kl-expand (fname)
+  (ee-expand fname))
+
+(defun ee-kl-prefixp (prefix str)
+  "If STR starts with PREFIX then return STR minus that prefix.
+When STR doesn't start with PREFIX, return nil."
+  (and (<= (length prefix) (length str))
+       (equal prefix (substring str 0 (length prefix)))
+       (substring str (length prefix))))
+
+(defun ee-kl-cds ()
+  "Return a copy of `ee-code-c-d-pairs' with all `d's ee-kl-expanded."
+  (cl-loop for (c d) in ee-code-c-d-pairs
+          collect (list c (ee-kl-expand d))))
+
+(defun ee-kl-lrcds (fname)
+  "Return all the `c-d's in (ee-kl-cds) that match FNAME.
+Each matching `c-d' is converted to an `l-r-c-d'."
+  (cl-loop for (c d) in (ee-kl-cds)
+          if (ee-kl-prefixp d fname)
+          collect (let* ((r (ee-kl-prefixp d fname))
+                         (l (length r)))
+                    (list l r c d))))
+
+(defun ee-kl-lrcd (fname)
+  "Return the best lrcd in (ee-kl-lrcds FNAME).
+If (ee-kl-lrcds FNAME) doesn't return any matching `lrcd's, return nil."
+  (let* ((lrcds (ee-kl-lrcds fname))
+        (l< (lambda (lrcd1 lrcd2) (< (car lrcd1) (car lrcd2))))
+        (lrcds-sorted (sort lrcds l<)))
+    (car lrcds-sorted)))
+
+
+
+
 ;;;   ____                     
 ;;;  / ___|_   _  ___  ___ ___ 
 ;;; | |  _| | | |/ _ \/ __/ __|
@@ -838,19 +902,19 @@ Put in the kill ring a link to the preceding anchor."
 ;;; |____/ \___|_| |_| |_|\___/ 
 ;;;                             
 ;; «demo»  (to ".demo")
-;; See: (find-kla-test-intro)
-;;      (find-kla-test-intro "2. Setup for a demo")
+;; See: (find-kla-intro)
+;;      (find-kla-intro "2. Setup for a demo")
 ;; TODO: How obsolete is this? Check and rewrite!
 
 (defun ee-kla-demo-write-file (fname contents)
-  "See: (find-kla-test-intro)"
+  "See: (find-kla-intro)"
   (write-region contents nil fname))
 
 (defun ee-kla-demo-write-three-files ()
-  "See: (find-kla-test-intro)"
+  "See: (find-kla-intro)"
   ;;
-  (ee-kla-demo-write-file "/tmp/eev-kla-test/dira/foo"
-  "This file: /tmp/eev-kla-test/dira/foo
+  (ee-kla-demo-write-file "/tmp/eev-kla/dira/foo"
+  "This file: /tmp/eev-kla/dira/foo
 Index:
 # «.a1»   (to \"a1\")
 # «.a2»   (to \"a2\")\n
@@ -858,8 +922,8 @@ Body:
 # «a1»    (to \".a1\")\n
 # «a2»    (to \".a2\")\n\n")
   ;;
-  (ee-kla-demo-write-file "/tmp/eev-kla-test/dirb/bar"
-  "This file: /tmp/eev-kla-test/dirb/bar
+  (ee-kla-demo-write-file "/tmp/eev-kla/dirb/bar"
+  "This file: /tmp/eev-kla/dirb/bar
 Index:
 -- «.b1»   (to \"b1\")
 -- «.b2»   (to \"b2\")\n
@@ -867,8 +931,8 @@ Body:
 -- «b1»    (to \".b1\")\n
 -- «b2»    (to \".b2\")\n\n")
   ;;
-  (ee-kla-demo-write-file "/tmp/eev-kla-test/.dir-locals.el"
-  ";; This file: /tmp/eev-kla-test/.dir-locals.el
+  (ee-kla-demo-write-file "/tmp/eev-kla/.dir-locals.el"
+  ";; This file: /tmp/eev-kla/.dir-locals.el
 ;;
 (; (\"dira\" . ((nil . ((ee-preferred-c . \"klata\")))))
  (\"\"     . ((nil . ((ee-preferred-c . \"klat\")))))
diff --git a/eev-tlinks.el b/eev-tlinks.el
index d540693d6e..cb0b4a0576 100644
--- a/eev-tlinks.el
+++ b/eev-tlinks.el
@@ -125,6 +125,7 @@
 ;; «.find-1stclassvideoindex»          (to "find-1stclassvideoindex")
 ;; «.find-1stclassvideodef»            (to "find-1stclassvideodef")
 ;; «.find-1stclassvideos»              (to "find-1stclassvideos")
+;;   «.1c»                             (to "1c")
 ;; «.find-advicebefore-links»          (to "find-advicebefore-links")
 ;; «.find-osm-links»                   (to "find-osm-links")
 ;; «.find-pip3-links»                  (to "find-pip3-links")
@@ -3313,6 +3314,9 @@ For more info on this particular video, run:
             ,@finds)
           rest)))
 
+;; «1c»  (to ".1c")
+;; Suggestion: put the alias below in your init file.
+;; (defalias '1c 'find-1stclassvideos)
 
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]