Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A second format for the history #8

Open
edrx opened this issue Jun 18, 2022 · 4 comments
Open

A second format for the history #8

edrx opened this issue Jun 18, 2022 · 4 comments

Comments

@edrx
Copy link

edrx commented Jun 18, 2022

Hi Mario,

can you help me to add a second format for the "history" to inspector?
I saw that one of the buffer-local variables of an "*inspector*"
buffer is `inspector-history`, and I'm imagining some changes in which
inspector would also keep a second buffer-local variable, called, say,
`inspector-history-b`... let me start by explaining its format.

If we run this with our favorite variant or C-x C-e,

  (setq aaa '(20 (((3 3.0) "3") 30 300) 40))
  (inspect-expression 'aaa)

then we can navigate to "sub-objects" of aaa, in this order:

   (20 (((3 3.0) "3") 30 300) 40)
       (((3 3.0) "3") 30 300)
        ((3 3.0) "3")
         (3 3.0)
            3.0

After reaching the 3.0 the value of `inspector-history-b` would the
`reverse` of this list:

  (aaa
   (nth 1 it)
   car
   car
   cdr)

The first element of that list is something that when eval-ed would
yield the original object on which we called inspector, and the other
items of the list are instructions to obtain each next object from the
previous one... I played a bit with a prototype of this idea, and I
used this code:

  (defun ee-sub1 (it f)
    (if (symbolp f) (funcall f it) (eval f)))
  
  (defun ee-sub (itfs)
    (let* ((it (eval (car itfs)))
           (fs (cdr itfs)))
      (while fs
        (setq it (ee-sub1 it (car fs)))
        (setq fs (cdr fs)))
      it))
  
  (setq aaa '(20 (((3 3.0) "3") 30 300) 40))
  
  (ee-sub '(aaa))
  (ee-sub '(aaa cadr))
  (ee-sub '(aaa cadr car))
  (ee-sub '(aaa cadr car (car it)))
  (ee-sub '(aaa cadr car (car it) cadr))

This feature would be very useful to me because with it I will be able
to keep series of elisp hyperlinks like this

  (find-einspectorb '(aaa))
  (find-einspectorb '(aaa cadr))
  (find-einspectorb '(aaa cadr car))
  (find-einspectorb '(aaa cadr car (car it)))
  (find-einspectorb '(aaa cadr car (car it) cadr))

in my notes - for the rationale see
<http://angg.twu.net/find-elisp-intro.html>, from 15:58 onwards, and
<http://angg.twu.net/eev-intros/find-here-links-intro.html#2> - and
this would be great for inspecting objects that contain byte-compiled
code, because then I will be able to record a path to a position that
I want to understand, then I can run some sexps like (load "foo.el") -
not (load "foo.elc")! - and then I'll be able to follow the same path
and see if the byte-compiled code became a lambda...
@mmontone
Copy link
Owner

mmontone commented Jun 18, 2022

Hi.

I don't understand this stuff very well. I'm a bit concerned it might complicate the inspector package unnecessarily. Do you think this could be implemented as a separate package as an extension? I can modify the inspector history calls somehow so that you can plug-in your package.

@edrx
Copy link
Author

edrx commented Jun 18, 2022

Hi Mario,

Hi! Sure, let's keep this idea in a separate file that can be loaded
after inspector, and that adds some functions and redefines some other
ones...

Can you take a look at this

http://angg.twu.net/elisp/eev-inspect.el.html
http://angg.twu.net/elisp/eev-inspect.el

and see if it makes sense? And then if it does, can you take a look at
the definition of `inspect-expression-b' and help me with the setqs in
comments?

Thanks in advance!!!
  Eduardo

@mmontone
Copy link
Owner

mmontone commented Jun 18, 2022

Hi,
sorry, but I don't have much time for this atm. I can evaluate a pull request and merge, but you have to do the work.

About your question:

;;
    ;; HELP NEEDED HERE:
    ;; These setqs need to be run in the "*inspector" buffer.
    ;; Mario, what is the right way to do that?
    ;; (setq inspector-inspected-object (car history))
    ;; (setq inspector-history (cdr history))
    ;; (setq inspector-history-b history-b)
    ;;

Use

(with-current-buffer "*inspector*"
 (setq inspector-inspected-object (car history))
  (setq inspector-history (cdr history))
   (setq inspector-history-b history-b))

@edrx
Copy link
Author

edrx commented Jun 19, 2022

Thanks! It works, and this does a part of what I need. The other part will require patching several of the "(cl-defmethod inspect-object ...)"s, and I don't have time to play with that now, either... so: see you in a few months, and thanks for inspector! =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants