Subject: bug#6187: Wrong type argument: number-of-marker-p, nil

From: Christophe TROESTLER <[email-masked]>
Date: Sat, 13 Aug 2011 00:34:48 +0200 (CEST)

I redefined select-safe-coding-system-interactively to try to track
the bug and it confirms that the variable `unsafe', AFTER the “(setq
unsafe …”, has value ((iso-latin-1-unix)) ― which then returns (nil)
when processed with

    (mapcar #'(lambda (x) (car (cadr x))) unsafe)

The correct value for `unsafe' is (iso-latin-1-unix (1 . 7868))

Note that the bug is not present when Emacs starts, it only shows up
after some time.  My wild guess is that somehow regions are processed
incorrectly ― I have some region issues with other Emacs packages too.

The backtrace :

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  min(nil)
  apply(min nil)
  (goto-char (apply (quote min) (mapcar ... unsafe)))
  (progn (pop-to-buffer bufname) (goto-char (apply ... ...)))
  (if (and unsafe (not ...)) (progn (pop-to-buffer bufname) (goto-char ...)))
  (when (and unsafe (not ...)) (pop-to-buffer bufname) (goto-char (apply ... ...)))
  (save-excursion (when (and unsafe ...) (pop-to-buffer bufname) (goto-char ...)) (with-output-to-temp-buffer "*Warning*" (with-current-buffer standard-output ... ... ...)) (setq coding-system (read-coding-system ... default)) (setq last-coding-system-specified coding-system))
  (let ((window-configuration ...) (bufname ...) coding-system) (save-excursion (when ... ... ...) (with-output-to-temp-buffer "*Warning*" ...) (setq coding-system ...) (setq last-coding-system-specified coding-system)) (kill-buffer "*Warning*") (set-window-configuration window-configuration) coding-system)
  select-safe-coding-system-interactively(1 3 (utf-8 viscii gb18030 utf-7 utf-16 utf-16be-with-signature utf-16le-with-signature utf-16be utf-16le x-ctext iso-2022-7bit utf-8-auto utf-8-with-signature emacs-mule raw-text iso-2022-8bit-ss2 iso-2022-7bit-lock vietnamese-tcvn vietnamese-viqr vietnamese-vscii utf-7-imap utf-8-emacs no-conversion compound-text-with-extensions ctext-no-compositions iso-2022-7bit-ss2) (iso-latin-1-unix) nil utf-8)
  select-safe-coding-system(1 3 iso-latin-1-unix nil "/tmp/a.txt")
  write-region(nil nil "/tmp/a.txt" nil t "/tmp/a.txt")
  basic-save-buffer-2()
  basic-save-buffer-1()
  basic-save-buffer()
  save-buffer(1)
  call-interactively(save-buffer nil nil)