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

Fix loading large non file-visiting buffers + simplification of the implementation #6

Merged
merged 4 commits into from
Jun 26, 2024

Conversation

abougouffa
Copy link
Contributor

@abougouffa abougouffa commented Jun 26, 2024

This PR fixes #5 and simplifies the implementation in these manners:

  1. There is no need to advice find-file-noselect, the file will be opened in all cases, and if we want to check for the /file size/ or for /too long lines/, we can do it inside the set-auto-mode-0 advice function (using the current buffer and the (buffer-file-name)).
  2. The current implementation can cause some extra overhead by opening the file to detect too long lines (why we open the file temporarily while we can check for long lines inside set-auto-mode-0's advice?)
  3. So, the guard-lf--line-too-long-p function has been modified to work on a buffer instead of a file (to avoid opening the file temporarily).

Edit

I think, by using the buffer-size to calculate the current buffer size, we don't even need to get the file size from the file system's attributes. At the set-auto-mode-0 level, the file would be already inserted in the current buffer, so we can relay on (buffer-size)!

Copy link
Member

@jcs090218 jcs090218 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense! Thank you!

@jcs090218 jcs090218 merged commit dcc3dd3 into jcs-elpa:master Jun 26, 2024
10 of 11 checks passed
@abougouffa
Copy link
Contributor Author

Thank you for your responsiveness! @jcs090218

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

Successfully merging this pull request may close these issues.

guard-lf fails to trigger in non file visiting buffers
2 participants