Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 101060. ------------------------------------------------------------ revno: 101060 committer: Jan D branch nick: trunk timestamp: Fri 2010-08-13 08:57:12 +0200 message: Fix typo. diff: === modified file 'etc/NEWS' --- etc/NEWS 2010-08-12 14:44:16 +0000 +++ etc/NEWS 2010-08-13 06:57:12 +0000 @@ -106,7 +106,7 @@ ** GTK tool bars can be placed on the left/right or top/bottom of the frame. The frame-parameter tool-bar-position controls this. It takes the values -top, left, tight or bottom. The Options => Show/Hide menu has entries +top, left, right or bottom. The Options => Show/Hide menu has entries for this. ** The colors for selected text (the region face) are taken from the GTK ------------------------------------------------------------ revno: 101059 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2010-08-12 16:44:16 +0200 message: 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. diff: === modified file 'etc/NEWS' --- etc/NEWS 2010-08-11 18:28:10 +0000 +++ etc/NEWS 2010-08-12 14:44:16 +0000 @@ -424,6 +424,7 @@ * 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. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-08-12 12:46:24 +0000 +++ lisp/ChangeLog 2010-08-12 14:44:16 +0000 @@ -1,5 +1,11 @@ 2010-08-12 Stefan Monnier + * 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. === modified file 'lisp/emacs-lisp/lisp-mode.el' --- lisp/emacs-lisp/lisp-mode.el 2010-05-14 16:41:01 +0000 +++ lisp/emacs-lisp/lisp-mode.el 2010-08-12 14:44:16 +0000 @@ -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'.") === modified file 'lisp/progmodes/octave-mod.el' --- lisp/progmodes/octave-mod.el 2010-08-12 12:46:24 +0000 +++ lisp/progmodes/octave-mod.el 2010-08-12 14:44:16 +0000 @@ -294,17 +294,16 @@ (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.") === modified file 'lisp/progmodes/scheme.el' --- lisp/progmodes/scheme.el 2010-01-13 08:35:10 +0000 +++ lisp/progmodes/scheme.el 2010-08-12 14:44:16 +0000 @@ -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)) === modified file 'src/ChangeLog' --- src/ChangeLog 2010-08-11 18:47:34 +0000 +++ src/ChangeLog 2010-08-12 14:44:16 +0000 @@ -1,3 +1,22 @@ +2010-08-12 Stefan Monnier + + 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 * 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 * 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 @@ -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 * 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) === modified file 'src/casefiddle.c' --- src/casefiddle.c 2010-07-08 21:25:08 +0000 +++ src/casefiddle.c 2010-08-12 14:44:16 +0000 @@ -243,7 +243,8 @@ && (!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; === modified file 'src/syntax.c' --- src/syntax.c 2010-07-12 17:47:17 +0000 +++ src/syntax.c 2010-08-12 14:44:16 +0000 @@ -34,6 +34,60 @@ #include "syntax.h" #include "intervals.h" +#include "category.h" + +/* 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. The char is part of a delimiter for comments of style "b". + 7. This character is part of a nestable comment sequence. + 8. The char is part of a delimiter for comments of style "c". + 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 and 8 are used to discriminate between 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 markers can start style a, b, c, or bc. + Style a is always the default. + For 2-char comment markers, the style b flag is only looked up on the second + char of the comment marker and on the first char of the comment ender. + For style c (like to for the nested flag), the flag can be placed on any + one of the chars. + */ + +/* 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_STYLEB(flags) (((flags) >> 21) & 1) +#define SYNTAX_FLAGS_COMMENT_STYLEC(flags) (((flags) >> 22) & 2) +/* FLAGS should be the flags of the main char of the comment marker, e.g. + the second for comstart and the first for comend. */ +#define SYNTAX_FLAGS_COMMENT_STYLE(flags, other_flags) \ + (SYNTAX_FLAGS_COMMENT_STYLEB (flags) \ + | SYNTAX_FLAGS_COMMENT_STYLEC (flags) \ + | SYNTAX_FLAGS_COMMENT_STYLEC (other_flags)) + +#define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1) + +/* These macros extract a particular flag for a given character. */ + +#define SYNTAX_COMEND_FIRST(c) \ + (SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c))) +#define SYNTAX_PREFIX(c) (SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c))) /* We use these constants in place for comment-style and string-ender-char to distinguish comments/strings started by @@ -41,7 +95,6 @@ #define ST_COMMENT_STYLE (256 + 1) #define ST_STRING_STYLE (256 + 2) -#include "category.h" Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; @@ -106,6 +159,11 @@ int, Lisp_Object, int); static int in_classes (int, Lisp_Object); +/* Whether the syntax of the character C has the prefix flag set. */ +int syntax_prefix_flag_p (int c) +{ + return SYNTAX_PREFIX (c); +} struct gl_state_s gl_state; /* Global state of syntax parser. */ @@ -514,7 +572,8 @@ /* Check for 2-char comment markers. */ com2start = (SYNTAX_FLAGS_COMSTART_FIRST (syntax) && SYNTAX_FLAGS_COMSTART_SECOND (prev_syntax) - && comstyle == SYNTAX_FLAGS_COMMENT_STYLE (prev_syntax) + && (comstyle + == SYNTAX_FLAGS_COMMENT_STYLE (prev_syntax, syntax)) && (SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax) || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested); com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax) @@ -543,7 +602,8 @@ && SYNTAX_FLAGS_COMEND_FIRST (next_syntax)) || ((com2end || comnested) && SYNTAX_FLAGS_COMSTART_SECOND (syntax) - && comstyle == SYNTAX_FLAGS_COMMENT_STYLE (syntax) + && (comstyle + == SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_syntax)) && SYNTAX_FLAGS_COMSTART_FIRST (next_syntax))) goto lossage; /* UPDATE_SYNTAX_TABLE_FORWARD (next + 1); */ @@ -563,7 +623,7 @@ code = Scomment; /* Ignore comment starters of a different style. */ else if (code == Scomment - && (comstyle != SYNTAX_FLAGS_COMMENT_STYLE (syntax) + && (comstyle != SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) || SYNTAX_FLAGS_COMMENT_NESTED (syntax) != comnested)) continue; @@ -613,7 +673,7 @@ break; case Sendcomment: - if (SYNTAX_FLAGS_COMMENT_STYLE (syntax) == comstyle + if (SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == comstyle && ((com2end && SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax)) || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested) /* This is the same style of comment ender as ours. */ @@ -930,6 +990,10 @@ case 'n': val |= 1 << 22; break; + + case 'c': + val |= 1 << 23; + break; } if (val < XVECTOR (Vsyntax_code_object)->size && NILP (match)) @@ -969,12 +1033,13 @@ 3 means CHAR is the start of a two-char comment end sequence. 4 means CHAR is the second character of such a sequence. -There can be up to two orthogonal comment sequences. This is to support +There can be several orthogonal comment sequences. This is to support language modes such as C++. By default, all comment sequences are of style a, but you can set the comment sequence style to b (on the second character -of a comment-start, or the first character of a comment-end sequence) using -this flag: +of a comment-start, and the first character of a comment-end sequence) and/or +c (on any of its chars) using this flag: b means CHAR is part of comment sequence b. + c means CHAR is part of comment sequence c. n means CHAR is part of a nestable comment sequence. p means CHAR is a prefix character for `backward-prefix-chars'; @@ -1017,7 +1082,9 @@ (Lisp_Object syntax) { register enum syntaxcode code; - char desc, start1, start2, end1, end2, prefix, comstyle, comnested; + int syntax_code; + char desc, start1, start2, end1, end2, prefix, + comstyleb, comstylec, comnested; char str[2]; Lisp_Object first, match_lisp, value = syntax; @@ -1048,14 +1115,16 @@ return syntax; } - code = (enum syntaxcode) (XINT (first) & 0377); - start1 = (XINT (first) >> 16) & 1; - start2 = (XINT (first) >> 17) & 1; - end1 = (XINT (first) >> 18) & 1; - end2 = (XINT (first) >> 19) & 1; - prefix = (XINT (first) >> 20) & 1; - comstyle = (XINT (first) >> 21) & 1; - comnested = (XINT (first) >> 22) & 1; + syntax_code = XINT (first); + code = (enum syntaxcode) (syntax_code & 0377); + start1 = SYNTAX_FLAGS_COMSTART_FIRST (syntax_code); + start2 = SYNTAX_FLAGS_COMSTART_SECOND (syntax_code);; + end1 = SYNTAX_FLAGS_COMEND_FIRST (syntax_code); + end2 = SYNTAX_FLAGS_COMEND_SECOND (syntax_code); + prefix = SYNTAX_FLAGS_PREFIX (syntax_code); + comstyleb = SYNTAX_FLAGS_COMMENT_STYLEB (syntax_code); + comstylec = SYNTAX_FLAGS_COMMENT_STYLEC (syntax_code); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax_code); if ((int) code < 0 || (int) code >= (int) Smax) { @@ -1084,8 +1153,10 @@ if (prefix) insert ("p", 1); - if (comstyle) + if (comstyleb) insert ("b", 1); + if (comstylec) + insert ("c", 1); if (comnested) insert ("n", 1); @@ -1145,8 +1216,10 @@ insert_string (",\n\t is the first character of a comment-end sequence"); if (end2) insert_string (",\n\t is the second character of a comment-end sequence"); - if (comstyle) + if (comstyleb) insert_string (" (comment style b)"); + if (comstylec) + insert_string (" (comment style c)"); if (comnested) insert_string (" (nestable)"); @@ -2060,7 +2133,7 @@ FROM_BYTE is the bytepos corresponding to FROM. Do not move past STOP (a charpos). The comment over which we have to jump is of style STYLE - (either SYNTAX_COMMENT_STYLE(foo) or ST_COMMENT_STYLE). + (either SYNTAX_FLAGS_COMMENT_STYLE(foo) or ST_COMMENT_STYLE). NESTING should be positive to indicate the nesting at the beginning for nested comments and should be zero or negative else. ST_COMMENT_STYLE cannot be nested. @@ -2087,7 +2160,7 @@ { register int c, c1; register enum syntaxcode code; - register int syntax; + register int syntax, other_syntax; if (nesting <= 0) nesting = -1; @@ -2109,7 +2182,7 @@ syntax = SYNTAX_WITH_FLAGS (c); code = syntax & 0xff; if (code == Sendcomment - && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style + && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? (nesting > 0 && --nesting == 0) : nesting < 0)) /* we have encountered a comment end of the same style @@ -2125,7 +2198,7 @@ if (nesting > 0 && code == Scomment && SYNTAX_FLAGS_COMMENT_NESTED (syntax) - && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style) + && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style) /* we have encountered a nested comment of the same style as the comment sequence which began this comment section */ nesting++; @@ -2134,11 +2207,13 @@ forw_incomment: if (from < stop && SYNTAX_FLAGS_COMEND_FIRST (syntax) - && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), - SYNTAX_COMEND_SECOND (c1)) + other_syntax = SYNTAX_WITH_FLAGS (c1), + SYNTAX_FLAGS_COMEND_SECOND (other_syntax)) + && SYNTAX_FLAGS_COMMENT_STYLE (syntax, other_syntax) == style && ((SYNTAX_FLAGS_COMMENT_NESTED (syntax) || - SYNTAX_COMMENT_NESTED (c1)) ? nesting > 0 : nesting < 0)) + SYNTAX_FLAGS_COMMENT_NESTED (other_syntax)) + ? nesting > 0 : nesting < 0)) { if (--nesting <= 0) /* we have encountered a comment end of the same style @@ -2155,10 +2230,11 @@ && from < stop && SYNTAX_FLAGS_COMSTART_FIRST (syntax) && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), - SYNTAX_COMMENT_STYLE (c1) == style - && SYNTAX_COMSTART_SECOND (c1)) + other_syntax = SYNTAX_WITH_FLAGS (c1), + SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax) == style + && SYNTAX_FLAGS_COMSTART_SECOND (other_syntax)) && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) || - SYNTAX_COMMENT_NESTED (c1))) + SYNTAX_FLAGS_COMMENT_NESTED (other_syntax))) /* we have encountered a nested comment of the same style as the comment sequence which began this comment section */ @@ -2209,7 +2285,7 @@ { do { - int comstart_first; + int comstart_first, syntax, other_syntax; if (from == stop) { @@ -2218,15 +2294,17 @@ return Qnil; } c = FETCH_CHAR_AS_MULTIBYTE (from_byte); + syntax = SYNTAX_WITH_FLAGS (c); code = SYNTAX (c); - comstart_first = SYNTAX_COMSTART_FIRST (c); - comnested = SYNTAX_COMMENT_NESTED (c); - comstyle = SYNTAX_COMMENT_STYLE (c); + comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); INC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); if (from < stop && comstart_first && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), - SYNTAX_COMSTART_SECOND (c1))) + other_syntax = SYNTAX_WITH_FLAGS (c1), + SYNTAX_FLAGS_COMSTART_SECOND (other_syntax))) { /* We have encountered a comment start sequence and we are ignoring all text inside comments. We must record @@ -2234,8 +2312,9 @@ only a comment end of the same style actually ends the comment section. */ code = Scomment; - comstyle = SYNTAX_COMMENT_STYLE (c1); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); + comnested + = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); INC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); } @@ -2271,7 +2350,7 @@ { while (1) { - int quoted; + int quoted, syntax; if (from <= stop) { @@ -2284,15 +2363,17 @@ /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ quoted = char_quoted (from, from_byte); c = FETCH_CHAR_AS_MULTIBYTE (from_byte); + syntax = SYNTAX_WITH_FLAGS (c); code = SYNTAX (c); comstyle = 0; - comnested = SYNTAX_COMMENT_NESTED (c); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); if (code == Sendcomment) - comstyle = SYNTAX_COMMENT_STYLE (c); - if (from > stop && SYNTAX_COMEND_SECOND (c) + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); + if (from > stop && SYNTAX_FLAGS_COMEND_SECOND (syntax) && prev_char_comend_first (from, from_byte) && !char_quoted (from - 1, dec_bytepos (from_byte))) { + int other_syntax; /* We must record the comment style encountered so that later, we can match only the proper comment begin sequence of the same style. */ @@ -2301,8 +2382,10 @@ /* Calling char_quoted, above, set up global syntax position at the new value of FROM. */ c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); - comstyle = SYNTAX_COMMENT_STYLE (c1); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + other_syntax = SYNTAX_WITH_FLAGS (c1); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); + comnested + = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); } if (code == Scomment_fence) @@ -2349,7 +2432,7 @@ { /* Failure: we should go back to the end of this not-quite-endcomment. */ - if (SYNTAX(c) != code) + if (SYNTAX (c) != code) /* It was a two-char Sendcomment. */ INC_BOTH (from, from_byte); goto leave; @@ -2423,21 +2506,23 @@ { while (from < stop) { - int comstart_first, prefix; + int comstart_first, prefix, syntax, other_syntax; UPDATE_SYNTAX_TABLE_FORWARD (from); c = FETCH_CHAR_AS_MULTIBYTE (from_byte); + syntax = SYNTAX_WITH_FLAGS (c); code = SYNTAX_WITH_MULTIBYTE_CHECK (c); - comstart_first = SYNTAX_COMSTART_FIRST (c); - comnested = SYNTAX_COMMENT_NESTED (c); - comstyle = SYNTAX_COMMENT_STYLE (c); - prefix = SYNTAX_PREFIX (c); + comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); + prefix = SYNTAX_FLAGS_PREFIX (syntax); if (depth == min_depth) last_good = from; INC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); if (from < stop && comstart_first && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte), - SYNTAX_COMSTART_SECOND (c)) + other_syntax = SYNTAX_WITH_FLAGS (c), + SYNTAX_FLAGS_COMSTART_SECOND (other_syntax)) && parse_sexp_ignore_comments) { /* we have encountered a comment start sequence and we @@ -2446,9 +2531,9 @@ only a comment end of the same style actually ends the comment section */ code = Scomment; - c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); - comstyle = SYNTAX_COMMENT_STYLE (c1); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); + comnested + = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); INC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); } @@ -2592,29 +2677,34 @@ { while (from > stop) { + int syntax; DEC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_BACKWARD (from); c = FETCH_CHAR_AS_MULTIBYTE (from_byte); + syntax= SYNTAX_WITH_FLAGS (c); code = SYNTAX_WITH_MULTIBYTE_CHECK (c); if (depth == min_depth) last_good = from; comstyle = 0; - comnested = SYNTAX_COMMENT_NESTED (c); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); if (code == Sendcomment) - comstyle = SYNTAX_COMMENT_STYLE (c); - if (from > stop && SYNTAX_COMEND_SECOND (c) + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); + if (from > stop && SYNTAX_FLAGS_COMEND_SECOND (syntax) && prev_char_comend_first (from, from_byte) && parse_sexp_ignore_comments) { /* We must record the comment style encountered so that later, we can match only the proper comment begin sequence of the same style. */ + int c1, other_syntax; DEC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_BACKWARD (from); code = Sendcomment; c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); - comstyle = SYNTAX_COMMENT_STYLE (c1); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + other_syntax = SYNTAX_WITH_FLAGS (c1); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); + comnested + = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); } /* Quoting turns anything except a comment-ender @@ -2625,7 +2715,7 @@ DEC_BOTH (from, from_byte); code = Sword; } - else if (SYNTAX_PREFIX (c)) + else if (SYNTAX_FLAGS_PREFIX (syntax)) continue; switch (SWITCH_ENUM_CAST (code)) @@ -2949,8 +3039,11 @@ oldstate = Fcdr (oldstate); oldstate = Fcdr (oldstate); tem = Fcar (oldstate); - state.comstyle = NILP (tem) ? 0 : (EQ (tem, Qsyntax_table) - ? ST_COMMENT_STYLE : 1); + state.comstyle = (NILP (tem) + ? 0 + : (EQ (tem, Qsyntax_table) + ? ST_COMMENT_STYLE + : INTEGERP (tem) ? XINT (tem) : 1)); oldstate = Fcdr (oldstate); tem = Fcar (oldstate); @@ -2995,22 +3088,25 @@ while (from < end) { + int syntax; INC_FROM; code = prev_from_syntax & 0xff; if (from < end && SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) && (c1 = FETCH_CHAR (from_byte), - SYNTAX_COMSTART_SECOND (c1))) + syntax = SYNTAX_WITH_FLAGS (c1), + SYNTAX_FLAGS_COMSTART_SECOND (syntax))) /* Duplicate code to avoid a complex if-expression which causes trouble for the SGI compiler. */ { /* Record the comment style we have entered so that only the comment-end sequence of the same style actually terminates the comment section. */ - state.comstyle = SYNTAX_COMMENT_STYLE (c1); + state.comstyle + = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); comnested = SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + comnested = comnested || SYNTAX_FLAGS_COMMENT_NESTED (syntax); state.incomment = comnested ? 1 : -1; state.comstr_start = prev_from; INC_FROM; @@ -3028,7 +3124,7 @@ } else if (code == Scomment) { - state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax); + state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax, 0); state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? 1 : -1); state.comstr_start = prev_from; @@ -3221,8 +3317,7 @@ else an integer (the current comment nesting). 5. t if following a quote character. 6. the minimum paren-depth encountered during this scan. - 7. t if in a comment of style b; symbol `syntax-table' if the comment - should be terminated by a generic comment delimiter. + 7. style of comment, if any. 8. character address of start of comment or string; nil if not in one. 9. Intermediate data for continuation of parsing (subject to change). If third arg TARGETDEPTH is non-nil, parsing stops if the depth @@ -3258,8 +3353,10 @@ SET_PT (state.location); return Fcons (make_number (state.depth), - Fcons (state.prevlevelstart < 0 ? Qnil : make_number (state.prevlevelstart), - Fcons (state.thislevelstart < 0 ? Qnil : make_number (state.thislevelstart), + Fcons (state.prevlevelstart < 0 + ? Qnil : make_number (state.prevlevelstart), + Fcons (state.thislevelstart < 0 + ? Qnil : make_number (state.thislevelstart), Fcons (state.instring >= 0 ? (state.instring == ST_STRING_STYLE ? Qt : make_number (state.instring)) : Qnil, @@ -3270,8 +3367,9 @@ Fcons (make_number (state.mindepth), Fcons ((state.comstyle ? (state.comstyle == ST_COMMENT_STYLE - ? Qsyntax_table : Qt) : - Qnil), + ? Qsyntax_table + : make_number (state.comstyle)) + : Qnil), Fcons (((state.incomment || (state.instring >= 0)) ? make_number (state.comstr_start) === modified file 'src/syntax.h' --- src/syntax.h 2010-07-02 09:26:33 +0000 +++ src/syntax.h 2010-08-12 14:44:16 +0000 @@ -128,56 +128,9 @@ : 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, ------------------------------------------------------------ revno: 101058 committer: Jason Rumney branch nick: trunk timestamp: Thu 2010-08-12 22:28:43 +0800 message: (add_registry): Set path for runemacs.exe to use. diff: === modified file 'nt/ChangeLog' --- nt/ChangeLog 2010-08-08 21:12:29 +0000 +++ nt/ChangeLog 2010-08-12 14:28:43 +0000 @@ -1,3 +1,7 @@ +2010-08-12 Jason Rumney + + * addpm.c (add_registry): Set path for runemacs.exe to use. + 2010-08-08 Óscar Fuentes * cmdproxy.c (main): Use _snprintf instead of wsprintf, === modified file 'nt/addpm.c' --- nt/addpm.c 2010-07-20 20:21:03 +0000 +++ nt/addpm.c 2010-08-12 14:28:43 +0000 @@ -62,6 +62,8 @@ #define REG_GTK "SOFTWARE\\GTK\\2.0" #define REG_APP_PATH \ "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\emacs.exe" +#define REG_RUNEMACS_PATH \ + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\runemacs.exe" static struct entry { @@ -129,10 +131,25 @@ /* Make sure the emacs bin directory continues to be searched first by including it as well. */ char *dll_paths; + HKEY runemacs_key = NULL; len = strlen (path) + 5 + size; dll_paths = (char *) alloca (size + strlen (path) + 1); sprintf (dll_paths, "%s\\bin;%s", path, gtk_path); RegSetValueEx (hrootkey, "Path", 0, REG_SZ, dll_paths, len); + + /* Set the same path for runemacs.exe, as the Explorer shell + looks this up, so the above does not take effect when + emacs.exe is spawned from runemacs.exe. */ + if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, REG_RUNEMACS_PATH, + 0, "", REG_OPTION_NON_VOLATILE, + KEY_WRITE, NULL, &runemacs_key, NULL) + == ERROR_SUCCESS) + { + RegSetValueEx (runemacs_key, "Path", 0, REG_SZ, + dll_paths, len); + + RegCloseKey (runemacs_key); + } } } RegCloseKey (gtk_key); ------------------------------------------------------------ revno: 101057 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2010-08-12 14:46:24 +0200 message: Fix last change. * lisp/progmodes/octave-mod.el (octave-mode-syntax-table): Better describe the problem. (octave-fill-paragraph): Also update caller. (octave-completion-at-point-function): Fix up typo. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-08-12 11:22:16 +0000 +++ lisp/ChangeLog 2010-08-12 12:46:24 +0000 @@ -11,7 +11,7 @@ (octave-uncomment-region, octave-comment-indent) (octave-indent-for-comment): Remove. (octave-indent-calculate): Rename from calculate-octave-indent. - (octave-indent-line): Update caller. + (octave-indent-line, octave-fill-paragraph): Update caller. (octave-initialize-completions): No need to make an alist. (octave-completion-at-point-function): New function. (octave-complete-symbol): Use it. === modified file 'lisp/progmodes/octave-mod.el' --- lisp/progmodes/octave-mod.el 2010-08-12 11:22:16 +0000 +++ lisp/progmodes/octave-mod.el 2010-08-12 12:46:24 +0000 @@ -294,17 +294,17 @@ (modify-syntax-entry ?\" "\"" table) (modify-syntax-entry ?. "w" table) (modify-syntax-entry ?_ "w" table) - ;; FIXME: The < property of # and % makes Emacs-23 ignore any subsequent - ;; char including {, so it never gets to see the multi-line comments. - ;; This is a shortcoming in syntax.c. In Twelf-mode (which also suffers - ;; from this problem) we work around the issue by setting "% " rather than - ;; just "%" as a comment-starter, but it seems this wouldn't cut it - ;; for Octave. - ;; Hopefully we'll get to fix this in Emacs-24. + ;; FIXME: 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. (modify-syntax-entry ?\% "< 13" table) (modify-syntax-entry ?\# "< 13" table) (modify-syntax-entry ?\{ "(} 2b" table) - (modify-syntax-entry ?\} "){ 4" table) + (modify-syntax-entry ?\} "){ 4b" table) (modify-syntax-entry ?\n ">" table) table) "Syntax table in use in `octave-mode' buffers.") @@ -1118,7 +1118,7 @@ (beginning-of-line) (point))) (cfc (current-fill-column)) - (ind (calculate-octave-indent)) + (ind (octave-indent-calculate)) comment-prefix) (save-restriction (goto-char beg) @@ -1195,10 +1195,10 @@ (defun octave-completion-at-point-function () "Find the text to complete and the corresponding table." - (let ((beg (save-excursion (backward-sexp 1) (point))) - (end (if (< beg (point)) - (save-excursion (goto-char beg) (forward-sexp 1) (point)) - (point)))) + (let* ((beg (save-excursion (backward-sexp 1) (point))) + (end (if (< beg (point)) + (save-excursion (goto-char beg) (forward-sexp 1) (point)) + (point)))) (list beg end octave-completion-alist))) (defun octave-complete-symbol () ------------------------------------------------------------ revno: 101056 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2010-08-12 13:22:16 +0200 message: Misc code cleanup of octave-mode.el. * lisp/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. (octave-mode-syntax-table): Support %{..%} comments (sort of). (octave-mode): Use define-derived-mode. Set completion-at-point-functions and don't set columns. Don't disable adaptive-fill-regexp. (octave-describe-major-mode, octave-comment-region) (octave-uncomment-region, octave-comment-indent) (octave-indent-for-comment): Remove. (octave-indent-calculate): Rename from calculate-octave-indent. (octave-indent-line): Update caller. (octave-initialize-completions): No need to make an alist. (octave-completion-at-point-function): New function. (octave-complete-symbol): Use it. (octave-insert-defun): Use define-skeleton. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-08-12 10:46:44 +0000 +++ lisp/ChangeLog 2010-08-12 11:22:16 +0000 @@ -1,7 +1,24 @@ 2010-08-12 Stefan Monnier - * progmodes/octave-mod.el (octave-mode-map): Use comment-dwim (bug#6829). - (octave-mode): Set comment-add. + * 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. + (octave-mode-syntax-table): Support %{..%} comments (sort of). + (octave-mode): Use define-derived-mode. + Set completion-at-point-functions and don't set columns. + Don't disable adaptive-fill-regexp. + (octave-describe-major-mode, octave-comment-region) + (octave-uncomment-region, octave-comment-indent) + (octave-indent-for-comment): Remove. + (octave-indent-calculate): Rename from calculate-octave-indent. + (octave-indent-line): Update caller. + (octave-initialize-completions): No need to make an alist. + (octave-completion-at-point-function): New function. + (octave-complete-symbol): Use it. + (octave-insert-defun): Use define-skeleton. + + * progmodes/octave-mod.el (octave-mode): Set comment-add. + (octave-mode-map): Use comment-dwim (bug#6829). 2010-08-12 Antoine Levitt (tiny change) === modified file 'lisp/progmodes/octave-mod.el' --- lisp/progmodes/octave-mod.el 2010-08-12 10:46:44 +0000 +++ lisp/progmodes/octave-mod.el 2010-08-12 11:22:16 +0000 @@ -4,7 +4,7 @@ ;; Free Software Foundation, Inc. ;; Author: Kurt Hornik -;; Author: John Eaton +;; Author: John Eaton ;; Maintainer: Kurt Hornik ;; Keywords: languages @@ -92,7 +92,7 @@ (defvar octave-comment-char ?# "Character to start an Octave comment.") (defvar octave-comment-start - (string octave-comment-char ?\ ) + (string octave-comment-char ?\s) "String to insert to start a new Octave in-line comment.") (defvar octave-comment-start-skip "\\s<+\\s-*" "Regexp to match the start of an Octave comment up to its body.") @@ -195,13 +195,10 @@ (define-key map " " 'octave-electric-space) (define-key map "\n" 'octave-reindent-then-newline-and-indent) (define-key map "\e\n" 'octave-indent-new-comment-line) - (define-key map "\e\t" 'octave-complete-symbol) (define-key map "\M-\C-a" 'octave-beginning-of-defun) (define-key map "\M-\C-e" 'octave-end-of-defun) (define-key map "\M-\C-h" 'octave-mark-defun) (define-key map "\M-\C-q" 'octave-indent-defun) - (define-key map "\C-c;" 'octave-comment-region) - (define-key map "\C-c:" 'octave-uncomment-region) (define-key map "\C-c\C-b" 'octave-submit-bug-report) (define-key map "\C-c\C-p" 'octave-previous-code-line) (define-key map "\C-c\C-n" 'octave-next-code-line) @@ -266,14 +263,14 @@ ["Kill Process" octave-kill-process t]) "-" ["Indent Line" indent-according-to-mode t] - ["Complete Symbol" octave-complete-symbol t] + ["Complete Symbol" completion-at-point t] "-" ["Toggle Abbrev Mode" abbrev-mode t] ["Toggle Auto-Fill Mode" auto-fill-mode t] "-" ["Submit Bug Report" octave-submit-bug-report t] "-" - ["Describe Octave Mode" octave-describe-major-mode t] + ["Describe Octave Mode" describe-mode t] ["Lookup Octave Index" octave-help t]) "Menu for Octave mode.") @@ -297,8 +294,17 @@ (modify-syntax-entry ?\" "\"" table) (modify-syntax-entry ?. "w" table) (modify-syntax-entry ?_ "w" table) - (modify-syntax-entry ?\% "<" table) - (modify-syntax-entry ?\# "<" table) + ;; FIXME: The < property of # and % makes Emacs-23 ignore any subsequent + ;; char including {, so it never gets to see the multi-line comments. + ;; This is a shortcoming in syntax.c. In Twelf-mode (which also suffers + ;; from this problem) we work around the issue by setting "% " rather than + ;; just "%" as a comment-starter, but it seems this wouldn't cut it + ;; for Octave. + ;; Hopefully we'll get to fix this in Emacs-24. + (modify-syntax-entry ?\% "< 13" table) + (modify-syntax-entry ?\# "< 13" table) + (modify-syntax-entry ?\{ "(} 2b" table) + (modify-syntax-entry ?\} "){ 4" table) (modify-syntax-entry ?\n ">" table) table) "Syntax table in use in `octave-mode' buffers.") @@ -401,7 +407,7 @@ ;;;###autoload -(defun octave-mode () +(define-derived-mode octave-mode prog-mode "Octave" "Major mode for editing Octave code. This mode makes it easier to write Octave code by helping with @@ -484,53 +490,39 @@ This automatically sets up a mail buffer with version information already added. You just need to add a description of the problem, including a reproducible test case and send the message." - (interactive) - (kill-all-local-variables) - - (use-local-map octave-mode-map) - (setq major-mode 'octave-mode) - (setq mode-name "Octave") (setq local-abbrev-table octave-abbrev-table) - (set-syntax-table octave-mode-syntax-table) - - (make-local-variable 'indent-line-function) - (setq indent-line-function 'octave-indent-line) - - (make-local-variable 'comment-start) - (setq comment-start octave-comment-start) - (make-local-variable 'comment-end) - (setq comment-end "") - (make-local-variable 'comment-column) - (setq comment-column 32) - (make-local-variable 'comment-start-skip) - (setq comment-start-skip "\\s<+\\s-*") - (make-local-variable 'comment-indent-function) - (setq comment-indent-function 'octave-comment-indent) + + (set (make-local-variable 'indent-line-function) 'octave-indent-line) + + (set (make-local-variable 'comment-start) octave-comment-start) + (set (make-local-variable 'comment-end) "") + ;; Don't set it here: it's not really a property of the language, + ;; just a personal preference of the author. + ;; (set (make-local-variable 'comment-column) 32) + (set (make-local-variable 'comment-start-skip) "\\s<+\\s-*") (set (make-local-variable 'comment-add) 1) - (make-local-variable 'parse-sexp-ignore-comments) - (setq parse-sexp-ignore-comments t) - (make-local-variable 'paragraph-start) - (setq paragraph-start (concat "\\s-*$\\|" page-delimiter)) - (make-local-variable 'paragraph-separate) - (setq paragraph-separate paragraph-start) - (make-local-variable 'paragraph-ignore-fill-prefix) - (setq paragraph-ignore-fill-prefix t) - (make-local-variable 'fill-paragraph-function) - (setq fill-paragraph-function 'octave-fill-paragraph) - (make-local-variable 'adaptive-fill-regexp) - (setq adaptive-fill-regexp nil) - (make-local-variable 'fill-column) - (setq fill-column 72) - (make-local-variable 'normal-auto-fill-function) - (setq normal-auto-fill-function 'octave-auto-fill) - - (make-local-variable 'font-lock-defaults) - (setq font-lock-defaults '(octave-font-lock-keywords nil nil)) - - (make-local-variable 'imenu-generic-expression) - (setq imenu-generic-expression octave-mode-imenu-generic-expression - imenu-case-fold-search nil) + (set (make-local-variable 'parse-sexp-ignore-comments) t) + (set (make-local-variable 'paragraph-start) + (concat "\\s-*$\\|" page-delimiter)) + (set (make-local-variable 'paragraph-separate) paragraph-start) + (set (make-local-variable 'paragraph-ignore-fill-prefix) t) + (set (make-local-variable 'fill-paragraph-function) 'octave-fill-paragraph) + ;; FIXME: Why disable it? + ;; (set (make-local-variable 'adaptive-fill-regexp) nil) + ;; Again, this is not a property of the language, don't set it here. + ;; (set (make-local-variable 'fill-column) 72) + (set (make-local-variable 'normal-auto-fill-function) 'octave-auto-fill) + + (set (make-local-variable 'font-lock-defaults) + '(octave-font-lock-keywords nil nil)) + + (set (make-local-variable 'imenu-generic-expression) + octave-mode-imenu-generic-expression) + (set (make-local-variable 'imenu-case-fold-search) nil) + + (add-hook 'completion-at-point-functions + 'octave-completion-at-point-function nil t) (octave-add-octave-menu) (octave-initialize-completions) @@ -543,25 +535,22 @@ (call-interactively 'info-lookup-symbol))) ;;; Miscellaneous useful functions -(defun octave-describe-major-mode () - "Describe the current major mode." - (interactive) - (describe-function major-mode)) (defsubst octave-in-comment-p () "Return t if point is inside an Octave comment." - (interactive) (save-excursion + ;; FIXME: use syntax-ppss? (nth 4 (parse-partial-sexp (line-beginning-position) (point))))) (defsubst octave-in-string-p () "Return t if point is inside an Octave string." - (interactive) (save-excursion + ;; FIXME: use syntax-ppss? (nth 3 (parse-partial-sexp (line-beginning-position) (point))))) (defsubst octave-not-in-string-or-comment-p () "Return t if point is not inside an Octave string or comment." + ;; FIXME: Use syntax-ppss? (let ((pps (parse-partial-sexp (line-beginning-position) (point)))) (not (or (nth 3 pps) (nth 4 pps))))) @@ -620,23 +609,9 @@ (delete-horizontal-space) (insert (concat " " octave-continuation-string)))) -;;; Comments -(defun octave-comment-region (beg end &optional arg) - "Comment or uncomment each line in the region as Octave code. -See `comment-region'." - (interactive "r\nP") - (let ((comment-start (char-to-string octave-comment-char))) - (comment-region beg end arg))) - -(defun octave-uncomment-region (beg end &optional arg) - "Uncomment each line in the region as Octave code." - (interactive "r\nP") - (or arg (setq arg 1)) - (octave-comment-region beg end (- arg))) - ;;; Indentation -(defun calculate-octave-indent () +(defun octave-indent-calculate () "Return appropriate indentation for current line as Octave code. Returns an integer (the column to indent to) unless the line is a comment line with fixed goal golumn. In that case, returns a list whose @@ -722,36 +697,13 @@ (beginning-of-line) (and (bobp) (looking-at "\\s-*#!")))) -(defun octave-comment-indent () - (if (or (looking-at "\\s<\\s<\\s<") - (octave-before-magic-comment-p)) - 0 - (if (looking-at "\\s<\\s<") - (calculate-octave-indent) - (skip-syntax-backward " ") - (max (if (bolp) 0 (+ 1 (current-column))) - comment-column)))) - -(defun octave-indent-for-comment () - "Maybe insert and indent an Octave comment. -If there is no comment already on this line, create a code-level comment -\(started by two comment characters) if the line is empty, or an in-line -comment (started by one comment character) otherwise. -Point is left after the start of the comment which is properly aligned." - (interactive) - (beginning-of-line) - (if (looking-at "^\\s-*$") - (insert octave-block-comment-start) - (indent-for-comment)) - (indent-according-to-mode)) - (defun octave-indent-line (&optional arg) "Indent current line as Octave code. With optional ARG, use this as offset unless this line is a comment with fixed goal column." (interactive) (or arg (setq arg 0)) - (let ((icol (calculate-octave-indent)) + (let ((icol (octave-indent-calculate)) (relpos (- (current-column) (current-indentation)))) (if (listp icol) (setq icol (car icol)) @@ -1237,20 +1189,24 @@ (if octave-completion-alist () (setq octave-completion-alist - (mapcar '(lambda (var) (cons var var)) - (append octave-reserved-words - octave-text-functions - octave-variables))))) + (append octave-reserved-words + octave-text-functions + octave-variables)))) + +(defun octave-completion-at-point-function () + "Find the text to complete and the corresponding table." + (let ((beg (save-excursion (backward-sexp 1) (point))) + (end (if (< beg (point)) + (save-excursion (goto-char beg) (forward-sexp 1) (point)) + (point)))) + (list beg end octave-completion-alist))) (defun octave-complete-symbol () "Perform completion on Octave symbol preceding point. Compare that symbol against Octave's reserved words and builtin variables." (interactive) - (let* ((end (point)) - (beg (save-excursion (backward-sexp 1) (point)))) - (completion-in-region beg end octave-completion-alist))) - + (apply 'completion-in-region (octave-completion-at-point-function))) ;;; Electric characters && friends (defun octave-reindent-then-newline-and-indent () @@ -1324,42 +1280,27 @@ (list-abbrevs)) (setq unread-command-events (list c)))))) -(defun octave-insert-defun (name args vals) +(define-skeleton octave-insert-defun "Insert an Octave function skeleton. Prompt for the function's name, arguments and return values (to be entered without parens)." - (interactive - (list - (read-from-minibuffer "Function name: " - (substring (buffer-name) 0 -2)) - (read-from-minibuffer "Arguments: ") - (read-from-minibuffer "Return values: "))) - (let ((string (format "%s %s (%s)" - (cond - ((string-equal vals "") - vals) - ((string-match "[ ,]" vals) - (concat " [" vals "] =")) - (t - (concat " " vals " ="))) - name - args)) - (prefix octave-block-comment-start)) - (if (not (bobp)) (newline)) - (insert "function" string) - (indent-according-to-mode) - (newline 2) - (insert prefix "usage: " string) - (reindent-then-newline-and-indent) - (insert prefix) - (reindent-then-newline-and-indent) - (insert prefix) - (indent-according-to-mode) - (save-excursion - (newline 2) - (insert "endfunction") - (indent-according-to-mode)))) - + (let* ((defname (substring (buffer-name) 0 -2)) + (name (read-string (format "Function name (default %s): " defname) + nil nil defname)) + (args (read-string "Arguments: ")) + (vals (read-string "Return values: "))) + (format "%s%s (%s)" + (cond + ((string-equal vals "") vals) + ((string-match "[ ,]" vals) (concat "[" vals "] = ")) + (t (concat vals " = "))) + name + args)) + \n "function " > str \n \n + octave-block-comment-start "usage: " str \n + octave-block-comment-start \n octave-block-comment-start + \n _ \n + "endfunction" > \n) ;;; Menu (defun octave-add-octave-menu () ------------------------------------------------------------ revno: 101055 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2010-08-12 12:46:44 +0200 message: * lisp/progmodes/octave-mod.el (octave-mode-map): Use comment-dwim. (octave-mode): Set comment-add. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-08-12 08:55:20 +0000 +++ lisp/ChangeLog 2010-08-12 10:46:44 +0000 @@ -1,3 +1,8 @@ +2010-08-12 Stefan Monnier + + * progmodes/octave-mod.el (octave-mode-map): Use comment-dwim (bug#6829). + (octave-mode): Set comment-add. + 2010-08-12 Antoine Levitt (tiny change) * cus-edit.el (custom-save-variables, custom-save-faces): Fix up === modified file 'lisp/progmodes/octave-mod.el' --- lisp/progmodes/octave-mod.el 2010-05-20 15:12:20 +0000 +++ lisp/progmodes/octave-mod.el 2010-08-12 10:46:44 +0000 @@ -194,7 +194,6 @@ (define-key map ";" 'octave-electric-semi) (define-key map " " 'octave-electric-space) (define-key map "\n" 'octave-reindent-then-newline-and-indent) - (define-key map "\e;" 'octave-indent-for-comment) (define-key map "\e\n" 'octave-indent-new-comment-line) (define-key map "\e\t" 'octave-complete-symbol) (define-key map "\M-\C-a" 'octave-beginning-of-defun) @@ -507,6 +506,7 @@ (setq comment-start-skip "\\s<+\\s-*") (make-local-variable 'comment-indent-function) (setq comment-indent-function 'octave-comment-indent) + (set (make-local-variable 'comment-add) 1) (make-local-variable 'parse-sexp-ignore-comments) (setq parse-sexp-ignore-comments t) ------------------------------------------------------------ revno: 101054 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2010-08-12 11:02:02 +0200 message: * doc/misc/cl.texi (Mapping over Sequences): Rename mapc => cl-mapc. diff: === modified file 'doc/misc/ChangeLog' --- doc/misc/ChangeLog 2010-08-09 02:30:10 +0000 +++ doc/misc/ChangeLog 2010-08-12 09:02:02 +0000 @@ -1,3 +1,7 @@ +2010-08-12 Stefan Monnier + + * cl.texi (Mapping over Sequences): Rename mapc => cl-mapc. + 2010-08-09 Jay Belanger * calc.texi (Customizing Calc): Rearrange description of new === modified file 'doc/misc/cl.texi' --- doc/misc/cl.texi 2010-06-23 02:57:26 +0000 +++ doc/misc/cl.texi 2010-08-12 09:02:02 +0000 @@ -3763,10 +3763,10 @@ @code{car}s of the advancing pointers. @end defun -@defun mapc function seq &rest more-seqs +@defun cl-mapc function seq &rest more-seqs This function is like @code{mapcar*}, except that the values returned by @var{function} are ignored and thrown away rather than being -collected into a list. The return value of @code{mapc} is @var{seq}, +collected into a list. The return value of @code{cl-mapc} is @var{seq}, the first sequence. This function is more general than the Emacs primitive @code{mapc}. @end defun ------------------------------------------------------------ revno: 101053 author: Antoine Levitt committer: Stefan Monnier branch nick: trunk timestamp: Thu 2010-08-12 10:55:20 +0200 message: * lisp/cus-edit.el (custom-save-variables, custom-save-faces): Fix up indentation of inserted comment. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-08-11 18:28:10 +0000 +++ lisp/ChangeLog 2010-08-12 08:55:20 +0000 @@ -1,3 +1,8 @@ +2010-08-12 Antoine Levitt (tiny change) + + * cus-edit.el (custom-save-variables, custom-save-faces): Fix up + indentation of inserted comment. + 2010-08-11 Jan Djärv * faces.el (region): Add type gtk that uses gtk colors. @@ -11,8 +16,8 @@ (sql-product-alist): Add :prompt-cont-regexp property for several database products. (sql-prompt-cont-regexp): New variable. - (sql-output-newline-count, sql-output-by-send): New - variables. Record number of newlines in input text. + (sql-output-newline-count, sql-output-by-send): + New variables. Record number of newlines in input text. (sql-send-string): Handle multiple filters and count newlines. (sql-send-magic-terminator): Count terminator newline. (sql-interactive-remove-continuation-prompt): Filters output to @@ -20,8 +25,7 @@ (sql-interactive-mode): Set up new variables, prompt regexp and output filter. (sql-mode-sqlite-font-lock-keywords): Correct some keywords. - (sql-make-alternate-buffer-name): Correct buffer name in edge - cases. + (sql-make-alternate-buffer-name): Correct buffer name in edge cases. 2010-08-10 Stefan Monnier === modified file 'lisp/cus-edit.el' --- lisp/cus-edit.el 2010-04-20 18:52:07 +0000 +++ lisp/cus-edit.el 2010-08-12 08:55:20 +0000 @@ -4404,10 +4404,10 @@ (unless (bolp) (princ "\n")) (princ "(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right.\n") + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right.\n") (dolist (symbol saved-list) (let ((spec (car-safe (get symbol 'theme-value))) (value (get symbol 'saved-value)) @@ -4480,10 +4480,10 @@ (unless (bolp) (princ "\n")) (princ "(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right.\n") + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right.\n") (dolist (symbol saved-list) (let ((spec (car-safe (get symbol 'theme-face))) (value (get symbol 'saved-face)) ------------------------------------------------------------ revno: 101052 committer: Jan D branch nick: trunk timestamp: Wed 2010-08-11 20:47:34 +0200 message: * xfns.c (Fx_hide_tip): Check FRAME_LIVE_P (f) before calling xg_hide_tooltip. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2010-08-11 18:28:10 +0000 +++ src/ChangeLog 2010-08-11 18:47:34 +0000 @@ -2,6 +2,7 @@ * xfns.c (x_defined_color): If USE_GTK, call xg_check_special_colors first. + (Fx_hide_tip): Check FRAME_LIVE_P (f) before calling xg_hide_tooltip. * gtkutil.h (xg_check_special_colors): Declare. === modified file 'src/xfns.c' --- src/xfns.c 2010-08-11 18:28:10 +0000 +++ src/xfns.c 2010-08-11 18:47:34 +0000 @@ -5237,7 +5237,7 @@ /* When using system tooltip, tip_frame is the Emacs frame on which the tip is shown. */ f = XFRAME (frame); - if (xg_hide_tooltip (f)) + if (FRAME_LIVE_P (f) && xg_hide_tooltip (f)) frame = Qnil; #endif