From 8b446eb69b418599978f5fc3729b5fa42aa7e2fd Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 29 Jul 2025 08:33:30 -0700 Subject: [PATCH 1/2] Pass buffer to text= for clarity --- lisp/ess-r-flymake.el | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lisp/ess-r-flymake.el b/lisp/ess-r-flymake.el index a9fedb311..ae56c46a6 100644 --- a/lisp/ess-r-flymake.el +++ b/lisp/ess-r-flymake.el @@ -27,7 +27,7 @@ ;; Flymake is the built-in Emacs package that supports on-the-fly ;; syntax checking. This file adds support for this in ess-r-mode by ;; relying on the lintr package, available on CRAN and currently -;; hosted at https://github.com/jimhester/lintr. +;; hosted at https://github.com/r-lib/lintr. ;;; Code: @@ -76,28 +76,26 @@ each element is passed as argument to `lintr::linters_with_defaults'." (defvar-local ess-r--flymake-proc nil) (defvar-local ess-r--lintr-file nil - "Location of the .lintr file for this buffer.") + "Location of the .lintr config file for this buffer.") (defvar ess-r--flymake-def-linter (replace-regexp-in-string "[\n\t ]+" " " "esslint <- function(str, ...) { - if (!suppressWarnings(require(lintr, quietly=T))) { + if (!suppressWarnings(requireNamespace('lintr', quietly=TRUE))) { cat('@@error: @@`lintr` package not installed') + } else if (packageVersion('lintr') <= '3.0.0') { + cat('@@error: @@Need `lintr` version > v3.0.0') } else { - if (packageVersion('lintr') <= '3.0.0') { - cat('@@error: @@Need `lintr` version > v3.0.0') - } else { - tryCatch(lintr::lint(commandArgs(TRUE), ...), - error = function(e) { - cat('@@warning: @@', conditionMessage(e)) - }) - } + tryCatch(lintr::lint(text=commandArgs(TRUE), ..., parse_settings=TRUE), + error = function(e) { + cat('@@warning: @@', conditionMessage(e)) + }) } };")) (defun ess-r--find-lintr-file () - "Return the absolute path to the .lintr file. + "Return the absolute path to the .lintr config file. Check first the current directory, then the project root, then the package root, then the user's home directory. Return nil if we couldn't find a .lintr file." From 8cf3fc7201bc06736c11a97df01296ec364112fd Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 29 Jul 2025 08:42:52 -0700 Subject: [PATCH 2/2] don't re-read commandArgs --- lisp/ess-r-flymake.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ess-r-flymake.el b/lisp/ess-r-flymake.el index ae56c46a6..f223a6089 100644 --- a/lisp/ess-r-flymake.el +++ b/lisp/ess-r-flymake.el @@ -87,7 +87,7 @@ each element is passed as argument to `lintr::linters_with_defaults'." } else if (packageVersion('lintr') <= '3.0.0') { cat('@@error: @@Need `lintr` version > v3.0.0') } else { - tryCatch(lintr::lint(text=commandArgs(TRUE), ..., parse_settings=TRUE), + tryCatch(lintr::lint(text=str, ..., parse_settings=TRUE), error = function(e) { cat('@@warning: @@', conditionMessage(e)) })