reddit / emacs

How can I style a (custom) link?

authsec · 2022-12-30 23:56
Hi everyone! Can someone please explain to me how I can "style" a (custom or built in) link properly? What I want to achieve is basically some similar look, to what you can do with e.g. the `:before` element in CSS, where you e.g. display a little link icon in front the actual link. The icons can come from a font like e.g. Fontawesome and/or svg source. With the following code I managed to show an icon from `all-the-icons`, which I replaced with the letter `M` here for better readability. The problem with this is however, that it does not only change the word `menu` to an `M` inside the link only. (org-deflink menu "Style and export for menu links" [:face '(:box "gray60" :background "gray95" :foreground "purple")]) (setq prettify-symbols-alist '(("menu" . "M"))) (prettify-symbols-mode 1) The plain text looks like: [Plain Text](https://preview.redd.it/a7u7q0xgi49a1.png?width=978&format=png&auto=webp&s=63e0a2c9b76e3627b3d26372c4a9baad80c8eb96) and the "styled" version of that input looks like: [Styled Text](https://preview.redd.it/5apfsonqi49a1.png?width=1000&format=png&auto=webp&s=c20c9467d3be14a8c68be75697110e874b56109b)
casouri · 2022-12-31 01:44
You would need to use the before-string text property, and use either jit-lock-functions or font-lock-add-keywords to add text properties automatically.
yantar92 · 2022-12-31 18:40
You can set `:activate-func` custom link property. It will be used to fontify the link.