branch: externals/eev
commit 8e0a51c7a950ee9a1ca474780037cd285dcb9ef1
Author: Eduardo Ochs <[email protected]>
Commit: Eduardo Ochs <[email protected]>

    Added `find-estruct'.
---
 ChangeLog           |   6 ++++
 VERSION             |   4 +--
 eev-blinks.el       | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 eev-compose-hash.el |   4 +--
 eev-pdflike.el      |  16 +++++++--
 eev.el              |   2 +-
 6 files changed, 123 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c9c2124..c99ba5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-06-08  Eduardo Ochs  <[email protected]>
+
+       * eev-blinks.el (ee-struct-class, ee-struct-slot-names)
+       (ee-struct-slot-names+, ee-struct-index-table)
+       (ee-struct-to-string, find-estruct): new functions.
+
 2021-06-07  Eduardo Ochs  <[email protected]>
 
        * eev-compose-hash.el: new file.
diff --git a/VERSION b/VERSION
index bc42da5..65ccbf4 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Mon Jun  7 07:38:02 GMT 2021
-Mon Jun  7 04:38:02 -03 2021
+Tue Jun  8 15:32:09 GMT 2021
+Tue Jun  8 12:32:09 -03 2021
diff --git a/eev-blinks.el b/eev-blinks.el
index e69252d..d29c0ed 100644
--- a/eev-blinks.el
+++ b/eev-blinks.el
@@ -21,7 +21,7 @@
 ;;
 ;; Author:     Eduardo Ochs <[email protected]>
 ;; Maintainer: Eduardo Ochs <[email protected]>
-;; Version:    20210607
+;; Version:    20210608
 ;; Keywords:   e-scripts
 ;;
 ;; Latest version: <http://angg.twu.net/eev-current/eev-blinks.el>
@@ -53,6 +53,7 @@
 ;; «.find-eoutput»             (to "find-eoutput")
 ;; «.find-estring»             (to "find-estring")
 ;; «.find-ehashtable»          (to "find-ehashtable")
+;; «.find-estruct»             (to "find-estruct")
 ;; «.find-sh»                  (to "find-sh")
 ;; «.find-man»                 (to "find-man")
 ;; «.find-man-bug»             (to "find-man-bug")
@@ -622,6 +623,103 @@ newlines, as \"big strings\". This is a bit childish, I 
know..."
 
 
 
+;;;   __ _           _                 _                   _   
+;;;  / _(_)_ __   __| |       ___  ___| |_ _ __ _   _  ___| |_ 
+;;; | |_| | '_ \ / _` |_____ / _ \/ __| __| '__| | | |/ __| __|
+;;; |  _| | | | | (_| |_____|  __/\__ \ |_| |  | |_| | (__| |_ 
+;;; |_| |_|_| |_|\__,_|      \___||___/\__|_|   \__,_|\___|\__|
+;;;                                                            
+;; «find-estruct»  (to ".find-estruct")
+;; Hyperlinks that display human-readable versions of structures
+;; created with cl-defstruct. To understand how this works, try this:
+;;
+;;         (cl-defstruct mytriple a b c)
+;;                 (make-mytriple :a 22 :c "44")
+;;   (find-estruct (make-mytriple :a 22 :c "44"))
+;;
+;; The second sexp returns this:
+;;
+;;   #s(mytriple 22 nil "44")
+;;
+;; that is difficult to read because it doesn't show the field names.
+;; The `find-estruct' sexp above converts that to a multi-line
+;; representation that shows the slot numbers and the field names.
+;;
+;; See: (find-clnode "Structures")
+;;      (find-clnode "Structures" "cl-defstruct")
+;; https://lists.gnu.org/archive/html/help-gnu-emacs/2021-06/msg00177.html
+;;
+;; (find-epp (macroexpand ' (cl-defstruct mypoint x y) ))
+;;
+;; (cl-defstruct mypoint x y)
+;; (cl-defstruct (mypoint-colored (:include point)) color)
+;;
+;; (setq myp (make-mypoint         :x 3 :y 4))
+;; (setq myp (make-mypoint-colored :x 3 :y 4))
+;; (setq myp (make-mypoint-colored :x 3 :y 4 :color "green"))
+;; 
+;;                       (ee-struct-class       myp)
+;;                       (ee-struct-slot-names  myp)
+;;                       (ee-struct-slot-names+ myp)
+;;                       (ee-struct-index-table myp)
+;;      (find-ehashtable (ee-struct-index-table myp))
+;;       (gethash 'x     (ee-struct-index-table myp))
+;;       (gethash 'y     (ee-struct-index-table myp))
+;;       (gethash 'color (ee-struct-index-table myp))
+;;                                              myp
+;;                       (ee-struct-to-string   myp)
+;;
+;;                                (find-estruct myp)
+;;               (find-estruct (ee-struct-class myp))
+;;
+;; WARNING: this is a quick hack.
+;; THANKS: to pjb from #emacs.
+
+(defun ee-struct-class (stro)
+  (get (type-of stro) 'cl--class))
+
+(defun ee-struct-slot-names (stro)
+  (cl-mapcar 'cl--slot-descriptor-name
+            (cl--struct-class-slots (ee-struct-class stro))))
+
+(defun ee-struct-slot-names+ (stro)
+  (cons '<type-name-field> (ee-struct-slot-names stro)))
+
+(defun ee-struct-index-table (stro)
+  (cl--struct-class-index-table (ee-struct-class stro)))
+
+(defun ee-struct-to-string (stro)
+  "Convert the structure object STRO to a multi-line string.
+Here is an example. In
+
+  (cl-defstruct mytriple a b c)
+  (make-mytriple :a 22 :c \"44\")
+    --> #s(mytriple 22 nil \"44\")
+
+the representation `#s(mytriple 22 nil \"44\")' is difficult to
+read because is does't have the field names. This function
+converts that a series of lines of the form \"slotnumber
+fieldname value\", like this:
+
+  (ee-struct-to-string (make-mytriple :a 22 :c \"44\"))
+    --> 0 <type-name-field> mytriple
+        1 a 22
+        2 b nil
+        3 c \"44\"
+"
+  (let* ((ns (number-sequence 0 (length stro)))
+        (fieldnames (ee-struct-slot-names+ stro))
+        (lines (cl-mapcar
+                (lambda (n name o) (format "%d %S %S\n" n name o))
+                ns fieldnames stro)))
+    (apply 'concat lines)))
+
+(defun find-estruct (stro &rest pos-spec-list)
+  (apply 'find-estring (ee-struct-to-string stro) pos-spec-list))
+
+
+
+
 
 ;;;   __ _           _           _     
 ;;;  / _(_)_ __   __| |      ___| |__  
diff --git a/eev-compose-hash.el b/eev-compose-hash.el
index 1407863..5e06967 100644
--- a/eev-compose-hash.el
+++ b/eev-compose-hash.el
@@ -82,7 +82,7 @@
 ;; terminology and the names of the variables and functions. I am
 ;; currently using these terms:
 ;;
-;;   a "keys" mean "a pair of easy-to-type characters" (that have an
+;;   a "keys" means "a pair of easy-to-type characters" (that have an
 ;;     unicode character associated to them,
 ;;
 ;;   a "pos" means this unicode character,
@@ -338,7 +338,7 @@ instead of inserting."
   × xx \\times
   ¬ nt \\neg
 
-  face: ee-composes-face-green
+  face: eev-glyph-face-green
   « <<
   » >>
 
diff --git a/eev-pdflike.el b/eev-pdflike.el
index 690bd3b..7af6f50 100644
--- a/eev-pdflike.el
+++ b/eev-pdflike.el
@@ -1,6 +1,6 @@
 ;;; eev-pdflike.el -- hyperlinks to documents made of pages.
 
-;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2021 Free Software Foundation, Inc.
 ;;
 ;; This file is part of GNU eev.
 ;;
@@ -19,7 +19,7 @@
 ;;
 ;; Author:     Eduardo Ochs <[email protected]>
 ;; Maintainer: Eduardo Ochs <[email protected]>
-;; Version:    20210208
+;; Version:    20210608
 ;; Keywords:   e-scripts
 ;;
 ;; Latest version: <http://angg.twu.net/eev-current/eev-pdflike.el>
@@ -624,12 +624,22 @@ newline are spurious - and replaces them by \"(ff)\"."
 ;;   https://en.wikipedia.org/wiki/Xpdf
 ;;   
https://askubuntu.com/questions/1245518/how-to-install-xpdf-on-ubuntu-20-04
 
+(defvar ee-find-xpdf-colon "")
+(defun  ee-find-xpdf-colon ()
+  "Return \":\" or \"\" according to the version of xpdf.
+Some versions of xpdf need a \":\" before the page number -
+they need be called as \"xpdf foo.pdf :42\" instead of as
+\"xpdf foo.pdf 42\". In the future this function will try
+to guess correctly if the \":\" is needed or not, but this
+version just returns the value of the variable
+`ee-find-xpdf-colon'.")
+
 (defvar ee-find-xpdf-page-options '("-fullscreen"))
 (defun  ee-find-xpdf-page (fname &optional page &rest rest)
   `("xpdf"
     ,@ee-find-xpdf-page-options
     ,fname
-    ,@(if page `(,(format "%d" page)))
+    ,@(if page `(,(format "%s%d" (ee-find-xpdf-colon) page)))
     ))
 
 ;; (find-code-pdfbackend "xpdf-page")
diff --git a/eev.el b/eev.el
index 8698d27..96da6bd 100644
--- a/eev.el
+++ b/eev.el
@@ -6,7 +6,7 @@
 ;; Package-Requires: ((emacs "24.4"))
 ;; Keywords: lisp e-scripts
 ;; URL: http://angg.twu.net/#eev
-;; Version: 20210607
+;; Version: 20210608
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by

Reply via email to