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 byte-compilation warnings #74

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

d-torrance
Copy link
Member

We move up some defvar's, call declare-function on a function from another package, and remove the use of an obsolete variable to fix some warnings that were emitted when byte-compiling.

We also add a GitHub workflow to byte-compile pull requests.

@d-torrance
Copy link
Member Author

Huh, the workflow isn't running. Maybe it has to be on the main branch first?

It ran successfully when I tested it using on: push instead of on: pull_request: https://github.com/d-torrance/M2-emacs/actions/runs/10659953599/job/29543250635

@d-torrance d-torrance force-pushed the byte-compilation-warnings branch 2 times, most recently from 2e9f52e to 9af6000 Compare September 5, 2024 23:30
@d-torrance
Copy link
Member Author

I noticed a silly typo I made in the last regex in #73 after all of a sudden a bunch of my errors weren't highlighting. I pushed the fix to main and rebased this on top of it.

@mahrud
Copy link
Member

mahrud commented Sep 5, 2024

I'm a little unsure how to review this PR. Can you think of anyone else to ask?

@d-torrance
Copy link
Member Author

Maybe @DanGrayson? We're the only three folks with a halfway decent number of commits in this repository.

Anyways, here's a bit more explanation if that helps. I noticed that when I started up Emacs, I had a bunch of M2-related warnings. You can reproduce them on the command line from the current tip of the main branch:

$ emacs --batch -f batch-byte-compile M2*.el M2-symbols.el.gz
Loading /etc/emacs/site-start.d/00debian.el (source)...
Loading /etc/emacs/site-start.d/50auctex.el (source)...
Loading /usr/share/emacs/site-lisp/auctex.el (source)...
Loading /usr/share/emacs/site-lisp/preview-latex.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50boxes.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell (native compiled elisp)...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /etc/emacs/site-start.d/50emms.el (source)...
Loading /etc/emacs/site-start.d/50gcl.el (source)...
Loading /etc/emacs/site-start.d/50gtk-doc-tools.el (source)...
Loading /etc/emacs/site-start.d/50latexmk.el (source)...
Loading /etc/emacs/site-start.d/50lilypond-data.el (source)...
Loading /etc/emacs/site-start.d/50mu4e.el (source)...
Loading /etc/emacs/site-start.d/50recutils.el (source)...
recutils removed but not purged, skipping setup
Loading /etc/emacs/site-start.d/50tcsh.el (source)...

In M2-comint-mode:
M2.el:55:46: Warning: reference to free variable ‘M2-error-regexp-alist’
M2.el:57:15: Warning: reference to free variable ‘M2-transform-file-match-alist’
M2.el:129:7: Warning: assignment to free variable ‘M2-common-menu’
M2.el:156:4: Warning: reference to free variable ‘M2-common-menu’

In M2-set-demo-buffer:
M2.el:472:9: Warning: assignment to free variable ‘M2-demo-buffer’

In M2-switch-to-demo-buffer:
M2.el:477:21: Warning: reference to free variable ‘M2-demo-buffer’

In M2-get-input-from-demo-buffer:
M2.el:503:32: Warning: reference to free variable ‘M2-demo-buffer’

In end of data:
M2.el:537:4: Warning: the function ‘compilation-forget-errors’ is not known to be defined.
uncompressing M2-symbols.el.gz...
uncompressing M2-symbols.el.gz...done

In toplevel form:
M2-symbols.el.gz:10:8: Warning: ‘max-specpdl-size’ is an obsolete variable (as of 29.1).

The solutions for each of these issues:

  • The "free variable" warnings were coming from the fact that we weren't calling defvar on the variables before we were using them. (And for M2-common-menu, we weren't calling it at all!) Moving up the corresponding defvar statements (and adding one for M2-common-menu) fixes the warnings.
  • The "function ... not known to be defined" warning was because the byte compiler didn't know that compile will be loaded and compilation-forget-errors available at runtime. Adding declare-function let's it know that it's okay.
  • According to the documentation, max-specpdl-size doesn't do anything anymore, so we just remove it.

The workflow hopefully will run the above check on pull requests.

@mahrud
Copy link
Member

mahrud commented Oct 18, 2024

At this point, I'm a little worried that if we merge this now there won't be enough time to discover any potential bugs. Let's merge this after the release?

@d-torrance
Copy link
Member Author

What bugs might there be? The changes are all very minor -- basically just moving around some code and removing a call to a function that's been a noop for the last few Emacs releases.

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.

2 participants