r-lib / cli

Tools for making beautiful & useful command line interfaces
https://cli.r-lib.org/
Other
625 stars 66 forks source link

In emacs_version(): NAs introduced by coercion #689

Open charmoniumQ opened 2 months ago

charmoniumQ commented 2 months ago
> cli::num_ansi_colors()
[1] 256
Warning message:
In emacs_version() : NAs introduced by coercion
>

I've determined this is because emacs_version expects INSIDE_EMACS to be some kind of version string, but Emacs vterm sets INSIDE_EMACS to vterm.

Should we special case vterm in emacs_version?

gaborcsardi commented 2 months ago

Well, that is a pretty nasty thing to do, I would say. They really should not do that. Now how are we supposed to determine the Emacs version?

Emacs sets the environment variable INSIDE_EMACS in the subshell to ‘version,comint’, where version is the Emacs version (e.g., ‘28.1’). Programs can check this variable to determine whether they are running inside an Emacs subshell.

https://www.gnu.org/software/emacs/manual/html_node/emacs/Interactive-Shell.html

In any case, I don't think we need to special case it, we can just return NA_integer_ if it is not a version number, and get rid of the warning. Would you like to submit a PR? (No pressure, really.)