(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.
(_ :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