Issues with screenshoting long buffers #7

Open
opened 2021-04-11 20:23:21 +00:00 by zackteo · 10 comments
zackteo commented 2021-04-11 20:23:21 +00:00 (Migrated from github.com)

When I screenshot org-mode buffers, it will cut off content after a certain length like so ...
image
My current workaround is quite silly, I will keep repeating the content until the screenshot expands to fit more content and crop out the rest. Example of screenshot size expanding ...
image

When I screenshot `org-mode` buffers, it will cut off content after a certain length like so ... ![image](https://user-images.githubusercontent.com/7510179/114320009-7f424e80-9b46-11eb-8dc6-7533f824e025.png) My current workaround is quite silly, I will keep repeating the content until the screenshot expands to fit more content and crop out the rest. Example of screenshot size expanding ... ![image](https://user-images.githubusercontent.com/7510179/114320055-c3355380-9b46-11eb-9642-38839ac1fee4.png)
Jake-Moss commented 2021-08-27 02:05:53 +00:00 (Migrated from github.com)

I have also been running into this for a while but been unable to consistently reproduce until now, it occurs when the Maximum width is too small and lines wrap

Screenshot with Maximum width set to the default 120
image
Screenshot with Maximum width set to 400
image

Could this be happening in org buffers when the width of the plain text exceeds the maximum but the displayed doesn't?

I have also been running into this for a while but been unable to consistently reproduce until now, it occurs when the `Maximum width` is too small and lines wrap Screenshot with `Maximum width` set to the default `120` ![image](https://user-images.githubusercontent.com/49361082/131060075-f78b1917-b593-4c2f-9b81-1c6ef0517f25.png) Screenshot with `Maximum width` set to `400` ![image](https://user-images.githubusercontent.com/49361082/131060202-891f8ea5-8ed9-4d1e-b64e-e140d577f6d2.png) Could this be happening in org buffers when the width of the plain text exceeds the maximum but the displayed doesn't?
tecosaur commented 2021-09-09 14:05:43 +00:00 (Migrated from github.com)

Mmm, there's a known issue where line wrapping isn't accounted for — not because I don't care about line wrapping, I just don't know how to determine how many lines are wrapped. If anyone has an idea, I'd love to hear.

Mmm, there's a known issue where line wrapping isn't accounted for — not because I don't care about line wrapping, I just don't know how to determine how many lines are wrapped. If anyone has an idea, I'd love to hear.
tecosaur commented 2022-10-18 02:39:34 +00:00 (Migrated from github.com)

Line wrapping is now accounted for as of dac727e98e. There's a different issue with the posframe maximum height, but that can be another issue if anybody wants to raise it.

Line wrapping is now accounted for as of dac727e98eba67cd553300a704ab4a66e20db733. There's a different issue with the posframe maximum height, but that can be another issue if anybody wants to raise it.
Jake-Moss commented 2022-10-18 09:59:50 +00:00 (Migrated from github.com)

In my testing for #10 I've run into some issues with short screenshots, and just in general

;; Install use-package
(straight-use-package 'use-package)

(setq straight-use-package-by-default t)

  • 1line
    image
;; Install use-package
  • 2 lines
    image
;; Install use-package
(straight-use-package 'use-package)
  • 3 lines
    image
;; Install use-package
(straight-use-package 'use-package)
<< pretend this is empty, github truncates the code block >>
  • 4 lines
    image
;; Install use-package
(straight-use-package 'use-package)

(setq straight-use-package-by-default t)
  • 5 lines
    image
;; Install use-package
(straight-use-package 'use-package)

(setq straight-use-package-by-default t)
<< pretend this is empty, github truncates the code block >>

In addition also seems to be truncating the whole buffer (even with -W set to 120 to avoid line wrapping, it still wraps)
image

;;; init.el --- Description -*- lexical-binding: t; -*-

;; Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;; Install use-package
(straight-use-package 'use-package)

(setq straight-use-package-by-default t)

(use-package lsp-mode
  :init
  ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
  (setq lsp-keymap-prefix "C-c l")
  :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
         (c-mode . lsp))
  :config
  (eval-after-load 'lsp-clangd
   '(add-to-list 'lsp-clients-clangd-args "--log=verbose"))
  :commands lsp)

(use-package screenshot
  :straight (:host github :repo "tecosaur/screenshot" :build (:not compile)))

(setq lsp-log-io t)

In my testing for #10 I've run into some issues with short screenshots, and just in general ```lisp ;; Install use-package (straight-use-package 'use-package) (setq straight-use-package-by-default t) ``` - 1line ![image](https://user-images.githubusercontent.com/49361082/196397686-918f27f2-608e-4eef-9758-66fdf24b4978.png) ```lisp ;; Install use-package ``` - 2 lines ![image](https://user-images.githubusercontent.com/49361082/196397753-c578639b-ee50-431d-95aa-3d9c86c56b12.png) ```lisp ;; Install use-package (straight-use-package 'use-package) ``` - 3 lines ![image](https://user-images.githubusercontent.com/49361082/196397876-1fa02fbf-7638-4956-a816-d5e4498d8bd8.png) ```lisp ;; Install use-package (straight-use-package 'use-package) << pretend this is empty, github truncates the code block >> ``` - 4 lines ![image](https://user-images.githubusercontent.com/49361082/196397845-7aabb68c-0ba1-4e09-9a86-7ce2a6addb77.png) ```lisp ;; Install use-package (straight-use-package 'use-package) (setq straight-use-package-by-default t) ``` - 5 lines ![image](https://user-images.githubusercontent.com/49361082/196398106-a3fe48b0-b05c-41e0-a326-a36259eaa114.png) ```lisp ;; Install use-package (straight-use-package 'use-package) (setq straight-use-package-by-default t) << pretend this is empty, github truncates the code block >> ``` In addition also seems to be truncating the whole buffer (even with `-W` set to 120 to avoid line wrapping, it still wraps) ![image](https://user-images.githubusercontent.com/49361082/196399290-828c3c19-21e6-4295-ae67-55a0435abf0b.png) ```lisp ;;; init.el --- Description -*- lexical-binding: t; -*- ;; Bootstrap straight (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) ;; Install use-package (straight-use-package 'use-package) (setq straight-use-package-by-default t) (use-package lsp-mode :init ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l") (setq lsp-keymap-prefix "C-c l") :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode) (c-mode . lsp)) :config (eval-after-load 'lsp-clangd '(add-to-list 'lsp-clients-clangd-args "--log=verbose")) :commands lsp) (use-package screenshot :straight (:host github :repo "tecosaur/screenshot" :build (:not compile))) (setq lsp-log-io t) ```
tecosaur commented 2022-10-18 10:13:53 +00:00 (Migrated from github.com)

Thanks for those samples. I'll see if that matches what I see.


  • one line

image

  • two lines

image

  • four lines

image

  • long lines

image

  • long lines with wrapping

image


Seems like the line wrapping was slightly under-counted in the last example, but other than that it seems fine my end 🤔.

With the blank line examples, it's worth notice I've recently made trailing whitespace trimming more aggressive.

Thanks for those samples. I'll see if that matches what I see. ----- - one line ![image](https://user-images.githubusercontent.com/20903656/196401972-32d92374-2472-42de-a6d9-ba0b0f518716.png) - two lines ![image](https://user-images.githubusercontent.com/20903656/196402054-7133337c-e701-40b6-aea6-4227ce244698.png) - four lines ![image](https://user-images.githubusercontent.com/20903656/196402189-752e3a6e-a42f-4765-9dfd-c6c4868a7307.png) - long lines ![image](https://user-images.githubusercontent.com/20903656/196402411-34b74e64-a7bd-49f6-b811-39fd021ec3f1.png) - long lines with wrapping ![image](https://user-images.githubusercontent.com/20903656/196402620-ffd7889f-7738-44ef-a2f1-c5d9f66c7d1a.png) ----- Seems like the line wrapping was slightly under-counted in the last example, but other than that it seems fine my end :thinking:. With the blank line examples, it's worth notice I've recently made trailing whitespace trimming more aggressive.
Jake-Moss commented 2022-10-18 10:30:08 +00:00 (Migrated from github.com)

Interesting, with no blank lines I'm able to get this results (No. lines 1 -5) using

;; Install use-package
(straight-use-package 'use-package)
;; Another comment
(setq straight-use-package-by-default t)
;; Some more text

image
image
image
image
image

All taken using these settings,
image

Would it be system related?
I'm running Fedora release 36 with Gnome 42.4 and X11.
I've moved over to a vanilla config to hopefully make it reproducible for you.

Interesting, with no blank lines I'm able to get this results (No. lines 1 -5) using ```lisp ;; Install use-package (straight-use-package 'use-package) ;; Another comment (setq straight-use-package-by-default t) ;; Some more text ``` ![image](https://user-images.githubusercontent.com/49361082/196405824-2978f601-4325-4e86-8e4a-3c596b08a93e.png) ![image](https://user-images.githubusercontent.com/49361082/196405931-6cc360a5-c8f9-4536-b957-6d11e0b01752.png) ![image](https://user-images.githubusercontent.com/49361082/196405981-0cd5e6ec-78b5-4593-a783-e815f2127d7c.png) ![image](https://user-images.githubusercontent.com/49361082/196406052-29212fed-dab1-42f9-adf8-dc6ad6687266.png) ![image](https://user-images.githubusercontent.com/49361082/196406084-f4d107d2-ae65-49c9-b3a8-cb62bc432442.png) All taken using these settings, ![image](https://user-images.githubusercontent.com/49361082/196405680-9b03639d-e5ae-440d-b168-0031df06b143.png) Would it be system related? I'm running Fedora release 36 with Gnome 42.4 and X11. I've moved over to a vanilla config to hopefully make it reproducible for you.
tecosaur commented 2023-01-18 16:45:12 +00:00 (Migrated from github.com)

The cause of this issue was not obvious to me, so it's been slightly forgotten about, but thanks for the vanilla example. If/when I do finally get to this, I expect that to be a big help.

The cause of this issue was not obvious to me, so it's been slightly forgotten about, but thanks for the vanilla example. If/when I do finally get to this, I expect that to be a big help.
tecosaur commented 2023-01-20 11:39:50 +00:00 (Migrated from github.com)

@Jake-Moss in the recent batch of development I've done (a whole bunch of improvements 🎉) I may have run into what's causing this. Can you try tweaking the font size and seeing if there's a certain size where the sizing "matches"? It seems the posframe size is calculated based on the size of the active window at the time, not the font size of the buffer about to be shown.

;; Within (defun posframe-show ...)
(font-height (with-current-buffer (window-buffer parent-window)
               (posframe--get-font-height position)))

There's also the issue of the posframe not being able to be generated as larger than the display, which it used to be able to do.

Since these issues are both posframe related, @tumashu might you be able to give any advice here?

@Jake-Moss in the recent batch of development I've done (a whole bunch of improvements :tada:) I may have run into what's causing this. Can you try tweaking the font size and seeing if there's a certain size where the sizing "matches"? It seems the posframe size is calculated based on the size of the active window at the time, not the font size of the buffer about to be shown. ```lisp ;; Within (defun posframe-show ...) (font-height (with-current-buffer (window-buffer parent-window) (posframe--get-font-height position))) ``` There's also the issue of the posframe not being able to be generated as larger than the display, which it used to be able to do. Since these issues are both posframe related, @tumashu might you be able to give any advice here?
Jake-Moss commented 2023-01-22 12:30:20 +00:00 (Migrated from github.com)

Thanks for your work on this, I've done a bit of testing and you were bang on that there was a good font size that worked.
For me 9 works (sometimes). Unfortunately I've found it also seems to be dependent on the size of my current emacs frame, though that may be related to the "larger than display" issue you mentioned as making the frame larger doesn't effect the output.

I've got a series of screenshots below using this buffer

;;; init.el --- Description -*- lexical-binding: t; -*-

;; Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;; Install use-package
(straight-use-package 'use-package)
;; Another comment
(setq straight-use-package-by-default t)
;; Some more text

(use-package lsp-mode
  :init
  ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
  (setq lsp-keymap-prefix "C-c l")
  :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
         (c-mode . lsp))
  :config
  (eval-after-load 'lsp-clangd
   '(add-to-list 'lsp-clients-clangd-args "--log=verbose"))
  :commands lsp)

(use-package screenshot
  :straight (:host github :repo "tecosaur/screenshot" :build (:not compile)))

(setq lsp-log-io t)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(screenshot-font-size 9))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

  • Maximised (title bar still visible), 14 (default font size)
    image

  • Full screen gnome bar and title bar not visible, 14 (default font size)
    image

  • Not maximised width, but maximised height, 14
    image

  • smaller window, 14
    image

  • maximised, title bar and gnome bar visible, 9
    image

  • full screen, 9
    image

  • full height, 9
    image

  • smaller window, 9
    image

Interestingly I couldn't see a difference between maximised and fullscreen.

Thanks for your work on this, I've done a bit of testing and you were bang on that there was a good font size that worked. For me 9 works (sometimes). Unfortunately I've found it also seems to be dependent on the size of my current emacs frame, though that may be related to the "larger than display" issue you mentioned as making the frame larger doesn't effect the output. I've got a series of screenshots below using this buffer ```lisp ;;; init.el --- Description -*- lexical-binding: t; -*- ;; Bootstrap straight (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) ;; Install use-package (straight-use-package 'use-package) ;; Another comment (setq straight-use-package-by-default t) ;; Some more text (use-package lsp-mode :init ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l") (setq lsp-keymap-prefix "C-c l") :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode) (c-mode . lsp)) :config (eval-after-load 'lsp-clangd '(add-to-list 'lsp-clients-clangd-args "--log=verbose")) :commands lsp) (use-package screenshot :straight (:host github :repo "tecosaur/screenshot" :build (:not compile))) (setq lsp-log-io t) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(screenshot-font-size 9)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) ``` - Maximised (title bar still visible), 14 (default font size) ![image](https://user-images.githubusercontent.com/49361082/213915702-2612be22-1b59-414d-b280-d0e265acca91.png) - Full screen gnome bar and title bar not visible, 14 (default font size) ![image](https://user-images.githubusercontent.com/49361082/213915711-4062202a-be40-4f86-bca5-9c0d8a342050.png) - Not maximised width, but maximised height, 14 ![image](https://user-images.githubusercontent.com/49361082/213915729-47f4b940-a282-4f06-bfcc-3174338de685.png) - smaller window, 14 ![image](https://user-images.githubusercontent.com/49361082/213915732-f6c54f28-75d6-451b-8e92-755d4847d678.png) - maximised, title bar and gnome bar visible, 9 ![image](https://user-images.githubusercontent.com/49361082/213915736-b5c7423d-4692-451b-a5e8-0ecc800a31d8.png) - full screen, 9 ![image](https://user-images.githubusercontent.com/49361082/213915744-91590312-77c3-49bc-bf3c-e227c1511a38.png) - full height, 9 ![image](https://user-images.githubusercontent.com/49361082/213915746-a693717e-ef3c-4ac6-ad66-5cce6b1877b2.png) - smaller window, 9 ![image](https://user-images.githubusercontent.com/49361082/213915751-09293764-498d-4616-ba4e-03e1fdef68d8.png) Interestingly I couldn't see a difference between maximised and fullscreen.
Jake-Moss commented 2023-01-22 13:18:12 +00:00 (Migrated from github.com)

As a side note, changing the font size to 9 has actually fixed this on my wayland + pgtk build. Previously if the font was too large the screenshot would only contain the background.
image

As a side note, changing the font size to 9 has actually fixed this on my wayland + pgtk build. Previously if the font was too large the screenshot would only contain the background. ![image](https://user-images.githubusercontent.com/49361082/213917843-c6b20ce9-87b9-496c-b421-21cc0a852e8e.png)
Sign in to join this conversation.
No description provided.