Skip to content

Milestone 3: Breaking Refactor#96

Draft
mekeor wants to merge 50 commits intomasterfrom
milestone-03-breaking-refactor
Draft

Milestone 3: Breaking Refactor#96
mekeor wants to merge 50 commits intomasterfrom
milestone-03-breaking-refactor

Conversation

@mekeor
Copy link
Collaborator

@mekeor mekeor commented Dec 6, 2024

Changelog

Let's first set up the Changelog so that later commits can keep it updated.

  • Incorporate changelog into readme/manual.

Delete obsolete code

First of all, we delete code, so that we don't waste time fixing obsolete code.

Following files were already independently deleted by Yury on the master branch:

  • -debug
  • -dev

Features and other code:

  • Abbrev table
  • Tool-bar menu entry for Flycheck
  • Feature of whitespace cleanup before save
  • Feature of automatic version detection, and related code
  • Note that we do not delete lean4-input-export-translations and lean4-input-export-translations-to-stdout function definitions from -input file because it'd be a waste of time as later milestones/PRs will reimplement -input. See: Rework Abbreviations for Input Method #93.)

And, at least temporarily:

Separate concerns

We separate concerns, i.e. we move definitions of functions and variables as well as other code to those files where they belong, so that we don't keep stumbling upon our own feet but rather have a nice and tidy code base, in particular for later PRs.

Delete -settings file after moving following out of it:

  • Keybindings to -mode
  • Move -show-file-progress to -fringe
  • Move -highlight-inaccessible-names to -info
  • Move customization group and mode hook to -mode

Move following code out of -mode file:

  • Definition of -tab-indent to -eri
  • Input related code to -input
  • Addition to markdown-code-lang-modes to new -markdown
  • lsp-mode related code to new -lsp
  • Evaluate if moving Flycheck related code to new -flycheck makes sense. No, it doesn't.

Rename variables and functions such that they use the prefix of the file
where they are defined:

  • -lsp
  • -input
  • -eri
  • -info

Note that we do not rename -info file to -lsp-info, even though Lean4 Info currently only works for lsp-mode, as we hope that it might perhaps eventually also work with Eglot.

Minor mode lean4-info-mode

  • Define minor mode lean4-info-mode

Minor mode lean4-lsp-mode

We separate logic relating Lean4-Mode to lsp-mode into a new minor mode. This lays the ground for later PRs that'd provide alternative minor modes for using alternative LSP clients, like Eglot.

  • Define minor mode lean4-lsp-mode
  • Move all lsp-mode specific keybindings to lean4-lsp-mode-map

Refactor Lean4-Mode

  • Replace lean4-hooks-alist with entries in lean4-mode-hook
  • Replace lean4-mode-setup with entries in lean4-mode-hook
  • Tidy up lean4-mode definition by using setq-local and with entries in lean4-mode-hook

Globally consistent patterns

We consistently implement repository-wide code patterns and conventions. We do so near the end of the PR in order to reduce chances for merge conflicts when reordering commits within this PR's branch.

Consistently use Lean4 name across project:

  • In description in first line of Emacs-Lisp files (prop-line)
  • In docstrings
  • As symbol of customization group
  • As name of input method, if existent

Other:

  • Style of URLs in code comments
  • Order of require (1. built-ins, 2. third-party, 3. local)
  • Style of copyright statement
  • Capitalization of "This file is NOT part of GNU Emacs"

Improve documentation and formalia

  • Improve phrasing of code comments
  • Improve Emacs-Lisp file commentary sections
  • Reformat Package-Requires library header. Won't do this because of incompatibility with Melpazoid.
  • Fix errors reported by Melpazoid

In readme/manual:

@mekeor mekeor force-pushed the milestone-03-breaking-refactor branch 4 times, most recently from a8916aa to 1754b21 Compare December 12, 2024 21:35
@mekeor mekeor force-pushed the milestone-03-breaking-refactor branch 3 times, most recently from cbd02ea to 1305317 Compare January 15, 2025 23:28
@mekeor mekeor force-pushed the milestone-03-breaking-refactor branch 2 times, most recently from 465952c to 586c29d Compare April 25, 2025 23:15
@mekeor mekeor mentioned this pull request May 5, 2025
@mekeor mekeor force-pushed the milestone-03-breaking-refactor branch from 586c29d to d6770bd Compare May 13, 2025 15:46
@mekeor mekeor closed this May 13, 2025
@mekeor mekeor force-pushed the milestone-03-breaking-refactor branch from d6770bd to 76895d8 Compare May 13, 2025 15:46
@mekeor mekeor reopened this May 13, 2025
@mekeor mekeor force-pushed the milestone-03-breaking-refactor branch 2 times, most recently from d97cd65 to 93b92cd Compare May 13, 2025 17:23
@mekeor mekeor force-pushed the milestone-03-breaking-refactor branch 6 times, most recently from ed6adac to d5cfe10 Compare May 25, 2025 23:21
@mekeor mekeor force-pushed the milestone-03-breaking-refactor branch 8 times, most recently from 7876af5 to f79c6a2 Compare June 6, 2025 23:52
mekeor added 29 commits July 15, 2025 00:12
- Delete lean4-info-toggle.
- In lean4-mode-map, bind C-c C-i to lean4-info-mode instead.
- Adapt readme and manuals.
- Move lean4-hooks-alist from lean4-mode.el to lean4-info-hookings and
  deal with it in lean4-info-mode.
The lean4-mode-setup function was almost empty.  The only thing it was
doing is to set flycheck-disabled-checkers to nil buffer-locally.  But
after testing, this setting is the default / initial value already and
thus not needed.
Even if compilation-mode-font-lock-keywords should be nil when
`compile` is called from Lean4-Mode due to the way Lake's or Lean's
build log looks, this doesn't justify globally setting
compilation-mode-font-lock-keywords to nil because this screws up
`compile` for the Emacs session permanently.
1. Built-ins
2. Third-party (any Elpa)
3. Local (lean4-*)
Citing Wikipedia <https://en.wikipedia.org/wiki/All_rights_reserved>:

    “The requirement to add the "all rights reserved" notice became
    essentially obsolete on August 23, 2000, when Nicaragua became the
    final member of the Buenos Aires Convention to also become a
    signatory to the Berne Convention. As of that date, every country
    that was a member of the Buenos Aires Convention (which is the
    only copyright treaty requiring this notice to be used) was also a
    member of Berne, which requires protection be granted without any
    formality of notice of copyright.”
- Rephrase some comments

- Reduce multiple consecutive blank lines to single blank lines

- Avoid exceeding fill-column with comments

- Use `;;;;* ` prefix for outline/heading comments (for code
  navigation)
- Fixes issue #101 “Document the pitfall of modifying lean4-mode-hook
  before Lean4-Mode has been loaded”.
@mekeor mekeor force-pushed the milestone-03-breaking-refactor branch from c68cd95 to cca95cb Compare July 14, 2025 22:18
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.

1 participant