The problem is that Emacs doesn't include \r characters in buffers when loading DOS \r\n format files, but \r characters are counted by the compiler and SLIME in finding note positions. So for each line before a compiler note in a DOS format file, note position is moved forward one char.
I've only tested this in SBCL on Linux and LispWorks on Windows.
Here's code to fix it in slime.el. Maybe someone more knowledgeable can confirm that checking for "dos" appearing in buffer-file-coding-system is the right way to detect DOS newline format?
(defun emacs-pos-from-dos-file-pos (file-pos) (let ((fixed-file-pos file-pos) (emacs-pos 1)) (while (< emacs-pos fixed-file-pos) (when (= (char-after emacs-pos) 10) (decf fixed-file-pos)) (incf emacs-pos)) emacs-pos))
(defun slime-compile-note-fix-position-for-dos-file (note) (let ((i 0) (new-note nil)) (while (< i (length note)) (setq new-note (append new-note (list (nth i note)))) (if (eql (nth i note) :location) (let* ((location (nth (+ i 1) note)) (fixed-location (mapcar (lambda (entry) (if (and (listp entry) (eql (first entry) :position)) (append (list :position (emacs-pos-from-dos-file-pos (second entry))) (nthcdr 2 entry)) entry)) location))) (setq new-note (append new-note (list fixed-location)))) (setq new-note (append new-note (list (nth (+ i 1) note))))) (incf i 2)) new-note))
(defun slime-compilation-finished (compilation-result buffer &optional emacs-snapshot) (with-struct (slime-compilation-result. notes durations) compilation-result (let* ((coding-system (buffer-local-value 'buffer-file-coding-system buffer)) (fixed-notes (if (and coding-system (string-match ".*dos.*" (symbol-name coding-system))) (mapcar #'slime-compile-note-fix-position-for-dos-file notes) notes))) (with-current-buffer buffer (setf slime-compilation-just-finished t) (setf (slime-compilation-result.notes compilation-result) fixed-notes) (setf slime-last-compilation-result compilation-result) (slime-show-note-counts fixed-notes (reduce #'+ durations)) (when slime-highlight-compiler-notes (slime-highlight-notes fixed-notes))) (run-hook-with-args 'slime-compilation-finished-hook fixed-notes emacs-snapshot))))