aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.c
diff options
context:
space:
mode:
authorPaul Eggert2016-04-14 08:21:34 -0700
committerPaul Eggert2016-04-14 08:23:00 -0700
commit32364bbbaa8bda68228a3b0191c0b340c252d2a2 (patch)
tree4629f3a685ae49f87e075610915bd722fb70aa66 /src/doc.c
parent567ab529f313bc8fe68d25b2ca95f5987cce81a1 (diff)
downloademacs-32364bbbaa8bda68228a3b0191c0b340c252d2a2.tar.gz
emacs-32364bbbaa8bda68228a3b0191c0b340c252d2a2.zip
substitute-command-keys keeps quotes’ text props
Problem reported by Clément Pit--Claudel (Bug#23254). * src/doc.c: Include intervals.h. (Fsubstitute_command_keys): If the only substitutions are for quotes, copy the source string’s text properties too, since no substring lengths have changed.
Diffstat (limited to 'src/doc.c')
-rw-r--r--src/doc.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/doc.c b/src/doc.c
index 1d466612c66..7cdb0d03a81 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -34,6 +34,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
34#include "coding.h" 34#include "coding.h"
35#include "buffer.h" 35#include "buffer.h"
36#include "disptab.h" 36#include "disptab.h"
37#include "intervals.h"
37#include "keymap.h" 38#include "keymap.h"
38 39
39/* Buffer used for reading from documentation file. */ 40/* Buffer used for reading from documentation file. */
@@ -739,6 +740,7 @@ Otherwise, return a new string. */)
739{ 740{
740 char *buf; 741 char *buf;
741 bool changed = false; 742 bool changed = false;
743 bool nonquotes_changed = false;
742 unsigned char *strp; 744 unsigned char *strp;
743 char *bufp; 745 char *bufp;
744 ptrdiff_t idx; 746 ptrdiff_t idx;
@@ -786,7 +788,7 @@ Otherwise, return a new string. */)
786 { 788 {
787 /* \= quotes the next character; 789 /* \= quotes the next character;
788 thus, to put in \[ without its special meaning, use \=\[. */ 790 thus, to put in \[ without its special meaning, use \=\[. */
789 changed = true; 791 changed = nonquotes_changed = true;
790 strp += 2; 792 strp += 2;
791 if (multibyte) 793 if (multibyte)
792 { 794 {
@@ -946,6 +948,8 @@ Otherwise, return a new string. */)
946 length = SCHARS (tem); 948 length = SCHARS (tem);
947 length_byte = SBYTES (tem); 949 length_byte = SBYTES (tem);
948 subst: 950 subst:
951 nonquotes_changed = true;
952 subst_quote:
949 changed = true; 953 changed = true;
950 { 954 {
951 ptrdiff_t offset = bufp - buf; 955 ptrdiff_t offset = bufp - buf;
@@ -967,7 +971,7 @@ Otherwise, return a new string. */)
967 length = 1; 971 length = 1;
968 length_byte = sizeof uLSQM - 1; 972 length_byte = sizeof uLSQM - 1;
969 idx = strp - SDATA (string) + 1; 973 idx = strp - SDATA (string) + 1;
970 goto subst; 974 goto subst_quote;
971 } 975 }
972 else if (strp[0] == '`' && quoting_style == STRAIGHT_QUOTING_STYLE) 976 else if (strp[0] == '`' && quoting_style == STRAIGHT_QUOTING_STYLE)
973 { 977 {
@@ -1003,7 +1007,22 @@ Otherwise, return a new string. */)
1003 } 1007 }
1004 1008
1005 if (changed) /* don't bother if nothing substituted */ 1009 if (changed) /* don't bother if nothing substituted */
1006 tem = make_string_from_bytes (buf, nchars, bufp - buf); 1010 {
1011 tem = make_string_from_bytes (buf, nchars, bufp - buf);
1012 if (!nonquotes_changed)
1013 {
1014 /* Nothing has changed other than quoting, so copy the string’s
1015 text properties. FIXME: Text properties should survive other
1016 changes too. */
1017 INTERVAL interval_copy = copy_intervals (string_intervals (string),
1018 0, SCHARS (string));
1019 if (interval_copy)
1020 {
1021 set_interval_object (interval_copy, tem);
1022 set_string_intervals (tem, interval_copy);
1023 }
1024 }
1025 }
1007 else 1026 else
1008 tem = string; 1027 tem = string;
1009 xfree (buf); 1028 xfree (buf);