Support (locale-info 'paper) on GNU platforms

* configure.ac (HAVE_LANGINFO__NL_PAPER_WIDTH): New macro.
* src/fns.c (Flocale_info) [HAVE_LANGINFO__NL_PAPER_WIDTH]:
Get paper width and height from locale.
This commit is contained in:
Paul Eggert 2019-02-02 13:23:04 -08:00
parent 42c8399059
commit 713eece307
4 changed files with 33 additions and 20 deletions

View file

@ -4492,15 +4492,27 @@ fi
AC_SUBST(XGSELOBJ)
dnl Adapted from Haible's version.
AC_CACHE_CHECK([for nl_langinfo and CODESET], emacs_cv_langinfo_codeset,
AC_CACHE_CHECK([for nl_langinfo and CODESET], [emacs_cv_langinfo_codeset],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
[[char* cs = nl_langinfo(CODESET);]])],
emacs_cv_langinfo_codeset=yes,
emacs_cv_langinfo_codeset=no)
[[char *cs = nl_langinfo(CODESET);]])],
[emacs_cv_langinfo_codeset=yes],
[emacs_cv_langinfo_codeset=no])
])
if test $emacs_cv_langinfo_codeset = yes; then
AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
if test "$emacs_cv_langinfo_codeset" = yes; then
AC_DEFINE([HAVE_LANGINFO_CODESET], 1,
[Define if you have <langinfo.h> and nl_langinfo (CODESET).])
AC_CACHE_CHECK([for nl_langinfo and _NL_PAPER_WIDTH],
[emacs_cv_langinfo__nl_paper_width],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
[[char *cs = nl_langinfo (_NL_PAPER_WIDTH);]])],
[emacs_cv_langinfo__nl_paper_width=yes],
[emacs_cv_langinfo__nl_paper_width=no])
])
if test "$emacs_cv_langinfo__nl_paper_width" = yes; then
AC_DEFINE([HAVE_LANGINFO__NL_PAPER_WIDTH], 1,
[Define if you have <langinfo.h> and nl_langinfo (_NL_PAPER_WIDTH).])
fi
fi
AC_TYPE_MBSTATE_T

View file

@ -1527,6 +1527,9 @@ systems, the XRender extension to X11 is required for this to be
available; the configure script will test for it and, if found, enable
scaling.)
+++
** (locale-info 'paper) now returns the paper size on GNUish hosts.
The new function 'image-scaling-p' can be used to test whether any
given frame supports resizing.

View file

@ -2727,7 +2727,6 @@ See also `locale-charset-language-names', `locale-language-names',
(let ((paper (locale-info 'paper))
locale)
(if paper
;; This will always be null at the time of writing.
(cond
((equal paper '(216 279))
(setq ps-paper-type 'letter))

View file

@ -3118,8 +3118,8 @@ The data read from the system are decoded using `locale-coding-system'. */)
str = nl_langinfo (CODESET);
return build_string (str);
}
#ifdef DAY_1
else if (EQ (item, Qdays)) /* e.g. for calendar-day-name-array */
# ifdef DAY_1
if (EQ (item, Qdays)) /* E.g., for calendar-day-name-array. */
{
Lisp_Object v = make_nil_vector (7);
const int days[7] = {DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7};
@ -3136,9 +3136,9 @@ The data read from the system are decoded using `locale-coding-system'. */)
}
return v;
}
#endif /* DAY_1 */
#ifdef MON_1
else if (EQ (item, Qmonths)) /* e.g. for calendar-month-name-array */
# endif
# ifdef MON_1
if (EQ (item, Qmonths)) /* E.g., for calendar-month-name-array. */
{
Lisp_Object v = make_nil_vector (12);
const int months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7,
@ -3153,13 +3153,12 @@ The data read from the system are decoded using `locale-coding-system'. */)
}
return v;
}
#endif /* MON_1 */
/* LC_PAPER stuff isn't defined as accessible in glibc as of 2.3.1,
but is in the locale files. This could be used by ps-print. */
#ifdef PAPER_WIDTH
else if (EQ (item, Qpaper))
return list2i (nl_langinfo (PAPER_WIDTH), nl_langinfo (PAPER_HEIGHT));
#endif /* PAPER_WIDTH */
# endif
# ifdef HAVE_LANGINFO__NL_PAPER_WIDTH
if (EQ (item, Qpaper))
return list2i ((intptr_t) nl_langinfo (_NL_PAPER_WIDTH),
(intptr_t) nl_langinfo (_NL_PAPER_HEIGHT));
# endif
#endif /* HAVE_LANGINFO_CODESET*/
return Qnil;
}