nobiot / org-transclusion

Emacs package to enable transclusion with Org Mode
https://nobiot.github.io/org-transclusion/
GNU General Public License v3.0
902 stars 43 forks source link

How to add background to transclusion text #222

Closed 101scholar closed 5 months ago

101scholar commented 5 months ago

In early videos, I saw transclusion text has a colored background. Now the color only activates in live-sync-edit mode. I wonder if it is possible to add colored background in default read-only mode.

I know transclusion text is marked with different fringe color. But when I use olivetti-mode with olivetti-style setting to 'fancy, the fringe disappears. So I wonder if it is possible to make background color instead of fringe color to be different. Thanks.

nobiot commented 5 months ago

There should be a face for this. Can you check customize-face, etc. And see if any one of the faces works for your purpose?

nobiot commented 5 months ago

Refer to this if you prefer to see the source code: https://github.com/nobiot/org-transclusion/blob/main/org-transclusion.el#L140

101scholar commented 5 months ago

I tried, but it does not change how it looks. Moreover, when I call describe-face on the transclusion text, no org-transclusion-*-face shows up. I doubt that the face is not activated.

Below is my configuration and screenshot

(use-package org-transclusion
  :config
  (require 'org-transclusion-indent-mode))
Snipaste_2024-02-19_16-48-07
101scholar commented 5 months ago

I also tried it with emacs -Q in case some other packages overwrites the behavior. But the result is the same and no background color appears after I call org-transclusion-add.

101scholar commented 5 months ago

After reading the source code, I guess it is not currently supported? Face org-transclusion behaves like org-transclusion-fringe but in a terminal mode without graphic display. Maybe treat this issue as a feature request for overlay on transclusion text, similar to what is done in live sync edit, such that background color can be customized.

nobiot commented 5 months ago

This is the default color (no background visible in graphical user interface). You should be able to customize the color, for example, by customize-face.

101scholar commented 5 months ago

I tried this and set foreground and background to blue

(set-face-attribute 'org-transclusion nil :background "#2c4dd1" :foreground "#2c4dd1")

but nothing works, same as the screenshot shown above.

nobiot commented 5 months ago

It works on my end like this:

image

nobiot commented 5 months ago
(custom-set-faces '(org-transclusion ((t (:extend t :background "#ecf7ed")))))
101scholar commented 5 months ago

Not working for me.

image
101scholar commented 5 months ago

Here is my emacs information:

The above screenshot is after executing

(custom-set-faces '(org-transclusion ((t (:extend t :background "#ecf7ed")))))

and M-x call org-transclusion-add.

nobiot commented 5 months ago

I guess you are using GNU ELPA, and not GNU-devel ELPA.

This is the fix currently only available with the GNU-devel (http://elpa.gnu.org/devel/). You are probably using the GNU ELPA repo.

Refer to installation on README:

101scholar commented 5 months ago

Thanks! it works now.

nobiot commented 5 months ago

How do you make it work?

101scholar commented 5 months ago

I read the source code in the github and found it is different from my local source code. So I just realized the install version is GNU ELPA. After I reinstall the GNU-devel ELPA, it works. Thanks for helping me solve this!

nobiot commented 5 months ago

Thanks!