From: Eshel Yaron Date: Fri, 7 Mar 2025 14:53:30 +0000 (+0100) Subject: sh-script.el: Fix fixing Flymake diagnostics from other buffer X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1db9b48b20b9c272624ae83d71cf78e2fc796b22;p=emacs.git sh-script.el: Fix fixing Flymake diagnostics from other buffer * lisp/progmodes/sh-script.el (sh-shellcheck-fix): --- diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 7a745c380b6..ab2e30dcee2 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -3241,20 +3241,21 @@ shell command and conveniently use this command." (defvar-local sh--shellcheck-process nil) -(defun sh-shellcheck-fix (data) +(defun sh-shellcheck-fix (source data) "Format DATA, a cons cell (TITLE . FIX), as a Flymake fix suggestion." - `((,(car data) - ((,(current-buffer) - ,@(mapcar - (lambda (rep) - (let-alist rep - (without-restriction - (save-excursion - (goto-char (point-min)) - (list (1- (+ (pos-bol .line) .column)) - (1- (+ (pos-bol .endLine) .endColumn)) - .replacement))))) - (alist-get 'replacements (cdr data)))))))) + (with-current-buffer source + `((,(car data) + ((,(current-buffer) + ,@(mapcar + (lambda (rep) + (let-alist rep + (without-restriction + (save-excursion + (goto-char (point-min)) + (list (1- (+ (pos-bol .line) .column)) + (1- (+ (pos-bol .endLine) .endColumn)) + .replacement))))) + (alist-get 'replacements (cdr data))))))))) (defun sh-shellcheck-flymake (report-fn &rest _args) "Flymake backend using the shellcheck program. @@ -3299,7 +3300,8 @@ member of `flymake-diagnostic-functions'." (_ :note)) (format "SC%s: %s" .code .message) (cons .message .fix) nil - (when (consp .fix) #'sh-shellcheck-fix))))) + (when (consp .fix) + (apply-partially #'sh-shellcheck-fix source)))))) (funcall report-fn)))) (kill-buffer (process-buffer proc))))))) (unless dialect