0

I was on the fence about raising this on GitHub, but it's not necessarily a feature request and it certainly isn't a bug report.

I'd like to add some actionability to every reference to commits within Magit. For instance, I'd like to add a 'browse this commit on GitHub' feature to Magithub, but I don't want to track down all the places commits are displayed to a user – I'd like to just say 'commit references should have this additional behavior' and have that just work.

Soon, I'll want to do something similar for branches, and I can easily see this list growing. A one-off solution for commits clearly won't scale well.

Is this possible already in Magit? If not, how should an implementation approach this? My guess is that the text should use a local keymap that can be modified by consumers. (If the latter, I will definitely add this as a feature request on the tracker and link the discussions together.)

1

Each section has a type and for some section types, including the ones you have mentioned, a type-specific keymap exists named magit-TYPE-section-map. Also look at the various magit-*-at-point functions in magit-git.el and how they are used in hairy cases elsewhere.

To get information about the section at point use M-x magit-describe-section. The first symbol inside the printed vector is the section type.

A section (currently) can only have one type, which can complicate matters. For example all children of a log have type commit, even those that a tag and/or branch point at.

So if you want a command to be available whenever there is a branch at point, then you would have to bind it not only in magit-branch-section-map but also magit-commit-section-map. And then you would have to dispatch again inside the command itself. The functions I have mention help here, but you should also read Matching Sections.

  • @SeanAllred Does that answer your question? – tarsius Nov 9 '17 at 19:59
  • Sorry for the delayed response; oddly, I didn't get a notification for this. – Sean Allred Nov 12 '17 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.