From 0d68ebb4014d602342491cdf9f9562beea076caf Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 6 Jul 2024 17:36:30 +0200 Subject: [PATCH] checkdoc: Relax footer line check for recent Emacs * lisp/emacs-lisp/checkdoc.el (checkdoc-file-comments-engine): Don't require a footer line unless 'lm-package-needs-footer-line' returns true. (cherry picked from commit d826240fa56230ef1561d5b4807284ce98a8c6b6) --- etc/NEWS | 20 +++++++++++++++++++ lisp/emacs-lisp/checkdoc.el | 39 +++++++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 3d2b86cfb6a..ba58fa7b319 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -70,6 +70,26 @@ Advanced" node in the EWW manual. By customizing 'shr-image-zoom-levels', you can change the list of zoom levels that SHR cycles through when calling 'shr-zoom-image'. +** Emacs Lisp mode + +--- +*** Checkdoc no longer warns about missing footer lines in some cases. +Emacs Lisp libraries have traditionally ended with a footer line +(sometimes referred to as "terminating comment"). Their purpose was to +easily detect files that had been truncated in transit on ancient and +less reliable connections: + + ;; some-cool-package.el ends here + +'checkdoc' will no longer warn if that line is missing for packages that +explicitly only support Emacs 30.1 or later, as specified in the +"Package-Requires" header. The reason for keeping the warning for +packages that support earlier versions of Emacs is that package.el in +those versions can't install packages where that line is missing. + +This change affects both 'M-x checkdoc' and the corresponding flymake +backend. + * New Modes and Packages in Emacs 31.1 diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index b0c812f9533..bdb4896a6d1 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -2516,21 +2516,30 @@ Code:, and others referenced in the style guide." ;; * Library footer (save-excursion (goto-char (point-max)) - (if (not (re-search-backward - ;; This should match the requirement in - ;; `package-buffer-info'. - (concat "^;;; " (regexp-quote (concat fn fe)) " ends here") - nil t)) - (if (checkdoc-y-or-n-p "No identifiable footer! Add one?") - (progn - (goto-char (point-max)) - (insert "\n(provide '" fn ")\n\n;;; " fn fe " ends here\n")) - (checkdoc-create-error - (format "The footer should be: (provide '%s)\\n;;; %s%s ends here" - fn fn fe) - ;; The buffer may be empty. - (max (point-min) (1- (point-max))) - (point-max))))) + (let* ((footer-line (lm-package-needs-footer-line))) + (if (not (re-search-backward + ;; This should match the requirement in + ;; `package-buffer-info'. + (if footer-line + (concat "^;;; " (regexp-quote (concat fn fe)) " ends here") + (concat "\n(provide '" fn ")\n")) + nil t)) + (if (checkdoc-y-or-n-p (if footer-line + "No identifiable footer! Add one?" + "No `provide' statement! Add one?")) + (progn + (goto-char (point-max)) + (insert (if footer-line + (concat "\n(provide '" fn ")\n\n;;; " fn fe " ends here\n") + (concat "\n(provide '" fn ")\n")))) + (checkdoc-create-error + (if footer-line + (format "The footer should be: (provide '%s)\\n;;; %s%s ends here" + fn fn fe) + (format "The footer should be: (provide '%s)\\n" fn)) + ;; The buffer may be empty. + (max (point-min) (1- (point-max))) + (point-max)))))) err)) ;; The below checks will not return errors if the user says NO -- 2.39.2