Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8638769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:49:16+00:00 2026-06-12T10:49:16+00:00

C-x v = vc-diff is good. However, I can work with the diff directly

  • 0

C-x v = vc-diff is good. However, I can work with the diff
directly if the diff was shown in a magit-status buffer.

I’ve tried to do just that here:

(defvar le::vc-diff-data nil)
(defun le::magit-go-to-change-once ()
  (destructuring-bind (filename orig-buff relative-name) le::vc-diff-data
    (pop-to-buffer "*magit: magit*")
    (goto-char (point-min))
    (if (and (search-forward-regexp "^Changes:$" nil t)
             ;; WIP fix
             (progn (magit-show-level-2) t)
             (search-forward relative-name nil t))
        (progn (recenter-top-bottom 0)
               ;; WIP fix me here
               (magit-show-level-4)
               )
      ;; no diff
      (pop-to-buffer orig-buf)
      (message "no diff found.")))
  (remove-hook 'magit-refresh-status-hook #'le::magit-go-to-change-once))

(defadvice vc-diff (around magit-redirect activate compile)
  "redirect to magit"
  (let* ((vc-info (vc-deduce-fileset t))
         (filename (buffer-file-name))
         (orig-buf (current-buffer))
         (relative-name (replace-regexp-in-string
                         (concat "\\`"
                                 (regexp-quote (expand-file-name (locate-dominating-file filename ".git"))))
                         "" filename)))
    (if (string-equal "Git" (car vc-info))
        (progn
          (setq le::vc-diff-data (list filename orig-buf relative-name))
          (add-hook 'magit-refresh-status-hook #'le::magit-go-to-change-once)
          (call-interactively 'magit-status))
      ad-do-it)))

However the “magit-show-level*” function fails. It works when I use
eval-expression in the magit buffer though. So maybe this is a timing issue
and I have to hook in somewhere else.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:49:17+00:00Added an answer on June 12, 2026 at 10:49 am

    As said in my comment, the hook is called at a time when section related function will not work. You could try magit from there: https://github.com/vanicat/magit/tree/t/refresh-stasus-hook, your code should work with it.

    Bye the way your proposition is interesting, and integrate it into magit contrib’s proposition could be great.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just trying to get diff to work better for certain kinds of documents. With
I am looking for a Standard Inheritance System that can work in both node.js
Can anyone recommend a good XML diff and merge tool?
When I have a diff, how can I colorize it so that it looks
The diff program, in its various incarnations, is reasonably good at computing the difference
I know about git diff branch1 branch2 . However, I would like to see
Is there a diff tool that allows saving of the compare markup? To clarify,
So the utility Diff works just like I want for 2 files, but I
I'm trying to diff two strings by phrase, similar to the way that StackOverflow
What is a good method for using diff to show a percentage difference between

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.