aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorJacob S. Gordon2025-05-19 15:05:37 -0400
committerEli Zaretskii2025-06-14 17:07:19 +0300
commit5bd9fa084dcf0ce8efaaf9212c24addec48d824f (patch)
treee032a62cd687f5a15d24595684bfd1d16647e0ae /doc/misc
parent82766b71a45a691e19386422d3a12a3e0321b2e8 (diff)
downloademacs-5bd9fa084dcf0ce8efaaf9212c24addec48d824f.tar.gz
emacs-5bd9fa084dcf0ce8efaaf9212c24addec48d824f.zip
calc: Allow strings with character codes above Latin-1
The current behavior of the functions 'calc-display-strings', 'strings', and 'bstrings' is to skip any vector containing integers outside the Latin-1 range (0x00-0xFF). We introduce a custom variable 'calc-string-maximum-character' to replace this hard-coded maximum, and to allow vectors containing higher character codes to be displayed as strings. The default value of 0xFF preserves the existing behavior. * lisp/calc/calc.el (calc-string-maximum-character): Add custom variable 'calc-string-maximum-character'. * lisp/calc/calccomp.el (math-vector-is-string): Replace hard-coded maximum with 'calc-string-maximum-character', and the 'natnump' assertion with 'characterp'. The latter guards against the maximum being larger than '(max-char)', but not on invalid types of the maximum such as strings. * test/lisp/calc/calc-tests.el (calc-math-vector-is-string): Add tests for 'math-vector-is-string' using different values of 'calc-string-maximum-character'. * doc/misc/calc.texi (Quick Calculator, Strings, Customizing Calc): Add variable definition for 'calc-string-maximum-character' and reference thereof when discussing 'calc-display-strings'. Generalize a comment about string display and availability of 8-bit fonts. (Bug#78528)
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/calc.texi56
1 files changed, 43 insertions, 13 deletions
diff --git a/doc/misc/calc.texi b/doc/misc/calc.texi
index 61466b55201..eda442ecb38 100644
--- a/doc/misc/calc.texi
+++ b/doc/misc/calc.texi
@@ -10179,7 +10179,7 @@ result @samp{[120]} (because 120 is the ASCII code of the lower-case
10179is displayed only according to the current mode settings. But 10179is displayed only according to the current mode settings. But
10180running Quick Calc again and entering @samp{120} will produce the 10180running Quick Calc again and entering @samp{120} will produce the
10181result @samp{120 (16#78, 8#170, x)} which shows the number in its 10181result @samp{120 (16#78, 8#170, x)} which shows the number in its
10182decimal, hexadecimal, octal, and ASCII forms. 10182decimal, hexadecimal, octal, and character forms.
10183 10183
10184Please note that the Quick Calculator is not any faster at loading 10184Please note that the Quick Calculator is not any faster at loading
10185or computing the answer than the full Calculator; the name ``quick'' 10185or computing the answer than the full Calculator; the name ``quick''
@@ -10836,11 +10836,11 @@ from 1 to @samp{n}.
10836@cindex Strings 10836@cindex Strings
10837@cindex Character strings 10837@cindex Character strings
10838Character strings are not a special data type in the Calculator. 10838Character strings are not a special data type in the Calculator.
10839Rather, a string is represented simply as a vector all of whose 10839Rather, a string is represented simply as a vector all of whose elements
10840elements are integers in the range 0 to 255 (ASCII codes). You can 10840are integers in the Latin-1 range 0 to 255. You can enter a string at
10841enter a string at any time by pressing the @kbd{"} key. Quotation 10841any time by pressing the @kbd{"} key. Quotation marks and backslashes
10842marks and backslashes are written @samp{\"} and @samp{\\}, respectively, 10842are written @samp{\"} and @samp{\\}, respectively, inside strings.
10843inside strings. Other notations introduced by backslashes are: 10843Other notations introduced by backslashes are:
10844 10844
10845@example 10845@example
10846@group 10846@group
@@ -10857,21 +10857,24 @@ inside strings. Other notations introduced by backslashes are:
10857 10857
10858@noindent 10858@noindent
10859Finally, a backslash followed by three octal digits produces any 10859Finally, a backslash followed by three octal digits produces any
10860character from its ASCII code. 10860character from its code.
10861 10861
10862@kindex d " 10862@kindex d "
10863@pindex calc-display-strings 10863@pindex calc-display-strings
10864Strings are normally displayed in vector-of-integers form. The 10864Strings are normally displayed in vector-of-integers form. The
10865@w{@kbd{d "}} (@code{calc-display-strings}) command toggles a mode in 10865@w{@kbd{d "}} (@code{calc-display-strings}) command toggles a mode in
10866which any vectors of small integers are displayed as quoted strings 10866which any vectors of small integers are displayed as quoted strings
10867instead. 10867instead. The display of strings containing higher character codes can
10868be enabled by increasing the custom variable
10869@code{calc-string-maximum-character} (@pxref{Customizing Calc}).
10868 10870
10869The backslash notations shown above are also used for displaying 10871The backslash notations shown above are also used for displaying
10870strings. Characters 128 and above are not translated by Calc; unless 10872strings. For ASCII control characters (below 32), and for the
10871you have an Emacs modified for 8-bit fonts, these will show up in 10873@code{DEL} character (127), Calc uses the backslash-letter combination
10872backslash-octal-digits notation. For characters below 32, and 10874if there is one, or otherwise uses a @samp{\^} sequence. Control
10873for character 127, Calc uses the backslash-letter combination if 10875characters above 127 are not translated by Calc, and will show up in
10874there is one, or otherwise uses a @samp{\^} sequence. 10876backslash-octal-digits notation. The display of higher character codes
10877will depend on your display settings and system font coverage.
10875 10878
10876The only Calc feature that uses strings is @dfn{compositions}; 10879The only Calc feature that uses strings is @dfn{compositions};
10877@pxref{Compositions}. Strings also provide a convenient 10880@pxref{Compositions}. Strings also provide a convenient
@@ -35684,6 +35687,33 @@ choose from, or the user can enter their own date.
35684The default value of @code{calc-gregorian-switch} is @code{nil}. 35687The default value of @code{calc-gregorian-switch} is @code{nil}.
35685@end defvar 35688@end defvar
35686 35689
35690@defvar calc-string-maximum-character
35691@xref{Strings}.@*
35692
35693The variable @code{calc-string-maximum-character} is the maximum value
35694of a vector's elements for @code{calc-display-strings}, @code{string},
35695and @code{bstring} to display the vector as a string. This maximum
35696@emph{must} represent a character, i.e. it's a non-negative integer less
35697than or equal to @code{(max-char)} or @code{0x3FFFFF}. Any negative
35698value effectively disables the display of strings, and for values larger
35699than @code{0x3FFFFF} the display acts as if the maximum were
35700@code{0x3FFFFF}. Some natural choices (and their resulting ranges) are:
35701
35702@itemize
35703@item
35704@code{0x7F} or 127 (ASCII),
35705@item
35706@code{0xFF} or 255 (Latin-1, the default),
35707@item
35708@code{0x10FFFF} (Unicode),
35709@item
35710@code{0x3FFFFF} (Emacs).
35711@end itemize
35712
35713The default value of @code{calc-string-maximum-character} is @code{0xFF}
35714or 255.
35715@end defvar
35716
35687@node Reporting Bugs 35717@node Reporting Bugs
35688@appendix Reporting Bugs 35718@appendix Reporting Bugs
35689 35719