radian-software / radian

🍉 Dotfiles that marry elegance and practicality.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

define-minor-mode radian-fix-whitespace-mode uses keywords in Emacs 28.0.5

analyticd opened this issue · comments

This could be premature for most people since it relates to Emacs 28.0.5, but define-minor-mode does not use positional arguments anymore and generates a warning.

I think the fix would be:

(define-minor-mode radian-fix-whitespace-mode
  "Minor mode to automatically fix whitespace on save.
If enabled, then saving the buffer deletes all trailing
whitespace and ensures that the file ends with exactly one
newline."
  :init-value nil
  :lighter nil
  :keymap nil
  :after-hook
  (if radian-fix-whitespace-mode
      (progn
        (setq require-final-newline t)
        (add-hook 'before-save-hook #'delete-trailing-whitespace nil 'local))
    (setq require-final-newline nil)
    (remove-hook 'before-save-hook #'delete-trailing-whitespace 'local)))

and

(define-minor-mode radian-highlight-long-lines-mode
    "Minor mode for highlighting long lines."
    :init-value nil
    :lighter nil
    :keymap nil
    :after-hook
    (if radian-highlight-long-lines-mode
        (progn
          (setq-local whitespace-style '(face lines-tail))
          (setq-local whitespace-line-column 79)
          (whitespace-mode +1))
      (whitespace-mode -1)
      (kill-local-variable 'whitespace-style)
      (kill-local-variable 'whitespace-line-column)))

after that the warnings go away.

Great, thanks for the heads-up! We don't actually need to explicitly set those to nil I think, the main thing is we have to include :after-hook to prevent the body from being interpreted as a positional argument in Emacs <28.