dmitrym0 / org-hyperscheduler

org-hyperscheduler is an Emacs package that helps you organize your day.
GNU General Public License v3.0
188 stars 14 forks source link

PROPERTIES put after SCHEDULED causes weird org layout issue #26

Closed ParetoOptimalDev closed 12 months ago

ParetoOptimalDev commented 1 year ago

Version info:

GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
Org mode version 9.6.8 ( @ /nix/store/vz1nbik66l0cc43vmak3mh5qinbvi44m-emacs-packages-deps/share/emacs/site-lisp/elpa/org-9.6.8/)

The issue that happens is basically instead of:

* task 1
* task 2

Some sort of display error happens when PROPERTIES is after SCHEDULED and it is displayed like:

*task 1 * task 2

I've experienced this in the past and been able to use org-cycle a few times to fix things or org-fold-reveal but it doesn't seem to make a difference here.

It's possible this is a regression with org 9.6 and a bug needs reported upstream, but it's also pretty easy (maybe) to put properties before scheduled I think.

ParetoOptimalDev commented 1 year ago

This is actually even more subtle and specific to me or perhaps other org-roam users that hide properties. It only happens when properties are hidden with something like:

(defun org-hide-properties ()
  "Hide all org-mode headline property drawers in buffer. Could be slow if it has a lot of overlays."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward
            "^ *:properties:\n\\( *:.+?:.*\n\\)+ *:end:\n" nil t)
      (let ((ov_this (make-overlay (match-beginning 0) (match-end 0))))
        (overlay-put ov_this 'display "")
        (overlay-put ov_this 'hidden-prop-drawer t))))
  (put 'org-toggle-properties-hide-state 'state 'hidden))

I believe it happens because previously the properties included the newline, but when they are hidden with the code above it also includes the newline.

Perhaps the issue is this custom code then and only the \n needs removed from the code above.

The problem with that is this was originally used to hide properties at the top of an org-roam file like:

:PROPERTIES:
:ID:       450b7062-4f9c-4773-adf5-bfa84f99f410
:END:
#+title: 2023-08-29

So capturing the newline is necessary to avoid a redundant newline.

Anywho... this is clearly not a hyperscheduler issue but hyperscheduler could work around it.

If you think working around it for this likely very narrow case, I can look into doing it. Or perhaps I need to improve org-hide-properties to not match a newline when under a heading.

Thanks for your time and the package though!

dmitrym0 commented 1 year ago

Hey @ParetoOptimalDev, can you show me a self contained example? I haven't seen this with my instance yet.

ParetoOptimalDev commented 12 months ago

@dmitrym0 I gave detailed reproduction steps here... I meant to link you to those earlier.

This isn't org-hyperscheduler's fault though. It's the fault of the code from org-roam or my fault for using it for more than it was intended.

I don't think there's anything to do on the org-hyperscheduler side here.

If you have a better suggestion for code improvements to what I suggested here though I wouldn't mind ;)