diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/callint.c | 1 | ||||
| -rw-r--r-- | src/doc.c | 62 | ||||
| -rw-r--r-- | src/editfns.c | 5 |
3 files changed, 66 insertions, 2 deletions
diff --git a/src/callint.c b/src/callint.c index 2ff2f80d740..be0fb1a84df 100644 --- a/src/callint.c +++ b/src/callint.c | |||
| @@ -511,6 +511,7 @@ invoke it. If KEYS is omitted or nil, the return value of | |||
| 511 | for (i = 2; *tem; i++) | 511 | for (i = 2; *tem; i++) |
| 512 | { | 512 | { |
| 513 | visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n")); | 513 | visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n")); |
| 514 | visargs[1] = Finternal__text_restyle (visargs[1]); | ||
| 514 | if (strchr (SSDATA (visargs[1]), '%')) | 515 | if (strchr (SSDATA (visargs[1]), '%')) |
| 515 | callint_message = Fformat (i - 1, visargs + 1); | 516 | callint_message = Fformat (i - 1, visargs + 1); |
| 516 | else | 517 | else |
| @@ -1028,6 +1028,67 @@ Otherwise, return a new string. */) | |||
| 1028 | xfree (buf); | 1028 | xfree (buf); |
| 1029 | RETURN_UNGCPRO (tem); | 1029 | RETURN_UNGCPRO (tem); |
| 1030 | } | 1030 | } |
| 1031 | |||
| 1032 | DEFUN ("internal--text-restyle", Finternal__text_restyle, | ||
| 1033 | Sinternal__text_restyle, 1, 1, 0, | ||
| 1034 | doc: /* Return STRING, possibly substituting quote characters. | ||
| 1035 | |||
| 1036 | In the result, replace each curved single quote (\\=‘ and \\=’) by | ||
| 1037 | left and right quote characters as specified by ‘text-quoting-style’. | ||
| 1038 | |||
| 1039 | Return the original STRING in the common case where no changes are needed. | ||
| 1040 | Otherwise, return a new string. */) | ||
| 1041 | (Lisp_Object string) | ||
| 1042 | { | ||
| 1043 | bool changed = false; | ||
| 1044 | |||
| 1045 | CHECK_STRING (string); | ||
| 1046 | if (! STRING_MULTIBYTE (string)) | ||
| 1047 | return string; | ||
| 1048 | |||
| 1049 | enum text_quoting_style quoting_style = text_quoting_style (); | ||
| 1050 | if (quoting_style == CURVE_QUOTING_STYLE) | ||
| 1051 | return string; | ||
| 1052 | |||
| 1053 | ptrdiff_t bsize = SBYTES (string); | ||
| 1054 | unsigned char const *strp = SDATA (string); | ||
| 1055 | unsigned char const *strlim = strp + bsize; | ||
| 1056 | USE_SAFE_ALLOCA; | ||
| 1057 | char *buf = SAFE_ALLOCA (bsize); | ||
| 1058 | char *bufp = buf; | ||
| 1059 | ptrdiff_t nchars = 0; | ||
| 1060 | |||
| 1061 | while (strp < strlim) | ||
| 1062 | { | ||
| 1063 | unsigned char const *cp = strp; | ||
| 1064 | switch (STRING_CHAR_ADVANCE (strp)) | ||
| 1065 | { | ||
| 1066 | case LEFT_SINGLE_QUOTATION_MARK: | ||
| 1067 | *bufp++ = quoting_style == GRAVE_QUOTING_STYLE ? '`': '\''; | ||
| 1068 | changed = true; | ||
| 1069 | break; | ||
| 1070 | |||
| 1071 | case RIGHT_SINGLE_QUOTATION_MARK: | ||
| 1072 | *bufp++ = '\''; | ||
| 1073 | changed = true; | ||
| 1074 | break; | ||
| 1075 | |||
| 1076 | default: | ||
| 1077 | do | ||
| 1078 | *bufp++ = *cp++; | ||
| 1079 | while (cp != strp); | ||
| 1080 | |||
| 1081 | break; | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | nchars++; | ||
| 1085 | } | ||
| 1086 | |||
| 1087 | Lisp_Object result | ||
| 1088 | = changed ? make_string_from_bytes (buf, nchars, bufp - buf) : string; | ||
| 1089 | SAFE_FREE (); | ||
| 1090 | return result; | ||
| 1091 | } | ||
| 1031 | 1092 | ||
| 1032 | void | 1093 | void |
| 1033 | syms_of_doc (void) | 1094 | syms_of_doc (void) |
| @@ -1061,4 +1122,5 @@ displayable, and like ‘grave’ otherwise. */); | |||
| 1061 | defsubr (&Sdocumentation_property); | 1122 | defsubr (&Sdocumentation_property); |
| 1062 | defsubr (&Ssnarf_documentation); | 1123 | defsubr (&Ssnarf_documentation); |
| 1063 | defsubr (&Ssubstitute_command_keys); | 1124 | defsubr (&Ssubstitute_command_keys); |
| 1125 | defsubr (&Sinternal__text_restyle); | ||
| 1064 | } | 1126 | } |
diff --git a/src/editfns.c b/src/editfns.c index 8ac0ef16999..da7d554fd94 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3696,8 +3696,8 @@ usage: (message FORMAT-STRING &rest ARGS) */) | |||
| 3696 | } | 3696 | } |
| 3697 | else | 3697 | else |
| 3698 | { | 3698 | { |
| 3699 | register Lisp_Object val; | 3699 | args[0] = Finternal__text_restyle (args[0]); |
| 3700 | val = Fformat (nargs, args); | 3700 | Lisp_Object val = Fformat (nargs, args); |
| 3701 | message3 (val); | 3701 | message3 (val); |
| 3702 | return val; | 3702 | return val; |
| 3703 | } | 3703 | } |
| @@ -3722,6 +3722,7 @@ usage: (message-box FORMAT-STRING &rest ARGS) */) | |||
| 3722 | } | 3722 | } |
| 3723 | else | 3723 | else |
| 3724 | { | 3724 | { |
| 3725 | args[0] = Finternal__text_restyle (args[0]); | ||
| 3725 | Lisp_Object val = Fformat (nargs, args); | 3726 | Lisp_Object val = Fformat (nargs, args); |
| 3726 | Lisp_Object pane, menu; | 3727 | Lisp_Object pane, menu; |
| 3727 | struct gcpro gcpro1; | 3728 | struct gcpro gcpro1; |