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

subed recenters on save, breaking scroll-all-mode #35

Open
mooseyboots opened this issue May 12, 2021 · 3 comments
Open

subed recenters on save, breaking scroll-all-mode #35

mooseyboots opened this issue May 12, 2021 · 3 comments

Comments

@mooseyboots
Copy link

mooseyboots commented May 12, 2021

first, thx for your great package, it's nifty as.

so subed recenters, or rather scrolls so that point is 4/5 down the frame, on save. i guess in its sanitizing of things.

i didn't mind it all that much until i started using scroll-all-mode, which allows you to synchronize the scrolling of two windows. using it with subed, you can align the scrolling of two subtitles files, for translating. but when i save my srt file, only one of the windows gets recentered, putting the synchronized scroll out of sync.

it's not a killer issue, but perhaps it's also simple to avoid?

update: hm maybe scroll-all-mode is just too bare bones, as it really ought to work with recenter, which emacs calls the "basic scrolling command"(!). perhaps some subed users have an alternative approach for synchronized scrolling?

i guess scroll-syncing the subtitles by their numbers would be a colossal effort? that would be killer, but i'm not sure how it could be done.

@rndusr
Copy link
Collaborator

rndusr commented May 13, 2021 via email

@mooseyboots
Copy link
Author

thanks for taking a look. unfortunately i'm more subtitler than programmer. my emacs debugging mostly amounts to enabling edebug-defun and hitting space bar and looking on.

seems like its in subed-srt--sort, but not the santitize or validate functions it runs, or in subed-save-excursion. the latter i struggled to take a look at w my beginner's skills. if i swapped it out for a vanilla save-excursion, point would be at beginning of buffer after save.

thanks anyway, and again for the package.

@mooseyboots
Copy link
Author

mooseyboots commented Jun 8, 2021

a workaround to run recenter-top-bottom after saving, only when in subed mode:

(setq-default subed-save-buffer-advice nil)

(add-hook 'subed-mode-hook (lambda () (setq-local subed-save-buffer-advice t)))

(defadvice save-buffer (after recenter activate)
  (when (equal subed-save-buffer-advice t)
    (recenter-top-bottom)))

sachac added a commit that referenced this issue Feb 7, 2022
This should reduce the disruption to things like the mark
ring. (Related to #57 and #55, and might address #35 as well?)

* subed/subed-common.el (sanitize): Separate the sanitize and
  sanitize-format functions.
  (sanitize-format): New generic function.
  (validate): Separate the validate and validate-format functions.
  (validate-format): New generic function.
  (regenerate-ids): Have generic implementation.
  (subed-sanitize-functions): Move to subed-config.el.
  (subed-validate-functions): Move to subed-config.el.
  (subed-prepare-to-save): Call subed-sanitize and subed-validate.
  (subed--sorted-p): New function to test if the subtitles are sorted.
  (sort): Make interactive. Sort only if unsorted, which should
  minimize interference with flycheck and the mark ring.
* subed/subed-config.el (subed-sanitize-functions): New customizable
  variable.
  (subed-validate-functions): New customizable variable.
* subed/subed-srt.el (subed--sanitize-format): Define this instead of
  subed--sanitize.
  (subed--validate-format): Define this instead of subed--validate.
* subed/subed-vtt.el (subed--sanitize-format): Define this instead of
  subed--sanitize.
  (subed--validate-format): Define this instead of subed--validate.
  (subed--sort): Remove format-specific implementation.
* tests/test-subed-common.el ("Trimming subtitles when configured to
  check on save reports overlaps."): Specify options.
  ("Sorting"): Add test cases.
* tests/test-subed-vtt.el ("Sorting preserves point in the current
  subtitle when subtitle text is empty."): Tweak position check.
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