alphapapa / burly.el

Save and restore frames and windows with their buffers in Emacs
GNU General Public License v3.0
301 stars 14 forks source link

Various problems #53

Closed northjayd closed 2 years ago

northjayd commented 2 years ago

Hi I am having trouble getting some features to work:

Indirect buffers:

If I save an indirect buffer in a burly bookmark, only that buffer will be restored and it will be as a single window. All other windows will not restore.

The error is: burly-bookmark-handler: Wrong type argument: listp, org-fold-outline

These all produce the same error:

Folds and cursor location:

Folds are not restored, therefore, if cursor location is saved while on a subtree heading, and then the buffer's folds are all closed to top level heading, when bookmark is restored, the cursor will be on that subtree's top level parent heading, losing the place of the original cursor location.

alphapapa commented 2 years ago

I'm guessing you're using a bleeding-edge version of Org, which has the new org-fold library and features. Please provide the versions of Org and Emacs that you're using.

alphapapa commented 2 years ago

@yantar92 You may want to be in the loop on this, as I'm guessing that it may also affect other packages.

northjayd commented 2 years ago

I'm guessing you're using a bleeding-edge version of Org, which has the new org-fold library and features. Please provide the versions of Org and Emacs that you're using.

Emacs is 28.1 Org-mode is 9.6

yantar92 commented 2 years ago

Can you M-x toggle-debug-on-error and then report the full backtrace?

northjayd commented 2 years ago

Can you M-x toggle-debug-on-error and then report the full backtrace?

Debugger entered--Lisp error: (wrong-type-argument listp org-fold-outline)
  signal(wrong-type-argument (listp org-fold-outline))
  burly-bookmark-handler(("test" (url . "emacs+burly+windows:?%28%28%28min-height%20.%204%2...") (handler . burly-bookmark-handler)))
  bookmark-handle-bookmark("test")
  bookmark--jump-via("test" pop-to-buffer-same-window)
  bookmark-jump("test")
  #f(compiled-function (x) #<bytecode 0xa12ba9593727806>)("test")
  ivy-call()
  ivy-read("Create or jump to bookmark: " ("test" "body" "music study dashboard" "Burly: modes" "org-refile-last-stored" "org-capture-last-stored") :history bookmark-history :action #f(compiled-function (x) #<bytecode 0xa12ba9593727806>) :caller counsel-bookmark)
  counsel-bookmark()
  funcall-interactively(counsel-bookmark)
  call-interactively(counsel-bookmark nil nil)
  command-execute(counsel-bookmark)
yantar92 commented 2 years ago

Thanks!

Now, can you first evaluate

(defun burly-bookmark-handler (bookmark)
  "Handler function for Burly BOOKMARK."
  (let ((previous-name burly-opened-bookmark-name))
    ;; Set opened bookmark name before actually opening it so that the
    ;; tabs-mode advice functions can use it beforehand.
    (setf burly-opened-bookmark-name (car bookmark))
    (unwind-protect
        (burly-open-url (alist-get 'url (bookmark-get-bookmark-record bookmark)))
      (setf burly-opened-bookmark-name previous-name))))

and then report the backtrace again?

northjayd commented 2 years ago

Debugger entered--Lisp error: (wrong-type-argument listp org-fold-outline)
  signal(wrong-type-argument (listp org-fold-outline))
  (condition-case err (burly-open-url (alist-get 'url (bookmark-get-bookmark-record bookmark))) (error (setq burly-opened-bookmark-name previous-name) (signal (car err) (cdr err))))
  (let ((previous-name burly-opened-bookmark-name)) (setq burly-opened-bookmark-name (car bookmark)) (condition-case err (burly-open-url (alist-get 'url (bookmark-get-bookmark-record bookmark))) (error (setq burly-opened-bookmark-name previous-name) (signal (car err) (cdr err)))))
  burly-bookmark-handler(("test" (url . "emacs+burly+windows:?%28%28%28min-height%20.%204%2...") (handler . burly-bookmark-handler)))
  bookmark-handle-bookmark("test")
  bookmark--jump-via("test" pop-to-buffer-same-window)
  bookmark-jump("test")
  #f(compiled-function (x) #<bytecode 0xbc70e289ecdb806>)("test")
  ivy-call()
  ivy-read("Create or jump to bookmark: " ("test" "body" "music study dashboard" "Burly: modes" "org-refile-last-stored" "org-capture-last-stored") :history bookmark-history :action #f(compiled-function (x) #<bytecode 0xbc70e289ecdb806>) :caller counsel-bookmark)
  counsel-bookmark()
  funcall-interactively(counsel-bookmark)
  call-interactively(counsel-bookmark nil nil)
  command-execute(counsel-bookmark)
yantar92 commented 2 years ago

Oops. My code was not good enough to uncover the real backtrace. Try

(defun burly-bookmark-handler (bookmark)
  "Handler function for Burly BOOKMARK."
  (let ((previous-name burly-opened-bookmark-name))
    ;; Set opened bookmark name before actually opening it so that the
    ;; tabs-mode advice functions can use it beforehand.
    (setf burly-opened-bookmark-name (car bookmark))
    (burly-open-url (alist-get 'url (bookmark-get-bookmark-record bookmark)))))

but note that burly can be broken afterwards and you may want to restart Emacs after reporting the backtrace again.

northjayd commented 2 years ago

I'm not getting a backtrace anymore after evaling your new function, but I still get the backtrace with the original function. I do get an error in the modeline, and sometimes it opens up an empty backtrace window but most often it doesn't.

After a restart, when I open the bookmark after evaling your new function, the error is: Wrong type argument: listp, 90

After a restart, if I open the bookmark with the original function first, I get the original backtrace. But then if I eval the new function (after having done it first with the original) and then open the bookmark the error is: Wrong type argument: listp, 0

Basically If I load yours first: listp, 90 If I do the original first and then yours after: listp, 0

yantar92 commented 2 years ago

@alphapapa This appears to be not confined to the Org mode staff then. Maybe some generic print/read issue? I've seen such in Emacs 28 with undohist.

alphapapa commented 2 years ago

@yantar92 I've no idea. Sorry for involving you if it's not related to your work on Org, and thanks for your help here.

@northjayd Please try to reproduce in a clean Emacs configuration, e.g. using emacs -q or https://github.com/alphapapa/with-emacs.sh

northjayd commented 2 years ago

There were no errors anymore, but it still doesn't work in the clean config In all cases folds still do not persist.

some tests:

Two buffers in two side by side windows. One window is the cloned indirect buffer of the other buffer:

closing: Results feel all over the place to me. I've really never gotten Burly to work for me, even on my old computer a while ago. When I make a bookmark without indirect buffers just so I can have multiple windows of an org file with the cursor on different headings, it has worked for a little while, but often on a future open for no reason the cursors have jumped to a random location. In many or most cases as far as I know there hasn't even been any deleted or added lines of text or moved headings.

Folds also never persist.

Happily though Burly reliably opens window arrangements of specific image files

alphapapa commented 2 years ago

@northjayd It seems that you're reporting various different problems at once, like folds not persisting, buffers not restoring to the correct windows, point not being where you expected it, etc. This makes it difficult to identify the problems and any possible root cause.

As well, while I appreciate your trying to be detailed in your tests, you didn't write the tests in a reproducible way. A more useful example would be something like:

  1. M-x foo RET.
  2. Press C-c C-x b.

Expected result: X was Y.

Actual result: X was Z.

Then I could repeat the steps on my end and try to reproduce the problem.

Regarding outline folding: As far as I'm aware, the outline visibility has never been preserved, because I'm not aware of it being possible to do so. I don't know where you got the impression that such a feature was intended. It is a nice idea, and maybe it could be done, but I've never written any code for it.

Results feel all over the place to me. I've really never gotten Burly to work for me, even on my old computer a while ago.

I'm afraid I can't do anything with that kind of description. What I know is that I use Burly every day to restore window configurations including Org buffers, org-ql-view buffers, magit-status buffers, ement-room buffers, ement-taxy-view-list-buffers, dired buffers, etc, and it works reliably for me.

Having said that, some of the related Emacs functionality is like a black box (e.g. window/frame configurations), and it can be difficult to identify and solve problems in related code. It's certainly possible you have encountered bugs that need to be solved, either in Emacs and/or in Burly, but in order to do so, we will need to be methodical, precise, and comprehensive in the debugging process. That means starting each test from a clean slate, in a clean configuration, and reporting all of the steps followed, in exacting detail.

It would be best if you would report each distinct problem in a separate issue so they can be solved individually.

northjayd commented 2 years ago

As far as I'm aware, the outline visibility has never been preserved, because I'm not aware of it being possible to do so. I don't know where you got the impression that such a feature was intended.

Oh wow sorry, I don't know why I assumed/thought that either. My bad.

As well, while I appreciate your trying to be detailed in your tests, you didn't write the tests in a reproducible way

Ok I'll try to get a better grasp on what I think is happening, and open up separate issues and try to write them better to be reproducible. For indirect buffers and the point.

So for the folding, I was going to attempt to make some small functions that in them would call individual burly bookmarks, so to as well load in things like web browsers on certain webpages into a specific window (I use exwm). So maybe I can have the functions also run org-occur into the org buffers to show my desired headings, for the folds.

Awesome ok thank you, I appreciate your work

alphapapa commented 2 years ago

As far as I'm aware, the outline visibility has never been preserved, because I'm not aware of it being possible to do so. I don't know where you got the impression that such a feature was intended.

Oh wow sorry, I don't know why I assumed/thought that either. My bad.

No problem. This all gets pretty complicated with various packages and features interacting.

As well, while I appreciate your trying to be detailed in your tests, you didn't write the tests in a reproducible way

Ok I'll try to get a better grasp on what I think is happening, and open up separate issues and try to write them better to be reproducible. For indirect buffers and the point.

Thanks.

So for the folding, I was going to attempt to make some small functions that in them would call individual burly bookmarks, so to as well load in things like web browsers on certain webpages into a specific window (I use exwm). So maybe I can have the functions also run org-occur into the org buffers to show my desired headings, for the folds.

I'm not sure exactly what you mean. But maybe it would suffice to, e.g. call org-reveal after restoring a bookmarked entry. Maybe we could add a hook to Burly that would let you call functions to do things like that.

Awesome ok thank you, I appreciate your work

Thanks, and I appreciate your reporting problems so we can try to improve Burly.

Since you're going to open specific issues for those problems, I'll close this one and be on the lookout for your next reports.