weirdNox / org-noter

Emacs document annotator, using Org-mode
GNU General Public License v3.0
1.07k stars 101 forks source link

org-noter-insert-note complains, "valign--flag-region-advice: Args out of range: 194, 519" #148

Open Arbitrageur opened 3 years ago

Arbitrageur commented 3 years ago

I'm using Spacemacs on mac.

When I hit i(org-noter-insert-note), it fails to create a new entry and complains "Args out of range"

As far as I found, when I start org-noter, org-mode narrowed and outline-show-entry function in org-noter-insert-note failed

because (point-min) gives 195 in the note buffer.

How can I resolve this issue?

Arbitrageur commented 3 years ago

I'm not sure this is the proper solution but it works.

    (defun my/outline-show-entry ()
      "Show the body directly following this heading.
Show the heading too, if it is currently invisible."
      (interactive)
      (save-excursion
        (outline-back-to-heading t)
        (outline-flag-region (max (1- (point)) (point-min))
                             (progn
                               (outline-next-preface)
                               (if (= 1 (- (point-max) (point)))
                                   (point-max)
                                 (point)))
                             nil)))
    (advice-add 'outline-show-entry :override #'my/outline-show-entry)
stewmehr commented 2 years ago

I've run into the same issue and the changes to outline-show-entry suggested above worked for me. I did not investigate this any further but I think that this has only happened for documents with relatively long content before the "Notes" section where (point-min) in the narrowed buffer took high values.