eschulte / epresent

Presentations in Emacs -- based on Org-mode
183 stars 51 forks source link

Make sure the presentation frame shows the intended buffer #64

Open kqr opened 5 years ago

kqr commented 5 years ago

I have an after-make-frame-functions hook that switches new frames to the scratch buffer, which broke epresent: it only ever showed an empty presentation!

My current workaround is to define advice around epresent--get-frame which gets the current buffer, calls epresent--get-frame, and then switches to the buffer, as such:

(define-advice epresent--get-frame
      (:around (actual-get-frame &rest args) epresent-frame-set-buffer)
    (let ((presentation-buffer (current-buffer)))
      (apply actual-get-frame args)
      (switch-to-buffer presentation-buffer)
      epresent--frame))

I realised, however, that epresent-run already gets the correct buffer – it just doesn't switch to it after creating the frame! So that's what this fix implements.

kqr commented 5 years ago

Separately, one of the reasons this was hard to debug was that the "EPresent can only be used from Org Mode" check happens /not/ just before presentation is about to start, but rather just after the command is invoked. This has the potential of hiding multiple errors, and better practise would be to have the precondition check as close as possible to the thing where the precondition actually applies.

That said, in this specific case, it would only guard against this particular error, I think, and that is why I have left the precondition where it is.