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

Per-site link formatting #107

Closed
azzamsa opened this issue Aug 5, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@azzamsa
Copy link

commented Aug 5, 2018

I use org-cliplink dozens times every day. Really grateful for this awesome package.

Most of the time I use it to fetch github repo link. which will result into

- [[https://github.com/uutils/coreutils][GitHub - uutils/coreutils: Cross-platform Rust rewrite of...]]

Can we add org-cliplink config so that it has setting for every site. e.g github. So the result will be

- [[https://github.com/uutils/coreutils][Cross-platform Rust rewrite of the GNU coreutils]]

Or we can add other "string" before the description. e.g "Github : desc"

I think, maybe this #99 issue also can be solved using this method.

PS: inspired form chitsaou/copy-as-markdown#52

Thank you for this awesome package.

rexim added a commit that referenced this issue Aug 5, 2018

@rexim

This comment has been minimized.

Copy link
Owner

commented Aug 5, 2018

@azzamsa it's already possible to achieve what you want. Please check out Custom Transformers section of the README and let me know what you think. It's not really convenient or intuitive, but you can use the example from there as a temporary workaround until we implement something more friendly.

@azzamsa

This comment has been minimized.

Copy link
Author

commented Aug 6, 2018

wow, that so fast :).

I tried it. works great for me.

But I still haven't time to hack it. Can org-cliplink recalculate org-cliplink-max-length when the original description trimmed ?

# original
[[https://github.com/rexim/org-cliplink][GitHub - rexim/org-cliplink: Insert org-mode links from c...]]

# custom
[[https://github.com/rexim/org-cliplink][Insert org-mode links from c...]]
@rexim

This comment has been minimized.

Copy link
Owner

commented Aug 7, 2018

@azzamsa no it cannot right now. And I think it's a bug #108. I'll try to find time to fix it this week.

@azzamsa

This comment has been minimized.

Copy link
Author

commented Aug 7, 2018

At first I thought I don't pay attention to README file. Because this feature already there.

Turn out it just implemented after I opened the issue. I was surprised how fast it is to extend lisp program.

@rexim

This comment has been minimized.

Copy link
Owner

commented Aug 10, 2018

@azzamsa the org-cliplink-max-length recalculation problem should be fixed on the next update.

@azzamsa

This comment has been minimized.

Copy link
Author

commented Aug 11, 2018

This is the last result I get

[[https://github.com/rexim/org-cliplink][GitHub - rexim/org-cliplink: Insert org-mode links from c...]]

[[https://github.com/rexim/org-cliplink][Insert org-mode links from clipboard]]

Yes, it's differ from this result #107 (comment)

But I still wondering. If we count the first line (fetched using original org-cliplink) the modeline says it's 60 char. But the second line (with custom org-cliplink) just 36 char. Is this by design ?

@rexim

This comment has been minimized.

Copy link
Owner

commented Aug 11, 2018

@azzamsa I'm not sure if I understand you.

Right now org-cliplink-insert-transformed-title:

  • gets the title as it is,
  • passes it through a custom transformer (like removing GitHub prefix in your case)
  • cuts the transformed result to length equal to org-cliplink-max-length (which is 80 by default).
  • and inserts it to the current buffer

If the title fits org-cliplink-max-length after the transformation it will not be cut. And this is exactly what we see in your case.

@azzamsa

This comment has been minimized.

Copy link
Author

commented Aug 12, 2018

Oh, sorry.

I didn't notice that this repo description is only:

Insert org-mode links from clipboard

Which is has maximum string length 36. So I thought the calculation was wrong. Now I tried to the longer string.

[[https://github.com/donnemartin/system-design-primer][GitHub - donnemartin/system-design-primer: Learn how to d...]] 
# length result = 177

[[https://github.com/donnemartin/system-design-primer][Learn how to design large-scale systems. Prep for the sys...]]
# length result = 177

Everything is OK and the calculation is works.

Thanks a lot for org-cliplink.
I don't know how to say thanks. You are very kind.

@azzamsa

This comment has been minimized.

Copy link
Author

commented Aug 14, 2018

Thank you so much for org-cliplink. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.