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

Rearview mirror #107

Open
masatake opened this issue Nov 24, 2021 · 4 comments
Open

Rearview mirror #107

masatake opened this issue Nov 24, 2021 · 4 comments

Comments

@masatake
Copy link
Member

The peek window is for forward-reading.
I wonder how useful if we can use it for backward-reading.

  1. you are at an interesting function, "memmove":
    origin

  2. you will do M-. to go to the definition:
    jumpto

  3. you may wonder how the function is called. e.g. association between the arguments in the caller context and the parameter in the callee context.

  4. turn on the rearview mirror:
    rearview

You don't have to break the reading-context with M-,.
Just an idea.

@masatake masatake changed the title rearview mirror Rearview mirror Nov 24, 2021
@AmaiKinono
Copy link
Member

I think citre-peek can already do this.

  • After you jump to a definition in a peek session, you can just browse the peek history to see how it's called.
  • We have citre-peek-backward-in-chain-after-jump to automatically do this after every jump.
  • We can have a command for this so you can turn on the rearview mirror when you want.

What you described is likely to be an extension for xref (so it's not in the scope of Citre).

@AmaiKinono
Copy link
Member

I've create a little helper for you ;)

(require 'citre-common-tag)
(require 'citre-ui-peek)

(defun peek-back-after-xref ()
  (let* ((marker (caar (xref--get-history)))
         (buf (marker-buffer marker))
         tag)
    (with-current-buffer buf
      (save-excursion
        (goto-char marker)
        (setq tag (citre-make-tag-of-current-location
                   (if-let ((sym (symbol-at-point)))
                       (symbol-name sym) ".")))))
    (citre-peek-show (list tag))))

(add-hook 'xref-after-jump-hook #'peek-back-after-xref)

@masatake
Copy link
Member Author

Thank you. It works. This is a great hint for me.

  • in the context, citre-peek-file-content-height can be smaller.
  • it will be better if the peek window is displayed before the point.
  • the color of the peek window can differ between the front and rear.

Maybe these are my homework.

The rearview helps a code reader associate arguments seen in a function call and parameters in the function definition.

@AmaiKinono
Copy link
Member

For now all these aspects are controlled by global variables, or hard coded. So although the appearance you want is actually easy to implement, it's harder to adopt it in the current codebase.

It's not clear to me how this fits into the citre-peek tool for now. Maybe one possible approach is to:

  • Bind a set of properties to a peek session.
  • Offer a set of API to the user so they can write commands to peek all sorts of things.

I think i've seen a somewhat similar work in a package called peek.

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