Subject: bug#15007: 24.3.50; Small improvement for calendar

From: Vladimir Lomov <[email-masked]>
Date: Fri, 2 Aug 2013 16:49:09 +0900

--text follows this line--

Hello,
first of all this is NOT a bug report but a feature request.  At
the moment function `calendar-generate-month' (defined and used in file
`calendar.el') has this line
   (calendar-day-name (mod (+ calendar-week-start-day i) 7) nil t))
which instructs function `calendar-day-name' to use
`calendar-day-name-array' (nil argument) for name of a day. This name
will be further truncated and used for month header.

For Russian this is unfavourable because shorter day names are first two
consonant letters of full name. If to define array
`calendar-day-abbrev-array' then function `calendar-day-name' can use it
if to pass `t' instead of `nil'.

I suggest to change that line to this
   (calendar-day-name (mod (+ calendar-week-start-day i) 7) t t))
which will cause to use `calendar-day-abbrev-array'.

AFAIU, this shouldn't break anything. If variable
`calendar-day-abbrev-array' is not set it is constructed from
`calendar-day-name-array' so it simply will contain first three letters
from names in `calendar-day-name-array' (e.g., "Monday" -> "Mon" and in
function `calendar-generate-month' this will give "Mo"). The only
drawback here if someone sets and uses `calendar-day-abbrev-array' for
other purposes but expects usual behavior from `calendar'
(`calendar-generate-month').

If this is a good reason to not change that line then I propose
following small patch

=== modified file 'lisp/calendar/calendar.el'
--- lisp/calendar/calendar.el	2013-02-12 04:46:18 +0000
+++ lisp/calendar/calendar.el	2013-08-02 06:06:25 +0000
@@ -193,6 +193,14 @@
 (define-obsolete-variable-alias 'view-diary-entries-initially
   'calendar-view-diary-initially-flag "23.1")
 
+(defcustom calendar-use-day-name-abbrev nil
+  "Non-nil means to use `calendar-day-abbrev-array' instead of
+`calendar-day-name-array' when generate a month. This is required when
+abbreviated name of a day doesn't coincide with first two letters of
+day name."
+  :type 'boolean
+  :group 'calendar)
+
 (defcustom calendar-view-diary-initially-flag nil
   "Non-nil means display current date's diary entries on entry to calendar.
 The diary is displayed in another window when the calendar is first displayed,
@@ -1531,7 +1539,7 @@
      (insert
       (progn
         (setq string
-              (calendar-day-name (mod (+ calendar-week-start-day i) 7) nil t))
+              (calendar-day-name (mod (+ calendar-week-start-day i) 7) calendar-use-day-name-abbrev t))
         (if enable-multibyte-characters
             (truncate-string-to-width string calendar-day-header-width)
           (substring string 0 calendar-day-header-width)))

It introduces a new user option, `nil' by default, which allows to use
`calendar-day-abbrev-array' instead of `calendar-day-name-array' in
`calendar-generate-month' (by function `calendar-day-name').

---
WBR, Vladimir Lomov

In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.8.2)
 of 2013-08-02 on smoon4
Bzr revision: 113648 [email-masked]
Windowing system distributor `The X.Org Foundation', version 11.0.11402000
Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
 --libexecdir=/usr/lib --with-xpm --with-jpeg --with-tiff --with-gif
 --with-png --with-rsvg --with-x-toolkit=gtk3 --with-xft --with-libotf
 --with-dbus --with-gsettings --without-sound CFLAGS='-march=x86-64
 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4'
 CPPFLAGS='-D_FORTIFY_SOURCE=2'
 LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro''

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: ru_RU.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  erc-services-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  diff-auto-refine-mode: t
  global-auto-complete-mode: t
  auto-complete-mode: t
  shell-dirtrack-mode: t
  show-paren-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x c a l e n <tab> <return> q C-x 5 0 M-x r e p o 
r t - e m a c s - b u g <return>

Recent messages:
Loading /home/vladimir/.emacs.d/auto-complete-us.el (source)...done
Loading /home/vladimir/.emacs.d/magit-us.el (source)...
Loading /usr/share/emacs/site-lisp/magit/magit-version.el (source)...done
Loading /home/vladimir/.emacs.d/magit-us.el (source)...done
Loading /home/vladimir/.emacs.d/erc-us.el (source)...
Loading /home/vladimir/.emacs.d/erc-auth.el (source)...done
Loading /home/vladimir/.emacs.d/erc-us.el (source)...done
Loading /home/vladimir/.emacs.d/keybinds-us.el (source)...done
Starting Emacs daemon.
When done with this frame, type C-x 5 0 [2 times]

Load-path shadows:
/usr/share/emacs/site-lisp/org/ob-dot hides /usr/share/emacs/24.3.50/lisp/org/ob-dot
/usr/share/emacs/site-lisp/org/org-ctags hides /usr/share/emacs/24.3.50/lisp/org/org-ctags
/usr/share/emacs/site-lisp/org/org-version hides /usr/share/emacs/24.3.50/lisp/org/org-version
/usr/share/emacs/site-lisp/org/ob-picolisp hides /usr/share/emacs/24.3.50/lisp/org/ob-picolisp
/usr/share/emacs/site-lisp/org/ob-sh hides /usr/share/emacs/24.3.50/lisp/org/ob-sh
/usr/share/emacs/site-lisp/org/org-colview hides /usr/share/emacs/24.3.50/lisp/org/org-colview
/usr/share/emacs/site-lisp/org/ob-gnuplot hides /usr/share/emacs/24.3.50/lisp/org/ob-gnuplot
/usr/share/emacs/site-lisp/org/ob-C hides /usr/share/emacs/24.3.50/lisp/org/ob-C
/usr/share/emacs/site-lisp/org/org-plot hides /usr/share/emacs/24.3.50/lisp/org/org-plot
/usr/share/emacs/site-lisp/org/org-feed hides /usr/share/emacs/24.3.50/lisp/org/org-feed
/usr/share/emacs/site-lisp/org/ob-latex hides /usr/share/emacs/24.3.50/lisp/org/ob-latex
/usr/share/emacs/site-lisp/org/ob-octave hides /usr/share/emacs/24.3.50/lisp/org/ob-octave
/usr/share/emacs/site-lisp/org/ob-ruby hides /usr/share/emacs/24.3.50/lisp/org/ob-ruby
/usr/share/emacs/site-lisp/org/ob-lob hides /usr/share/emacs/24.3.50/lisp/org/ob-lob
/usr/share/emacs/site-lisp/org_contrib/lisp/org-wl hides /usr/share/emacs/24.3.50/lisp/org/org-wl
/usr/share/emacs/site-lisp/org/ob hides /usr/share/emacs/24.3.50/lisp/org/ob
/usr/share/emacs/site-lisp/org_contrib/lisp/org-vm hides /usr/share/emacs/24.3.50/lisp/org/org-vm
/usr/share/emacs/site-lisp/org/ob-table hides /usr/share/emacs/24.3.50/lisp/org/ob-table
/usr/share/emacs/site-lisp/org/ob-exp hides /usr/share/emacs/24.3.50/lisp/org/ob-exp
/usr/share/emacs/site-lisp/org/ob-ocaml hides /usr/share/emacs/24.3.50/lisp/org/ob-ocaml
/usr/share/emacs/site-lisp/org/ob-R hides /usr/share/emacs/24.3.50/lisp/org/ob-R
/usr/share/emacs/site-lisp/org/ob-js hides /usr/share/emacs/24.3.50/lisp/org/ob-js
/usr/share/emacs/site-lisp/org/ob-io hides /usr/share/emacs/24.3.50/lisp/org/ob-io
/usr/share/emacs/site-lisp/org/org-datetree hides /usr/share/emacs/24.3.50/lisp/org/org-datetree
/usr/share/emacs/site-lisp/org/ob-awk hides /usr/share/emacs/24.3.50/lisp/org/ob-awk
/usr/share/emacs/site-lisp/org/org-id hides /usr/share/emacs/24.3.50/lisp/org/org-id
/usr/share/emacs/site-lisp/org/ob-asymptote hides /usr/share/emacs/24.3.50/lisp/org/ob-asymptote
/usr/share/emacs/site-lisp/org/org-capture hides /usr/share/emacs/24.3.50/lisp/org/org-capture
/usr/share/emacs/site-lisp/org/org-indent hides /usr/share/emacs/24.3.50/lisp/org/org-indent
/usr/share/emacs/site-lisp/org/ob-ledger hides /usr/share/emacs/24.3.50/lisp/org/ob-ledger
/usr/share/emacs/site-lisp/org/ob-sql hides /usr/share/emacs/24.3.50/lisp/org/ob-sql
/usr/share/emacs/site-lisp/org/ob-fortran hides /usr/share/emacs/24.3.50/lisp/org/ob-fortran
/usr/share/emacs/site-lisp/org/ob-sass hides /usr/share/emacs/24.3.50/lisp/org/ob-sass
/usr/share/emacs/site-lisp/org/ob-sqlite hides /usr/share/emacs/24.3.50/lisp/org/ob-sqlite
/usr/share/emacs/site-lisp/org/org hides /usr/share/emacs/24.3.50/lisp/org/org
/usr/share/emacs/site-lisp/org/org-timer hides /usr/share/emacs/24.3.50/lisp/org/org-timer
/usr/share/emacs/site-lisp/org/org-attach hides /usr/share/emacs/24.3.50/lisp/org/org-attach
/usr/share/emacs/site-lisp/org/ob-calc hides /usr/share/emacs/24.3.50/lisp/org/ob-calc
/usr/share/emacs/site-lisp/org/org-footnote hides /usr/share/emacs/24.3.50/lisp/org/org-footnote
/usr/share/emacs/site-lisp/org/ob-css hides /usr/share/emacs/24.3.50/lisp/org/ob-css
/usr/share/emacs/site-lisp/org/ob-lisp hides /usr/share/emacs/24.3.50/lisp/org/ob-lisp
/usr/share/emacs/site-lisp/org/org-irc hides /usr/share/emacs/24.3.50/lisp/org/org-irc
/usr/share/emacs/site-lisp/org/org-compat hides /usr/share/emacs/24.3.50/lisp/org/org-compat
/usr/share/emacs/site-lisp/org/ob-maxima hides /usr/share/emacs/24.3.50/lisp/org/ob-maxima
/usr/share/emacs/site-lisp/org/ob-scheme hides /usr/share/emacs/24.3.50/lisp/org/ob-scheme
/usr/share/emacs/site-lisp/org_contrib/lisp/org-mac-message hides /usr/share/emacs/24.3.50/lisp/org/org-mac-message
/usr/share/emacs/site-lisp/org/org-archive hides /usr/share/emacs/24.3.50/lisp/org/org-archive
/usr/share/emacs/site-lisp/org/ob-screen hides /usr/share/emacs/24.3.50/lisp/org/ob-screen
/usr/share/emacs/site-lisp/org/org-bibtex hides /usr/share/emacs/24.3.50/lisp/org/org-bibtex
/usr/share/emacs/site-lisp/org/ob-tangle hides /usr/share/emacs/24.3.50/lisp/org/ob-tangle
/usr/share/emacs/site-lisp/org/ob-plantuml hides /usr/share/emacs/24.3.50/lisp/org/ob-plantuml
/usr/share/emacs/site-lisp/org/org-faces hides /usr/share/emacs/24.3.50/lisp/org/org-faces
/usr/share/emacs/site-lisp/org/org-eshell hides /usr/share/emacs/24.3.50/lisp/org/org-eshell
/usr/share/emacs/site-lisp/org/ob-shen hides /usr/share/emacs/24.3.50/lisp/org/ob-shen
/usr/share/emacs/site-lisp/org/org-clock hides /usr/share/emacs/24.3.50/lisp/org/org-clock
/usr/share/emacs/site-lisp/org/org-mouse hides /usr/share/emacs/24.3.50/lisp/org/org-mouse
/usr/share/emacs/site-lisp/org/org-list hides /usr/share/emacs/24.3.50/lisp/org/org-list
/usr/share/emacs/site-lisp/org/org-pcomplete hides /usr/share/emacs/24.3.50/lisp/org/org-pcomplete
/usr/share/emacs/site-lisp/org/ob-clojure hides /usr/share/emacs/24.3.50/lisp/org/ob-clojure
/usr/share/emacs/site-lisp/org/ob-keys hides /usr/share/emacs/24.3.50/lisp/org/ob-keys
/usr/share/emacs/site-lisp/org/ob-haskell hides /usr/share/emacs/24.3.50/lisp/org/ob-haskell
/usr/share/emacs/site-lisp/org/org-rmail hides /usr/share/emacs/24.3.50/lisp/org/org-rmail
/usr/share/emacs/site-lisp/org/ob-perl hides /usr/share/emacs/24.3.50/lisp/org/ob-perl
/usr/share/emacs/site-lisp/org/org-docview hides /usr/share/emacs/24.3.50/lisp/org/org-docview
/usr/share/emacs/site-lisp/org/ob-python hides /usr/share/emacs/24.3.50/lisp/org/ob-python
/usr/share/emacs/site-lisp/org/org-inlinetask hides /usr/share/emacs/24.3.50/lisp/org/org-inlinetask
/usr/share/emacs/site-lisp/org/org-habit hides /usr/share/emacs/24.3.50/lisp/org/org-habit
/usr/share/emacs/site-lisp/org/ob-emacs-lisp hides /usr/share/emacs/24.3.50/lisp/org/ob-emacs-lisp
/usr/share/emacs/site-lisp/org/org-macs hides /usr/share/emacs/24.3.50/lisp/org/org-macs
/usr/share/emacs/site-lisp/org/ob-mscgen hides /usr/share/emacs/24.3.50/lisp/org/ob-mscgen
/usr/share/emacs/site-lisp/org/org-entities hides /usr/share/emacs/24.3.50/lisp/org/org-entities
/usr/share/emacs/site-lisp/org/org-src hides /usr/share/emacs/24.3.50/lisp/org/org-src
/usr/share/emacs/site-lisp/org/ob-ref hides /usr/share/emacs/24.3.50/lisp/org/ob-ref
/usr/share/emacs/site-lisp/org/org-mhe hides /usr/share/emacs/24.3.50/lisp/org/org-mhe
/usr/share/emacs/site-lisp/org/org-bbdb hides /usr/share/emacs/24.3.50/lisp/org/org-bbdb
/usr/share/emacs/site-lisp/org/org-table hides /usr/share/emacs/24.3.50/lisp/org/org-table
/usr/share/emacs/site-lisp/org/ob-scala hides /usr/share/emacs/24.3.50/lisp/org/ob-scala
/usr/share/emacs/site-lisp/org_contrib/lisp/org-mew hides /usr/share/emacs/24.3.50/lisp/org/org-mew
/usr/share/emacs/site-lisp/org/ob-comint hides /usr/share/emacs/24.3.50/lisp/org/ob-comint
/usr/share/emacs/site-lisp/org/org-mobile hides /usr/share/emacs/24.3.50/lisp/org/org-mobile
/usr/share/emacs/site-lisp/org/org-install hides /usr/share/emacs/24.3.50/lisp/org/org-install
/usr/share/emacs/site-lisp/org/org-crypt hides /usr/share/emacs/24.3.50/lisp/org/org-crypt
/usr/share/emacs/site-lisp/org/org-element hides /usr/share/emacs/24.3.50/lisp/org/org-element
/usr/share/emacs/site-lisp/org/ob-matlab hides /usr/share/emacs/24.3.50/lisp/org/ob-matlab
/usr/share/emacs/site-lisp/org/org-loaddefs hides /usr/share/emacs/24.3.50/lisp/org/org-loaddefs
/usr/share/emacs/site-lisp/org/org-agenda hides /usr/share/emacs/24.3.50/lisp/org/org-agenda
/usr/share/emacs/site-lisp/org/ob-ditaa hides /usr/share/emacs/24.3.50/lisp/org/ob-ditaa
/usr/share/emacs/site-lisp/org/ob-lilypond hides /usr/share/emacs/24.3.50/lisp/org/ob-lilypond
/usr/share/emacs/site-lisp/org/ob-java hides /usr/share/emacs/24.3.50/lisp/org/ob-java
/usr/share/emacs/site-lisp/org/org-protocol hides /usr/share/emacs/24.3.50/lisp/org/org-protocol
/usr/share/emacs/site-lisp/org/org-gnus hides /usr/share/emacs/24.3.50/lisp/org/org-gnus
/usr/share/emacs/site-lisp/org/org-w3m hides /usr/share/emacs/24.3.50/lisp/org/org-w3m
/usr/share/emacs/site-lisp/org/ob-org hides /usr/share/emacs/24.3.50/lisp/org/ob-org
/usr/share/emacs/site-lisp/org/ob-eval hides /usr/share/emacs/24.3.50/lisp/org/ob-eval
/usr/share/emacs/site-lisp/org/org-info hides /usr/share/emacs/24.3.50/lisp/org/org-info

Features:
(shadow sort mail-extr emacsbug message idna rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils mule-util
cal-move server erc-services erc-list erc-menu erc-join erc-ring
erc-networks erc-pcomplete erc-track erc-match erc-button wid-edit
erc-fill erc-stamp erc-netsplit erc-goodies erc erc-backend erc-compat
pp magit-cherry magit-bisect magit-key-mode magit magit-version
thingatpt log-edit pcvs-util add-log grep compile epa derived epg
epg-config diff-mode magit-compat auto-complete-config auto-complete
cl-macs gv popup cl calfw-ical url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util url-parse
auth-source eieio eieio-core gnus-util mm-util mail-prsvr password-cache
url-vars mailcap icalendar diary-lib diary-loaddefs calfw-org org-agenda
calfw edmacro kmacro cl-loaddefs cl-lib holidays hol-loaddefs ob-sh
shell ob-perl ob-latex ob-asymptote ob-gnuplot ox-latex ox-icalendar
ox-html ox-ascii ox-publish ox org-element org byte-opt warnings
bytecomp byte-compile cconv nadvice advice help-fns org-macro
org-footnote org-pcomplete pcomplete org-list org-faces org-entities
noutline outline easy-mmode org-version ob-emacs-lisp ob ob-tangle
org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint comint
ansi-color ring ob-core ob-eval org-compat org-macs org-loaddefs
format-spec find-func cal-menu calendar cal-loaddefs preview-latex
tex-site auto-loads ido quail help-mode easymenu time-date paren
cyril-util tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win
x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar 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 minibuffer loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)