Commit c5683ceb authored by Stefan Monnier's avatar Stefan Monnier

Introduce a new comment style "c" flag.

* src/syntax.c (SYNTAX_FLAGS_COMMENT_STYLEB)
(SYNTAX_FLAGS_COMMENT_STYLEC): New macros.
(SYNTAX_FLAGS_COMMENT_STYLE): Use them, add an argument.
(syntax_prefix_flag_p): New function.
(Fstring_to_syntax): Understand new "c" flag.
(Finternal_describe_syntax_value): Recognize new flag; use the
SYNTAX_FLAGS_* macros.
(scan_sexps_forward, Fparse_partial_sexp): Change representation of
comment style to accomodate the new styles.
(back_comment, forw_comment, Fforward_comment, scan_lists)
(scan_sexps_forward): Update code to obey the new comment style flag.
* src/syntax.h: Move SYNTAX_FLAGS_FOO() macros to syntax.c.
* src/casefiddle.c (casify_region): Use the new syntax_prefix_flag_p.
* lisp/progmodes/octave-mod.el (octave-mode-syntax-table): Use the new "c"
comment style.
* lisp/progmodes/scheme.el (scheme-mode-syntax-table):
* lisp/emacs-lisp/lisp-mode.el (lisp-mode-syntax-table): Remove spurious
"b" flag in "14b" syntax.

Fixes: debbugs:6834
parent 856a6b77
......@@ -424,6 +424,7 @@ has now been removed.
* Lisp changes in Emacs 24.1
** Syntax tables support a new "comment style c" additionally to style b.
** frame-local variables cannot be let-bound any more.
** prog-mode is a new major-mode meant to be the parent of programming mode.
** define-minor-mode accepts a new keyword :variable.
......
2010-08-12 Stefan Monnier <monnier@iro.umontreal.ca>
* progmodes/octave-mod.el (octave-mode-syntax-table): Use the new "c"
comment style (bug#6834).
* progmodes/scheme.el (scheme-mode-syntax-table):
* emacs-lisp/lisp-mode.el (lisp-mode-syntax-table): Remove spurious
"b" flag in "' 14b" syntax.
* progmodes/octave-mod.el (octave-mode-map): Remove special bindings
for (un)commenting the region and performing completion.
(octave-mode-menu): Use standard commands for help and completion.
......
......@@ -85,7 +85,7 @@
(let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
(modify-syntax-entry ?\[ "_ " table)
(modify-syntax-entry ?\] "_ " table)
(modify-syntax-entry ?# "' 14b" table)
(modify-syntax-entry ?# "' 14" table)
(modify-syntax-entry ?| "\" 23bn" table)
table)
"Syntax table used in `lisp-mode'.")
......
......@@ -294,17 +294,16 @@ parenthetical grouping.")
(modify-syntax-entry ?\" "\"" table)
(modify-syntax-entry ?. "w" table)
(modify-syntax-entry ?_ "w" table)
;; FIXME: The "b" flag only applies to the second letter of the comstart
;; The "b" flag only applies to the second letter of the comstart
;; and the first letter of the comend, i.e. the "4b" below is ineffective.
;; If we try to put `b' on the single-line comments, we get a similar
;; problem where the % and # chars appear as first chars of the 2-char
;; comend, so the multi-line ender is also turned into style-b.
;; Really, we can't make it work without extending the syntax-tables, or
;; via font-lock-syntactic-keywords.
;; So we need the new "c" comment style.
(modify-syntax-entry ?\% "< 13" table)
(modify-syntax-entry ?\# "< 13" table)
(modify-syntax-entry ?\{ "(} 2b" table)
(modify-syntax-entry ?\} "){ 4b" table)
(modify-syntax-entry ?\{ "(} 2c" table)
(modify-syntax-entry ?\} "){ 4c" table)
(modify-syntax-entry ?\n ">" table)
table)
"Syntax table in use in `octave-mode' buffers.")
......
......@@ -107,7 +107,7 @@
;; Special characters
(modify-syntax-entry ?, "' " st)
(modify-syntax-entry ?@ "' " st)
(modify-syntax-entry ?# "' 14b" st)
(modify-syntax-entry ?# "' 14" st)
(modify-syntax-entry ?\\ "\\ " st)
st))
......
2010-08-12 Stefan Monnier <monnier@iro.umontreal.ca>
Introduce a new comment style "c" flag.
* syntax.c (SYNTAX_FLAGS_COMMENT_STYLEB)
(SYNTAX_FLAGS_COMMENT_STYLEC): New macros.
(SYNTAX_FLAGS_COMMENT_STYLE): Use them, add an argument.
(syntax_prefix_flag_p): New function.
(Fstring_to_syntax): Understand new "c" flag.
(Finternal_describe_syntax_value): Recognize new flag; use the
SYNTAX_FLAGS_* macros.
(scan_sexps_forward, Fparse_partial_sexp): Change representation of
comment style to accomodate the new styles.
(back_comment, forw_comment, Fforward_comment, scan_lists)
(scan_sexps_forward): Update code to obey the new comment style flag.
* syntax.h: Move SYNTAX_FLAGS_FOO() macros to syntax.c.
* casefiddle.c (casify_region): Use the new syntax_prefix_flag_p.
2010-08-11 Jan Djärv <jan.h.d@swipnet.se>
* xfns.c (x_defined_color): If USE_GTK, call xg_check_special_colors
......@@ -21,8 +40,8 @@
* xselect.c (Fx_get_atom_name): Use char empty[] instead of literal "".
* xrdb.c (get_system_app): Make path const and use char *p for non-const
char.
* xrdb.c (get_system_app): Make path const and use char *p for
non-const char.
* xmenu.c (Fx_popup_dialog): error_name is const char*.
(xmenu_show): error parameter is const char **. pane_string is const
......@@ -80,9 +99,9 @@
2010-08-09 Dan Nicolaescu <dann@ics.uci.edu>
* font.h (font_parse_xlfd, font_parse_fcname, font_unparse_fcname)
(font_parse_name): font_open_by_name):
(font_parse_name, font_open_by_name):
* font.c (font_parse_xlfd, font_parse_fcname, font_unparse_fcname)
(font_parse_name): font_open_by_name): Remove const.
(font_parse_name, font_open_by_name): Remove const.
2010-08-09 Andreas Schwab <schwab@linux-m68k.org>
......@@ -205,17 +224,17 @@
* s/freebsd.h (DECLARE_GETPWUID_WITH_UID_T): Remove, unused.
* xrdb.c: Remove include guard. Remove
DECLARE_GETPWUID_WITH_UID_T conditional it had no effect.
* xrdb.c: Remove include guard.
Remove DECLARE_GETPWUID_WITH_UID_T conditional it had no effect.
Remove #if 0 code. Replace malloc->xmalloc, free->xfree,
realloc->xrealloc instead of using #defines.
2010-08-08 Eli Zaretskii <eliz@gnu.org>
* cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line):
* editfns.c (Fline_beginning_position, Fline_end_position): State
in the doc strings that start and end of line are in the logical
order.
* editfns.c (Fline_beginning_position, Fline_end_position):
State in the doc strings that start and end of line are in the
logical order.
* xdisp.c (display_line): Move the handling of overlay arrow after
the call to find_row_edges. (Bug#6699)
......
......@@ -243,7 +243,8 @@ casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e)
&& (!inword || flag != CASE_CAPITALIZE_UP))
c = UPCASE1 (c);
if ((int) flag >= (int) CASE_CAPITALIZE)
inword = ((SYNTAX (c) == Sword) && (inword || !SYNTAX_PREFIX (c)));
inword = ((SYNTAX (c) == Sword)
&& (inword || !syntax_prefix_flag_p (c)));
if (c != c2)
{
last = start;
......
This diff is collapsed.
......@@ -128,56 +128,9 @@ extern Lisp_Object syntax_temp;
: Qnil))
#endif
/* Then there are seven single-bit flags that have the following meanings:
1. This character is the first of a two-character comment-start sequence.
2. This character is the second of a two-character comment-start sequence.
3. This character is the first of a two-character comment-end sequence.
4. This character is the second of a two-character comment-end sequence.
5. This character is a prefix, for backward-prefix-chars.
6. see below
7. This character is part of a nestable comment sequence.
Note that any two-character sequence whose first character has flag 1
and whose second character has flag 2 will be interpreted as a comment start.
bit 6 is used to discriminate between two different comment styles.
Languages such as C++ allow two orthogonal syntax start/end pairs
and bit 6 is used to determine whether a comment-end or Scommentend
ends style a or b. Comment start sequences can start style a or b.
Style a is always the default.
*/
/* These macros extract a particular flag for a given character. */
#define SYNTAX_COMSTART_FIRST(c) ((SYNTAX_WITH_FLAGS (c) >> 16) & 1)
#define SYNTAX_COMSTART_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 17) & 1)
#define SYNTAX_COMEND_FIRST(c) ((SYNTAX_WITH_FLAGS (c) >> 18) & 1)
#define SYNTAX_COMEND_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 19) & 1)
#define SYNTAX_PREFIX(c) ((SYNTAX_WITH_FLAGS (c) >> 20) & 1)
#define SYNTAX_COMMENT_STYLE(c) ((SYNTAX_WITH_FLAGS (c) >> 21) & 1)
#define SYNTAX_COMMENT_NESTED(c) ((SYNTAX_WITH_FLAGS (c) >> 22) & 1)
/* These macros extract specific flags from an integer
that holds the syntax code and the flags. */
#define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1)
#define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1)
#define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1)
#define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1)
#define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1)
#define SYNTAX_FLAGS_COMMENT_STYLE(flags) (((flags) >> 21) & 1)
#define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1)
/* Whether the syntax of the character C has the prefix flag set. */
extern int syntax_prefix_flag_p (int c);
/* This array, indexed by a character, contains the syntax code which that
character signifies (as a char). For example,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment