1

A recent feature request raised a new area of integration/customization for me. I've developed a package to browse GitHub content and we'd like to be able to store a link to the current 'thing' using org-store-link (C-c C-l). Problem is – it doesn't seem like I can change the behavior of the https? protocol without completely replacing it.

At any given time, there are multiple things you might want to get the link for – and they'd all be https? links. How can I define multiple functions for a link type such that they can provide multiple options? Reading org-link-parameters and org-store-link-functions, this doesn't appear to be possible.


Pursuant to the comments below…

This is for proposed Magithub functionality. Magithub is a Magit-based GitHub client that can view issues, pull requests, and comments (among other things). You can choose to visit the current 'thing' in the browser using w, though sometimes the current 'thing' is ambiguous. For example, if point is at a comment, it is also technically at an issue or PR. Point could even be at a link within a comment on an issue – and now there are three distinct link candidates for storing. Ideally, org-store-link should at this point prompt for which link should be stored (which does appear to be possible per the results-alist variable in the definition). The list of functions though comes from the return of org-store-link-functions which collects over org-link-parameters, so it seems it's not as simple as adding a function to a list.

When org-store-link completes, I'm guessing org-stored-links would just have a list ("some human-readable title I define" "https://github.com/some/project/issues/123") added as an element.

Sean Allred
  • 6,861
  • 16
  • 85
  • I don't have time right now to read your question carefully (sorry), but maybe an [Org link that invokes a bookmark](https://www.emacswiki.org/emacs/BookmarkPlus#OrgModeLinksThatJumpToBookmarks) would help? The bookmark invocation can do anything you like. – Drew Feb 17 '18 at 16:04
  • IMHO If you need special functionality for certain `https` entries changing the `:action` property in the `https` entry of `org-link-parameters` is just wrong. Better define a new entry with a new protocol type in `org-link-parameters`. If I understand [your answer to the feature request](https://github.com/vermiculus/magithub/issues/284) right you already suggested something like that with `github:`. The function registered as `:action`-property of that protocol can open a popup-menu (defined e.g. with `easy-menu-define`). – Tobias Feb 17 '18 at 20:59
  • @tobias I have a feeling though people will want to use use http links more. After that I could just add a browse-url handler. – Sean Allred Feb 17 '18 at 21:23
  • Changing :action is indeed entirely inappropriate. – Sean Allred Feb 17 '18 at 21:29
  • Yes `:action` is inappropriate since I actually meant `:follow`;-). – Tobias Feb 17 '18 at 21:52
  • You wrote: "I have a feeling though people will want to use http links more.". Hm, in my experience it is bad to change something where the user has very clear expectations (as e.g., follow url). If you need new functionality then mark it clearly with a new protocol. For that reason it is that simple to define a new one in org-mode. I've done that within our organization for bug-tracker links (T:NUMBER) and for helpdesk tickets (H:NUMBER). Further example: https://emacs.stackexchange.com/questions/38098/ – Tobias Feb 17 '18 at 21:59
  • @Tobias now that I'm at a computer… :-) I don't want to change the behavior of http links. I want to teach `org-store-link` how to recognize the links inside these magit sections so that they can be inserted elsewhere. I really don't care what people do with the links after they've been stored – if they want to use magithub to browse all github links, they can inject the browse-url support :-) – Sean Allred Feb 17 '18 at 22:29
  • @SeanAllred Please provide a sample org-file contents in the question with the link format that should be recognized by `org-store-link`. Please also add what `org-store-link` should add for the link in `org-stored-links`. – Tobias Feb 17 '18 at 22:46
  • @Tobias I'm not sure that's possible; the data to be recognized by `org-store-link` is not in the buffer-string at all – it's within a data structure returned by `(magit-section-value (magit-current-section))`. But I will try. – Sean Allred Feb 17 '18 at 22:48
  • Yes. Currently it is really difficult to comprehend what you want. You should add a reproducible recipe for getting the information you want to put into `org-stored-link`. Maybe that is also the main part for getting the job done. – Tobias Feb 17 '18 at 22:55
  • @Tobias See edit. – Sean Allred Feb 17 '18 at 23:02

0 Answers0