purcell / package-lint

A linting library for elisp package metadata
GNU General Public License v3.0
193 stars 34 forks source link

Dubious error about ostensibly removed eldoc face #187

Closed protesilaos closed 4 years ago

protesilaos commented 4 years ago

Thank you for providing this package! I am trying to configure eldoc-highlight-function-argument only to get an error:

`eldoc-highlight-function-argument' was removed in Emacs version 25.1

Checking the source code, does not seem to indicate that this face has been removed. M-x find-library eldoc contains this:

(defface eldoc-highlight-function-argument
  '((t (:inherit bold)))
  "Face used for the argument at point in a function's argument list.
Note that this face has no effect unless the `eldoc-documentation-function'
handles it explicitly."
  :group 'eldoc)
;;;###autoload
(defvar eldoc-documentation-function #'ignore
  "Function to call to return doc string.
The function of no args should return a one-line string for displaying
doc about a function etc. appropriate to the context around point.
It should return nil if there's no doc appropriate for the context.
Typically doc is returned if point is on a function-like name or in its
arg list.

The result is used as is, so the function must explicitly handle
the variables `eldoc-argument-case' and `eldoc-echo-area-use-multiline-p',
and the face `eldoc-highlight-function-argument', if they are to have any
effect.

Major modes should modify this variable using `add-function', for example:
  (add-function :before-until (local \\='eldoc-documentation-function)
                #\\='foo-mode-eldoc-function)
so that the global documentation function (i.e. the default value of the
variable) is taken into account if the major mode specific function does not
return any documentation.")

The face's docstring does offer a warning. Same for the eldoc-documentation-function. Though I cannot pinpoint the source of the error message I am getting.

Is this error spurious? Is there some way to silence the linter?

fbergroth commented 4 years ago

The issue seems to be that there used to be a function named eldoc-highlight-function-argument before emacs-25, but there is also a face named eldoc-highlight-function-argument with the same name which triggers the error.

purcell commented 4 years ago

Can you share some code which, when linted, produces this issue?

protesilaos commented 4 years ago

Sure, this is in the context of a theme. Here is a minimal code that reproduces the issue:

;;; testing-theme.el --- Testing -*- lexical-binding:t -*-

;; Author: Protesilaos Stavrou <info@protesilaos.com>
;; URL: https://protesilaos.com
;; Version: 0.1.0
;; Package-Requires: ((emacs "26.1"))

;;; Commentary:

;; This is a test.

;;; Code:
(deftheme testing
  "Testing.")

(custom-theme-set-faces
 'testing
 `(eldoc-highlight-function-argument ((t :foreground "red"))))

(provide-theme 'testing)

(provide 'testing-theme)
;;; testing-theme.el ends here
purcell commented 4 years ago

Thanks, that's helpful. The issue here is that package-lint only has very basic detection of references to functions and variables, and to package-lint the above looks like it calls eldoc-highlight-function-argument as a function. We don't actually macroexpand or execute the code to detect which references actually are variables and functions, because that would be unsafe in the context of MELPA etc. So this is unlikely to get fixed, but to placate package-lint in this instance you could reformulate it slightly:

(custom-theme-set-faces
 'testing
 (list 'eldoc-highlight-function-argument '((t :foreground "red"))))
protesilaos commented 4 years ago

Thank you for this! It woks. This issue can be closed now.