Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on preview if eww-auto-rename-buffer is t #737

Closed
zealotrush opened this issue Dec 8, 2022 · 6 comments
Closed

Error on preview if eww-auto-rename-buffer is t #737

zealotrush opened this issue Dec 8, 2022 · 6 comments

Comments

@zealotrush
Copy link

Expected Behavior

  1. Set eww-auto-rename-buffer to t.
  2. Run markdown-live-preview-mode in a markdown buffer.

After that, a live preview of the markdown buffer should be displayed in a new window.

Actual Behavior

The live preview window does not appear. Following error is echoed.

markdown-live-preview-mode: Wrong type argument: stringp, nil

Steps to Reproduce

  1. emacs -Q --load path/to/markdown-mode.el test-case.md
  2. Evaluate: (customize-set-variable 'eww-auto-rename-buffer t)
  3. In the markdown buffer, M-x, markdown-live-preview-mode

Backtrace

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  set-buffer(nil)
  (save-current-buffer (set-buffer output-buffer) (setq markdown-live-preview-source-buffer cur-buf) (add-hook 'kill-buffer-hook #'markdown-live-preview-remove-on-kill t t))
  (let ((output-buffer (funcall markdown-live-preview-window-function export-file))) (save-current-buffer (set-buffer output-buffer) (setq markdown-live-preview-source-buffer cur-buf) (add-hook 'kill-buffer-hook #'markdown-live-preview-remove-on-kill t t)) (save-current-buffer (set-buffer cur-buf) (setq markdown-live-preview-buffer output-buffer)))
  (progn (let ((output-buffer (funcall markdown-live-preview-window-function export-file))) (save-current-buffer (set-buffer output-buffer) (setq markdown-live-preview-source-buffer cur-buf) (add-hook 'kill-buffer-hook #'markdown-live-preview-remove-on-kill t t)) (save-current-buffer (set-buffer cur-buf) (setq markdown-live-preview-buffer output-buffer))))
  (unwind-protect (progn (let ((output-buffer (funcall markdown-live-preview-window-function export-file))) (save-current-buffer (set-buffer output-buffer) (setq markdown-live-preview-source-buffer cur-buf) (add-hook 'kill-buffer-hook #'markdown-live-preview-remove-on-kill t t)) (save-current-buffer (set-buffer cur-buf) (setq markdown-live-preview-buffer output-buffer)))) (set-window-configuration wconfig))
  (let ((wconfig (current-window-configuration))) (unwind-protect (progn (let ((output-buffer (funcall markdown-live-preview-window-function export-file))) (save-current-buffer (set-buffer output-buffer) (setq markdown-live-preview-source-buffer cur-buf) (add-hook 'kill-buffer-hook #'markdown-live-preview-remove-on-kill t t)) (save-current-buffer (set-buffer cur-buf) (setq markdown-live-preview-buffer output-buffer)))) (set-window-configuration wconfig)))
  (let* ((markdown-live-preview-currently-exporting t) (cur-buf (current-buffer)) (export-file (markdown-export filename)) (window-data (markdown-live-preview-window-serialize markdown-live-preview-buffer))) (let ((wconfig (current-window-configuration))) (unwind-protect (progn (let ((output-buffer (funcall markdown-live-preview-window-function export-file))) (save-current-buffer (set-buffer output-buffer) (setq markdown-live-preview-source-buffer cur-buf) (add-hook 'kill-buffer-hook #'markdown-live-preview-remove-on-kill t t)) (save-current-buffer (set-buffer cur-buf) (setq markdown-live-preview-buffer output-buffer)))) (set-window-configuration wconfig))) (save-current-buffer (set-buffer cur-buf) (mapc #'markdown-live-preview-window-deserialize window-data) (let ((buf (get-file-buffer export-file))) (if buf (progn (kill-buffer buf)))) (if (and export-file (file-exists-p export-file) (eq markdown-live-preview-delete-export 'delete-on-export)) (progn (delete-file export-file))) markdown-live-preview-buffer))
  (progn (let* ((markdown-live-preview-currently-exporting t) (cur-buf (current-buffer)) (export-file (markdown-export filename)) (window-data (markdown-live-preview-window-serialize markdown-live-preview-buffer))) (let ((wconfig (current-window-configuration))) (unwind-protect (progn (let ((output-buffer ...)) (save-current-buffer (set-buffer output-buffer) (setq markdown-live-preview-source-buffer cur-buf) (add-hook ... ... t t)) (save-current-buffer (set-buffer cur-buf) (setq markdown-live-preview-buffer output-buffer)))) (set-window-configuration wconfig))) (save-current-buffer (set-buffer cur-buf) (mapc #'markdown-live-preview-window-deserialize window-data) (let ((buf (get-file-buffer export-file))) (if buf (progn (kill-buffer buf)))) (if (and export-file (file-exists-p export-file) (eq markdown-live-preview-delete-export 'delete-on-export)) (progn (delete-file export-file))) markdown-live-preview-buffer)))
  (if filename (progn (let* ((markdown-live-preview-currently-exporting t) (cur-buf (current-buffer)) (export-file (markdown-export filename)) (window-data (markdown-live-preview-window-serialize markdown-live-preview-buffer))) (let ((wconfig (current-window-configuration))) (unwind-protect (progn (let (...) (save-current-buffer ... ... ...) (save-current-buffer ... ...))) (set-window-configuration wconfig))) (save-current-buffer (set-buffer cur-buf) (mapc #'markdown-live-preview-window-deserialize window-data) (let ((buf (get-file-buffer export-file))) (if buf (progn (kill-buffer buf)))) (if (and export-file (file-exists-p export-file) (eq markdown-live-preview-delete-export 'delete-on-export)) (progn (delete-file export-file))) markdown-live-preview-buffer))))
  (let ((filename (markdown-live-preview-get-filename))) (if filename (progn (let* ((markdown-live-preview-currently-exporting t) (cur-buf (current-buffer)) (export-file (markdown-export filename)) (window-data (markdown-live-preview-window-serialize markdown-live-preview-buffer))) (let ((wconfig (current-window-configuration))) (unwind-protect (progn (let ... ... ...)) (set-window-configuration wconfig))) (save-current-buffer (set-buffer cur-buf) (mapc #'markdown-live-preview-window-deserialize window-data) (let ((buf ...)) (if buf (progn ...))) (if (and export-file (file-exists-p export-file) (eq markdown-live-preview-delete-export ...)) (progn (delete-file export-file))) markdown-live-preview-buffer)))))
  markdown-live-preview-export()
  (markdown-display-buffer-other-window (markdown-live-preview-export))
  (if (markdown-live-preview-get-filename) (markdown-display-buffer-other-window (markdown-live-preview-export)) (markdown-live-preview-mode -1) (user-error "Buffer %s does not visit a file" (current-buffer)))
  (if markdown-live-preview-mode (if (markdown-live-preview-get-filename) (markdown-display-buffer-other-window (markdown-live-preview-export)) (markdown-live-preview-mode -1) (user-error "Buffer %s does not visit a file" (current-buffer))) (markdown-live-preview-remove))
  (let ((last-message (current-message))) (setq markdown-live-preview-mode (cond ((eq arg 'toggle) (not markdown-live-preview-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))) (if (boundp 'local-minor-modes) (progn (setq local-minor-modes (delq 'markdown-live-preview-mode local-minor-modes)) (if markdown-live-preview-mode (progn (setq local-minor-modes (cons 'markdown-live-preview-mode local-minor-modes)))))) (if markdown-live-preview-mode (if (markdown-live-preview-get-filename) (markdown-display-buffer-other-window (markdown-live-preview-export)) (markdown-live-preview-mode -1) (user-error "Buffer %s does not visit a file" (current-buffer))) (markdown-live-preview-remove)) (run-hooks 'markdown-live-preview-mode-hook (if markdown-live-preview-mode 'markdown-live-preview-mode-on-hook 'markdown-live-preview-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "Markdown-Live-Preview mode %sabled%s" (if markdown-live-preview-mode "en" "dis") local))))))
  markdown-live-preview-mode(toggle)
  funcall-interactively(markdown-live-preview-mode toggle)
  command-execute(markdown-live-preview-mode)

Software Versions

  • Markdown Mode: markdown-mode, version 2.6-alpha
  • Emacs: GNU Emacs 30.0.50 (build 1, aarch64-apple-darwin22.1.0, NS appkit-2299.00 Version 13.0.1 (Build 22A400)) of 2022-12-05
  • OS: macOS Ventura
@zealotrush zealotrush changed the title Error if eww-auto-rename-buffer is t Error on preview if eww-auto-rename-buffer is t Dec 8, 2022
@syohex
Copy link
Collaborator

syohex commented Dec 9, 2022

@zealotrush How about #738 ?

BTW t is not valid value of eww-auto-rename-buffer. It accepts 'title, 'url or function. (However the implementation treats all non-nil values as well as 'title except `'url and function)

https://github.com/emacs-mirror/emacs/blob/abbb0faceaedea5369eba68c43e0b19dc861810f/lisp/net/eww.el#L182-L208

@zealotrush
Copy link
Author

How about #738 ?

It fixes the error. But the EWW preview buffer does not update automatically. I have to do a manual eww-reload (g) to update the preview.

BTW t is not valid value of eww-auto-rename-buffer. It accepts 'title, 'url or function. (However the implementation treats all non-nil values as well as 'title except `'url and function)

Yes, you are right. Thanks for the reminder!

@syohex
Copy link
Collaborator

syohex commented Dec 9, 2022

But the EWW preview buffer does not update automatically. I have to do a manual eww-reload (g) to update the preview.

Ah, if eww-auto-rename-buffer is non-nil, then eww creates new buffer every buffer updating. I'll tackle the issue this weekend.

@syohex
Copy link
Collaborator

syohex commented Dec 9, 2022

@zealotrush I've updated eb3f3be. Please try it again.

@zealotrush
Copy link
Author

I've updated eb3f3be. Please try it again.

Now it's completely fixed. Thanks!

@syohex
Copy link
Collaborator

syohex commented Dec 10, 2022

Thanks for testing.

@syohex syohex closed this as completed Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants