Subject: bug#74438: 29.1; global-mark-ring does not work as described

From: Nikolay Kudryavtsev <[email-masked]>
Date: Fri, 22 Nov 2024 15:39:36 +0300

Sorry, but your code does not demonstrate at what points you're pushing 
the mark(s). If you get the file-a marker before doing any write 
operations, you should be safe:

(defun json-diff ()
   (interactive)
   (let ((buffer-a (find-file (make-temp-file "json-diff"))))
     (with-current-buffer buffer-a (push-mark))
     ;; At this point we presumably no longer have the mark for buffer-a 
for some reason
     (let ((first-mark (car global-mark-ring)))
       (with-current-buffer (marker-buffer first-mark)
         (message (format "Working with %s at %s" (buffer-file-name 
(current-buffer)) (marker-position first-mark)))))))

But be aware that you're never really safe if you're relying on the mark 
ring here. If json-diff is an interactive command, nothing is stopping 
the user from pushing another mark to the ring in between of specifying 
file-a and file-b. Even worse if you're trying to get something from the 
previous command(as you said in the letter before), because you can 
never be sure what the previous command was and what it did.

Also, I don't know where did you get the last-global-mark thing, it's 
not something that's in the Emacs 29 or 30's core.