this post was submitted on 29 Nov 2023
1 points (100.0% liked)

Emacs

310 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

Is there a way to replace all hyperlinks in a buffer with some shorthand phrase say "link" while keeping them as clickable links to their respective site?

I've been importing csv files as tables and one of the columns stores links but they're quite long and making things awkward looking so I'd like to replace them with some shorthand.

Sorry, probably a noob question, still new.

you are viewing a single comment's thread
view the rest of the comments
[–] MitchellMarquez42@alien.top 1 points 9 months ago

you can do this with an Overlay, if you know where the link starts and ends. For example I have the buffer README.org

#+title: hypop - emacs minibuffer-frame + hyprland

* Demo
https://www.youtube.com/watch?v=jXRt598HqCY

the first character of the link is the 60th and the last is the 103rd. So I could write

(with-current-buffer "README.org"
  (overlay-put (make-overlay 60 103) 'display "link"))

Clicking the "link" text still opens YouTube as expected.

To do this all over a buffer you'd want to add a font-lock rule based on a regular expression like browse-url-button-regexp.

If you only need it in Org files, there's probably some machinery to facilitate that as well