org-noter icon indicating copy to clipboard operation
org-noter copied to clipboard

Line wrapping

Open rumsant opened this issue 6 years ago • 9 comments

I am a new user to org-noter. I have been unable to find a way to get the notes frame to wrap lines once they reach the edge of the frame. Every other instance in my emacs does this with no problem, and I'm unable to find a way to get the notes window to do so as well. I've tried every variable I can think of, but the notes window just does not seem to respond normally.

Has anyone else had this problem? Is there something that I'm missing that you could suggest I try?

Thank you.

rumsant avatar Oct 13 '18 21:10 rumsant

I believe this may be related to org-startup-truncated being t by default. Try setting it to nil and check if it fixed it.

I tried to reproduce with a clean emacs with emacs -Q -l org-noter.el and setting that variable to nil before opening the file would wrap lines on both the Doc.org buffer and the indirect buffer (Notes of ...).

weirdNox avatar Oct 17 '18 10:10 weirdNox

I have this same issue. I haven't tried with a clean emacs but (setq setting org-startup-truncated nil) in the current instance does not fix this issue.

Neither truncate-long-lines or visual-line-mode toggle have any effect.

Xparx avatar Jan 25 '19 17:01 Xparx

Ok, I hope you can provide more info on this issue :)

I usually don't have wrapping enabled. However, when I set truncate-lines to nil with toggle-truncate-lines in the Org file, it stays the same after creating a session and wraps successfully.

Have you tried setting the org-startup-truncated variable to nil before opening the Org document itself? Does it wrap in the document before opening the session?

weirdNox avatar Jan 28 '19 00:01 weirdNox

Thanks for the response. I will give a bit more detail as soon as I get back to the issue.

How I set the variable was that I opened ielm and entered (setq org-startup-truncated nil) then opened my bibnotes with the org-noter headering and then entered org-noter with M-x org-noter RET.

I will try to open emacs -Q and try this but I'm not the best emacs hacker. I'll guess I can just load-file org-noter and see if it works that way?

Xparx avatar Jan 28 '19 02:01 Xparx

Ok, thanks!

I will try to open emacs -Q and try this but I'm not the best emacs hacker. I'll guess I can just load-file org-noter and see if it works that way?

Yes, I believe after you do emacs -Q, if your packages are at the default location, you can just run M-x package-initialize and then M-x package-load RET org-noter

When you get back to it, could you also check the value of the variable truncate-lines (it is less error prone to check with M-:) both on the original buffer and on the org-noter buffer?

weirdNox avatar Jan 28 '19 15:01 weirdNox

Some additional info, hopefully helpful, regarding this issue:

  1. org-startup-truncated didn’t work for me either. However, enabling and then disabling truncation (M-x toggle-truncate-lines) in notes.org buffer worked, meaning that only after I did that, visual-line-mode worked again. However, the effect is only temporary: when I fold and unfold a section, or switch to next or previous section, wrapping gets disabled again.

  2. The main culprit in my case was actually org-indent-mode, which I keep enabled:

(add-hook 'org-mode-hook (lambda () (org-indent-mode 1)))

If Org indenting is enabled, activating and deactivating visual-line-mode has no effect and text doesn’t get wrapped (unless I first toggle truncation as described above). If I disable this line and restart Emacs, everything works as expected.

EDIT: I just noticed that if I dedicate one org document to only one book (so that the NOTER_DOCUMENT is under the first level heading), this issue with text wrapping disappears. However, if I tried to use one org document for multiple books (so that every book is under a second level heading, not a first), only then truncating gets all messed up. Maybe org-noter isn’t intended for usage like this, to have multiple PDFs in a single .org document under lower level headings?

This was tested on clean Emacs 26.1 setup, with only org-noter and pdf-tools packages installed. Org-mode is built-in version 9.1.9.

mehor avatar Jul 08 '19 07:07 mehor

Hello! I tried to understand and solve this issue some time ago, and forgot to share my findings, sorry! What @mehor found is coherent with what I discovered.

While implementing org-noter, I found out that, when using org-indent-mode, documents that start deep in a tree of notes would be very far to the right after narrowing to the document subtree in the indirect buffer. So, what I did to solve that problem is to have org-noter--set-notes-scroll, which runs every time scroll happens, that scrolls the buffer horizontally to the left.

This is what causes the problem because, as you can see in the Emacs documentation:

When the text in a window is scrolled horizontally, text lines are truncated rather than continued.

Also, that is why I couldn't reproduce the problem, because I would create a test document with long lines that would have the root at the first level, which does not need scrolling (and also why disabling org-indent-mode hides the problem)!

I thought of some ways to solve this problem:

  • One would be to have a hook/advice change the value of the indentation spacing, so we wouldn't have to scroll, but this has the problem of affecting both the indirect buffer as well as the original one because we would change text properties (which are shared)
  • We could also apply overlays, but it seems that Emacs doesn't scale well with many of them, so we would have to be smart when applying them if we did that only in regions (to not have either hiccups or badly displayed text when scrolling). We would also have to know which indirect buffers to update (there may be many sessions open from the same original buffer)

I then stopped having free time to explore more, but this is a issue that should be solved. Unfortunately, the odds are not looking good :(

weirdNox avatar Aug 12 '19 23:08 weirdNox

Thanks for the explanation. I use non-truncated lines (line wrapping) and this solved the problem for me:

(defun my/no-op (&rest args))
(advice-add 'org-noter--set-notes-scroll :override 'my/no-op)

eslgastal avatar Nov 13 '20 12:11 eslgastal

Thanks for the explanation. I use non-truncated lines (line wrapping) and this solved the problem for me:

(defun my/no-op (&rest args))
(advice-add 'org-noter--set-notes-scroll :override 'my/no-op)

This also solved the problem for me

threddast avatar Apr 07 '22 11:04 threddast