Support (locale-info 'paper) on MS-Windows
* src/w32proc.c (LOCALE_IPAPERSIZE): Define if undefined. (nl_langinfo): Support _NL_PAPER_WIDTH and _NL_PAPER_HEIGHT like glibc does. * src/fns.c (Flocale_info): Update the doc string. * nt/inc/langinfo.h: Add _NL_PAPER_WIDTH and _NL_PAPER_HEIGHT to the enumeration. (_NL_PAPER_WIDTH, _NL_PAPER_HEIGHT): Define namesake macros. * nt/mingw-cfg.site (emacs_cv_langinfo__nl_paper_width): Set to 'yes'. * doc/lispref/nonascii.texi (Locales): Update the documentation of 'locale-info' for the argument of 'paper'. * etc/NEWS: Update the locale-info entry.
This commit is contained in:
parent
d5f629d193
commit
f37000aeb2
6 changed files with 52 additions and 10 deletions
|
@ -2115,9 +2115,9 @@ Return a 12-element vector of month names (locale items @code{MON_1}
|
|||
through @code{MON_12}).
|
||||
|
||||
@item paper
|
||||
Return a list @code{(@var{width} @var{height})} for the default paper
|
||||
size measured in millimeters (locale items @code{PAPER_WIDTH} and
|
||||
@code{PAPER_HEIGHT}).
|
||||
Return a list @w{@code{(@var{width} @var{height})}} of 2 integers, for
|
||||
the default paper size measured in millimeters (locale items
|
||||
@code{_NL_PAPER_WIDTH} and @code{_NL_PAPER_HEIGHT}).
|
||||
@end table
|
||||
|
||||
If the system can't provide the requested information, or if
|
||||
|
|
8
etc/NEWS
8
etc/NEWS
|
@ -1533,12 +1533,14 @@ 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.
|
||||
|
||||
+++
|
||||
** (locale-info 'paper) now returns the paper size on systems that support it.
|
||||
This is currently supported on GNUish hosts and on modern versions of
|
||||
MS-Windows.
|
||||
|
||||
|
||||
* Changes in Emacs 27.1 on Non-Free Operating Systems
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ enum {
|
|||
DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7,
|
||||
MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7, MON_8, MON_9, MON_10,
|
||||
MON_11, MON_12,
|
||||
_NL_PAPER_WIDTH, _NL_PAPER_HEIGHT,
|
||||
|
||||
/* Number of enumerated values. */
|
||||
_NL_NUM
|
||||
|
@ -55,6 +56,9 @@ enum {
|
|||
#define MON_11 MON_11
|
||||
#define MON_12 MON_12
|
||||
|
||||
#define _NL_PAPER_WIDTH _NL_PAPER_WIDTH
|
||||
#define _NL_PAPER_HEIGHT _NL_PAPER_HEIGHT
|
||||
|
||||
extern char *nl_langinfo (nl_item);
|
||||
|
||||
#endif /* _LANGINFO_H */
|
||||
|
|
|
@ -109,6 +109,7 @@ gl_cv_func_pthread_sigmask_return_works=yes
|
|||
gl_cv_func_pthread_sigmask_unblock_works="not relevant"
|
||||
# Implemented in w32proc.c
|
||||
emacs_cv_langinfo_codeset=yes
|
||||
emacs_cv_langinfo__nl_paper_width=yes
|
||||
# Declared in ms-w32.h
|
||||
ac_cv_have_decl_alarm=yes
|
||||
# Avoid including the gnulib dup2 module
|
||||
|
|
|
@ -3100,8 +3100,9 @@ ITEM should be one of the following:
|
|||
|
||||
`months', returning a 12-element vector of month names (locale items MON_n);
|
||||
|
||||
`paper', returning a list (WIDTH HEIGHT) for the default paper size,
|
||||
both measured in millimeters (locale items PAPER_WIDTH, PAPER_HEIGHT).
|
||||
`paper', returning a list of 2 integers (WIDTH HEIGHT) for the default
|
||||
paper size, both measured in millimeters (locale items _NL_PAPER_WIDTH,
|
||||
_NL_PAPER_HEIGHT).
|
||||
|
||||
If the system can't provide such information through a call to
|
||||
`nl_langinfo', or if ITEM isn't from the list above, return nil.
|
||||
|
|
|
@ -3248,6 +3248,12 @@ such programs cannot be invoked by Emacs anyway. */)
|
|||
}
|
||||
|
||||
#ifdef HAVE_LANGINFO_CODESET
|
||||
|
||||
/* If we are compiling for compatibility with older 32-bit Windows
|
||||
versions, this might not be defined by the Windows headers. */
|
||||
#ifndef LOCALE_IPAPERSIZE
|
||||
# define LOCALE_IPAPERSIZE 0x100A
|
||||
#endif
|
||||
/* Emulation of nl_langinfo. Used in fns.c:Flocale_info. */
|
||||
char *
|
||||
nl_langinfo (nl_item item)
|
||||
|
@ -3260,7 +3266,8 @@ nl_langinfo (nl_item item)
|
|||
LOCALE_SMONTHNAME1, LOCALE_SMONTHNAME2, LOCALE_SMONTHNAME3,
|
||||
LOCALE_SMONTHNAME4, LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6,
|
||||
LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8, LOCALE_SMONTHNAME9,
|
||||
LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12
|
||||
LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12,
|
||||
LOCALE_IPAPERSIZE, LOCALE_IPAPERSIZE
|
||||
};
|
||||
|
||||
static char *nl_langinfo_buf = NULL;
|
||||
|
@ -3269,6 +3276,8 @@ nl_langinfo (nl_item item)
|
|||
if (nl_langinfo_len <= 0)
|
||||
nl_langinfo_buf = xmalloc (nl_langinfo_len = 1);
|
||||
|
||||
char *retval = nl_langinfo_buf;
|
||||
|
||||
if (item < 0 || item >= _NL_NUM)
|
||||
nl_langinfo_buf[0] = 0;
|
||||
else
|
||||
|
@ -3290,6 +3299,8 @@ nl_langinfo (nl_item item)
|
|||
if (nl_langinfo_len <= need_len)
|
||||
nl_langinfo_buf = xrealloc (nl_langinfo_buf,
|
||||
nl_langinfo_len = need_len);
|
||||
retval = nl_langinfo_buf;
|
||||
|
||||
if (!GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP,
|
||||
nl_langinfo_buf, nl_langinfo_len))
|
||||
nl_langinfo_buf[0] = 0;
|
||||
|
@ -3306,9 +3317,32 @@ nl_langinfo (nl_item item)
|
|||
nl_langinfo_buf[1] = 'p';
|
||||
}
|
||||
}
|
||||
else if (item == _NL_PAPER_WIDTH || item == _NL_PAPER_HEIGHT)
|
||||
{
|
||||
static const int paper_size[][2] =
|
||||
{
|
||||
{ -1, -1 },
|
||||
{ 216, 279 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 216, 356 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 297, 420 },
|
||||
{ 210, 297 }
|
||||
};
|
||||
int idx = atoi (nl_langinfo_buf);
|
||||
if (0 <= idx && idx < ARRAYELTS (paper_size))
|
||||
retval = (char *)(intptr_t) (item == _NL_PAPER_WIDTH
|
||||
? paper_size[idx][0]
|
||||
: paper_size[idx][1]);
|
||||
else
|
||||
retval = (char *)(intptr_t) -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nl_langinfo_buf;
|
||||
return retval;
|
||||
}
|
||||
#endif /* HAVE_LANGINFO_CODESET */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue