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

org-mode links become invisible #329

Open
borwick opened this issue Apr 4, 2023 · 3 comments
Open

org-mode links become invisible #329

borwick opened this issue Apr 4, 2023 · 3 comments

Comments

@borwick
Copy link

borwick commented Apr 4, 2023

Hello! I'm not sure exactly what changed, but sometime between fall 2022 and now (April 2023), when I use polymode with org-mode, my org-mode links become invisible. They do not become invisible when I'm in regular org-mode. Here is my polymode setup:

(use-package polymode
  :config
  (define-hostmode poly-mml-hostmode :mode 'notmuch-message-mode)
  (define-innermode jb-poly-org-innermode
    :mode 'org-mode
    :head-matcher "^--text follows this line--$"
    :tail-matcher "^THISNEVEREXISTS$"
    :head-mode 'host
    :tail-mode 'org-mode)
  (define-polymode poly-org-mode
    :hostmode 'poly-mml-hostmode
    :innermodes '(jb-poly-org-innermode))
  (add-hook 'mml-mode-hook
	    (lambda () (local-set-key (kbd "C-c o") #'poly-org-mode)))
  )

I'm doing this so I can write an email in org-mode format and then use org-mime to HTMLize it.

If I am using this mode and then insert a link, the link becomes invisible.

What the buffer looks like:

From: test@example.com
To: test@example.com
Subject: Test
Fcc: sent
--text follows this line--
This is a .

However, what's actually in the buffer is; this is what I see if I run M-x visible-mode:

From: test@example.com
To: test@example.com
Subject: Test
Fcc: sent
--text follows this line--
This is a [[https://example.com][link]].

If I take the same content and paste it into a new buffer, test.org, I see the link rendered the way that I want (where I see the text but can interact with it to see the link):

From: test@example.com
To: test@example.com
Subject: Test
Fcc: sent
--text follows this line--
This is a link.

How should I go about determining what's different in polymode's version of org-mode vs. what I'm experiencing in a "true" org-mode buffer? I can definitely use visible-mode as a workaround but I'd love to know what's going on!

@yoshinari-nomura
Copy link

I have the same problem with Polymode 20230317.1218 and Emacs 29.2.50.

Invoke emacs with -q option, and eval below:

(add-to-list 'load-path "~/.emacs.d/versions/29.2/elpa/polymode-20230317.1218")

(require 'polymode)

(define-innermode poly-org-innermode
  :mode 'org-mode
  :head-matcher "^[*]+ .*"
  :tail-matcher "^[^ \n\t*#]\\|\\'"
  :head-mode 'body
  :tail-mode 'host)

(define-hostmode poly-fundamental-hostmode
  :mode 'fundamental-mode)

(define-polymode poly-fundamental-mode
  :hostmode 'poly-fundamental-hostmode
  :innermodes '(poly-org-innermode))

Then creat a buffer with fundamental-mode.
Yank this text:

* 2024-01-29
  [[https://github.com/polymode/polymode][polymode]] is awesome!

M-x poly-fundamental-mode becomes:

* 2024-01-29
   is awesome!

link looks invisible. If you cut and paste the invisible text to another buffer,
polymode becomes awesome again 😄

@yoshinari-nomura
Copy link

I found that org-mode uses buffer-invisibility-spec to control the appearance of invisible text. Polymode introduces buffer-invisibility-spec from host into inner.

I think host needs to setup buffer-invisibility-spec as that of org-mode.

Eval below before M-x poly-fundamental-mode in host buffer works for me.

(setq buffer-invisibility-spec
      (with-temp-buffer
        (org-mode)
        buffer-invisibility-spec))

@borwickatuw
Copy link

FYI that works for me!

  (advice-add 'poly-org-mode
	      :before
	      (lambda () (setq buffer-invisibility-spec
		    (with-temp-buffer
		      (org-mode)
		      buffer-invisibility-spec))))

I'm sure there is a better way to do this, e.g. to figure out what's going on with buffer-invisibility-spec, but this works! Thank you @yoshinari-nomura !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants