protesilaos / dired-preview

Automatically preview file at point in Emacs Dired.
GNU General Public License v3.0
57 stars 2 forks source link

Issue with `hexl-toggle` pdf files #16

Open iago-pssjd opened 1 month ago

iago-pssjd commented 1 month ago

FYI

https://gitlab.com/protesilaos/dired-preview/-/issues/1

Thanks!

protesilaos commented 1 month ago

From: iago-pssjd @.***> Date: Mon, 21 Oct 2024 07:05:21 -0700

FYI

https://gitlab.com/protesilaos/dired-preview/-/issues/1

Thanks!

Thank you! I will check there later and report back to you. It seems I did not receive a notification about it, which is strange...

-- Protesilaos Stavrou https://protesilaos.com

protesilaos commented 4 weeks ago

I am looking into this but I cannot tell what the problem is. I even used this function, which does not work:

(defun dired-preview-hexl-toggle ()
  "Toggle preview between text and `hexl-mode'."
  (interactive)
  (dired-preview-with-window
    (if (derived-mode-p 'hexl-mode)
        (cl-letf (((symbol-function 'yes-or-no-p) #'always)
                  ((symbol-function 'y-or-n-p) #'always))
          (hexl-mode-exit)
          (doc-view-mode))
      (hexl-mode)
      (dired-preview--add-truncation-message))))
protesilaos commented 4 weeks ago

I found what the issue is. In dired-preview--get-buffer we only insert part of the file, so we cannot toggle to a full buffer view. To do that, we need to kill the preview and then visit the large file. Maybe that is the way to go, though I am not sure this should be done with the current toggle.