Random blank buffer (2)

Issue #30 closed
Jon B
created an issue

This issue, described by another user, was marked as resolved but I also have this problem:

Blank buffers randomly appears instead of questions, with the vertical scrollbar locked at the bottom of the page... Resizing the emacs window makes the buffer go back to normal and shows the question.

(After resizing, emacs tells me: Buffer spanish.org has shrunk a lot; auto save disabled in that buffer until next real save...)

Then if I press a key, I'm asked to rate my answer but the solution doesn't show up.

GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0) + org-8.3.1 + lastest org-drill Clean .emacs file (no other packages)

Comments (28)

  1. Paul Sexton repo owner

    I tried once again to reproduce this, using:

    • GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)
    • Org mode 8.3 beta (2015-7-25)
    • Latest org-drill
    • Otherwise clean .emacs

    And I simply cannot. spanish.org works fine for me on multiple runs. Resizing the frame during drill sessions behaves normally.

    Sorry, but I think you must have found a bug with either org mode or Emacs. I don't have any other explanation.

  2. Jon B reporter

    I will send a bug report to Org-mode devellopers, in the hope it could help...

    Org-mode 8.2.1 +Latest org-drill is working fine for me.

    Now, time to experiment with org-drill!

    Many thanks for your work and your feedback.

  3. Andre Peric Tavares

    I get the same problem using Spacemacs (Org 8.3.2, latest org-drill) and on a fresh Emacs installation on Lubuntu (after adding org-plus-contrib).

    Hopefully org-mode devs will have a look into that.

  4. Keith Amidon

    I added an update to issue #28 before realizing this follow-up was still open and finding the advice here. The workaround appears to work for me and without ill effects on org files with latex fragments, even org-drill ones.

  5. Joe Schafer

    I made a function to automatically patch org.el based on @Naibaf_Regeir's fix. I made it because when I update org-mode, the fix is overwritten.

    (defun my:work-around-org-window-drill-bug ()
            "Comment out a troublesome line in `org-toggle-latex-fragment'.
    See https://bitbucket.org/eeeickythump/org-drill/issues/30 for
    details."
            (save-excursion
              (let ((org-library-location (concat
                                           (locate-library "org" 'nosuffix)
                                           ".el")))
                (with-current-buffer (find-file-noselect org-library-location)
                  (goto-char (point-min))
                  (search-forward "(set-window-start nil window-start)")
                  (back-to-indentation)
                  (if (looking-at ";; ")
                      (message "Already modified `org-toggle-latex-fragment' for `org-drill'")
                    (insert ";; ")
                    (save-buffer)
                    (byte-compile-file org-library-location)
                    (elisp--eval-defun)
                    (message "Modified `org-toggle-latex-fragment' for `org-drill'"))))))
    
  6. coyotespike

    Joe and Naibaf, thanks for that function. For some reason my Emacs displayed an error for elisp--eval-defun. I ran eval-buffer in a scratch buffer on (message (concat (locate-library "org" 'nosuffix) ".el"))) to find the right directory, then eval-buffer on org.el. Then it worked.

  7. Paul Sexton repo owner

    The following replaces an internal org-drill function. It attempts to undo the effects of the offending line in org.el by saving and then restoring the window-start position. You will need to ensure it is evaluated after org-drill is loaded, e.g. by putting it in your .emacs file. Try it and see if it solves the problem. Be warned, at least for me window-start is a slow function, taking several seconds to return, so this may slow down your drill sessions.

    (defun org-drill--show-latex-fragments ()
      (org-remove-latex-fragment-image-overlays)
      (cond
       ((fboundp 'org-toggle-latex-fragment)
        (let ((wstart (window-start nil)))
          (org-toggle-latex-fragment '(4))
          ;; Workaround for a display bug in org-toggle-latex-fragment
          (set-window-start nil wstart)))
       (t
        (org-preview-latex-fragment '(4)))))
    
  8. Joe Schafer

    Paul, that code works for two cards and displays a blank buffer. Even with using the fix of commenting out (set-window-start in org-toggle-latex-fragments that code doesn't work for me. I had to re-eval the original 'org-drill--show-latex-fragments` to get it working again.

    An alternate approach could be to advise org-toggle-latex-fragment so set-window-start is a noop.

    Also, anyone talked to the org-mode devs about this issue? Would they be willing to fix it upstream.

  9. Philipp Middendorf

    This is sort of an unusual fix for this, but couldn't we add a user-customizable variable telling org-drill not to call toggle-latex-fragment (and toggle inline images) when the drill starts? You could toggle those manually (or you do that automatically, anyway) before starting the drill.

  10. allan bailey

    I tried the above code fix on fedora23, x86_64, emacs 24.5.1, org-mode 8.3.3. The below 3 card t.org file I tested with seems to consistently always blank on the 1st card.

    * my notes
    
    ** 1st subheading
    
    *** something                                 :drill:
        this is some text about something.
    
    **** Answer
     this is the answer to 'something'
    
    ** 2nd subheading
    
    *** something2                                :drill:
        this is some text about something2.
    
    **** Answer
     this is the answer to 'something2'
    
    ** 3rd subheading
    
    *** something3                                :drill:
        this is some text about something3.
    
    **** Answer
     this is the answer to 'something3'
    
  11. Evgeny

    If I understand correct I need add this code:

    (defun org-drill--show-latex-fragments ()
      (org-remove-latex-fragment-image-overlays)
      (cond
       ((fboundp 'org-toggle-latex-fragment)
        (let ((wstart (window-start nil)))
          (org-toggle-latex-fragment '(4))
          ;; Workaround for a display bug in org-toggle-latex-fragment
          (set-window-start nil wstart)))
       (t
        (org-preview-latex-fragment '(4)))))
    

    after this code in my .emacs file:

      '(progn
        (add-to-list 'load-path "~/Dropbox/Orgzly/org-drill/")
        (require 'org-drill)))
    

    For me this not help. Or I misunderstood what you need to do?

  12. Paul Sexton repo owner

    If more recent versions of Emacs do not exhibit this bug, then it seems like this must be a display bug in Emacs. Anyone suffering from it should try using a later version of Emacs.

  13. Log in to comment