aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
authorStefan Monnier2010-12-06 11:37:26 -0500
committerStefan Monnier2010-12-06 11:37:26 -0500
commitbba3e50834d3957fe2b6f345075a6f38839de4bc (patch)
tree8fb0a1cd741c2e9329e9323db8db6366d37ab8f3 /src/lread.c
parent7454326ab9058b94b956d8c2ac3d3f340281467d (diff)
downloademacs-bba3e50834d3957fe2b6f345075a6f38839de4bc.tar.gz
emacs-bba3e50834d3957fe2b6f345075a6f38839de4bc.zip
* src/lread.c (read1): Allow newstyle unquote outside of backquote.
Disallow old-style backquotes inside new-style backquotes. Don't count unquotes to figure out when we're "syntactically inside but semantically outside of a backquote" any more. Extend the restriction no-unescaped-commas-and-backquotes-in-symbols to all contexts.
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c98
1 files changed, 46 insertions, 52 deletions
diff --git a/src/lread.c b/src/lread.c
index bfe3755cc51..c7b8e70963f 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2637,7 +2637,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2637 old-style. For Emacs-25, we should completely remove this 2637 old-style. For Emacs-25, we should completely remove this
2638 first_in_list exception (old-style can still be obtained via 2638 first_in_list exception (old-style can still be obtained via
2639 "(\`" anyway). */ 2639 "(\`" anyway). */
2640 if (first_in_list && next_char == ' ') 2640 if (!new_backquote_flag && first_in_list && next_char == ' ')
2641 { 2641 {
2642 Vold_style_backquotes = Qt; 2642 Vold_style_backquotes = Qt;
2643 goto default_label; 2643 goto default_label;
@@ -2654,33 +2654,48 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2654 } 2654 }
2655 } 2655 }
2656 case ',': 2656 case ',':
2657 if (new_backquote_flag) 2657 {
2658 { 2658 int next_char = READCHAR;
2659 Lisp_Object comma_type = Qnil; 2659 UNREAD (next_char);
2660 Lisp_Object value; 2660 /* Transition from old-style to new-style:
2661 int ch = READCHAR; 2661 It used to be impossible to have a new-style , other than within
2662 2662 a new-style `. This is sufficient when ` and , are used in the
2663 if (ch == '@') 2663 normal way, but ` and , can also appear in args to macros that
2664 comma_type = Qcomma_at; 2664 will not interpret them in the usual way, in which case , may be
2665 else if (ch == '.') 2665 used without any ` anywhere near.
2666 comma_type = Qcomma_dot; 2666 So we now use the same heuristic as for backquote: old-style
2667 else 2667 unquotes are only recognized when first on a list, and when
2668 { 2668 followed by a space.
2669 if (ch >= 0) UNREAD (ch); 2669 Because it's more difficult to peak 2 chars ahead, a new-style
2670 comma_type = Qcomma; 2670 ,@ can still not be used outside of a `, unless it's in the middle
2671 } 2671 of a list. */
2672 if (new_backquote_flag
2673 || !first_in_list
2674 || (next_char != ' ' && next_char != '@'))
2675 {
2676 Lisp_Object comma_type = Qnil;
2677 Lisp_Object value;
2678 int ch = READCHAR;
2672 2679
2673 new_backquote_flag--; 2680 if (ch == '@')
2674 value = read0 (readcharfun); 2681 comma_type = Qcomma_at;
2675 new_backquote_flag++; 2682 else if (ch == '.')
2676 return Fcons (comma_type, Fcons (value, Qnil)); 2683 comma_type = Qcomma_dot;
2677 } 2684 else
2678 else 2685 {
2679 { 2686 if (ch >= 0) UNREAD (ch);
2680 Vold_style_backquotes = Qt; 2687 comma_type = Qcomma;
2681 goto default_label; 2688 }
2682 }
2683 2689
2690 value = read0 (readcharfun);
2691 return Fcons (comma_type, Fcons (value, Qnil));
2692 }
2693 else
2694 {
2695 Vold_style_backquotes = Qt;
2696 goto default_label;
2697 }
2698 }
2684 case '?': 2699 case '?':
2685 { 2700 {
2686 int modifiers; 2701 int modifiers;
@@ -2707,26 +2722,9 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2707 c |= modifiers; 2722 c |= modifiers;
2708 2723
2709 next_char = READCHAR; 2724 next_char = READCHAR;
2710 if (next_char == '.') 2725 ok = (next_char <= 040
2711 { 2726 || (next_char < 0200
2712 /* Only a dotted-pair dot is valid after a char constant. */ 2727 && (strchr ("\"';()[]#?`,.", next_char))));
2713 int next_next_char = READCHAR;
2714 UNREAD (next_next_char);
2715
2716 ok = (next_next_char <= 040
2717 || (next_next_char < 0200
2718 && (strchr ("\"';([#?", next_next_char)
2719 || (!first_in_list && next_next_char == '`')
2720 || (new_backquote_flag && next_next_char == ','))));
2721 }
2722 else
2723 {
2724 ok = (next_char <= 040
2725 || (next_char < 0200
2726 && (strchr ("\"';()[]#?", next_char)
2727 || (!first_in_list && next_char == '`')
2728 || (new_backquote_flag && next_char == ','))));
2729 }
2730 UNREAD (next_char); 2728 UNREAD (next_char);
2731 if (ok) 2729 if (ok)
2732 return make_number (c); 2730 return make_number (c);
@@ -2868,9 +2866,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2868 2866
2869 if (next_char <= 040 2867 if (next_char <= 040
2870 || (next_char < 0200 2868 || (next_char < 0200
2871 && (strchr ("\"';([#?", next_char) 2869 && (strchr ("\"';([#?`,", next_char))))
2872 || (!first_in_list && next_char == '`')
2873 || (new_backquote_flag && next_char == ','))))
2874 { 2870 {
2875 *pch = c; 2871 *pch = c;
2876 return Qnil; 2872 return Qnil;
@@ -2895,9 +2891,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2895 while (c > 040 2891 while (c > 040
2896 && c != 0x8a0 /* NBSP */ 2892 && c != 0x8a0 /* NBSP */
2897 && (c >= 0200 2893 && (c >= 0200
2898 || (!strchr ("\"';()[]#", c) 2894 || !(strchr ("\"';()[]#`,", c))))
2899 && !(!first_in_list && c == '`')
2900 && !(new_backquote_flag && c == ','))))
2901 { 2895 {
2902 if (end - p < MAX_MULTIBYTE_LENGTH) 2896 if (end - p < MAX_MULTIBYTE_LENGTH)
2903 { 2897 {