Subject: 23.3; calendar-set-mode-line can cause `wrong-type-argument number-or-marker-p' with --batch
From: Adam Spiers <[email-masked]>
To: [email-masked]
Date: Mon, 05 Mar 2012 23:36:35 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

With org-mode configured appropriately, running:

    emacs --batch --load ~/.emacs --eval '(org-mobile-push)'

causes:

    Wrong type argument: number-or-marker-p, "90"

Re-running with stack-trace-on-error set to `t' showed:

    [... snipped ...]
    Creating agendas...
    OVERVIEW
    Loading vc-git...
    Preparing diary...
      calendar-string-spread(("Diary Entries") 45 "90")
      calendar-set-mode-line("Diary Entries")
      fancy-diary-display()
    [... snipped ...]

which quickly revealed a bug in calendar-set-mode-line:

    (and (= width 10)
         (not window-system)
         (setq width (or (getenv "COLUMNS") 80)))

This code attempts to treat width numerically; however when COLUMNS is
set in the environment and window-system is nil, both of which are true
in my scenario above, width is set to a string.  Here is a suggested
fix:

--- lisp/calendar/calendar.el.orig	2012-03-05 23:15:25.000000000 +0000
+++ lisp/calendar/calendar.el	2012-03-05 23:18:55.000000000 +0000
@@ -2548,7 +2548,7 @@
     ;; If no frame exists yet, we have no idea what width to use.
     (and (= width 10)
          (not window-system)
-         (setq width (or (getenv "COLUMNS") 80)))
+         (setq width (string-to-number (or (getenv "COLUMNS") "80"))))
     (setq mode-line-format
           (if buffer-file-name
               `("-" mode-line-modified

In GNU Emacs 23.3.1 (i386-redhat-linux-gnu, GTK+ Version 2.24.7)
 of 2012-01-13 on x86-18.phx2.fedoraproject.org
Windowing system distributor `Fedora Project', version 11.0.11004000
configured using `configure  '--build=i386-redhat-linux-gnu' '--host=i386-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm' '--with-x-toolkit=gtk' 'build_alias=i386-redhat-linux-gnu' 'host_alias=i386-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  gpm-mouse-mode: t
  eldoc-mode: t
  global-msf-abbrev-mode: t
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  display-time-mode: t
  recentf-mode: t
  show-paren-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-h i d m e m a c s <return> M-> M-< m s u b <tab> <backspace>
<backspace> <backspace> r e p o <tab> <tab> <backspace>
<backspace> <backspace> <backspace> b u g <tab> <tab> s
<return> 1 n n n <down> <down> <down> <down> <tab> <return> l
C-! c a l <return> M-b M-b M-b M-b M-b M-b M-b M-b M-b M-f M-f
<right> M-( C-/ C-M-( M-d M-d M-d M-d C-/ C-x C-s C-e <left>
<right> C-x C-e <help-echo> <down-mouse-1> <mouse-movement>
<mouse-movement> <drag-mouse-1> <help-echo> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> C-. C-! C-g
C-h i <down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> SPC SPC SPC SPC SPC
SPC SPC <next> <next> <prior> q M-x r e p o <tab> r <tab> e
<tab> <return> C-g C-M-c q M-x <up> <return>

Recent messages:
uncompressing emacs-6.gz...done
Undo! [2 times]
Saving file /home/adam/calendar.el...
Wrote /home/adam/calendar.el
Entering debugger...
Quit
Making completion list...
Quit
Entering debugger...
Back to top level.

Load-path shadows:
/usr/share/emacs/site-lisp/lilypond-init hides /usr/share/emacs/site-lisp/site-start.d/lilypond-init
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-w3m hides /usr/share/emacs/23.3/lisp/org/org-w3m
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-irc hides /usr/share/emacs/23.3/lisp/org/org-irc
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-html hides /usr/share/emacs/23.3/lisp/org/org-html
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-footnote hides /usr/share/emacs/23.3/lisp/org/org-footnote
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-protocol hides /usr/share/emacs/23.3/lisp/org/org-protocol
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-latex hides /usr/share/emacs/23.3/lisp/org/org-latex
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-datetree hides /usr/share/emacs/23.3/lisp/org/org-datetree
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-mhe hides /usr/share/emacs/23.3/lisp/org/org-mhe
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-docbook hides /usr/share/emacs/23.3/lisp/org/org-docbook
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-clock hides /usr/share/emacs/23.3/lisp/org/org-clock
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-timer hides /usr/share/emacs/23.3/lisp/org/org-timer
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-exp hides /usr/share/emacs/23.3/lisp/org/org-exp
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-compat hides /usr/share/emacs/23.3/lisp/org/org-compat
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-bibtex hides /usr/share/emacs/23.3/lisp/org/org-bibtex
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-info hides /usr/share/emacs/23.3/lisp/org/org-info
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-freemind hides /usr/share/emacs/23.3/lisp/org/org-freemind
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-habit hides /usr/share/emacs/23.3/lisp/org/org-habit
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-wl hides /usr/share/emacs/23.3/lisp/org/org-wl
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-rmail hides /usr/share/emacs/23.3/lisp/org/org-rmail
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-agenda hides /usr/share/emacs/23.3/lisp/org/org-agenda
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-remember hides /usr/share/emacs/23.3/lisp/org/org-remember
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-ascii hides /usr/share/emacs/23.3/lisp/org/org-ascii
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-archive hides /usr/share/emacs/23.3/lisp/org/org-archive
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-mouse hides /usr/share/emacs/23.3/lisp/org/org-mouse
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-mew hides /usr/share/emacs/23.3/lisp/org/org-mew
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-macs hides /usr/share/emacs/23.3/lisp/org/org-macs
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-crypt hides /usr/share/emacs/23.3/lisp/org/org-crypt
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-plot hides /usr/share/emacs/23.3/lisp/org/org-plot
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-attach hides /usr/share/emacs/23.3/lisp/org/org-attach
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-indent hides /usr/share/emacs/23.3/lisp/org/org-indent
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-vm hides /usr/share/emacs/23.3/lisp/org/org-vm
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-icalendar hides /usr/share/emacs/23.3/lisp/org/org-icalendar
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-id hides /usr/share/emacs/23.3/lisp/org/org-id
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-faces hides /usr/share/emacs/23.3/lisp/org/org-faces
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-jsinfo hides /usr/share/emacs/23.3/lisp/org/org-jsinfo
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-mac-message hides /usr/share/emacs/23.3/lisp/org/org-mac-message
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-inlinetask hides /usr/share/emacs/23.3/lisp/org/org-inlinetask
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-install hides /usr/share/emacs/23.3/lisp/org/org-install
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-bbdb hides /usr/share/emacs/23.3/lisp/org/org-bbdb
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-feed hides /usr/share/emacs/23.3/lisp/org/org-feed
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-colview hides /usr/share/emacs/23.3/lisp/org/org-colview
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-gnus hides /usr/share/emacs/23.3/lisp/org/org-gnus
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-table hides /usr/share/emacs/23.3/lisp/org/org-table
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-mobile hides /usr/share/emacs/23.3/lisp/org/org-mobile
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-exp-blocks hides /usr/share/emacs/23.3/lisp/org/org-exp-blocks
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org hides /usr/share/emacs/23.3/lisp/org/org
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-src hides /usr/share/emacs/23.3/lisp/org/org-src
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-xoxo hides /usr/share/emacs/23.3/lisp/org/org-xoxo
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-list hides /usr/share/emacs/23.3/lisp/org/org-list
/home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/pre/org-publish hides /usr/share/emacs/23.3/lisp/org/org-publish
/usr/share/emacs/23.3/lisp/calendar/icalendar hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/icalendar
/usr/share/emacs/23.3/lisp/mwheel hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/mwheel
/usr/share/emacs/23.3/lisp/emacs-lisp/elp hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/elp
/usr/share/emacs/23.3/lisp/tree-widget hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/tree-widget
/usr/share/emacs/23.3/lisp/ido hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/ido
/usr/share/emacs/23.3/lisp/scroll-all hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/scroll-all
/usr/share/emacs/23.3/lisp/pgg hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pgg
/usr/share/emacs/23.3/lisp/pgg-pgp5 hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pgg-pgp5
/usr/share/emacs/23.3/lisp/pgg-pgp hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pgg-pgp
/usr/share/emacs/23.3/lisp/pgg-parse hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pgg-parse
/usr/share/emacs/23.3/lisp/pgg-gpg hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pgg-gpg
/usr/share/emacs/23.3/lisp/pgg-def hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pgg-def
/usr/share/emacs/23.3/lisp/pcvs hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pcvs
/usr/share/emacs/23.3/lisp/pcvs-util hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pcvs-util
/usr/share/emacs/23.3/lisp/pcvs-parse hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pcvs-parse
/usr/share/emacs/23.3/lisp/pcvs-info hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pcvs-info
/usr/share/emacs/23.3/lisp/emacs-lisp/ewoc hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/ewoc
/usr/share/emacs/23.3/lisp/pcvs-defs hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/pcvs-defs
/usr/share/emacs/site-lisp/rpm-spec-mode hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/rpm-spec-mode
/usr/share/emacs/23.3/lisp/calendar/todo-mode hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/todo-mode
/usr/share/emacs/23.3/lisp/textmodes/css-mode hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/css-mode
/usr/share/emacs/23.3/lisp/textmodes/rst hides /home/adam/lib/emacs/GNU_Emacs/23.3/gnu/linux/post/rst
/usr/share/emacs/23.3/lisp/textmodes/remember hides /home/adam/local/share/emacs/site-lisp/remember
/usr/share/emacs/23.3/lisp/epa-mail hides /home/adam/local/share/emacs/site-lisp/epg/epa-mail
/usr/share/emacs/23.3/lisp/epa-file hides /home/adam/local/share/emacs/site-lisp/epg/epa-file
/usr/share/emacs/23.3/lisp/epa-dired hides /home/adam/local/share/emacs/site-lisp/epg/epa-dired
/usr/share/emacs/23.3/lisp/epa hides /home/adam/local/share/emacs/site-lisp/epg/epa
/usr/share/emacs/23.3/lisp/epg hides /home/adam/local/share/emacs/site-lisp/epg/epg
/usr/share/emacs/23.3/lisp/epg-config hides /home/adam/local/share/emacs/site-lisp/epg/epg-config

Features:
(shadow sort mail-extr message idna ecomplete rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader canlock
hashcash emacsbug vc-annotate bs eieio-custom eieio wid-browse org-xoxo
org-latex org-export-latex org-beamer org-icalendar org-docbook footnote
org-colview org-clock org-ascii calc calc-loaddefs calc-macs iso-transl
tar-mode conf-mode debug info-look org-publish org-protocol org-mouse
org-indent org-feed org-attach t-mouse remember org-remember
org-datetree vc-dir org-table mail-parse rfc2231 rfc2047 rfc2045 qp
ietf-drums mailcap align make-mode tidy html-mode jsp-html-helper-mode
asp-html-helper-mode php-html-helper-mode html-helper-mode cc-mode
cc-fonts cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
autoconf autoconf-mode time-stamp tex-mode compile latexenc texnfo-upd
jka-compr info texinfo browse-url thingatpt image-file bookmark cal-move
parse-time org-id tabify appt cal-china lunar solar cal-dst cal-bahai
cal-islam cal-hebrew holidays hol-loaddefs diary-lib diary-loaddefs
cal-iso cus-edit org-mobile epg epg-config org-archive ruby-mode
find-func eldoc ispell python-21 python dired-aux vc-arch vc-mtn vc-hg
msf-abbrev imenu as-gtd as-mairix org-mairix org-crypt org-wl org-w3m
org-vm org-rmail org-mhe org-mew org-irc org-jsinfo org-infojs org-html
org-exp ob-exp org-exp-blocks org-agenda org-info org-gnus org-docview
org-bibtex bibtex org-bbdb org-timer dabbrev rect dired vc-bzr sha1
hex-util vc-sccs vc-svn vc-cvs vc-rcs newcomment skeleton sh-script
executable log-edit ange-ftp hippie-exp log-view pcvs-util multi-isearch
xgit-dvc xgit xgit-annotate dvc-annotate xgit-log vc-git bzr-dvc tla
smerge-mode dvc-state dvc-config diff sendmail tla-gnus dvc-gnus
dvc-cmenu dvc-version bzr dvc-revlist dvc-diff dvc-unified dvc-tips
bzr-core tla-core pp ewoc tla-autoconf tla-defs dvc-site ffap add-log
diff-mode ediff-merg ediff-diff ediff-wind ediff-help ediff-util
ediff-mult ediff-init ediff xdarcs-core xgit-core xhg-core xmtn-minimal
tempo cperl-mode tramp-imap tramp-gw tramp-fish tramp-smb tramp-cache
tramp-ftp tramp-cmds tramp auth-source shell password-cache format-spec
tramp-compat trampver uniquify yasnippet dropdown-list derived edmacro
kmacro help-mode view assoc gnus gnus-ems nnheader gnus-util netrc
mail-utils mm-util mail-prsvr time delsel cus-start cus-load recentf
tree-widget paren folding-isearch folding ido vc vc-dispatcher
dvc-autoloads dvc-core dvc-lisp dvc-buffers dvc-ui dvc-register
dvc-utils mule-util dvc-emacs dvc-defs w3m-load org-install color-theme
wid-edit cl cl-19 pastels-on-dark-theme color-theme-autoloads
edit-server server midnight smooth-scrolling as-bindings org byte-opt
warnings bytecomp byte-compile advice help-fns advice-preload
ob-emacs-lisp ob-tangle ob-ref ob-lob ob-table org-footnote org-src
ob-comint comint ring ob-keys ob ob-eval org-pcomplete pcomplete
org-list org-faces org-compat org-entities org-macs time-date noutline
outline easy-mmode regexp-opt cal-menu easymenu calendar cal-loaddefs
as-require as-progress tooltip ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd font-setting tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs)