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