Now on revision 108427. ------------------------------------------------------------ revno: 108427 committer: Stefan Monnier branch nick: trunk timestamp: Tue 2012-05-29 23:59:42 -0400 message: * lisp/emacs-lisp/byte-run.el (defmacro, defun): Move from C. (macro-declaration-function): Move var from C code. (macro-declaration-function): Define function with defalias. * lisp/emacs-lisp/macroexp.el (macroexpand-all-1): * lisp/emacs-lisp/cconv.el (cconv-convert, cconv-analyse-form): * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Don't handle defun/defmacro any more. * lisp/emacs-lisp/bytecomp.el (byte-compile-arglist-signature): Provide fallback for unknown arglist. (byte-compile-arglist-warn): Change calling convention. (byte-compile-output-file-form): Move print-vars binding. (byte-compile-output-docform): Simplify accordingly. (byte-compile-file-form-defun, byte-compile-file-form-defmacro) (byte-compile-defmacro-declaration): Remove. (byte-compile-file-form-defmumble): Generalize to defalias. (byte-compile-output-as-comment): Return byte-positions. Simplify callers accordingly. (byte-compile-lambda): Use `assert'. (byte-compile-defun, byte-compile-defmacro): Remove. (byte-compile-file-form-defalias): Use byte-compile-file-form-defmumble. (byte-compile-defalias-warn): Remove. * src/eval.c (Fdefun, Fdefmacro, Vmacro_declaration_function): Move to byte-run.el. (Fautoload): Do the hash-doc more carefully. * src/data.c (Fdefalias): Purify definition, except for keymaps. (Qdefun): Move from eval.c. * src/lisp.h (Qdefun): Remove. * src/lread.c (read1): Tiny simplification. * lib-src/make-docfile.c: Improve comment style. (search_lisp_doc_at_eol): New function. (scan_lisp_file): Use it. diff: === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2012-05-26 22:38:19 +0000 +++ lib-src/ChangeLog 2012-05-30 03:59:42 +0000 @@ -1,3 +1,9 @@ +2012-05-30 Stefan Monnier + + * make-docfile.c: Improve comment style. + (search_lisp_doc_at_eol): New function. + (scan_lisp_file): Use it. + 2012-05-26 Glenn Morris * Makefile.in (INSTALL_DATA): Remove; unused. @@ -441,8 +447,8 @@ * etags.c (canonicalize_filename, ISUPPER): Fix last change. - * makefile.w32-in ($(BLD)/ebrowse.$(O), $(BLD)/pop.$(O)): Depend - on ../lib/min-max.h. + * makefile.w32-in ($(BLD)/ebrowse.$(O), $(BLD)/pop.$(O)): + Depend on ../lib/min-max.h. 2011-02-22 Paul Eggert @@ -2819,7 +2825,7 @@ * make-docfile.c (read_c_string_or_comment): Declare msgno. - * Makefile.in (YACC): Deleted. + * Makefile.in (YACC): Delete. 2002-10-19 Andreas Schwab @@ -3037,7 +3043,7 @@ (TeX_commands): Names now include the initial backslash. (TeX_commands): Names do not include numeric args #n. (TeX_commands): Correct line char number in tags. - (TEX_tabent, TEX_token): Deleted. + (TEX_tabent, TEX_token): Delete. (TeX_commands, TEX_decode_env): Streamlined. 2002-06-05 Francesco Potortì @@ -3078,7 +3084,7 @@ (main): New argument -d, for specifying directory. (usage): Document. (get_user_id): Compute. - (get_home_dir): Deleted. + (get_home_dir): Delete. (get_prefix): New function, taken from main. (main): Check whether or not we are running setuid. Move prefix computation to get_prefix. Don't call getpwent; we don't need to @@ -3339,7 +3345,7 @@ (LOOKING_AT, get_tag, PHP_functions): Use notinname. (Ada_getit, Ada_funcs, Python_functions, Scheme_functions): Clarified, using strneq or notinname. - (L_isdef, L_isquote): Removed. + (L_isdef, L_isquote): Remove. (Lisp_functions, L_getit): Clarified. * etags.c (P_): Rename to __P for consistency with config.h. @@ -3776,7 +3782,7 @@ comma when --declarations is used. (C_entries): More accurate tagging of members and declarations. (yacc_rules): Was global, made local to C_entries. - (next_token_is_func): Removed. + (next_token_is_func): Remove. (fvdef): New constants fdefunkey, fdefunname. (consider_token, C_entries): Use them. (C_entries): Build proper lisp names for Emacs DEFUNs. @@ -4252,7 +4258,7 @@ (find_entries, takeprec, getit, Fortran_functions, Perl_functions) (Python_functions, L_getit, Lisp_functions, Scheme_functions) (prolog_pred, erlanf_func, erlang_attribute): Use them. - (eat_white): Deleted. + (eat_white): Delete. * etags.c (CHAR, init): Keep into account non US-ASCII characters and compilers with default signed chars. @@ -4775,7 +4781,7 @@ 1997-05-13 Francesco Potortì * etags.c (TeX_functions): Cleaned up. - (tex_getit): Removed. + (tex_getit): Remove. 1997-05-13 Paul Eggert @@ -5296,7 +5302,7 @@ * etags.c: Prolog language totally rewritten. (Prolog_functions): Rewritten from scratch. - (skip_comment, prolog_getit): Removed. + (skip_comment, prolog_getit): Remove. (prolog_skip_comment): New function, like old skip_comment. (prolog_pred, prolog_atom, prolog_white): New functions. (erlang_func, erlang_attributes): Forward declarations added. @@ -5797,7 +5803,7 @@ 1995-01-12 Francesco Potortì (pot@cnuce.cnr.it) - * etags.c (FILEPOS, GET_CHARNO, GET_FILEPOS, max, LINENO): Deleted. + * etags.c (FILEPOS, GET_CHARNO, GET_FILEPOS, max, LINENO): Delete. (append_to_tagfile, typedefs, typedefs_and_cplusplus) (constantypedefs, update, vgrind_style, no_warnings) (cxref_style, cplusplus, noindentypedefs): Were int, now logical. @@ -5816,9 +5822,9 @@ (consider_token): Don't take a token as argument. Use savenstr when saving a tag in structtag. Callers changed. (TOKEN): Structure changed. Now used only in C_entries. - (TOKEN_SAVED_P, SAVE_TOKEN, RESTORE_TOKEN): Deleted. + (TOKEN_SAVED_P, SAVE_TOKEN, RESTORE_TOKEN): Delete. (C_entries): nameb and savenameb deleted. Use dinamic allocation. - (pfcnt): Deleted. Users updated. + (pfcnt): Delete. Users updated. (getit, Asm_labels, Pascal_functions, L_getit, get_scheme) (TEX_getit, prolog_getit): Use dinamic allocation for storing the tag instead of a fixed size buffer. @@ -6394,7 +6400,7 @@ 1994-03-25 Francesco Potortì (pot@cnuce.cnr.it) - * etags.c (emacs_tags_format, ETAGS): Removed. Use CTAGS instead. + * etags.c (emacs_tags_format, ETAGS): Remove. Use CTAGS instead. (main): Don't allow the use of -t and -T in etags mode. (print_help): Don't show options enabled by default. (print_version): Show the emacs version number if VERSION is #defined. @@ -6511,9 +6517,9 @@ 1994-01-14 Francesco Potortì (pot@cnuce.cnr.it) * etags.c (stab_entry, stab_create, stab_find, stab_search, - stab_type, add_keyword, C_reate_stab, C_create_stabs): Deleted. + stab_type, add_keyword, C_reate_stab, C_create_stabs): Delete. Use gperf generated hash table instead of linked list. - (C_stab_entry, hash, in_word_set, get_C_stab, C_symtype): Added. + (C_stab_entry, hash, in_word_set, get_C_stab, C_symtype): Add. Mostly code generated by gperf. (consider_token): Remove unused parameter `lp'. (PF_funcs, getit): Allow subroutine and similar declarations @@ -6832,7 +6838,7 @@ * etags.c (consider_token): Was `==', now is `='. (consider_token): DEFUNs now treated like funcs in ctags mode. - * etags.c (LEVEL_OK_FOR_FUNCDEF): Removed. + * etags.c (LEVEL_OK_FOR_FUNCDEF): Remove. (C_entries): Optimized the test that used LEVEL_OK_FOR_FUNCDEF. (C_entries): Remove a piece of useless code. (C_entries): Making typedef tags is delayed until a semicolon @@ -7131,10 +7137,10 @@ * etags.c (GET_COOKIE): And related macros removed. (logical): Is now int, no more a char. (reg): Define deleted. - (isgood, _gd, notgd): Deleted. - (gotone): Deleted. + (isgood, _gd, notgd): Delete. + (gotone): Delete. (TOKEN): Member linestart removed. - (linepos, prev_linepos, lb1): Deleted. + (linepos, prev_linepos, lb1): Delete. (main): Call initbuffer on lbs array instead of lb1. (init): Remove the initialization of the logical _gd array. (find_entries): A .sa suffix means assembler file. @@ -7142,7 +7148,7 @@ All C state machines rewritten. (C_entries): Complete rewrite. (condider_token): Complete rewrite. - (getline): Deleted. + (getline): Delete. 1993-03-01 Francesco Potortì (pot@fly.CNUCE.CNR.IT) === modified file 'lib-src/make-docfile.c' --- lib-src/make-docfile.c 2012-04-29 20:05:44 +0000 +++ lib-src/make-docfile.c 2012-05-30 03:59:42 +0000 @@ -35,7 +35,7 @@ #include -/* defined to be emacs_main, sys_fopen, etc. in config.h */ +/* Defined to be emacs_main, sys_fopen, etc. in config.h. */ #undef main #undef fopen #undef chdir @@ -66,7 +66,7 @@ #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) #endif -/* Use this to suppress gcc's `...may be used before initialized' warnings. */ +/* Use this to suppress gcc's `...may be used before initialized' warnings. */ #ifdef lint # define IF_LINT(Code) Code #else @@ -226,7 +226,7 @@ for (tmp = filename; *tmp; tmp++) { - if (IS_DIRECTORY_SEP(*tmp)) + if (IS_DIRECTORY_SEP (*tmp)) filename = tmp + 1; } @@ -675,14 +675,14 @@ if (infile == NULL && extension == 'o') { - /* try .m */ + /* Try .m. */ filename[strlen (filename) - 1] = 'm'; infile = fopen (filename, mode); if (infile == NULL) - filename[strlen (filename) - 1] = 'c'; /* don't confuse people */ + filename[strlen (filename) - 1] = 'c'; /* Don't confuse people. */ } - /* No error if non-ex input file */ + /* No error if non-ex input file. */ if (infile == NULL) { perror (filename); @@ -800,8 +800,8 @@ input_buffer[i++] = c; c = getc (infile); } - while (! (c == ',' || c == ' ' || c == '\t' || - c == '\n' || c == '\r')); + while (! (c == ',' || c == ' ' || c == '\t' + || c == '\n' || c == '\r')); input_buffer[i] = '\0'; name = xmalloc (i + 1); @@ -820,7 +820,7 @@ commas = 3; else if (defvarflag) commas = 1; - else /* For DEFSIMPLE and DEFPRED */ + else /* For DEFSIMPLE and DEFPRED. */ commas = 2; while (commas) @@ -838,9 +838,9 @@ if (c < 0) goto eof; ungetc (c, infile); - if (commas == 2) /* pick up minargs */ + if (commas == 2) /* Pick up minargs. */ scanned = fscanf (infile, "%d", &minargs); - else /* pick up maxargs */ + else /* Pick up maxargs. */ if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ maxargs = -1; else @@ -893,7 +893,7 @@ fprintf (outfile, "%s\n", input_buffer); if (comment) - getc (infile); /* Skip past `*' */ + getc (infile); /* Skip past `*'. */ c = read_c_string_or_comment (infile, 1, comment, &saw_usage); /* If this is a defun, find the arguments and print them. If @@ -979,7 +979,7 @@ problem because byte-compiler output follows this convention. The NAME and DOCSTRING are output. NAME is preceded by `F' for a function or `V' for a variable. - An entry is output only if DOCSTRING has \ newline just after the opening " + An entry is output only if DOCSTRING has \ newline just after the opening ". */ static void @@ -1020,6 +1020,32 @@ } static int +search_lisp_doc_at_eol (FILE *infile) +{ + char c = 0, c1 = 0, c2 = 0; + + /* Skip until the end of line; remember two previous chars. */ + while (c != '\n' && c != '\r' && c >= 0) + { + c2 = c1; + c1 = c; + c = getc (infile); + } + + /* If two previous characters were " and \, + this is a doc string. Otherwise, there is none. */ + if (c2 != '"' || c1 != '\\') + { +#ifdef DEBUG + fprintf (stderr, "## non-docstring in %s (%s)\n", + buffer, filename); +#endif + return 0; + } + return 1; +} + +static int scan_lisp_file (const char *filename, const char *mode) { FILE *infile; @@ -1033,7 +1059,7 @@ if (infile == NULL) { perror (filename); - return 0; /* No error */ + return 0; /* No error. */ } c = '\n'; @@ -1110,7 +1136,7 @@ type = 'F'; read_lisp_symbol (infile, buffer); - /* Skip the arguments: either "nil" or a list in parens */ + /* Skip the arguments: either "nil" or a list in parens. */ c = getc (infile); if (c == 'n') /* nil */ @@ -1154,39 +1180,18 @@ || ! strcmp (buffer, "defconst") || ! strcmp (buffer, "defcustom")) { - char c1 = 0, c2 = 0; type = 'V'; read_lisp_symbol (infile, buffer); if (saved_string == 0) - { - - /* Skip until the end of line; remember two previous chars. */ - while (c != '\n' && c != '\r' && c >= 0) - { - c2 = c1; - c1 = c; - c = getc (infile); - } - - /* If two previous characters were " and \, - this is a doc string. Otherwise, there is none. */ - if (c2 != '"' || c1 != '\\') - { -#ifdef DEBUG - fprintf (stderr, "## non-docstring in %s (%s)\n", - buffer, filename); -#endif - continue; - } - } + if (!search_lisp_doc_at_eol (infile)) + continue; } else if (! strcmp (buffer, "custom-declare-variable") || ! strcmp (buffer, "defvaralias") ) { - char c1 = 0, c2 = 0; type = 'V'; c = getc (infile); @@ -1221,31 +1226,12 @@ } if (saved_string == 0) - { - /* Skip to end of line; remember the two previous chars. */ - while (c != '\n' && c != '\r' && c >= 0) - { - c2 = c1; - c1 = c; - c = getc (infile); - } - - /* If two previous characters were " and \, - this is a doc string. Otherwise, there is none. */ - if (c2 != '"' || c1 != '\\') - { -#ifdef DEBUG - fprintf (stderr, "## non-docstring in %s (%s)\n", - buffer, filename); -#endif - continue; - } - } + if (!search_lisp_doc_at_eol (infile)) + continue; } else if (! strcmp (buffer, "fset") || ! strcmp (buffer, "defalias")) { - char c1 = 0, c2 = 0; type = 'F'; c = getc (infile); @@ -1278,26 +1264,8 @@ } if (saved_string == 0) - { - /* Skip to end of line; remember the two previous chars. */ - while (c != '\n' && c != '\r' && c >= 0) - { - c2 = c1; - c1 = c; - c = getc (infile); - } - - /* If two previous characters were " and \, - this is a doc string. Otherwise, there is none. */ - if (c2 != '"' || c1 != '\\') - { -#ifdef DEBUG - fprintf (stderr, "## non-docstring in %s (%s)\n", - buffer, filename); -#endif - continue; - } - } + if (!search_lisp_doc_at_eol (infile)) + continue; } else if (! strcmp (buffer, "autoload")) @@ -1339,23 +1307,10 @@ continue; } read_c_string_or_comment (infile, 0, 0, 0); - skip_white (infile); if (saved_string == 0) - { - /* If the next three characters aren't `dquote bslash newline' - then we're not reading a docstring. */ - if ((c = getc (infile)) != '"' - || (c = getc (infile)) != '\\' - || ((c = getc (infile)) != '\n' && c != '\r')) - { -#ifdef DEBUG - fprintf (stderr, "## non-docstring in %s (%s)\n", - buffer, filename); -#endif - continue; - } - } + if (!search_lisp_doc_at_eol (infile)) + continue; } #ifdef DEBUG @@ -1373,12 +1328,10 @@ continue; } - /* At this point, we should either use the previous - dynamic doc string in saved_string - or gobble a doc string from the input file. - - In the latter case, the opening quote (and leading - backslash-newline) have already been read. */ + /* At this point, we should either use the previous dynamic doc string in + saved_string or gobble a doc string from the input file. + In the latter case, the opening quote (and leading backslash-newline) + have already been read. */ putc (037, outfile); putc (type, outfile); === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 20:14:18 +0000 +++ lisp/ChangeLog 2012-05-30 03:59:42 +0000 @@ -1,8 +1,32 @@ +2012-05-30 Stefan Monnier + + * emacs-lisp/byte-run.el (defmacro, defun): Move from C. + (macro-declaration-function): Move var from C code. + (macro-declaration-function): Define function with defalias. + * emacs-lisp/macroexp.el (macroexpand-all-1): + * emacs-lisp/cconv.el (cconv-convert, cconv-analyse-form): + * emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Don't handle + defun/defmacro any more. + * emacs-lisp/bytecomp.el (byte-compile-arglist-signature): + Provide fallback for unknown arglist. + (byte-compile-arglist-warn): Change calling convention. + (byte-compile-output-file-form): Move print-vars binding. + (byte-compile-output-docform): Simplify accordingly. + (byte-compile-file-form-defun, byte-compile-file-form-defmacro) + (byte-compile-defmacro-declaration): Remove. + (byte-compile-file-form-defmumble): Generalize to defalias. + (byte-compile-output-as-comment): Return byte-positions. + Simplify callers accordingly. + (byte-compile-lambda): Use `assert'. + (byte-compile-defun, byte-compile-defmacro): Remove. + (byte-compile-file-form-defalias): + Use byte-compile-file-form-defmumble. + (byte-compile-defalias-warn): Remove. + 2012-05-29 Stefan Merten * textmodes/rst.el: Silence `checkdoc-ispell' errors where - possible. Fix authors. Improve comments. Improve loading of - `cl'. + possible. Fix authors. Improve comments. Improve loading of `cl'. (rst-mode-abbrev-table): Merge definition. (rst-mode): Make sure `font-lock-defaults' is buffer local. @@ -14,8 +38,8 @@ (icalendar-export-region): Export UID properly. 2012-05-29 Leo - * calendar/icalendar.el (icalendar-import-format): Add - `icalendar-import-format-uid' (Bug#11525). + * calendar/icalendar.el (icalendar-import-format): + Add `icalendar-import-format-uid' (Bug#11525). (icalendar-import-format-uid): New. (icalendar--parse-summary-and-rest, icalendar--format-ical-event): Export UID. === modified file 'lisp/emacs-lisp/byte-opt.el' --- lisp/emacs-lisp/byte-opt.el 2012-05-29 14:28:02 +0000 +++ lisp/emacs-lisp/byte-opt.el 2012-05-30 03:59:42 +0000 @@ -500,7 +500,7 @@ (prin1-to-string form)) nil) - ((memq fn '(defun defmacro function condition-case)) + ((memq fn '(function condition-case)) ;; These forms are compiled as constants or by breaking out ;; all the subexpressions and compiling them separately. form) === modified file 'lisp/emacs-lisp/byte-run.el' --- lisp/emacs-lisp/byte-run.el 2012-05-18 01:46:20 +0000 +++ lisp/emacs-lisp/byte-run.el 2012-05-30 03:59:42 +0000 @@ -34,33 +34,98 @@ ;; handle declarations in macro definitions and this is the first file ;; loaded by loadup.el that uses declarations in macros. -(defun macro-declaration-function (macro decl) - "Process a declaration found in a macro definition. +(defvar macro-declaration-function #'macro-declaration-function + "Function to process declarations in a macro definition. +The function will be called with two args MACRO and DECL. +MACRO is the name of the macro being defined. +DECL is a list `(declare ...)' containing the declarations. +The value the function returns is not used.") + +(defalias 'macro-declaration-function + #'(lambda (macro decl) + "Process a declaration found in a macro definition. This is set as the value of the variable `macro-declaration-function'. MACRO is the name of the macro being defined. DECL is a list `(declare ...)' containing the declarations. The return value of this function is not used." - ;; We can't use `dolist' or `cadr' yet for bootstrapping reasons. - (let (d) - ;; Ignore the first element of `decl' (it's always `declare'). - (while (setq decl (cdr decl)) - (setq d (car decl)) - (if (and (consp d) - (listp (cdr d)) - (null (cdr (cdr d)))) - (cond ((eq (car d) 'indent) - (put macro 'lisp-indent-function (car (cdr d)))) - ((eq (car d) 'debug) - (put macro 'edebug-form-spec (car (cdr d)))) - ((eq (car d) 'doc-string) - (put macro 'doc-string-elt (car (cdr d)))) - (t - (message "Unknown declaration %s" d))) - (message "Invalid declaration %s" d))))) - - -(setq macro-declaration-function 'macro-declaration-function) - + ;; We can't use `dolist' or `cadr' yet for bootstrapping reasons. + (let (d) + ;; Ignore the first element of `decl' (it's always `declare'). + (while (setq decl (cdr decl)) + (setq d (car decl)) + (if (and (consp d) + (listp (cdr d)) + (null (cdr (cdr d)))) + (cond ((eq (car d) 'indent) + (put macro 'lisp-indent-function (car (cdr d)))) + ((eq (car d) 'debug) + (put macro 'edebug-form-spec (car (cdr d)))) + ((eq (car d) 'doc-string) + (put macro 'doc-string-elt (car (cdr d)))) + (t + (message "Unknown declaration %s" d))) + (message "Invalid declaration %s" d)))))) + +(put 'defmacro 'doc-string-elt 3) +(defalias 'defmacro + (cons + 'macro + #'(lambda (name arglist &optional docstring decl &rest body) + "Define NAME as a macro. +When the macro is called, as in (NAME ARGS...), +the function (lambda ARGLIST BODY...) is applied to +the list ARGS... as it appears in the expression, +and the result should be a form to be evaluated instead of the original. + +DECL is a declaration, optional, which can specify how to indent +calls to this macro, how Edebug should handle it, and which argument +should be treated as documentation. It looks like this: + (declare SPECS...) +The elements can look like this: + (indent INDENT) + Set NAME's `lisp-indent-function' property to INDENT. + + (debug DEBUG) + Set NAME's `edebug-form-spec' property to DEBUG. (This is + equivalent to writing a `def-edebug-spec' for the macro.) + + (doc-string ELT) + Set NAME's `doc-string-elt' property to ELT." + (if (stringp docstring) nil + (if decl (setq body (cons decl body))) + (setq decl docstring) + (setq docstring nil)) + (if (or (null decl) (eq 'declare (car-safe decl))) nil + (setq body (cons decl body)) + (setq decl nil)) + (if (null body) (setq body '(nil))) + (if docstring (setq body (cons docstring body))) + ;; Can't use backquote because it's not defined yet! + (let* ((fun (list 'function (cons 'lambda (cons arglist body)))) + (def (list 'defalias + (list 'quote name) + (list 'cons ''macro fun)))) + (if decl + (list 'progn + (list 'funcall 'macro-declaration-function + (list 'quote name) + (list 'quote decl)) + def) + def))))) + +;; Now that we defined defmacro we can use it! +(defmacro defun (name arglist &optional docstring &rest body) + "Define NAME as a function. +The definition is (lambda ARGLIST [DOCSTRING] BODY...). +See also the function `interactive'." + (declare (doc-string 3)) + (if docstring (setq body (cons docstring body)) + (if (null body) (setq body '(nil)))) + (list 'defalias + (list 'quote name) + (list 'function + (cons 'lambda + (cons arglist body))))) ;; Redefined in byte-optimize.el. ;; This is not documented--it's not clear that we should promote it. === modified file 'lisp/emacs-lisp/bytecomp.el' --- lisp/emacs-lisp/bytecomp.el 2012-05-29 14:28:02 +0000 +++ lisp/emacs-lisp/bytecomp.el 2012-05-30 03:59:42 +0000 @@ -1169,12 +1169,14 @@ (t fn))))))) (defun byte-compile-arglist-signature (arglist) - (if (integerp arglist) - ;; New style byte-code arglist. - (cons (logand arglist 127) ;Mandatory. - (if (zerop (logand arglist 128)) ;No &rest. - (lsh arglist -8))) ;Nonrest. - ;; Old style byte-code, or interpreted function. + (cond + ;; New style byte-code arglist. + ((integerp arglist) + (cons (logand arglist 127) ;Mandatory. + (if (zerop (logand arglist 128)) ;No &rest. + (lsh arglist -8)))) ;Nonrest. + ;; Old style byte-code, or interpreted function. + ((listp arglist) (let ((args 0) opts restp) @@ -1190,7 +1192,9 @@ (setq opts (1+ opts)) (setq args (1+ args))))) (setq arglist (cdr arglist))) - (cons args (if restp nil (if opts (+ args opts) args)))))) + (cons args (if restp nil (if opts (+ args opts) args))))) + ;; Unknown arglist. + (t '(0)))) (defun byte-compile-arglist-signatures-congruent-p (old new) @@ -1250,8 +1254,8 @@ ;; and/or remember its arity if it's unknown. (or (and (or def (fboundp (car form))) ; might be a subr or autoload. (not (memq (car form) byte-compile-noruntime-functions))) - (eq (car form) byte-compile-current-form) ; ## this doesn't work - ; with recursion. + (eq (car form) byte-compile-current-form) ; ## This doesn't work + ; with recursion. ;; It's a currently-undefined function. ;; Remember number of args in call. (let ((cons (assq (car form) byte-compile-unresolved-functions)) @@ -1316,9 +1320,8 @@ ;; Warn if the function or macro is being redefined with a different ;; number of arguments. -(defun byte-compile-arglist-warn (form macrop) - (let* ((name (nth 1 form)) - (old (byte-compile-fdefinition name macrop)) +(defun byte-compile-arglist-warn (name arglist macrop) + (let* ((old (byte-compile-fdefinition name macrop)) (initial (and macrop (cdr (assq name byte-compile-initial-macro-environment))))) @@ -1337,12 +1340,12 @@ (`(closure ,_ ,args . ,_) args) ((pred byte-code-function-p) (aref old 0)) (t '(&rest def))))) - (sig2 (byte-compile-arglist-signature (nth 2 form)))) + (sig2 (byte-compile-arglist-signature arglist))) (unless (byte-compile-arglist-signatures-congruent-p sig1 sig2) (byte-compile-set-symbol-position name) (byte-compile-warn "%s %s used to take %s %s, now takes %s" - (if (eq (car form) 'defun) "function" "macro") + (if macrop "macro" "function") name (byte-compile-arglist-signature-string sig1) (if (equal sig1 '(1 . 1)) "argument" "arguments") @@ -1356,7 +1359,7 @@ 'byte-compile-inline-expand)) (byte-compile-warn "defsubst `%s' was used before it was defined" name)) - (setq sig (byte-compile-arglist-signature (nth 2 form)) + (setq sig (byte-compile-arglist-signature arglist) nums (sort (copy-sequence (cdr calls)) (function <)) min (car nums) max (car (nreverse nums))) @@ -2021,31 +2024,30 @@ ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")))) (defun byte-compile-output-file-form (form) - ;; writes the given form to the output buffer, being careful of docstrings + ;; Write the given form to the output buffer, being careful of docstrings ;; in defun, defmacro, defvar, defvaralias, defconst, autoload and ;; custom-declare-variable because make-docfile is so amazingly stupid. ;; defalias calls are output directly by byte-compile-file-form-defmumble; ;; it does not pay to first build the defalias in defmumble and then parse ;; it here. - (if (and (memq (car-safe form) '(defun defmacro defvar defvaralias defconst - autoload custom-declare-variable)) - (stringp (nth 3 form))) - (byte-compile-output-docform nil nil '("\n(" 3 ")") form nil - (memq (car form) - '(defvaralias autoload - custom-declare-variable))) - (let ((print-escape-newlines t) - (print-length nil) - (print-level nil) - (print-quoted t) - (print-gensym t) - (print-circle ; handle circular data structures - (not byte-compile-disable-print-circle))) + (let ((print-escape-newlines t) + (print-length nil) + (print-level nil) + (print-quoted t) + (print-gensym t) + (print-circle ; Handle circular data structures. + (not byte-compile-disable-print-circle))) + (if (and (memq (car-safe form) '(defun defmacro defvar defvaralias defconst + autoload custom-declare-variable)) + (stringp (nth 3 form))) + (byte-compile-output-docform nil nil '("\n(" 3 ")") form nil + (memq (car form) + '(defvaralias autoload + custom-declare-variable))) (princ "\n" byte-compile--outbuffer) (prin1 form byte-compile--outbuffer) nil))) -(defvar print-gensym-alist) ;Used before print-circle existed. (defvar byte-compile--for-effect) (defun byte-compile-output-docform (preface name info form specindex quoted) @@ -2075,7 +2077,6 @@ (setq position (byte-compile-output-as-comment (nth (nth 1 info) form) nil)) - (setq position (- (position-bytes position) (point-min) -1)) ;; If the doc string starts with * (a user variable), ;; negate POSITION. (if (and (stringp (nth (nth 1 info) form)) @@ -2088,17 +2089,7 @@ (insert preface) (prin1 name byte-compile--outbuffer))) (insert (car info)) - (let ((print-escape-newlines t) - (print-quoted t) - ;; For compatibility with code before print-circle, - ;; use a cons cell to say that we want - ;; print-gensym-alist not to be cleared - ;; between calls to print functions. - (print-gensym '(t)) - (print-circle ; handle circular data structures - (not byte-compile-disable-print-circle)) - print-gensym-alist ; was used before print-circle existed. - (print-continuous-numbering t) + (let ((print-continuous-numbering t) print-number-table (index 0)) (prin1 (car form) byte-compile--outbuffer) @@ -2121,8 +2112,6 @@ (byte-compile-output-as-comment (cons (car form) (nth 1 form)) t))) - (setq position (- (position-bytes position) - (point-min) -1)) (princ (format "(#$ . %d) nil" position) byte-compile--outbuffer) (setq form (cdr form)) @@ -2317,143 +2306,132 @@ (nth 1 (nth 1 form)) (byte-compile-keep-pending form))) -(put 'defun 'byte-hunk-handler 'byte-compile-file-form-defun) -(defun byte-compile-file-form-defun (form) - (byte-compile-file-form-defmumble form nil)) - -(put 'defmacro 'byte-hunk-handler 'byte-compile-file-form-defmacro) -(defun byte-compile-file-form-defmacro (form) - (byte-compile-file-form-defmumble form t)) - -(defun byte-compile-defmacro-declaration (form) - "Generate code for declarations in macro definitions. -Remove declarations from the body of the macro definition -by side-effects." - (let ((tail (nthcdr 2 form)) - (res '())) - (when (stringp (car (cdr tail))) - (setq tail (cdr tail))) - (while (and (consp (car (cdr tail))) - (eq (car (car (cdr tail))) 'declare)) - (let ((declaration (car (cdr tail)))) - (setcdr tail (cdr (cdr tail))) - (push `(if macro-declaration-function - (funcall macro-declaration-function - ',(car (cdr form)) ',declaration)) - res))) - res)) - -(defun byte-compile-file-form-defmumble (form macrop) - (let* ((name (car (cdr form))) - (this-kind (if macrop 'byte-compile-macro-environment - 'byte-compile-function-environment)) - (that-kind (if macrop 'byte-compile-function-environment - 'byte-compile-macro-environment)) - (this-one (assq name (symbol-value this-kind))) - (that-one (assq name (symbol-value that-kind))) - (byte-compile-free-references nil) - (byte-compile-free-assignments nil)) +(defun byte-compile-file-form-defmumble (name macro arglist body rest) + "Process a `defalias' for NAME. +If MACRO is non-nil, the definition is known to be a macro. +ARGLIST is the list of arguments, if it was recognized or t otherwise. +BODY of the definition, or t if not recognized. +Return non-nil if everything went as planned, or nil to imply that it decided +not to take responsibility for the actual compilation of the code." + (let* ((this-kind (if macro 'byte-compile-macro-environment + 'byte-compile-function-environment)) + (that-kind (if macro 'byte-compile-function-environment + 'byte-compile-macro-environment)) + (this-one (assq name (symbol-value this-kind))) + (that-one (assq name (symbol-value that-kind))) + (byte-compile-current-form name)) ; For warnings. + (byte-compile-set-symbol-position name) ;; When a function or macro is defined, add it to the call tree so that ;; we can tell when functions are not used. (if byte-compile-generate-call-tree - (or (assq name byte-compile-call-tree) - (setq byte-compile-call-tree - (cons (list name nil nil) byte-compile-call-tree)))) + (or (assq name byte-compile-call-tree) + (setq byte-compile-call-tree + (cons (list name nil nil) byte-compile-call-tree)))) - (setq byte-compile-current-form name) ; for warnings (if (byte-compile-warning-enabled-p 'redefine) - (byte-compile-arglist-warn form macrop)) + (byte-compile-arglist-warn name arglist macro)) + (if byte-compile-verbose - (message "Compiling %s... (%s)" - (or byte-compile-current-file "") (nth 1 form))) - (cond (that-one - (if (and (byte-compile-warning-enabled-p 'redefine) - ;; don't warn when compiling the stubs in byte-run... - (not (assq (nth 1 form) - byte-compile-initial-macro-environment))) - (byte-compile-warn + (message "Compiling %s... (%s)" + (or byte-compile-current-file "") name)) + (cond ((not (or macro (listp body))) + ;; We do not know positively if the definition is a macro + ;; or a function, so we shouldn't emit warnings. + ;; This also silences "multiple definition" warnings for defmethods. + nil) + (that-one + (if (and (byte-compile-warning-enabled-p 'redefine) + ;; Don't warn when compiling the stubs in byte-run... + (not (assq name byte-compile-initial-macro-environment))) + (byte-compile-warn "`%s' defined multiple times, as both function and macro" - (nth 1 form))) - (setcdr that-one nil)) - (this-one - (when (and (byte-compile-warning-enabled-p 'redefine) - ;; hack: don't warn when compiling the magic internal + name)) + (setcdr that-one nil)) + (this-one + (when (and (byte-compile-warning-enabled-p 'redefine) + ;; Hack: Don't warn when compiling the magic internal ;; byte-compiler macros in byte-run.el... - (not (assq (nth 1 form) - byte-compile-initial-macro-environment))) - (byte-compile-warn "%s `%s' defined multiple times in this file" - (if macrop "macro" "function") - (nth 1 form)))) - ((and (fboundp name) - (eq (car-safe (symbol-function name)) - (if macrop 'lambda 'macro))) - (when (byte-compile-warning-enabled-p 'redefine) - (byte-compile-warn "%s `%s' being redefined as a %s" - (if macrop "function" "macro") - (nth 1 form) - (if macrop "macro" "function"))) - ;; shadow existing definition - (set this-kind - (cons (cons name nil) - (symbol-value this-kind)))) - ) - (let ((body (nthcdr 3 form))) - (when (and (stringp (car body)) - (symbolp (car-safe (cdr-safe body))) - (car-safe (cdr-safe body)) - (stringp (car-safe (cdr-safe (cdr-safe body))))) - (byte-compile-set-symbol-position (nth 1 form)) - (byte-compile-warn "probable `\"' without `\\' in doc string of %s" - (nth 1 form)))) - - ;; Generate code for declarations in macro definitions. - ;; Remove declarations from the body of the macro definition. - (when macrop - (dolist (decl (byte-compile-defmacro-declaration form)) - (prin1 decl byte-compile--outbuffer))) - - (let* ((code (byte-compile-lambda (nthcdr 2 form) t))) - (if this-one - ;; A definition in b-c-initial-m-e should always take precedence - ;; during compilation, so don't let it be redefined. (Bug#8647) - (or (and macrop - (assq name byte-compile-initial-macro-environment)) - (setcdr this-one code)) - (set this-kind - (cons (cons name code) - (symbol-value this-kind)))) - (byte-compile-flush-pending) - (if (not (stringp (nth 3 form))) - ;; No doc string. Provide -1 as the "doc string index" - ;; so that no element will be treated as a doc string. - (byte-compile-output-docform - "\n(defalias '" - name - (if macrop '(" '(macro . #[" -1 "])") '(" #[" -1 "]")) - (append code nil) ; Turn byte-code-function-p into list. - (and (atom code) byte-compile-dynamic - 1) - nil) - ;; Output the form by hand, that's much simpler than having - ;; b-c-output-file-form analyze the defalias. - (byte-compile-output-docform - "\n(defalias '" - name - (if macrop '(" '(macro . #[" 4 "])") '(" #[" 4 "]")) - (append code nil) ; Turn byte-code-function-p into list. - (and (atom code) byte-compile-dynamic - 1) - nil)) - (princ ")" byte-compile--outbuffer) - nil))) - -;; Print Lisp object EXP in the output file, inside a comment, -;; and return the file position it will have. -;; If QUOTED is non-nil, print with quoting; otherwise, print without quoting. + (not (assq name byte-compile-initial-macro-environment))) + (byte-compile-warn "%s `%s' defined multiple times in this file" + (if macro "macro" "function") + name))) + ((and (fboundp name) + (eq (car-safe (symbol-function name)) + (if macro 'lambda 'macro))) + (when (byte-compile-warning-enabled-p 'redefine) + (byte-compile-warn "%s `%s' being redefined as a %s" + (if macro "function" "macro") + name + (if macro "macro" "function"))) + ;; Shadow existing definition. + (set this-kind + (cons (cons name nil) + (symbol-value this-kind)))) + ) + + (when (and (listp body) + (stringp (car body)) + (symbolp (car-safe (cdr-safe body))) + (car-safe (cdr-safe body)) + (stringp (car-safe (cdr-safe (cdr-safe body))))) + ;; FIXME: We've done that already just above, so this looks wrong! + ;;(byte-compile-set-symbol-position name) + (byte-compile-warn "probable `\"' without `\\' in doc string of %s" + name)) + + (if (not (listp body)) + ;; The precise definition requires evaluation to find out, so it + ;; will only be known at runtime. + ;; For a macro, that means we can't use that macro in the same file. + (progn + (unless macro + (push (cons name (if (listp arglist) `(declared ,arglist) t)) + byte-compile-function-environment)) + ;; Tell the caller that we didn't compile it yet. + nil) + + (let* ((code (byte-compile-lambda (cons arglist body) t))) + (if this-one + ;; A definition in b-c-initial-m-e should always take precedence + ;; during compilation, so don't let it be redefined. (Bug#8647) + (or (and macro + (assq name byte-compile-initial-macro-environment)) + (setcdr this-one code)) + (set this-kind + (cons (cons name code) + (symbol-value this-kind)))) + + (if rest + ;; There are additional args to `defalias' (like maybe a docstring) + ;; that the code below can't handle: punt! + nil + ;; Otherwise, we have a bona-fide defun/defmacro definition, and use + ;; special code to allow dynamic docstrings and byte-code. + (byte-compile-flush-pending) + (let ((index + ;; If there's no doc string, provide -1 as the "doc string + ;; index" so that no element will be treated as a doc string. + (if (not (stringp (car body))) -1 4))) + ;; Output the form by hand, that's much simpler than having + ;; b-c-output-file-form analyze the defalias. + (byte-compile-output-docform + "\n(defalias '" + name + (if macro `(" '(macro . #[" ,index "])") `(" #[" ,index "]")) + (append code nil) ; Turn byte-code-function-p into list. + (and (atom code) byte-compile-dynamic + 1) + nil)) + (princ ")" byte-compile--outbuffer) + t))))) + (defun byte-compile-output-as-comment (exp quoted) - (let ((position (point))) - (with-current-buffer byte-compile--outbuffer + "Print Lisp object EXP in the output file, inside a comment, +and return the file (byte) position it will have. +If QUOTED is non-nil, print with quoting; otherwise, print without quoting." + (with-current-buffer byte-compile--outbuffer + (let ((position (point))) ;; Insert EXP, and make it a comment with #@LENGTH. (insert " ") @@ -2478,13 +2456,12 @@ (position-bytes position)))) ;; Save the file position of the object. - ;; Note we should add 1 to skip the space - ;; that we inserted before the actual doc string, - ;; and subtract 1 to convert from an 1-origin Emacs position - ;; to a file position; they cancel. - (setq position (point)) - (goto-char (point-max))) - position)) + ;; Note we add 1 to skip the space that we inserted before the actual doc + ;; string, and subtract point-min to convert from an 1-origin Emacs + ;; position to a file position. + (prog1 + (- (position-bytes (point)) (point-min) -1) + (goto-char (point-max)))))) @@ -2581,14 +2558,15 @@ (lsh nonrest 8) (lsh rest 7))))) -;; Byte-compile a lambda-expression and return a valid function. -;; The value is usually a compiled function but may be the original -;; lambda-expression. -;; When ADD-LAMBDA is non-nil, the symbol `lambda' is added as head -;; of the list FUN and `byte-compile-set-symbol-position' is not called. -;; Use this feature to avoid calling `byte-compile-set-symbol-position' -;; for symbols generated by the byte compiler itself. + (defun byte-compile-lambda (fun &optional add-lambda reserved-csts) + "Byte-compile a lambda-expression and return a valid function. +The value is usually a compiled function but may be the original +lambda-expression. +When ADD-LAMBDA is non-nil, the symbol `lambda' is added as head +of the list FUN and `byte-compile-set-symbol-position' is not called. +Use this feature to avoid calling `byte-compile-set-symbol-position' +for symbols generated by the byte compiler itself." (if add-lambda (setq fun (cons 'lambda fun)) (unless (eq 'lambda (car-safe fun)) @@ -2649,24 +2627,23 @@ (byte-compile-make-lambda-lexenv fun)) reserved-csts))) ;; Build the actual byte-coded function. - (if (eq 'byte-code (car-safe compiled)) - (apply 'make-byte-code - (if lexical-binding - (byte-compile-make-args-desc arglist) - arglist) - (append - ;; byte-string, constants-vector, stack depth - (cdr compiled) - ;; optionally, the doc string. - (cond (lexical-binding - (require 'help-fns) - (list (help-add-fundoc-usage doc arglist))) - ((or doc int) - (list doc))) - ;; optionally, the interactive spec. - (if int - (list (nth 1 int))))) - (error "byte-compile-top-level did not return byte-code"))))) + (assert (eq 'byte-code (car-safe compiled))) + (apply #'make-byte-code + (if lexical-binding + (byte-compile-make-args-desc arglist) + arglist) + (append + ;; byte-string, constants-vector, stack depth + (cdr compiled) + ;; optionally, the doc string. + (cond (lexical-binding + (require 'help-fns) + (list (help-add-fundoc-usage doc arglist))) + ((or doc int) + (list doc))) + ;; optionally, the interactive spec. + (if int + (list (nth 1 int)))))))) (defvar byte-compile-reserved-constants 0) @@ -3066,9 +3043,9 @@ (byte-compile-check-variable var 'assign) (let ((lex-binding (assq var byte-compile--lexical-environment))) (if lex-binding - ;; VAR is lexically bound + ;; VAR is lexically bound. (byte-compile-stack-set (cdr lex-binding)) - ;; VAR is dynamically bound + ;; VAR is dynamically bound. (unless (or (not (byte-compile-warning-enabled-p 'free-vars)) (boundp var) (memq var byte-compile-bound-variables) @@ -3353,6 +3330,7 @@ (body (nthcdr 3 form)) (fun (byte-compile-lambda `(lambda ,vars . ,body) nil (length env)))) + (assert (> (length env) 0)) ;Otherwise, we don't need a closure. (assert (byte-code-function-p fun)) (byte-compile-form `(make-byte-code ',(aref fun 0) ',(aref fun 1) @@ -4074,36 +4052,11 @@ ;;; top-level forms elsewhere -(byte-defop-compiler-1 defun) -(byte-defop-compiler-1 defmacro) (byte-defop-compiler-1 defvar) (byte-defop-compiler-1 defconst byte-compile-defvar) (byte-defop-compiler-1 autoload) (byte-defop-compiler-1 lambda byte-compile-lambda-form) -(defun byte-compile-defun (form) - ;; This is not used for file-level defuns with doc strings. - (if (symbolp (car form)) - (byte-compile-set-symbol-position (car form)) - (byte-compile-set-symbol-position 'defun) - (error "defun name must be a symbol, not %s" (car form))) - (byte-compile-push-constant 'defalias) - (byte-compile-push-constant (nth 1 form)) - (byte-compile-push-constant (byte-compile-lambda (cdr (cdr form)) t)) - (byte-compile-out 'byte-call 2)) - -(defun byte-compile-defmacro (form) - ;; This is not used for file-level defmacros with doc strings. - (byte-compile-body-do-effect - (let ((decls (byte-compile-defmacro-declaration form)) - (code (byte-compile-lambda (cdr (cdr form)) t))) - `((defalias ',(nth 1 form) - ,(if (eq (car-safe code) 'make-byte-code) - `(cons 'macro ,code) - `'(macro . ,(eval code)))) - ,@decls - ',(nth 1 form))))) - ;; If foo.el declares `toto' as obsolete, it is likely that foo.el will ;; actually use `toto' in order for this obsolete variable to still work ;; correctly, so paradoxically, while byte-compiling foo.el, the presence @@ -4179,38 +4132,53 @@ (put 'defalias 'byte-hunk-handler 'byte-compile-file-form-defalias) ;; Used for eieio--defalias as well. (defun byte-compile-file-form-defalias (form) - (if (and (consp (cdr form)) (consp (nth 1 form)) - (eq (car (nth 1 form)) 'quote) - (consp (cdr (nth 1 form))) - (symbolp (nth 1 (nth 1 form)))) - (let ((constant - (and (consp (nthcdr 2 form)) - (consp (nth 2 form)) - (eq (car (nth 2 form)) 'quote) - (consp (cdr (nth 2 form))) - (symbolp (nth 1 (nth 2 form)))))) - (byte-compile-defalias-warn (nth 1 (nth 1 form))) - (push (cons (nth 1 (nth 1 form)) - (if constant (nth 1 (nth 2 form)) t)) - byte-compile-function-environment))) - ;; We used to just do: (byte-compile-normal-call form) - ;; But it turns out that this fails to optimize the code. - ;; So instead we now do the same as what other byte-hunk-handlers do, - ;; which is to call back byte-compile-file-form and then return nil. - ;; Except that we can't just call byte-compile-file-form since it would - ;; call us right back. - (byte-compile-keep-pending form) - ;; Return nil so the form is not output twice. - nil) + ;; For the compilation itself, we could largely get rid of this hunk-handler, + ;; if it weren't for the fact that we need to figure out when a defalias + ;; defines a macro, so as to add it to byte-compile-macro-environment. + ;; + ;; FIXME: we also use this hunk-handler to implement the function's dynamic + ;; docstring feature. We could actually implement it more elegantly in + ;; byte-compile-lambda so it applies to all lambdas, but the problem is that + ;; the resulting .elc format will not be recognized by make-docfile, so + ;; either we stop using DOC for the docstrings of preloaded elc files (at the + ;; cost of around 24KB on 32bit hosts, double on 64bit hosts) or we need to + ;; build DOC in a more clever way (e.g. handle anonymous elements). + (let ((byte-compile-free-references nil) + (byte-compile-free-assignments nil)) + (pcase form + ;; Decompose `form' into: + ;; - `name' is the name of the defined function. + ;; - `arg' is the expression to which it is defined. + ;; - `rest' is the rest of the arguments. + (`(,_ ',name ,arg . ,rest) + (pcase-let* + ;; `macro' is non-nil if it defines a macro. + ;; `fun' is the function part of `arg' (defaults to `arg'). + (((or (and (or `(cons 'macro ,fun) `'(macro . ,fun)) (let macro t)) + (and (let fun arg) (let macro nil))) + arg) + ;; `lam' is the lambda expression in `fun' (or nil if not + ;; recognized). + ((or `(,(or `quote `function) ,lam) (let lam nil)) + fun) + ;; `arglist' is the list of arguments (or t if not recognized). + ;; `body' is the body of `lam' (or t if not recognized). + ((or `(lambda ,arglist . ,body) + ;; `(closure ,_ ,arglist . ,body) + (and `(internal-make-closure ,arglist . ,_) (let body t)) + (and (let arglist t) (let body t))) + lam)) + (unless (byte-compile-file-form-defmumble + name macro arglist body rest) + (byte-compile-keep-pending form)))) -;; Turn off warnings about prior calls to the function being defalias'd. -;; This could be smarter and compare those calls with -;; the function it is being aliased to. -(defun byte-compile-defalias-warn (new) - (let ((calls (assq new byte-compile-unresolved-functions))) - (if calls - (setq byte-compile-unresolved-functions - (delq calls byte-compile-unresolved-functions))))) + ;; We used to just do: (byte-compile-normal-call form) + ;; But it turns out that this fails to optimize the code. + ;; So instead we now do the same as what other byte-hunk-handlers do, + ;; which is to call back byte-compile-file-form and then return nil. + ;; Except that we can't just call byte-compile-file-form since it would + ;; call us right back. + (t (byte-compile-keep-pending form))))) (byte-defop-compiler-1 with-no-warnings byte-compile-no-warnings) (defun byte-compile-no-warnings (form) === modified file 'lisp/emacs-lisp/cconv.el' --- lisp/emacs-lisp/cconv.el 2012-04-26 03:18:47 +0000 +++ lisp/emacs-lisp/cconv.el 2012-05-30 03:59:42 +0000 @@ -73,8 +73,6 @@ ;; since afterwards they can because obnoxious (warnings about an "unused ;; variable" should not be emitted when the variable use has simply been ;; optimized away). -;; - turn defun and defmacro into macros (and remove special handling of -;; `declare' afterwards). ;; - let macros specify that some let-bindings come from the same source, ;; so the unused warning takes all uses into account. ;; - let interactive specs return a function to build the args (to stash into @@ -410,20 +408,6 @@ . ,(mapcar (lambda (form) (cconv-convert form env extend)) forms))) - ;defun, defmacro - (`(,(and sym (or `defun `defmacro)) - ,func ,args . ,body) - (assert (equal body (caar cconv-freevars-alist))) - (assert (null (cdar cconv-freevars-alist))) - - (let ((new (cconv--convert-function args body env form))) - (pcase new - (`(function (lambda ,newargs . ,new-body)) - (assert (equal args newargs)) - `(,sym ,func ,args . ,new-body)) - (t (byte-compile-report-error - (format "Internal error in cconv of (%s %s ...)" sym func)))))) - ;condition-case (`(condition-case ,var ,protected-form . ,handlers) (let ((newform (cconv--convert-function @@ -618,15 +602,6 @@ (dolist (vardata newvars) (cconv--analyse-use vardata form "variable")))) - ; defun special form - (`(,(or `defun `defmacro) ,func ,vrs . ,body-forms) - (when env - (byte-compile-log-warning - (format "Function %S will ignore its context %S" - func (mapcar #'car env)) - t :warning)) - (cconv--analyse-function vrs body-forms nil form)) - (`(function (lambda ,vrs . ,body-forms)) (cconv--analyse-function vrs body-forms env form)) === modified file 'lisp/emacs-lisp/elint.el' --- lisp/emacs-lisp/elint.el 2012-01-19 07:21:25 +0000 +++ lisp/emacs-lisp/elint.el 2012-05-30 03:59:42 +0000 @@ -357,6 +357,8 @@ (set (make-local-variable 'elint-buffer-env) (elint-init-env elint-buffer-forms)) (if elint-preloaded-env + ;; FIXME: This doesn't do anything! Should we setq the result to + ;; elint-buffer-env? (elint-env-add-env elint-preloaded-env elint-buffer-env)) (set (make-local-variable 'elint-last-env-time) (buffer-modified-tick)) elint-buffer-forms)) === modified file 'lisp/emacs-lisp/lisp-mode.el' --- lisp/emacs-lisp/lisp-mode.el 2012-05-27 09:45:54 +0000 +++ lisp/emacs-lisp/lisp-mode.el 2012-05-30 03:59:42 +0000 @@ -135,11 +135,9 @@ ;; This was originally in autoload.el and is still used there. (put 'autoload 'doc-string-elt 3) -(put 'defun 'doc-string-elt 3) (put 'defmethod 'doc-string-elt 3) (put 'defvar 'doc-string-elt 3) (put 'defconst 'doc-string-elt 3) -(put 'defmacro 'doc-string-elt 3) (put 'defalias 'doc-string-elt 3) (put 'defvaralias 'doc-string-elt 3) (put 'define-category 'doc-string-elt 2) === modified file 'lisp/emacs-lisp/macroexp.el' --- lisp/emacs-lisp/macroexp.el 2012-01-19 07:21:25 +0000 +++ lisp/emacs-lisp/macroexp.el 2012-05-30 03:59:42 +0000 @@ -65,7 +65,7 @@ (,unshared nil) (,tail ,shared) ,var ,new-el) - (while ,tail + (while (consp ,tail) (setq ,var (car ,tail) ,new-el (progn ,@body)) (unless (eq ,var ,new-el) @@ -128,20 +128,6 @@ (cddr form)) (cdr form)) form)) - (`(defmacro ,name . ,args-and-body) - (push (cons name (cons 'lambda args-and-body)) - macroexpand-all-environment) - (let ((n 3)) - ;; Don't macroexpand `declare' since it should really be "expanded" - ;; away when `defmacro' is expanded, but currently defmacro is not - ;; itself a macro. So both `defmacro' and `declare' need to be - ;; handled directly in bytecomp.el. - ;; FIXME: Maybe a simpler solution is to (defalias 'declare 'quote). - (while (or (stringp (nth n form)) - (eq (car-safe (nth n form)) 'declare)) - (setq n (1+ n))) - (macroexpand-all-forms form n))) - (`(defun . ,_) (macroexpand-all-forms form 3)) (`(,(or `defvar `defconst) . ,_) (macroexpand-all-forms form 2)) (`(function ,(and f `(lambda . ,_))) (maybe-cons 'function === modified file 'lisp/loadup.el' --- lisp/loadup.el 2012-05-25 22:13:24 +0000 +++ lisp/loadup.el 2012-05-30 03:59:42 +0000 @@ -318,6 +318,21 @@ ;; At this point, we're ready to resume undo recording for scratch. (buffer-enable-undo "*scratch*") +(when (hash-table-p purify-flag) + (let ((strings 0) + (vectors 0) + (conses 0) + (others 0)) + (maphash (lambda (k v) + (cond + ((stringp k) (setq strings (1+ strings))) + ((vectorp k) (setq vectors (1+ vectors))) + ((consp k) (setq conses (1+ conses))) + (t (setq others (1+ others))))) + purify-flag) + (message "Pure-hashed: %d strings, %d vectors, %d conses, %d others" + strings vectors conses others))) + ;; Avoid error if user loads some more libraries now and make sure the ;; hash-consing hash table is GC'd. (setq purify-flag nil) === modified file 'src/ChangeLog' --- src/ChangeLog 2012-05-29 21:33:38 +0000 +++ src/ChangeLog 2012-05-30 03:59:42 +0000 @@ -1,3 +1,13 @@ +2012-05-30 Stefan Monnier + + * eval.c (Fdefun, Fdefmacro, Vmacro_declaration_function): + Move to byte-run.el. + (Fautoload): Do the hash-doc more carefully. + * data.c (Fdefalias): Purify definition, except for keymaps. + (Qdefun): Move from eval.c. + * lisp.h (Qdefun): Remove. + * lread.c (read1): Tiny simplification. + 2012-05-29 Troels Nielsen Do not create empty overlays with the evaporate property (Bug#9642). @@ -11,8 +21,8 @@ * w32term.c (my_bring_window_to_top): New function. (x_raise_frame): Use handle returned by DeferWindowPos, which - could be different from the original one. Call - my_bring_window_to_top instead of my_set_foreground_window. + could be different from the original one. + Call my_bring_window_to_top instead of my_set_foreground_window. (Bug#11513) * w32fns.c (w32_wnd_proc): Accept and process WM_EMACS_BRINGTOTOP @@ -103,12 +113,12 @@ 2012-05-26 Eli Zaretskii Extend mouse support on W32 text-mode console. - * xdisp.c (draw_row_with_mouse_face): Call - tty_draw_row_with_mouse_face for WINDOWSNT as well. + * xdisp.c (draw_row_with_mouse_face): + Call tty_draw_row_with_mouse_face for WINDOWSNT as well. * w32console.c: Include window.h. - (w32con_write_glyphs_with_face, tty_draw_row_with_mouse_face): New - functions. + (w32con_write_glyphs_with_face, tty_draw_row_with_mouse_face): + New functions. (initialize_w32_display): Initialize mouse-highlight data. * w32inevt.c: Include termchar.h and window.h. @@ -646,7 +656,7 @@ (marker_byte_position, Fbuffer_has_markers_at): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fset_marker, set_marker_restricted): Don't assume fixnum fits in int. - * menu.c (ensure_menu_items): Renamed from grow_menu_items. + * menu.c (ensure_menu_items): Rename from grow_menu_items. It now merely ensures that the menu is large enough, without necessarily growing it, as this avoids some integer overflow issues. All callers changed. @@ -1091,8 +1101,8 @@ * xdisp.c (handle_single_display_spec): Return 1 for left-margin and right-margin display specs even if the spec is invalid or we - are on a TTY, and thus unable to display on the fringes. That's - because the text with the property will not be displayed anyway, + are on a TTY, and thus unable to display on the fringes. + That's because the text with the property will not be displayed anyway, so we need to signal to the caller that this is a "replacing" display spec. This fixes display when the spec is invalid or we are on a TTY. === modified file 'src/data.c' --- src/data.c 2012-05-25 18:19:24 +0000 +++ src/data.c 2012-05-30 03:59:42 +0000 @@ -34,6 +34,7 @@ #include "syssignal.h" #include "termhooks.h" /* For FRAME_KBOARD reference in y-or-n-p. */ #include "font.h" +#include "keymap.h" #include /* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */ @@ -92,6 +93,7 @@ static Lisp_Object Qchar_table, Qbool_vector, Qhash_table; static Lisp_Object Qsubrp, Qmany, Qunevalled; Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; +static Lisp_Object Qdefun; Lisp_Object Qinteractive_form; @@ -130,7 +132,7 @@ } -/* Data type predicates */ +/* Data type predicates. */ DEFUN ("eq", Feq, Seq, 2, 2, 0, doc: /* Return t if the two args are the same Lisp object. */) @@ -656,6 +658,10 @@ if (CONSP (XSYMBOL (symbol)->function) && EQ (XCAR (XSYMBOL (symbol)->function), Qautoload)) LOADHIST_ATTACH (Fcons (Qt, symbol)); + if (!NILP (Vpurify_flag) + /* If `definition' is a keymap, immutable (and copying) is wrong. */ + && !KEYMAPP (definition)) + definition = Fpurecopy (definition); definition = Ffset (symbol, definition); LOADHIST_ATTACH (Fcons (Qdefun, symbol)); if (!NILP (docstring)) @@ -3085,6 +3091,8 @@ DEFSYM (Qbool_vector, "bool-vector"); DEFSYM (Qhash_table, "hash-table"); + DEFSYM (Qdefun, "defun"); + DEFSYM (Qfont_spec, "font-spec"); DEFSYM (Qfont_entity, "font-entity"); DEFSYM (Qfont_object, "font-object"); === modified file 'src/eval.c' --- src/eval.c 2012-05-25 18:19:24 +0000 +++ src/eval.c 2012-05-30 03:59:42 +0000 @@ -65,7 +65,7 @@ int gcpro_level; #endif -Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp, Qdefun; +Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp; Lisp_Object Qinhibit_quit; Lisp_Object Qand_rest; static Lisp_Object Qand_optional; @@ -593,109 +593,6 @@ } -DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0, - doc: /* Define NAME as a function. -The definition is (lambda ARGLIST [DOCSTRING] BODY...). -See also the function `interactive'. -usage: (defun NAME ARGLIST [DOCSTRING] BODY...) */) - (Lisp_Object args) -{ - register Lisp_Object fn_name; - register Lisp_Object defn; - - fn_name = Fcar (args); - CHECK_SYMBOL (fn_name); - defn = Fcons (Qlambda, Fcdr (args)); - if (!NILP (Vinternal_interpreter_environment)) /* Mere optimization! */ - defn = Ffunction (Fcons (defn, Qnil)); - if (!NILP (Vpurify_flag)) - defn = Fpurecopy (defn); - if (CONSP (XSYMBOL (fn_name)->function) - && EQ (XCAR (XSYMBOL (fn_name)->function), Qautoload)) - LOADHIST_ATTACH (Fcons (Qt, fn_name)); - Ffset (fn_name, defn); - LOADHIST_ATTACH (Fcons (Qdefun, fn_name)); - return fn_name; -} - -DEFUN ("defmacro", Fdefmacro, Sdefmacro, 2, UNEVALLED, 0, - doc: /* Define NAME as a macro. -The actual definition looks like - (macro lambda ARGLIST [DOCSTRING] [DECL] BODY...). -When the macro is called, as in (NAME ARGS...), -the function (lambda ARGLIST BODY...) is applied to -the list ARGS... as it appears in the expression, -and the result should be a form to be evaluated instead of the original. - -DECL is a declaration, optional, which can specify how to indent -calls to this macro, how Edebug should handle it, and which argument -should be treated as documentation. It looks like this: - (declare SPECS...) -The elements can look like this: - (indent INDENT) - Set NAME's `lisp-indent-function' property to INDENT. - - (debug DEBUG) - Set NAME's `edebug-form-spec' property to DEBUG. (This is - equivalent to writing a `def-edebug-spec' for the macro.) - - (doc-string ELT) - Set NAME's `doc-string-elt' property to ELT. - -usage: (defmacro NAME ARGLIST [DOCSTRING] [DECL] BODY...) */) - (Lisp_Object args) -{ - register Lisp_Object fn_name; - register Lisp_Object defn; - Lisp_Object lambda_list, doc, tail; - - fn_name = Fcar (args); - CHECK_SYMBOL (fn_name); - lambda_list = Fcar (Fcdr (args)); - tail = Fcdr (Fcdr (args)); - - doc = Qnil; - if (STRINGP (Fcar (tail))) - { - doc = XCAR (tail); - tail = XCDR (tail); - } - - if (CONSP (Fcar (tail)) - && EQ (Fcar (Fcar (tail)), Qdeclare)) - { - if (!NILP (Vmacro_declaration_function)) - { - struct gcpro gcpro1; - GCPRO1 (args); - call2 (Vmacro_declaration_function, fn_name, Fcar (tail)); - UNGCPRO; - } - - tail = Fcdr (tail); - } - - if (NILP (doc)) - tail = Fcons (lambda_list, tail); - else - tail = Fcons (lambda_list, Fcons (doc, tail)); - - defn = Fcons (Qlambda, tail); - if (!NILP (Vinternal_interpreter_environment)) /* Mere optimization! */ - defn = Ffunction (Fcons (defn, Qnil)); - defn = Fcons (Qmacro, defn); - - if (!NILP (Vpurify_flag)) - defn = Fpurecopy (defn); - if (CONSP (XSYMBOL (fn_name)->function) - && EQ (XCAR (XSYMBOL (fn_name)->function), Qautoload)) - LOADHIST_ATTACH (Fcons (Qt, fn_name)); - Ffset (fn_name, defn); - LOADHIST_ATTACH (Fcons (Qdefun, fn_name)); - return fn_name; -} - - DEFUN ("defvaralias", Fdefvaralias, Sdefvaralias, 2, 3, 0, doc: /* Make NEW-ALIAS a variable alias for symbol BASE-VARIABLE. Aliased variables always have the same value; setting one sets the other. @@ -2014,12 +1911,11 @@ /* Only add entries after dumping, because the ones before are not useful and else we get loads of them from the loaddefs.el. */ LOADHIST_ATTACH (Fcons (Qautoload, function)); - else - /* We don't want the docstring in purespace (instead, - Snarf-documentation should (hopefully) overwrite it). - We used to use 0 here, but that leads to accidental sharing in - purecopy's hash-consing, so we use a (hopefully) unique integer - instead. */ + else if (EQ (docstring, make_number (0))) + /* `read1' in lread.c has found the docstring starting with "\ + and assumed the docstring will be provided by Snarf-documentation, so it + passed us 0 instead. But that leads to accidental sharing in purecopy's + hash-consing, so we use a (hopefully) unique integer instead. */ docstring = make_number (XUNTAG (function, Lisp_Symbol)); return Ffset (function, Fpurecopy (list5 (Qautoload, file, docstring, @@ -3576,7 +3472,6 @@ DEFSYM (Qinteractive, "interactive"); DEFSYM (Qcommandp, "commandp"); - DEFSYM (Qdefun, "defun"); DEFSYM (Qand_rest, "&rest"); DEFSYM (Qand_optional, "&optional"); DEFSYM (Qclosure, "closure"); @@ -3638,23 +3533,16 @@ still determine whether to handle the particular condition. */); Vdebug_on_signal = Qnil; - DEFVAR_LISP ("macro-declaration-function", Vmacro_declaration_function, - doc: /* Function to process declarations in a macro definition. -The function will be called with two args MACRO and DECL. -MACRO is the name of the macro being defined. -DECL is a list `(declare ...)' containing the declarations. -The value the function returns is not used. */); - Vmacro_declaration_function = Qnil; - /* When lexical binding is being used, - vinternal_interpreter_environment is non-nil, and contains an alist + Vinternal_interpreter_environment is non-nil, and contains an alist of lexically-bound variable, or (t), indicating an empty environment. The lisp name of this variable would be `internal-interpreter-environment' if it weren't hidden. Every element of this list can be either a cons (VAR . VAL) specifying a lexical binding, or a single symbol VAR indicating that this variable should use dynamic scoping. */ - DEFSYM (Qinternal_interpreter_environment, "internal-interpreter-environment"); + DEFSYM (Qinternal_interpreter_environment, + "internal-interpreter-environment"); DEFVAR_LISP ("internal-interpreter-environment", Vinternal_interpreter_environment, doc: /* If non-nil, the current lexical environment of the lisp interpreter. @@ -3685,8 +3573,6 @@ defsubr (&Ssetq); defsubr (&Squote); defsubr (&Sfunction); - defsubr (&Sdefun); - defsubr (&Sdefmacro); defsubr (&Sdefvar); defsubr (&Sdefvaralias); defsubr (&Sdefconst); === modified file 'src/lisp.h' --- src/lisp.h 2012-05-27 07:51:09 +0000 +++ src/lisp.h 2012-05-30 03:59:42 +0000 @@ -3001,7 +3001,7 @@ extern void syms_of_lread (void); /* Defined in eval.c. */ -extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qdefun, Qmacro; +extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qmacro; extern Lisp_Object Qinhibit_quit, Qclosure; extern Lisp_Object Qand_rest; extern Lisp_Object Vautoload_queue; === modified file 'src/lread.c' --- src/lread.c 2012-05-26 08:30:49 +0000 +++ src/lread.c 2012-05-30 03:59:42 +0000 @@ -2982,7 +2982,7 @@ /* If purifying, and string starts with \ newline, return zero instead. This is for doc strings - that we are really going to find in etc/DOC.nn.nn */ + that we are really going to find in etc/DOC.nn.nn. */ if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel) return make_number (0); @@ -3095,18 +3095,17 @@ nbytes) : nbytes); - if (uninterned_symbol && ! NILP (Vpurify_flag)) - name = make_pure_string (read_buffer, nchars, nbytes, multibyte); - else - name = make_specified_string (read_buffer, nchars, nbytes, multibyte); + name = ((uninterned_symbol && ! NILP (Vpurify_flag) + ? make_pure_string : make_specified_string) + (read_buffer, nchars, nbytes, multibyte)); result = (uninterned_symbol ? Fmake_symbol (name) : Fintern (name, Qnil)); if (EQ (Vread_with_symbol_positions, Qt) || EQ (Vread_with_symbol_positions, readcharfun)) - Vread_symbol_positions_list = - Fcons (Fcons (result, make_number (start_position)), - Vread_symbol_positions_list); + Vread_symbol_positions_list + = Fcons (Fcons (result, make_number (start_position)), + Vread_symbol_positions_list); return result; } } @@ -3520,7 +3519,7 @@ We don't use Fexpand_file_name because that would make the directory absolute now. */ elt = concat2 (build_string ("../lisp/"), - Ffile_name_nondirectory (elt)); + Ffile_name_nondirectory (elt)); } else if (EQ (elt, Vload_file_name) && ! NILP (elt) ------------------------------------------------------------ revno: 108426 committer: Paul Eggert branch nick: trunk timestamp: Tue 2012-05-29 14:33:38 -0700 message: Fix ChangeLog entry by negating its 1st sentence. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-05-29 16:13:38 +0000 +++ src/ChangeLog 2012-05-29 21:33:38 +0000 @@ -1,6 +1,6 @@ 2012-05-29 Troels Nielsen - Do not avoid creating empty evaporating overlays (Bug#9642). + Do not create empty overlays with the evaporate property (Bug#9642). * buffer.c (Fmove_overlay): Reinstate the earlier fix for Bug#9642, but explicitly check that the buffer the overlay would be moved to is live and rearrange lines to make sure that errors ------------------------------------------------------------ revno: 108425 committer: Stefan Merten branch nick: trunk timestamp: Tue 2012-05-29 22:14:18 +0200 message: Silence `checkdoc-ispell' errors where possible. Fix authors. Improve comments. Improve loading of `cl'. (rst-mode-abbrev-table): Merge definition. (rst-mode): Make sure `font-lock-defaults' is buffer local. (rst-define-key, rst-deprecated-keys, rst-call-deprecated): Refactor. diff: === modified file 'etc/NEWS' --- etc/NEWS 2012-05-29 09:46:06 +0000 +++ etc/NEWS 2012-05-29 20:14:18 +0000 @@ -125,31 +125,31 @@ ** reStructuredText mode -*** Nearly all keys are rebound making room for more keys and comply -better to usage in other modes. Bindings are described with C-c C-h. - -*** Major revision of indentation. Now works very similarly to other modes. -TAB is your friend. - -*** Major revision of filling. Works fine with most of -reStructuredText syntax. Auto-filling is also supported. +*** Rebind nearly all keys making room for more keys and complying +better to usage in other modes. Describe bindings with C-c C-h. + +*** Major revision of indentation working very similar to other +modes. TAB is your friend. + +*** Major revision of filling working fine with most of +reStructuredText syntax. Support auto-filling. *** Major revision of comment handling. -*** Major revision of fontification. Now works with `jit-lock-mode'. - -*** reStructuredText syntax is covered more closely in many cases. -Among other things this improves the experience for Sphinx users. - -*** `rst-insert-list' inserts a new list or continues existing lists. - -*** Customization is extended, corrected and improved. +*** Major revision of fontification working with `jit-lock-mode'. + +*** Cover reStructuredText syntax more closely. Improve +the experience for Sphinx users. + +*** `rst-insert-list' inserts new list or continues existing lists. + +*** Extend correct and improve customization. *** Negative prefix argument always works for `rst-adjust'. -*** Window configuration is reset after displaying TOC. +*** Reset window configuration after displaying TOC. -*** There is a package version in `rst-version'. +*** Package version in `rst-version'. ** New `derived-mode' filter for Ibuffer, bound to `/ M'. `/ m' is now bound to filter by used-mode, which used to be bound to `/ M'. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 19:42:49 +0000 +++ lisp/ChangeLog 2012-05-29 20:14:18 +0000 @@ -1,3 +1,13 @@ +2012-05-29 Stefan Merten + + * textmodes/rst.el: Silence `checkdoc-ispell' errors where + possible. Fix authors. Improve comments. Improve loading of + `cl'. + + (rst-mode-abbrev-table): Merge definition. + (rst-mode): Make sure `font-lock-defaults' is buffer local. + (rst-define-key, rst-deprecated-keys, rst-call-deprecated): Refactor. + 2012-05-29 Ulf Jasper * calendar/icalendar.el @@ -791,6 +801,109 @@ * man.el (Man-unindent): Use text-property-default-nonsticky to prevent untabify from inheriting face properties (Bug#11408). +2012-05-05 Stefan Merten + + * textmodes/rst.el: Major merge with upstream development up to + Docutils SVN r7399 / rst.el V1.2.1. + + Clarify maintainership and authors. + + (rst-extract-version, rst-cvs-header, rst-cvs-rev) + (rst-cvs-timestamp, rst-svn-rev, rst-svn-timestamp) + (rst-official-version, rst-official-cvs-rev, rst-version) + (rst-package-emacs-version-alist): New functions and variables + for version information. + + (rst-bullets, rst-uri-schemes, rst-adornment-chars) + (rst-max-inline-length, rst-re-alist-def, rst-re-alist) + (rst-mode-syntax-table, rst-mode): New and corrected functions + and variables representing reStructuredText features. + + (rst-re): New function for reStructuredText regexes. Use in + many places. + + (rst-deprecated-keys, rst-call-deprecated, rst-define-key) + (rst-mode-map): Rebind keys. + + (rst-mode-lazy, rst-font-lock-keywords) + (rst-font-lock-extend-region) + (rst-font-lock-extend-region-internal) + (rst-font-lock-extend-region-extend) + (rst-font-lock-find-unindented-line-limit) + (rst-font-lock-find-unindented-line-match) + (rst-adornment-level, rst-font-lock-adornment-level) + (rst-font-lock-adornment-match) + (rst-font-lock-handle-adornment-pre-match-form) + (rst-font-lock-handle-adornment-matcher): Major revision of + font-locking. Integrate with other code. Use `jit-lock-mode'. + + (rst-preferred-adornments, rst-adjust-hook) + (rst-new-adornment-down, rst-preferred-bullets) + (rst-preferred-bullets, rst-indent, rst-indent-width) + (rst-indent-field, rst-indent-literal-normal) + (rst-indent-literal-minimized, rst-indent-comment): Change, + extend and improve customization. + + (rst-line-homogeneous-p, rst-line-homogeneous-nodent-p) + (rst-normalize-cursor-position, rst-get-decoration) + (rst-straighten-deco-spacing, rst-re-bullets, rst-re-items) + (rst-rstrip, rst-toc-insert-find-delete-contents) + (rst-shift-fill-region, rst-compute-bullet-tabs) + (rst-debug-print-tabs, rst-debug-mark-found) + (rst-shift-region-guts, rst-shift-region-right) + (rst-shift-region-left, rst-use-char-classes) + (rst-font-lock-keywords-function) + (rst-font-lock-indentation-point) + (rst-font-lock-find-unindented-line-begin) + (rst-font-lock-find-unindented-line-end) + (rst-font-lock-find-unindented-line) + (rst-font-lock-adornment-point, rst-font-lock-level) + (rst-adornment-level-alist): Remove functions and variables. + + (rst-compare-adornments, rst-get-adornment-match) + (rst-suggest-new-adornment, rst-get-adornments-around) + (rst-adornment-complete-p, rst-get-next-adornment) + (rst-adjust-adornment, rst-display-adornments-hierarchy) + (rst-straighten-adornments): Standardize function names to + use "adornment" instead of "decoration". Correct callers. + Similar standardizing in many places. + + (rst-update-section, rst-adjust, rst-promote-region) + (rst-enumerate-region, rst-bullet-list-region) + (rst-repeat-last-character): Correct use of `interactive'. + + (rst-classify-adornment, rst-find-all-adornments) + (rst-get-hierarchy, rst-adjust-adornment, rst-toc-update) + (rst-find-leftmost-column, rst-repeat-last-character): + Refactor functions. + + (rst-find-title-line, rst-reset-section-caches) + (rst-get-adornments-around, rst-adjust-adornment-work) + (rst-arabic-to-roman, rst-roman-to-arabic) + (rst-insert-list-pos, rst-insert-list-new-item) + (rst-insert-list-continue, rst-insert-list, rst-forward-line): + New functions. + + (rst-all-sections, rst-section-hierarchy) + (rst-arabic-to-roman, rst-initial-enums, rst-initial-items): + New variables. + + (rst-toc-return-wincfg, rst-toc-quit-window): Use window + configuration instead of only buffer. Change where necessary. + + (rst-line-tabs, rst-compute-tabs, rst-indent-line) + (rst-shift-region, rst-adaptive-fill): New functions for + indentation and filling. + + (rst-comment-line-break, rst-comment-indent) + (rst-comment-insert-comment, rst-comment-region) + (rst-uncomment-region): New functions for handling comments. + + (rst-compile): Quote shell arguments. + + (rst-compile-pdf-preview, rst-compile-slides-preview): + Delete temporary files after use. + 2012-05-05 Glenn Morris * calendar/cal-html.el: Optionally include holidays in the output. === modified file 'lisp/textmodes/rst.el' --- lisp/textmodes/rst.el 2012-05-29 06:16:49 +0000 +++ lisp/textmodes/rst.el 2012-05-29 20:14:18 +0000 @@ -3,7 +3,8 @@ ;; Copyright (C) 2003-2012 Free Software Foundation, Inc. ;; Maintainer: Stefan Merten -;; Author: Martin Blais , +;; Author: Stefan Merten , +;; Martin Blais , ;; David Goodger , ;; Wei-Wei Guo @@ -25,10 +26,10 @@ ;;; Commentary: ;; This package provides major mode rst-mode, which supports documents marked -;; up using the reStructuredText format. Support includes font locking as well -;; as a lot of convenience functions for editing. It does this by defining a -;; Emacs major mode: rst-mode (ReST). This mode is derived from text-mode. This -;; package also contains: +;; up using the reStructuredText format. Support includes font locking as well +;; as a lot of convenience functions for editing. It does this by defining a +;; Emacs major mode: rst-mode (ReST). This mode is derived from text-mode. +;; This package also contains: ;; ;; - Functions to automatically adjust and cycle the section underline ;; adornments; @@ -53,12 +54,12 @@ ;; http://docutils.sourceforge.net/docs/user/emacs.html ;; ;; -;; There are a number of convenient keybindings provided by rst-mode. +;; There are a number of convenient key bindings provided by rst-mode. ;; For more on bindings, see rst-mode-map below. There are also many variables ;; that can be customized, look for defcustom in this file. ;; ;; If you use the table-of-contents feature, you may want to add a hook to -;; update the TOC automatically everytime you adjust a section title:: +;; update the TOC automatically every time you adjust a section title:: ;; ;; (add-hook 'rst-adjust-hook 'rst-toc-update) ;; @@ -70,7 +71,7 @@ ;; ;; ;; Customization is done by customizable variables contained in customization -;; group "rst" and subgroups. Group "rst" is contained in the "wp" group. +;; group "rst" and subgroups. Group "rst" is contained in the "wp" group. ;; ;;; DOWNLOAD @@ -95,21 +96,23 @@ ;; want automatically enter rst-mode from any file with compatible extensions: ;; ;; (setq auto-mode-alist -;; (append '(("\\.txt$" . rst-mode) -;; ("\\.rst$" . rst-mode) -;; ("\\.rest$" . rst-mode)) auto-mode-alist)) +;; (append '(("\\.txt\\'" . rst-mode) +;; ("\\.rst\\'" . rst-mode) +;; ("\\.rest\\'" . rst-mode)) auto-mode-alist)) ;; ;;; Code: -(require 'cl) +(eval-when-compile + (require 'cl)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Versions (defun rst-extract-version (delim-re head-re re tail-re var &optional default) - "Return the version matching RE after regex DELIM-RE and HEAD-RE -and before TAIL-RE and DELIM-RE in VAR or DEFAULT for no match" + "Extract the version from a variable according to the given regexes. +Return the version after regex DELIM-RE and HEAD-RE matching RE +and before TAIL-RE and DELIM-RE in VAR or DEFAULT for no match." (if (string-match (concat delim-re head-re "\\(" re "\\)" tail-re delim-re) var) @@ -117,20 +120,20 @@ default)) ;; Use CVSHeader to really get information from CVS and not other version -;; control systems +;; control systems. (defconst rst-cvs-header - "$CVSHeader: sm/rst_el/rst.el,v 1.257 2012-04-29 15:01:17 stefan Exp $") + "$CVSHeader: sm/rst_el/rst.el,v 1.257.2.9 2012-05-29 19:53:00 stefan Exp $") (defconst rst-cvs-rev (rst-extract-version "\\$" "CVSHeader: \\S + " "[0-9]+\\(?:\\.[0-9]+\\)+" " .*" rst-cvs-header "0.0") - "The CVS revision of this file. CVS revision is the development revision.") + "The CVS revision of this file. CVS revision is the development revision.") (defconst rst-cvs-timestamp (rst-extract-version "\\$" "CVSHeader: \\S + \\S + " "[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+" " .*" rst-cvs-header "1970-01-01 00:00:00") - "The CVS timestamp of this file.") + "The CVS time stamp of this file.") -;; Use LastChanged... to really get information from SVN +;; Use LastChanged... to really get information from SVN. (defconst rst-svn-rev (rst-extract-version "\\$" "LastChangedRevision: " "[0-9]+" " " "$LastChangedRevision: 7399 $") @@ -139,9 +142,9 @@ (defconst rst-svn-timestamp (rst-extract-version "\\$" "LastChangedDate: " ".+?+" " " "$LastChangedDate: 2012-04-29 17:01:05 +0200 (Sun, 29 Apr 2012) $") - "The SVN timestamp of this file.") + "The SVN time stamp of this file.") -;; Maintained by the release process +;; Maintained by the release process. (defconst rst-official-version (rst-extract-version "%" "OfficialVersion: " "[0-9]+\\(?:\\.[0-9]+\\)+" " " "%OfficialVersion: 1.2.1 %") @@ -157,8 +160,8 @@ (format "%s (development %s [%s])" rst-official-version rst-cvs-rev rst-cvs-timestamp)) "The version string. -Starts with the current official version. For developer versions -in parentheses follows the development revision and the timestamp.") +Starts with the current official version. For developer versions +in parentheses follows the development revision and the time stamp.") (defconst rst-package-emacs-version-alist '(("1.0.0" . "24.0") @@ -187,12 +190,12 @@ ;; Facilities for regular expressions used everywhere ;; The trailing numbers in the names give the number of referenceable regex -;; groups contained in the regex +;; groups contained in the regex. ;; Used to be customizable but really is not customizable but fixed by the reST -;; syntax +;; syntax. (defconst rst-bullets - ;; Sorted so they can form a character class when concatenated + ;; Sorted so they can form a character class when concatenated. '(?- ?* ?+ ?\u2022 ?\u2023 ?\u2043) "List of all possible bullet characters for bulleted lists.") @@ -203,7 +206,7 @@ "Supported URI schemes.") (defconst rst-adornment-chars - ;; Sorted so they can form a character class when concatenated + ;; Sorted so they can form a character class when concatenated. '(?\] ?! ?\" ?# ?$ ?% ?& ?' ?\( ?\) ?* ?+ ?, ?. ?/ ?: ?\; ?< ?= ?> ?? ?@ ?\[ ?\\ ?^ ?_ ?` ?{ ?| ?} ?~ @@ -215,45 +218,45 @@ "Maximum length of inline markup to recognize.") (defconst rst-re-alist-def - ;; `*-beg' matches * at the beginning of a line - ;; `*-end' matches * at the end of a line - ;; `*-prt' matches a part of * - ;; `*-tag' matches * - ;; `*-sta' matches the start of * which may be followed by respective content - ;; `*-pfx' matches the delimiter left of * - ;; `*-sfx' matches the delimiter right of * - ;; `*-hlp' helper for * + ;; `*-beg' matches * at the beginning of a line. + ;; `*-end' matches * at the end of a line. + ;; `*-prt' matches a part of *. + ;; `*-tag' matches *. + ;; `*-sta' matches the start of * which may be followed by respective content. + ;; `*-pfx' matches the delimiter left of *. + ;; `*-sfx' matches the delimiter right of *. + ;; `*-hlp' helper for *. ;; ;; A trailing number says how many referenceable groups are contained. `( ;; Horizontal white space (`hws') (hws-prt "[\t ]") - (hws-tag hws-prt "*") ; Optional sequence of horizontal white space - (hws-sta hws-prt "+") ; Mandatory sequence of horizontal white space + (hws-tag hws-prt "*") ; Optional sequence of horizontal white space. + (hws-sta hws-prt "+") ; Mandatory sequence of horizontal white space. ;; Lines (`lin') - (lin-beg "^" hws-tag) ; Beginning of a possibly indented line - (lin-end hws-tag "$") ; End of a line with optional trailing white space - (linemp-tag "^" hws-tag "$") ; Empty line with optional white space + (lin-beg "^" hws-tag) ; Beginning of a possibly indented line. + (lin-end hws-tag "$") ; End of a line with optional trailing white space. + (linemp-tag "^" hws-tag "$") ; Empty line with optional white space. ;; Various tags and parts (ell-tag "\\.\\.\\.") ; Ellipsis - (bul-tag ,(concat "[" rst-bullets "]")) ; A bullet - (ltr-tag "[a-zA-Z]") ; A letter enumerator tag - (num-prt "[0-9]") ; A number enumerator part - (num-tag num-prt "+") ; A number enumerator tag - (rom-prt "[IVXLCDMivxlcdm]") ; A roman enumerator part - (rom-tag rom-prt "+") ; A roman enumerator tag - (aut-tag "#") ; An automatic enumerator tag - (dcl-tag "::") ; Double colon + (bul-tag ,(concat "[" rst-bullets "]")) ; A bullet. + (ltr-tag "[a-zA-Z]") ; A letter enumerator tag. + (num-prt "[0-9]") ; A number enumerator part. + (num-tag num-prt "+") ; A number enumerator tag. + (rom-prt "[IVXLCDMivxlcdm]") ; A roman enumerator part. + (rom-tag rom-prt "+") ; A roman enumerator tag. + (aut-tag "#") ; An automatic enumerator tag. + (dcl-tag "::") ; Double colon. ;; Block lead in (`bli') (bli-sfx (:alt hws-sta "$")) ; Suffix of a block lead-in with *optional* - ; immediate content + ; immediate content. ;; Various starts - (bul-sta bul-tag bli-sfx) ; Start of a bulleted item + (bul-sta bul-tag bli-sfx) ; Start of a bulleted item. ;; Explicit markup tag (`exm') (exm-tag "\\.\\.") @@ -261,101 +264,101 @@ (exm-beg lin-beg exm-sta) ;; Counters in enumerations (`cnt') - (cntany-tag (:alt ltr-tag num-tag rom-tag aut-tag)) ; An arbitrary counter - (cntexp-tag (:alt ltr-tag num-tag rom-tag)) ; An arbitrary explicit counter + (cntany-tag (:alt ltr-tag num-tag rom-tag aut-tag)) ; An arbitrary counter. + (cntexp-tag (:alt ltr-tag num-tag rom-tag)) ; An arbitrary explicit counter. ;; Enumerator (`enm') (enmany-tag (:alt (:seq cntany-tag "\\.") - (:seq "(?" cntany-tag ")"))) ; An arbitrary enumerator + (:seq "(?" cntany-tag ")"))) ; An arbitrary enumerator. (enmexp-tag (:alt (:seq cntexp-tag "\\.") (:seq "(?" cntexp-tag ")"))) ; An arbitrary explicit - ; enumerator + ; enumerator. (enmaut-tag (:alt (:seq aut-tag "\\.") - (:seq "(?" aut-tag ")"))) ; An automatic enumerator - (enmany-sta enmany-tag bli-sfx) ; An arbitrary enumerator start - (enmexp-sta enmexp-tag bli-sfx) ; An arbitrary explicit enumerator start + (:seq "(?" aut-tag ")"))) ; An automatic enumerator. + (enmany-sta enmany-tag bli-sfx) ; An arbitrary enumerator start. + (enmexp-sta enmexp-tag bli-sfx) ; An arbitrary explicit enumerator start. (enmexp-beg lin-beg enmexp-sta) ; An arbitrary explicit enumerator start - ; at the beginning of a line + ; at the beginning of a line. ;; Items may be enumerated or bulleted (`itm') - (itmany-tag (:alt enmany-tag bul-tag)) ; An arbitrary item tag + (itmany-tag (:alt enmany-tag bul-tag)) ; An arbitrary item tag. (itmany-sta-1 (:grp itmany-tag) bli-sfx) ; An arbitrary item start, group - ; is the item tag + ; is the item tag. (itmany-beg-1 lin-beg itmany-sta-1) ; An arbitrary item start at the ; beginning of a line, group is the - ; item tag + ; item tag. ;; Inline markup (`ilm') (ilm-pfx (:alt "^" hws-prt "[-'\"([{<\u2018\u201c\u00ab\u2019/:]")) (ilm-sfx (:alt "$" hws-prt "[]-'\")}>\u2019\u201d\u00bb/:.,;!?\\]")) ;; Inline markup content (`ilc') - (ilcsgl-tag "\\S ") ; A single non-white character - (ilcast-prt (:alt "[^*\\]" "\\\\.")) ; Part of non-asterisk content - (ilcbkq-prt (:alt "[^`\\]" "\\\\.")) ; Part of non-backquote content + (ilcsgl-tag "\\S ") ; A single non-white character. + (ilcast-prt (:alt "[^*\\]" "\\\\.")) ; Part of non-asterisk content. + (ilcbkq-prt (:alt "[^`\\]" "\\\\.")) ; Part of non-backquote content. (ilcbkqdef-prt (:alt "[^`\\\n]" "\\\\.")) ; Part of non-backquote - ; definition - (ilcbar-prt (:alt "[^|\\]" "\\\\.")) ; Part of non-vertical-bar content + ; definition. + (ilcbar-prt (:alt "[^|\\]" "\\\\.")) ; Part of non-vertical-bar content. (ilcbardef-prt (:alt "[^|\\\n]" "\\\\.")) ; Part of non-vertical-bar - ; definition - (ilcast-sfx "[^\t *\\]") ; Suffix of non-asterisk content - (ilcbkq-sfx "[^\t `\\]") ; Suffix of non-backquote content - (ilcbar-sfx "[^\t |\\]") ; Suffix of non-vertical-bar content - (ilcrep-hlp ,(format "\\{0,%d\\}" rst-max-inline-length)) ; Repeat count + ; definition. + (ilcast-sfx "[^\t *\\]") ; Suffix of non-asterisk content. + (ilcbkq-sfx "[^\t `\\]") ; Suffix of non-backquote content. + (ilcbar-sfx "[^\t |\\]") ; Suffix of non-vertical-bar content. + (ilcrep-hlp ,(format "\\{0,%d\\}" rst-max-inline-length)) ; Repeat count. (ilcast-tag (:alt ilcsgl-tag (:seq ilcsgl-tag ilcast-prt ilcrep-hlp - ilcast-sfx))) ; Non-asterisk content + ilcast-sfx))) ; Non-asterisk content. (ilcbkq-tag (:alt ilcsgl-tag (:seq ilcsgl-tag ilcbkq-prt ilcrep-hlp - ilcbkq-sfx))) ; Non-backquote content + ilcbkq-sfx))) ; Non-backquote content. (ilcbkqdef-tag (:alt ilcsgl-tag (:seq ilcsgl-tag ilcbkqdef-prt ilcrep-hlp - ilcbkq-sfx))) ; Non-backquote definition + ilcbkq-sfx))) ; Non-backquote definition. (ilcbar-tag (:alt ilcsgl-tag (:seq ilcsgl-tag ilcbar-prt ilcrep-hlp - ilcbar-sfx))) ; Non-vertical-bar content + ilcbar-sfx))) ; Non-vertical-bar content. (ilcbardef-tag (:alt ilcsgl-tag (:seq ilcsgl-tag ilcbardef-prt ilcrep-hlp - ilcbar-sfx))) ; Non-vertical-bar definition + ilcbar-sfx))) ; Non-vertical-bar definition. ;; Fields (`fld') - (fldnam-prt (:alt "[^:\n]" "\\\\:")) ; Part of a field name - (fldnam-tag fldnam-prt "+") ; A field name - (fld-tag ":" fldnam-tag ":") ; A field marker + (fldnam-prt (:alt "[^:\n]" "\\\\:")) ; Part of a field name. + (fldnam-tag fldnam-prt "+") ; A field name. + (fld-tag ":" fldnam-tag ":") ; A field marker. ;; Options (`opt') - (optsta-tag (:alt "[-+/]" "--")) ; Start of an option - (optnam-tag "\\sw" (:alt "-" "\\sw") "*") ; Name of an option - (optarg-tag (:shy "[ =]\\S +")) ; Option argument - (optsep-tag (:shy "," hws-prt)) ; Separator between options - (opt-tag (:shy optsta-tag optnam-tag optarg-tag "?")) ; A complete option + (optsta-tag (:alt "[-+/]" "--")) ; Start of an option. + (optnam-tag "\\sw" (:alt "-" "\\sw") "*") ; Name of an option. + (optarg-tag (:shy "[ =]\\S +")) ; Option argument. + (optsep-tag (:shy "," hws-prt)) ; Separator between options. + (opt-tag (:shy optsta-tag optnam-tag optarg-tag "?")) ; A complete option. ;; Footnotes and citations (`fnc') - (fncnam-prt "[^\]\n]") ; Part of a footnote or citation name - (fncnam-tag fncnam-prt "+") ; A footnote or citation name - (fnc-tag "\\[" fncnam-tag "]") ; A complete footnote or citation tag + (fncnam-prt "[^\]\n]") ; Part of a footnote or citation name. + (fncnam-tag fncnam-prt "+") ; A footnote or citation name. + (fnc-tag "\\[" fncnam-tag "]") ; A complete footnote or citation tag. (fncdef-tag-2 (:grp exm-sta) (:grp fnc-tag)) ; A complete footnote or citation definition - ; tag; first group is the explicit markup + ; tag. First group is the explicit markup ; start, second group is the footnote / - ; citation tag + ; citation tag. (fnc-sta-2 fncdef-tag-2 bli-sfx) ; Start of a footnote or citation - ; definition; first group is the explicit + ; definition. First group is the explicit ; markup start, second group is the - ; footnote / citation tag + ; footnote / citation tag. ;; Substitutions (`sub') - (sub-tag "|" ilcbar-tag "|") ; A complete substitution tag + (sub-tag "|" ilcbar-tag "|") ; A complete substitution tag. (subdef-tag "|" ilcbardef-tag "|") ; A complete substitution definition - ; tag + ; tag. ;; Symbol (`sym') (sym-tag (:shy "\\sw+" (:shy "\\s_\\sw+") "*")) @@ -367,62 +370,62 @@ (ado-prt "[" ,(concat rst-adornment-chars) "]") (adorep3-hlp "\\{3,\\}") ; There must be at least 3 characters because ; otherwise explicit markup start would be - ; recognized + ; recognized. (adorep2-hlp "\\{2,\\}") ; As `adorep3-hlp' but when the first of three - ; characters is matched differently + ; characters is matched differently. (ado-tag-1-1 (:grp ado-prt) "\\1" adorep2-hlp) ; A complete adornment, group is the first ; adornment character and MUST be the FIRST - ; group in the whole expression + ; group in the whole expression. (ado-tag-1-2 (:grp ado-prt) "\\2" adorep2-hlp) ; A complete adornment, group is the first ; adornment character and MUST be the - ; SECOND group in the whole expression + ; SECOND group in the whole expression. (ado-beg-2-1 "^" (:grp ado-tag-1-2) lin-end) ; A complete adornment line; first group is the whole ; adornment and MUST be the FIRST group in the whole ; expression; second group is the first adornment - ; character + ; character. ;; Titles (`ttl') - (ttl-tag "\\S *\\w\\S *") ; A title text - (ttl-beg lin-beg ttl-tag) ; A title text at the beginning of a line + (ttl-tag "\\S *\\w\\S *") ; A title text. + (ttl-beg lin-beg ttl-tag) ; A title text at the beginning of a line. ;; Directives and substitution definitions (`dir') (dir-tag-3 (:grp exm-sta) (:grp (:shy subdef-tag hws-sta) "?") (:grp sym-tag dcl-tag)) ; A directive or substitution definition - ; tag; first group is explicit markup + ; tag. First group is explicit markup ; start, second group is a possibly ; empty substitution tag, third group is ; the directive tag including the double - ; colon + ; colon. (dir-sta-3 dir-tag-3 bli-sfx) ; Start of a directive or substitution - ; definition; groups are as in dir-tag-3 + ; definition. Groups are as in dir-tag-3. ;; Literal block (`lit') (lit-sta-2 (:grp (:alt "[^.\n]" "\\.[^.\n]") ".*") "?" - (:grp dcl-tag) "$") ; Start of a literal block; first group is + (:grp dcl-tag) "$") ; Start of a literal block. First group is ; any text before the double colon tag which ; may not exist, second group is the double - ; colon tag + ; colon tag. ;; Comments (`cmt') (cmt-sta-1 (:grp exm-sta) "[^\[|_\n]" (:alt "[^:\n]" (:seq ":" (:alt "[^:\n]" "$"))) "*$") ; Start of a comment block; first group is explicit markup - ; start + ; start. ;; Paragraphs (`par') (par-tag- (:alt itmany-tag fld-tag opt-tag fncdef-tag-2 dir-tag-3 exm-tag) ) ; Tag at the beginning of a paragraph; there may be groups in - ; certain cases + ; certain cases. ) "Definition alist of relevant regexes. Each entry consists of the symbol naming the regex and an argument list for `rst-re'.") -;; FIXME: Use `sregex` or `rx` instead of re-inventing the wheel +;; FIXME: Use `sregex` or `rx` instead of re-inventing the wheel. (defun rst-re (&rest args) "Interpret ARGS as regular expressions and return a regex string. Each element of ARGS may be one of the following: @@ -433,8 +436,8 @@ A symbol which is resolved to a string using `rst-re-alist-def'. -A list with a keyword in the car. Each element of the cdr of such -a list is recursively interpreted as ARGS. The results of this +A list with a keyword in the car. Each element of the cdr of such +a list is recursively interpreted as ARGS. The results of this interpretation are concatenated according to the keyword. For the keyword `:seq' the results are simply concatenated. @@ -446,11 +449,10 @@ which is shy-grouped (\"\\(?:...\\)\"). For the keyword `:grp' the results are concatenated and form a -referenceable grouped (\"\\(...\\)\"). +referenceable group (\"\\(...\\)\"). After interpretation of ARGS the results are concatenated as for -`:seq'. -" +`:seq'." (apply 'concat (mapcar (lambda (re) @@ -484,7 +486,7 @@ ;; FIXME: Remove circular dependency between `rst-re' and `rst-re-alist'. (defconst rst-re-alist ;; Shadow global value we are just defining so we can construct it step by - ;; step + ;; step. (let (rst-re-alist) (dolist (re rst-re-alist-def) (setq rst-re-alist @@ -495,96 +497,78 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Mode definition. - -(defvar rst-deprecated-keys nil - "Alist mapping deprecated keys to the new key to use and the definition.") - -(require 'edmacro) - -(defun rst-call-deprecated () - (interactive) - (let* ((dep-key (this-command-keys-vector)) - (dep-key-s (format-kbd-macro dep-key)) - (fnd (assoc dep-key rst-deprecated-keys))) - (if (not fnd) - ;; Exact key sequence not found. Maybe a deprecated key sequence has - ;; been followed by another key. - (let* ((dep-key-pfx (butlast (append dep-key nil) 1)) - (dep-key-def (vconcat dep-key-pfx '(t))) - (fnd-def (assoc dep-key-def rst-deprecated-keys))) - (if (not fnd-def) - (error "Unknown deprecated key sequence %s" dep-key-s) - ;; Don't execute the command in this case - (message "[Deprecated use of key %s; use key %s instead]" - (format-kbd-macro dep-key-pfx) - (format-kbd-macro (second fnd-def))))) - (message "[Deprecated use of key %s; use key %s instead]" - dep-key-s (format-kbd-macro (second fnd))) - (call-interactively (third fnd))))) +;; Mode definition (defun rst-define-key (keymap key def &rest deprecated) - "Bind like `define-key' using DEPRECATED as deprecated key definitions. -DEPRECATED key definitions should be in vector notation. These -are defined as well but give an additional message." + "Bind like `define-key' but add deprecated key definitions. +KEYMAP, KEY, and DEF are as in `define-key'. DEPRECATED key +definitions should be in vector notation. These are defined as +well but give an additional message." (define-key keymap key def) (dolist (dep-key deprecated) - (push (list dep-key key def) rst-deprecated-keys) - (define-key keymap dep-key 'rst-call-deprecated))) + (define-key keymap dep-key + `(lambda () + ,(format "Deprecated binding for %s, use \\[%s] instead." def def) + (interactive) + (call-interactively ',def) + (message "[Deprecated use of key %s; use key %s instead]" + (key-description (this-command-keys)) + (key-description ,key)))))) ;; Key bindings. (defvar rst-mode-map (let ((map (make-sparse-keymap))) - ;; \C-c is the general keymap + ;; \C-c is the general keymap. (rst-define-key map [?\C-c ?\C-h] 'describe-prefix-bindings) ;; - ;; Section Adornments. + ;; Section Adornments ;; ;; The adjustment function that adorns or rotates a section title. (rst-define-key map [?\C-c ?\C-=] 'rst-adjust [?\C-c ?\C-a t]) (rst-define-key map [?\C-=] 'rst-adjust) ; (Does not work on the Mac OSX.) - ;; \C-c \C-a is the keymap for adornments + ;; \C-c \C-a is the keymap for adornments. (rst-define-key map [?\C-c ?\C-a ?\C-h] 'describe-prefix-bindings) - ;; Display the hierarchy of adornments implied by the current document contents. + ;; Display the hierarchy of adornments implied by the current document + ;; contents. (rst-define-key map [?\C-c ?\C-a ?\C-d] 'rst-display-adornments-hierarchy) ;; Homogenize the adornments in the document. (rst-define-key map [?\C-c ?\C-a ?\C-s] 'rst-straighten-adornments [?\C-c ?\C-s]) ;; - ;; Section Movement and Selection. + ;; Section Movement and Selection ;; ;; Mark the subsection where the cursor is. (rst-define-key map [?\C-\M-h] 'rst-mark-section - ;; same as mark-defun sgml-mark-current-element + ;; Same as mark-defun sgml-mark-current-element. [?\C-c ?\C-m]) ;; Move forward/backward between section titles. (rst-define-key map [?\C-\M-a] 'rst-forward-section - ;; same as beginning-of-defun + ;; Same as beginning-of-defun. [?\C-c ?\C-n]) (rst-define-key map [?\C-\M-e] 'rst-backward-section - ;; same as end-of-defun + ;; Same as end-of-defun. [?\C-c ?\C-p]) ;; - ;; Operating on regions. + ;; Operating on regions ;; - ;; \C-c \C-r is the keymap for regions + ;; \C-c \C-r is the keymap for regions. (rst-define-key map [?\C-c ?\C-r ?\C-h] 'describe-prefix-bindings) ;; Makes region a line-block. (rst-define-key map [?\C-c ?\C-r ?\C-l] 'rst-line-block-region [?\C-c ?\C-d]) - ;; Shift region left or right according to tabs + ;; Shift region left or right according to tabs. (rst-define-key map [?\C-c ?\C-r tab] 'rst-shift-region [?\C-c ?\C-r t] [?\C-c ?\C-l t]) ;; - ;; Operating on lists. + ;; Operating on lists ;; - ;; \C-c \C-l is the keymap for lists + ;; \C-c \C-l is the keymap for lists. (rst-define-key map [?\C-c ?\C-l ?\C-h] 'describe-prefix-bindings) ;; Makes paragraphs in region as a bullet list. (rst-define-key map [?\C-c ?\C-l ?\C-b] 'rst-bullet-list-region @@ -598,13 +582,13 @@ ;; Make sure that all the bullets in the region are consistent. (rst-define-key map [?\C-c ?\C-l ?\C-s] 'rst-straighten-bullets-region [?\C-c ?\C-w]) - ;; Insert a list item + ;; Insert a list item. (rst-define-key map [?\C-c ?\C-l ?\C-i] 'rst-insert-list) ;; - ;; Table-of-Contents Features. + ;; Table-of-Contents Features ;; - ;; \C-c \C-t is the keymap for table of contents + ;; \C-c \C-t is the keymap for table of contents. (rst-define-key map [?\C-c ?\C-t ?\C-h] 'describe-prefix-bindings) ;; Enter a TOC buffer to view and move to a specific section. (rst-define-key map [?\C-c ?\C-t ?\C-t] 'rst-toc) @@ -614,14 +598,14 @@ ;; Update the document's TOC (without changing the cursor position). (rst-define-key map [?\C-c ?\C-t ?\C-u] 'rst-toc-update [?\C-c ?\C-u]) - ;; Got to the section under the cursor (cursor must be in TOC). + ;; Go to the section under the cursor (cursor must be in TOC). (rst-define-key map [?\C-c ?\C-t ?\C-j] 'rst-goto-section [?\C-c ?\C-f]) ;; - ;; Converting Documents from Emacs. + ;; Converting Documents from Emacs ;; - ;; \C-c \C-c is the keymap for compilation + ;; \C-c \C-c is the keymap for compilation. (rst-define-key map [?\C-c ?\C-c ?\C-h] 'describe-prefix-bindings) ;; Run one of two pre-configured toolset commands on the document. (rst-define-key map [?\C-c ?\C-c ?\C-c] 'rst-compile @@ -644,8 +628,6 @@ ;; Abbrevs. -(defvar rst-mode-abbrev-table nil - "Abbrev table used while in `rst-mode'.") (define-abbrev-table 'rst-mode-abbrev-table (mapcar (lambda (x) (append x '(nil 0 system))) '(("contents" ".. contents::\n..\n ") @@ -654,7 +636,8 @@ ("skip" "\n\n[...]\n\n ") ("seq" "\n\n[...]\n\n ") ;; FIXME: Add footnotes, links, and more. - ))) + )) + "Abbrev table used while in `rst-mode'.") ;; Syntax table. @@ -711,7 +694,7 @@ :syntax-table rst-mode-syntax-table :group 'rst - ;; Paragraph recognition + ;; Paragraph recognition. (set (make-local-variable 'paragraph-separate) (rst-re '(:alt "\f" @@ -722,7 +705,7 @@ lin-end (:seq hws-tag par-tag- bli-sfx)))) - ;; Indenting and filling + ;; Indenting and filling. (set (make-local-variable 'indent-line-function) 'rst-indent-line) (set (make-local-variable 'adaptive-fill-mode) t) (set (make-local-variable 'adaptive-fill-regexp) @@ -730,7 +713,7 @@ (set (make-local-variable 'adaptive-fill-function) 'rst-adaptive-fill) (set (make-local-variable 'fill-paragraph-handle-comment) nil) - ;; Comments + ;; Comments. (set (make-local-variable 'comment-start) ".. ") (set (make-local-variable 'comment-start-skip) (rst-re 'lin-beg 'exm-tag 'bli-sfx)) @@ -738,10 +721,12 @@ (set (make-local-variable 'comment-multi-line) t) (set (make-local-variable 'comment-use-syntax) nil) ;; reStructuredText has not really a comment ender but nil is not really a - ;; permissible value + ;; permissible value. (set (make-local-variable 'comment-end) "") (set (make-local-variable 'comment-end-skip) nil) + ;; Commenting in reStructuredText is very special so use our own set of + ;; functions. (set (make-local-variable 'comment-line-break-function) 'rst-comment-line-break) (set (make-local-variable 'comment-indent-function) @@ -753,21 +738,15 @@ (set (make-local-variable 'uncomment-region-function) 'rst-uncomment-region) - ;; Font lock - (setq font-lock-defaults - '(rst-font-lock-keywords - t nil nil nil - (font-lock-multiline . t) - (font-lock-mark-block-function . mark-paragraph) - ;; rst-mode does not need font-lock-support-mode because it's fast - ;; enough. In fact using `jit-lock-mode` slows things down - ;; considerably even if `rst-font-lock-extend-region` is in place and - ;; compiled. - ;;(font-lock-support-mode . nil) - )) + ;; Font lock. + (set (make-local-variable 'font-lock-defaults) + '(rst-font-lock-keywords + t nil nil nil + (font-lock-multiline . t) + (font-lock-mark-block-function . mark-paragraph))) (add-hook 'font-lock-extend-region-functions 'rst-font-lock-extend-region t) - ;; Text after a changed line may need new fontification + ;; Text after a changed line may need new fontification. (set (make-local-variable 'jit-lock-contextually) t)) ;;;###autoload @@ -789,8 +768,8 @@ :group 'rst) ;; FIXME: can I somehow install these too? -;; :abbrev-table rst-mode-abbrev-table -;; :syntax-table rst-mode-syntax-table +;; :abbrev-table rst-mode-abbrev-table +;; :syntax-table rst-mode-syntax-table ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -883,10 +862,10 @@ "Preferred hierarchy of section title adornments. A list consisting of lists of the form (CHARACTER STYLE INDENT). -CHARACTER is the character used. STYLE is one of the symbols -OVER-AND-UNDER or SIMPLE. INDENT is an integer giving the wanted -indentation for STYLE OVER-AND-UNDER. CHARACTER and STYLE are -always used when a section adornment is described. In other +CHARACTER is the character used. STYLE is one of the symbols +OVER-AND-UNDER or SIMPLE. INDENT is an integer giving the wanted +indentation for STYLE OVER-AND-UNDER. CHARACTER and STYLE are +always used when a section adornment is described. In other places t instead of a list stands for a transition. This sequence is consulted to offer a new adornment suggestion @@ -991,7 +970,7 @@ (let ((marker (point-marker)) len) - ;; Fixup whitespace at the beginning and end of the line + ;; Fixup whitespace at the beginning and end of the line. (if (or (null indent) (eq style 'simple)) (setq indent 0)) (beginning-of-line) @@ -1001,10 +980,10 @@ (end-of-line) (delete-horizontal-space) - ;; Set the current column, we're at the end of the title line + ;; Set the current column, we're at the end of the title line. (setq len (+ (current-column) indent)) - ;; Remove previous line if it is an adornment + ;; Remove previous line if it is an adornment. (save-excursion (forward-line -1) (if (and (looking-at (rst-re 'ado-beg-2-1)) @@ -1013,24 +992,24 @@ (not (looking-at (rst-re 'ttl-beg))))) (rst-delete-entire-line))) - ;; Remove following line if it is an adornment + ;; Remove following line if it is an adornment. (save-excursion (forward-line +1) (if (looking-at (rst-re 'ado-beg-2-1)) (rst-delete-entire-line)) ;; Add a newline if we're at the end of the buffer, for the subsequence - ;; inserting of the underline + ;; inserting of the underline. (if (= (point) (buffer-end 1)) (newline 1))) - ;; Insert overline + ;; Insert overline. (if (eq style 'over-and-under) (save-excursion (beginning-of-line) (open-line 1) (insert (make-string len char)))) - ;; Insert underline + ;; Insert underline. (forward-line +1) (open-line 1) (insert (make-string len char)) @@ -1042,17 +1021,17 @@ (defun rst-classify-adornment (adornment end) "Classify adornment for section titles and transitions. ADORNMENT is the complete adornment string as found in the buffer -with optional trailing whitespace. END is the point after the +with optional trailing whitespace. END is the point after the last character of ADORNMENT. -Return a list. The first entry is t for a transition or a -cons (CHARACTER . STYLE). Check `rst-preferred-adornments' for +Return a list. The first entry is t for a transition or a +cons (CHARACTER . STYLE). Check `rst-preferred-adornments' for the meaning of CHARACTER and STYLE. The remaining list forms four match groups as returned by -`match-data'. Match group 0 matches the whole construct. Match -group 1 matches the overline adornment if present. Match group 2 -matches the section title text or the transition. Match group 3 +`match-data'. Match group 0 matches the whole construct. Match +group 1 matches the overline adornment if present. Match group 2 +matches the section title text or the transition. Match group 3 matches the underline adornment. Return nil if no syntactically valid adornment is found." @@ -1074,25 +1053,25 @@ (save-excursion (or (not (zerop (forward-line -1))) (looking-at (rst-re 'lin-end))))) - (ttl-blw ; Title found below starting here + (ttl-blw ; Title found below starting here. (save-excursion (and (zerop (forward-line 1)) (looking-at (rst-re 'ttl-beg)) (point)))) - (ttl-abv ; Title found above starting here + (ttl-abv ; Title found above starting here. (save-excursion (and (zerop (forward-line -1)) (looking-at (rst-re 'ttl-beg)) (point)))) - (und-fnd ; Matching underline found starting here + (und-fnd ; Matching underline found starting here. (save-excursion (and ttl-blw (zerop (forward-line 2)) (looking-at (rst-re ado-re 'lin-end)) (point)))) - (ovr-fnd ; Matching overline found starting here + (ovr-fnd ; Matching overline found starting here. (save-excursion (and ttl-abv (zerop (forward-line -2)) @@ -1101,14 +1080,14 @@ key beg-ovr end-ovr beg-txt end-txt beg-und end-und) (cond ((and nxt-emp prv-emp) - ;; A transition + ;; A transition. (setq key t beg-txt beg-pnt end-txt end-pnt)) ((or und-fnd ovr-fnd) - ;; An overline with an underline + ;; An overline with an underline. (setq key (cons ado-ch 'over-and-under)) - (let (;; Prefer overline match over underline match + (let (;; Prefer overline match over underline match. (und-pnt (if ovr-fnd beg-pnt und-fnd)) (ovr-pnt (if ovr-fnd ovr-fnd beg-pnt)) (txt-pnt (if ovr-fnd ttl-abv ttl-blw))) @@ -1122,7 +1101,7 @@ (setq beg-und (point) end-und (line-end-position)))) (ttl-abv - ;; An underline + ;; An underline. (setq key (cons ado-ch 'simple) beg-und beg-pnt end-und end-pnt) @@ -1130,7 +1109,7 @@ (setq beg-txt (point) end-txt (line-end-position))) (t - ;; Invalid adornment + ;; Invalid adornment. (setq key nil))) (if key (list key @@ -1141,15 +1120,15 @@ (defun rst-find-title-line () "Find a section title line around point and return its characteristics. If the point is on an adornment line find the respective title -line. If the point is on an empty line check previous or next -line whether it is a suitable title line and use it if so. If +line. If the point is on an empty line check previous or next +line whether it is a suitable title line and use it if so. If point is on a suitable title line use it. If no title line is found return nil. -Otherwise return as `rst-classify-adornment' does. However, if +Otherwise return as `rst-classify-adornment' does. However, if the title line has no syntactically valid adornment STYLE is nil -in the first element. If there is no adornment around the title +in the first element. If there is no adornment around the title CHARACTER is also nil and match groups for overline and underline are nil." (save-excursion @@ -1163,14 +1142,14 @@ (match-end 0)))) (cond ((not r) - ;; Invalid adornment - check whether this is an incomplete overline + ;; Invalid adornment - check whether this is an incomplete overline. (if (and (zerop (forward-line 1)) (looking-at (rst-re 'ttl-beg))) (list (cons char nil) orig-pnt (line-end-position) orig-pnt orig-end (point) (line-end-position) nil nil))) ((consp (car r)) - ;; A section title - not a transition + ;; A section title - not a transition. r)))) ((looking-at (rst-re 'lin-end)) (or @@ -1185,14 +1164,14 @@ (list (cons nil nil) (point) (line-end-position) nil nil (point) (line-end-position) nil nil))))) ((looking-at (rst-re 'ttl-beg)) - ;; Try to use the underline + ;; Try to use the underline. (let ((r (rst-classify-adornment (buffer-substring-no-properties (line-beginning-position 2) (line-end-position 2)) (line-end-position 2)))) (if r r - ;; No valid adornment found + ;; No valid adornment found. (list (cons nil nil) (point) (line-end-position) nil nil (point) (line-end-position) nil nil)))))))) @@ -1206,10 +1185,10 @@ (make-variable-buffer-local 'rst-all-sections) ;; FIXME: If this variable is set to a different value font-locking of section -;; headers is wrong +;; headers is wrong. (defvar rst-section-hierarchy nil "Section hierarchy in the buffer as determined by `rst-get-hierarchy'. -t when no section adornments were found. Value depends on +t when no section adornments were found. Value depends on `rst-all-sections'.") (make-variable-buffer-local 'rst-section-hierarchy) @@ -1222,7 +1201,7 @@ (defun rst-find-all-adornments () "Return all the section adornments in the current buffer. Return a list of (LINE . ADORNMENT) with ascending LINE where -LINE is the line containing the section title. ADORNMENT consists +LINE is the line containing the section title. ADORNMENT consists of a (CHARACTER STYLE INDENT) triple as described for `rst-preferred-adornments'. @@ -1236,15 +1215,15 @@ (let ((ado-data (rst-classify-adornment (match-string-no-properties 0) (point)))) (when (and ado-data - (consp (car ado-data))) ; Ignore transitions + (consp (car ado-data))) ; Ignore transitions. (set-match-data (cdr ado-data)) - (goto-char (match-beginning 2)) ; Goto the title start + (goto-char (match-beginning 2)) ; Goto the title start. (push (cons (1+ (count-lines (point-min) (point))) (list (caar ado-data) (cdar ado-data) (current-indentation))) positions) - (goto-char (match-end 0))))) ; Go beyond the whole thing + (goto-char (match-end 0))))) ; Go beyond the whole thing. (setq positions (nreverse positions)) (setq rst-all-sections (or positions t))))) (if (eq rst-all-sections t) @@ -1274,8 +1253,8 @@ "Return the hierarchy of section titles in the file. Return a list of adornments that represents the hierarchy of -section titles in the file. Each element consists of (CHARACTER -STYLE INDENT) as described for `rst-find-all-adornments'. If the +section titles in the file. Each element consists of (CHARACTER +STYLE INDENT) as described for `rst-find-all-adornments'. If the line number in IGNORE is specified, a possibly adornment found on that line is not taken into account when building the hierarchy. @@ -1292,7 +1271,7 @@ (setq rst-section-hierarchy (if ignore ;; Clear cache reflecting that a possible update is not - ;; reflected + ;; reflected. nil (or r t))) r))) @@ -1378,19 +1357,19 @@ ))) -;; FIXME: A line "``/`` full" is not accepted as a section title +;; FIXME: A line "``/`` full" is not accepted as a section title. (defun rst-adjust (pfxarg) "Auto-adjust the adornment around point. -Adjust/rotate the section adornment for the section title -around point or promote/demote the adornments inside the region, +Adjust/rotate the section adornment for the section title around +point or promote/demote the adornments inside the region, depending on if the region is active. This function is meant to be invoked possibly multiple times, and can vary its behavior -with a positive prefix argument (toggle style), or with a -negative prefix argument (alternate behavior). +with a positive PFXARG (toggle style), or with a negative +PFXARG (alternate behavior). -This function is a bit of a swiss knife. It is meant to adjust -the adornments of a section title in reStructuredText. It tries +This function is a bit of a swiss knife. It is meant to adjust +the adornments of a section title in reStructuredText. It tries to deal with all the possible cases gracefully and to do `the right thing' in all cases. @@ -1403,7 +1382,7 @@ The method can take either (but not both) of a. a (non-negative) prefix argument, which means to toggle the - adornment style. Invoke with a prefix arg for example; + adornment style. Invoke with a prefix argument for example; b. a negative numerical argument, which generally inverts the direction of search in the file or hierarchy. Invoke with C-- @@ -1447,7 +1426,8 @@ (defun rst-adjust-adornment (pfxarg) "Call `rst-adjust-adornment-work' interactively. -Keep this for compatibility for older bindings (are there any?)." +Keep this for compatibility for older bindings (are there any?). +Argument PFXARG has the same meaning as for `rst-adjust'." (interactive "P") (let* ((reverse-direction (and pfxarg (< (prefix-numeric-value pfxarg) 0))) @@ -1661,7 +1641,7 @@ ;; Else, we rotate, ignoring the adornment around the current ;; line... (let* ((hier (rst-get-hierarchy (line-number-at-pos))) - ;; Suggestion, in case we need to come up with something new + ;; Suggestion, in case we need to come up with something new. (suggestion (rst-suggest-new-adornment hier (car (rst-get-adornments-around)))) @@ -1703,7 +1683,7 @@ marker-list ) - ;; Skip the markers that come before the region beginning + ;; Skip the markers that come before the region beginning. (while (and cur (< (caar cur) region-begin-line)) (setq cur (cdr cur))) @@ -1768,7 +1748,7 @@ (interactive) (rst-reset-section-caches) (save-excursion - (let (;; Get a list of pairs of (level . marker) + (let (;; Get a list of pairs of (level . marker). (levels-and-markers (mapcar (lambda (ado) (cons (rst-position (cdr ado) @@ -1779,13 +1759,13 @@ (point-marker)))) (rst-find-all-adornments)))) (dolist (lm levels-and-markers) - ;; Go to the appropriate position + ;; Go to the appropriate position. (goto-char (cdr lm)) - ;; Apply the new styule + ;; Apply the new style. (apply 'rst-update-section (nth (car lm) rst-preferred-adornments)) - ;; Reset the market to avoid slowing down editing until it gets GC'ed + ;; Reset the market to avoid slowing down editing until it gets GC'ed. (set-marker (cdr lm) nil) ) ))) @@ -1798,7 +1778,7 @@ ;================================================= -; Borrowed from a2r.el (version 1.3), by Lawrence Mitchell +; Borrowed from a2r.el (version 1.3), by Lawrence Mitchell . ; I needed to make some tiny changes to the functions, so I put it here. ; -- Wei-Wei Guo @@ -1849,9 +1829,9 @@ (defun rst-find-pfx-in-region (beg end pfx-re) "Find all the positions of prefixes in region between BEG and END. -This is used to find bullets and enumerated list items. PFX-RE is +This is used to find bullets and enumerated list items. PFX-RE is a regular expression for matching the lines after indentation -with items. Returns a list of cons cells consisting of the point +with items. Returns a list of cons cells consisting of the point and the column of the point." (let ((pfx ())) (save-excursion @@ -1867,14 +1847,14 @@ (or (looking-at (rst-re 'lin-end)) ; ...empty, (> (current-column) pfx-col) ; ...deeper level, or (and (= (current-column) pfx-col) - (looking-at pfx-re)))))) ; ...pfx at same level + (looking-at pfx-re)))))) ; ...pfx at same level. (push (cons (point) (current-column)) pfx)) (forward-line 1)) ) (nreverse pfx))) (defun rst-insert-list-pos (newitem) - "Arrange relative position of a newly inserted list item. + "Arrange relative position of a newly inserted list item of style NEWITEM. Adding a new list might consider three situations: @@ -1922,11 +1902,11 @@ If user selects bullets or #, it's just added with position arranged by `rst-insert-list-pos'. -If user selects enumerations, a further prompt is given. User need to input a +If user selects enumerations, a further prompt is given. User need to input a starting item, for example 'e' for 'A)' style. The position is also arranged by `rst-insert-list-pos'." (interactive) - ;; FIXME: Make this comply to `interactive' standards + ;; FIXME: Make this comply to `interactive' standards. (let* ((itemstyle (completing-read "Select preferred item style [#.]: " rst-initial-items nil t nil nil "#.")) @@ -1934,7 +1914,7 @@ (match-string 0 itemstyle))) (no (save-match-data - ;; FIXME: Make this comply to `interactive' standards + ;; FIXME: Make this comply to `interactive' standards. (cond ((equal cnt "a") (let ((itemno (read-string "Give starting value [a]: " @@ -1969,10 +1949,11 @@ :package-version '(rst . "1.1.0")) (defun rst-insert-list-continue (curitem prefer-roman) - "Insert a list item with list start CURITEM including its indentation level." + "Insert a list item with list start CURITEM including its indentation level. +If PREFER-ROMAN roman numbering is preferred over using letters." (end-of-line) (insert - "\n" ; FIXME: Separating lines must be possible + "\n" ; FIXME: Separating lines must be possible. (cond ((string-match (rst-re '(:alt enmaut-tag bul-tag)) curitem) @@ -1983,17 +1964,17 @@ nil nil curitem)) ((and (string-match (rst-re 'rom-tag) curitem) (save-match-data - (if (string-match (rst-re 'ltr-tag) curitem) ; Also a letter tag + (if (string-match (rst-re 'ltr-tag) curitem) ; Also a letter tag. (save-excursion ;; FIXME: Assumes one line list items without separating - ;; empty lines + ;; empty lines. (if (and (zerop (forward-line -1)) (looking-at (rst-re 'enmexp-beg))) (string-match (rst-re 'rom-tag) - (match-string 0)) ; Previous was a roman tag - prefer-roman)) ; Don't know - use flag - t))) ; Not a letter tag + (match-string 0)) ; Previous was a roman tag. + prefer-roman)) ; Don't know - use flag. + t))) ; Not a letter tag. (replace-match (let* ((old (match-string 0 curitem)) (new (save-match-data @@ -2013,13 +1994,13 @@ (defun rst-insert-list (&optional prefer-roman) "Insert a list item at the current point. -The command can insert a new list or a continuing list. When it is called at a -non-list line, it will promote to insert new list. When it is called at a list +The command can insert a new list or a continuing list. When it is called at a +non-list line, it will promote to insert new list. When it is called at a list line, it will insert a list with the same list style. 1. When inserting a new list: -User is asked to select the item style first, for example (a), i), +. Use TAB +User is asked to select the item style first, for example (a), i), +. Use TAB for completion and choices. (a) If user selects bullets or #, it's just added. @@ -2036,7 +2017,7 @@ the problem elegantly in most situations. But when those overlapped list are preceded by a blank line, it is hard to determine which type to use automatically. The function uses alphabetical list by default. If you want -roman numerical list, just use a prefix (\\[universal-argument])." +roman numerical list, just use a prefix to set PREFER-ROMAN." (interactive "P") (beginning-of-line) (if (looking-at (rst-re 'itmany-beg-1)) @@ -2094,8 +2075,8 @@ "Get the hierarchical tree of section titles. Returns a hierarchical tree of the sections titles in the -document. This can be used to generate a table of contents for -the document. The top node will always be a nil node, with the +document. This can be used to generate a table of contents for +the document. The top node will always be a nil node, with the top level titles as children (there may potentially be more than one). @@ -2105,7 +2086,7 @@ If there are missing section levels, the section titles are inserted automatically, and the title string is set to nil, and the marker set to the first non-nil child of itself. -Conceptually, the nil nodes--i.e. those which have no title--are +Conceptually, the nil nodes--i.e.\ those which have no title--are to be considered as being the same line as their first non-nil child. This has advantages later in processing the graph." @@ -2148,14 +2129,14 @@ node children) - ;; If the next adornment matches our level + ;; If the next adornment matches our level. (when (and nado (= (car nado) lev)) - ;; Pop the next adornment and create the current node with it + ;; Pop the next adornment and create the current node with it. (setcdr ados (cddr ados)) (setq node (cdr nado)) ) ;; Else we let the node title/marker be unset. - ;; Build the child nodes + ;; Build the child nodes. (while (and (cdr ados) (> (caadr ados) lev)) (setq children (cons (rst-section-tree-rec ados (1+ lev)) @@ -2175,7 +2156,7 @@ "Find tree node at point. Given a computed and valid section tree in NODE and a point POINT (default being the current point in the current buffer), -find and return the node within the sectree where the cursor +find and return the node within the section tree where the cursor lives. Return values: a pair of (parent path, container subtree). @@ -2256,7 +2237,7 @@ The TOC is inserted indented at the current column." (interactive "P") (rst-reset-section-caches) - (let* (;; Check maximum level override + (let* (;; Check maximum level override. (rst-toc-insert-max-level (if (and (integerp pfxarg) (> (prefix-numeric-value pfxarg) 0)) (prefix-numeric-value pfxarg) rst-toc-insert-max-level)) @@ -2333,7 +2314,7 @@ fmt) (if do-child-numbering (progn - ;; Add a separating dot if there is already a prefix + ;; Add a separating dot if there is already a prefix. (when (> (length pfx) 0) (string-match (rst-re "[ \t\n]*\\'") pfx) (setq pfx (concat (replace-match "" t t pfx) "."))) @@ -2385,9 +2366,9 @@ (while (and (< (point) (point-max)) (or (if (looking-at - (rst-re 'hws-sta "\\S ")) ; indented content + (rst-re 'hws-sta "\\S ")) ; indented content. (setq last-real (point))) - (looking-at (rst-re 'lin-end)))) ; empty line + (looking-at (rst-re 'lin-end)))) ; empty line. (forward-line 1)) (if last-real (progn @@ -2517,12 +2498,14 @@ ;; FIXME: Cursor before or behind the list must be handled properly; before the ;; list should jump to the top and behind the list to the last normal -;; paragraph +;; paragraph. (defun rst-goto-section (&optional kill) - "Go to the section the current line describes." + "Go to the section the current line describes. +If KILL a toc buffer is destroyed." (interactive) (let ((pos (rst-toc-mode-find-section))) (when kill + ;; FIXME: This should rather go to `rst-toc-mode-goto-section'. (set-window-configuration (car rst-toc-return-wincfg)) (kill-buffer (get-buffer rst-toc-buffer-name))) (pop-to-buffer (marker-buffer pos)) @@ -2549,7 +2532,8 @@ (recenter 5))) (defun rst-toc-mode-mouse-goto-kill (event) - "Same as `rst-toc-mode-mouse-goto', but kill TOC buffer as well." + "Same as `rst-toc-mode-mouse-goto', but kill TOC buffer as well. +EVENT is the input event." (interactive "e") (call-interactively 'rst-toc-mode-mouse-goto event) (kill-buffer (get-buffer rst-toc-buffer-name))) @@ -2582,7 +2566,6 @@ ;; Note: use occur-mode (replace.el) as a good example to complete missing ;; features. - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Section movement commands ;; ========================= @@ -2633,12 +2616,15 @@ (interactive) (rst-forward-section -1)) -(defun rst-mark-section (&optional arg allow-extend) - "Select the section that point is currently in." +;; FIXME: What is `allow-extend' for? +(defun rst-mark-section (&optional count allow-extend) + "Select COUNT sections around point. +Mark following sections for positive COUNT or preceding sections +for negative COUNT." ;; Cloned from mark-paragraph. (interactive "p\np") - (unless arg (setq arg 1)) - (when (zerop arg) + (unless count (setq count 1)) + (when (zerop count) (error "Cannot mark zero sections")) (cond ((and allow-extend (or (and (eq last-command this-command) (mark t)) @@ -2646,12 +2632,12 @@ (set-mark (save-excursion (goto-char (mark)) - (rst-forward-section arg) + (rst-forward-section count) (point)))) (t - (rst-forward-section arg) + (rst-forward-section count) (push-mark nil t t) - (rst-forward-section (- arg))))) + (rst-forward-section (- count))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2672,12 +2658,12 @@ (forward-line 1))) mincol)) +;; FIXME: This definition is old and deprecated. We need to move to the newer +;; version below. (defmacro rst-iterate-leftmost-paragraphs (beg end first-only body-consequent body-alternative) - "FIXME This definition is old and deprecated / we need to move -to the newer version below: - -Call FUN at the beginning of each line, with an argument that + ;; FIXME: The following comment is pretty useless. + "Call FUN at the beginning of each line, with an argument that specifies whether we are at the first line of a paragraph that starts at the leftmost column of the given region BEG and END. Set FIRST-ONLY to true if you want to callback on the first line @@ -2686,7 +2672,7 @@ (let ((leftcol (rst-find-leftmost-column ,beg ,end)) (endm (copy-marker ,end))) - (do* (;; Iterate lines + (do* (;; Iterate lines. (l (progn (goto-char ,beg) (back-to-indentation)) (progn (forward-line 1) (back-to-indentation))) @@ -2710,6 +2696,8 @@ )))) +;; FIXME: This needs to be refactored. Probably this is simply a function +;; applying BODY rather than a macro. (defmacro rst-iterate-leftmost-paragraphs-2 (spec &rest body) "Evaluate BODY for each line in region defined by BEG END. LEFTMOST is set to true if the line is one of the leftmost of the @@ -2723,7 +2711,7 @@ (let ((,leftmost (rst-find-leftmost-column ,beg ,end)) (endm (copy-marker ,end))) - (do* (;; Iterate lines + (do* (;; Iterate lines. (l (progn (goto-char ,beg) (back-to-indentation)) (progn (forward-line 1) (back-to-indentation))) @@ -2751,8 +2739,9 @@ ;; Indentation ;; FIXME: At the moment only block comments with leading empty comment line are -;; supported; comment lines with leading comment markup should be also -;; supported; may be a customizable option could control which style to prefer +;; supported. Comment lines with leading comment markup should be also +;; supported. May be a customizable option could control which style to +;; prefer. (defgroup rst-indent nil "Settings for indentation in reStructuredText. @@ -2772,20 +2761,17 @@ :type '(integer)) (defcustom rst-indent-field 3 - "Default indentation for first line after a field or 0 to always indent for -content." + "Indentation for first line after a field or 0 to always indent for content." :group 'rst-indent :type '(integer)) (defcustom rst-indent-literal-normal 3 - "Default indentation for literal block after a markup on an own -line." + "Default indentation for literal block after a markup on an own line." :group 'rst-indent :type '(integer)) (defcustom rst-indent-literal-minimized 2 - "Default indentation for literal block after a minimized -markup." + "Default indentation for literal block after a minimized markup." :group 'rst-indent :type '(integer)) @@ -2795,30 +2781,30 @@ :type '(integer)) ;; FIXME: Must consider other tabs: -;; * Line blocks -;; * Definition lists -;; * Option lists +;; * Line blocks +;; * Definition lists +;; * Option lists (defun rst-line-tabs () "Return tabs of the current line or nil for no tab. The list is sorted so the tab where writing continues most likely -is the first one. Each tab is of the form (COLUMN . INNER). -COLUMN is the column of the tab. INNER is non-nil if this is an -inner tab. I.e. a tab which does come from the basic indentation +is the first one. Each tab is of the form (COLUMN . INNER). +COLUMN is the column of the tab. INNER is non-nil if this is an +inner tab. I.e. a tab which does come from the basic indentation and not from inner alignment points." (save-excursion (forward-line 0) (save-match-data (unless (looking-at (rst-re 'lin-end)) (back-to-indentation) - ;; Current indentation is always the least likely tab + ;; Current indendation is always the least likely tab. (let ((tabs (list (list (point) 0 nil)))) ; (POINT OFFSET INNER) - ;; Push inner tabs more likely to continue writing + ;; Push inner tabs more likely to continue writing. (cond - ;; Item + ;; Item. ((looking-at (rst-re '(:grp itmany-tag hws-sta) '(:grp "\\S ") "?")) (when (match-string 2) (push (list (match-beginning 2) 0 t) tabs))) - ;; Field + ;; Field. ((looking-at (rst-re '(:grp fld-tag) '(:grp hws-tag) '(:grp "\\S ") "?")) (unless (zerop rst-indent-field) @@ -2829,22 +2815,22 @@ (push (list (match-end 2) (if (string= (match-string 2) "") 1 0) t) tabs)))) - ;; Directive + ;; Directive. ((looking-at (rst-re 'dir-sta-3 '(:grp "\\S ") "?")) (push (list (match-end 1) 0 t) tabs) (unless (string= (match-string 2) "") (push (list (match-end 2) 0 t) tabs)) (when (match-string 4) (push (list (match-beginning 4) 0 t) tabs))) - ;; Footnote or citation definition + ;; Footnote or citation definition. ((looking-at (rst-re 'fnc-sta-2 '(:grp "\\S ") "?")) (push (list (match-end 1) 0 t) tabs) (when (match-string 3) (push (list (match-beginning 3) 0 t) tabs))) - ;; Comment + ;; Comment. ((looking-at (rst-re 'cmt-sta-1)) (push (list (point) rst-indent-comment t) tabs))) - ;; Start of literal block + ;; Start of literal block. (when (looking-at (rst-re 'lit-sta-2)) (let ((tab0 (first tabs))) (push (list (first tab0) @@ -2861,14 +2847,14 @@ (defun rst-compute-tabs (pt) "Build the list of possible tabs for all lines above. Search backwards from point PT to build the list of possible -tabs. Return a list of tabs sorted by likeliness to continue -writing like `rst-line-tabs'. Nearer lines have generally a -higher likeliness than farther lines. Return nil if no tab is found +tabs. Return a list of tabs sorted by likeliness to continue +writing like `rst-line-tabs'. Nearer lines have generally a +higher likeliness than farther lines. Return nil if no tab is found in the text above." (save-excursion (goto-char pt) - (let (leftmost ; Leftmost column found so far - innermost ; Leftmost column for inner tab + (let (leftmost ; Leftmost column found so far. + innermost ; Leftmost column for inner tab. tablist) (while (and (zerop (forward-line -1)) (or (not leftmost) @@ -2876,7 +2862,7 @@ (let* ((tabs (rst-line-tabs)) (leftcol (if tabs (apply 'min (mapcar 'car tabs))))) (when tabs - ;; Consider only lines indented less or same if not INNERMOST + ;; Consider only lines indented less or same if not INNERMOST. (when (or (not leftmost) (< leftcol leftmost) (and (not innermost) (= leftcol leftmost))) @@ -2894,7 +2880,7 @@ (not (memq newcol tablist))) (push newcol tablist)))) (setq innermost (if (some 'identity - (mapcar 'cdr tabs)) ; Has inner + (mapcar 'cdr tabs)) ; Has inner. leftcol innermost)) (setq leftmost leftcol))))) @@ -2903,13 +2889,13 @@ (defun rst-indent-line (&optional dflt) "Indent current line to next best reStructuredText tab. The next best tab is taken from the tab list returned by -`rst-compute-tabs' which is used in a cyclic manner. If the -current indentation does not end on a tab use the first one. If -the current indentation is on a tab use the next tab. This allows +`rst-compute-tabs' which is used in a cyclic manner. If the +current indentation does not end on a tab use the first one. If +the current indentation is on a tab use the next tab. This allows a repeated use of \\[indent-for-tab-command] to cycle through all -possible tabs. If no indentation is possible return `noindent' or -use DFLT. Return the indentation indented to. When point is in -indentation it ends up at its end. Otherwise the point is kept +possible tabs. If no indentation is possible return `noindent' or +use DFLT. Return the indentation indented to. When point is in +indentation it ends up at its end. Otherwise the point is kept relative to the content." (let* ((pt (point-marker)) (cur (current-indentation)) @@ -2936,46 +2922,46 @@ (defun rst-shift-region (beg end cnt) "Shift region BEG to END by CNT tabs. Shift by one tab to the right (CNT > 0) or left (CNT < 0) or -remove all indentation (CNT = 0). An tab is taken from the text -above. If no suitable tab is found `rst-indent-width' is used." +remove all indentation (CNT = 0). A tab is taken from the text +above. If no suitable tab is found `rst-indent-width' is used." (interactive "r\np") (let ((tabs (sort (rst-compute-tabs beg) (lambda (x y) (<= x y)))) (leftmostcol (rst-find-leftmost-column beg end))) (when (or (> leftmostcol 0) (> cnt 0)) - ;; Apply the indent + ;; Apply the indent. (indent-rigidly beg end (if (zerop cnt) (- leftmostcol) - ;; Find the next tab after the leftmost column + ;; Find the next tab after the leftmost column. (let* ((cmp (if (> cnt 0) '> '<)) (tabs (if (> cnt 0) tabs (reverse tabs))) (len (length tabs)) - (dir (signum cnt)) ; Direction to take - (abs (abs cnt)) ; Absolute number of steps to take - ;; Get the position of the first tab beyond leftmostcol + (dir (signum cnt)) ; Direction to take. + (abs (abs cnt)) ; Absolute number of steps to take. + ;; Get the position of the first tab beyond leftmostcol. (fnd (position-if (lambda (elt) (funcall cmp elt leftmostcol)) tabs)) - ;; Virtual position of tab + ;; Virtual position of tab. (pos (+ (or fnd len) (1- abs))) (tab (if (< pos len) - ;; Tab exists - use it + ;; Tab exists - use it. (nth pos tabs) - ;; Column needs to be computed + ;; Column needs to be computed. (let ((col (+ (or (car (last tabs)) leftmostcol) - ;; Base on last known column - (* (- pos (1- len)) ; Distance left - dir ; Direction to take + ;; Base on last known column. + (* (- pos (1- len)) ; Distance left. + dir ; Direction to take. rst-indent-width)))) (if (< col 0) 0 col))))) (- tab leftmostcol))))))) ;; FIXME: A paragraph with an (incorrectly) indented second line is not filled -;; correctly:: +;; correctly:: ;; -;; Some start -;; continued wrong +;; Some start +;; continued wrong (defun rst-adaptive-fill () "Return fill prefix found at point. Value for `adaptive-fill-function'." @@ -2983,9 +2969,9 @@ (match-string-no-properties 0)))) (if (save-match-data (not (string-match comment-start-skip fnd))) - ;; An non-comment prefix is fine + ;; An non-comment prefix is fine. fnd - ;; Matches a comment - return whitespace instead + ;; Matches a comment - return whitespace instead. (make-string (- (save-excursion (goto-char (match-end 0)) @@ -2999,7 +2985,8 @@ (defun rst-comment-line-break (&optional soft) "Break line and indent, continuing reStructuredText comment if within one. -Value for `comment-line-break-function'." +Value for `comment-line-break-function'. If SOFT use soft +newlines as mandated by `comment-line-break-function'." (if soft (insert-and-inherit ?\n) (newline 1)) @@ -3021,7 +3008,8 @@ (insert comment-start)) (defun rst-comment-region (beg end &optional arg) - "Comment the current region or uncomment it if ARG is \\[universal-argument]." + "Comment or uncomment the current region. +Region is from from BEG to END. Uncomment if ARG." (save-excursion (if (consp arg) (rst-uncomment-region beg end arg) @@ -3038,7 +3026,7 @@ (defun rst-uncomment-region (beg end &optional arg) "Uncomment the current region. -ARG is ignored" +Region is from BEG to END. ARG is ignored" (save-excursion (let (bol eol) (goto-char beg) @@ -3051,9 +3039,9 @@ ;;------------------------------------------------------------------------------ -;; FIXME: these next functions should become part of a larger effort to redo the -;; bullets in bulleted lists. The enumerate would just be one of the possible -;; outputs. +;; FIXME: These next functions should become part of a larger effort to redo +;; the bullets in bulleted lists. The enumerate would just be one of +;; the possible outputs. ;; ;; FIXME: We need to do the enumeration removal as well. @@ -3083,12 +3071,12 @@ (insert " ") )) -;; FIXME: Does not deal with a varying number of digits appropriately -;; FIXME: Does not deal with multiple levels independently -;; FIXME: Does not indent a multiline item correctly +;; FIXME: Does not deal with a varying number of digits appropriately. +;; FIXME: Does not deal with multiple levels independently. +;; FIXME: Does not indent a multiline item correctly. (defun rst-convert-bullets-to-enumeration (beg end) "Convert the bulleted and enumerated items in the region to enumerated lists. -Renumber as necessary." +Renumber as necessary. Region is from BEG to END." (interactive "r") (let* (;; Find items and convert the positions to markers. (items (mapcar @@ -3113,7 +3101,7 @@ (defun rst-line-block-region (rbeg rend &optional pfxarg) "Toggle line block prefixes for a region. -With prefix argument set the empty lines too." +Region is from RBEG to REND. With PFXARG set the empty lines too." (interactive "r\nP") (let ((comment-start "| ") (comment-end "") @@ -3135,7 +3123,7 @@ (require 'font-lock) -;; FIXME: The obsolete variables need to disappear +;; FIXME: The obsolete variables need to disappear. (defgroup rst-faces nil "Faces used in Rst Mode." :group 'rst @@ -3279,9 +3267,10 @@ :version "21.1") (defun rst-set-level-default (sym val) - "Set custom var SYM affecting section title text face and recompute the faces." + "Set custom variable SYM affecting section title text face. +Recompute the faces. VAL is the value to set." (custom-set-default sym val) - ;; Also defines the faces initially when all values are available + ;; Also defines the faces initially when all values are available. (and (boundp 'rst-level-face-max) (boundp 'rst-level-face-format-light) (boundp 'rst-level-face-base-color) @@ -3290,9 +3279,9 @@ (fboundp 'rst-define-level-faces) (rst-define-level-faces))) -;; Faces for displaying items on several levels; these definitions define +;; Faces for displaying items on several levels. These definitions define ;; different shades of gray where the lightest one (i.e. least contrasting) is -;; used for level 1 +;; used for level 1. (defcustom rst-level-face-max 6 "Maximum depth of levels for which section title faces are defined." :group 'rst-faces-defaults @@ -3362,10 +3351,10 @@ :value-type (face)) :set-after '(rst-level-face-max)) -;; FIXME: It should be possible to give "#RRGGBB" type of color values +;; FIXME: It should be possible to give "#RRGGBB" type of color values. (defun rst-define-level-faces () "Define the faces for the section title text faces from the values." - ;; All variables used here must be checked in `rst-set-level-default' + ;; All variables used here must be checked in `rst-set-level-default'. (let ((i 1)) (while (<= i rst-level-face-max) (let ((sym (intern (format "rst-level-%d-face" i))) @@ -3387,19 +3376,20 @@ (defvar rst-font-lock-keywords ;; The reST-links in the comments below all relate to sections in - ;; http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html + ;; http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html. `(;; FIXME: Block markup is not recognized in blocks after explicit markup - ;; start + ;; start. ;; Simple `Body Elements`_ ;; `Bullet Lists`_ - ;; FIXME: A bullet directly after a field name is not recognized + ;; FIXME: A bullet directly after a field name is not recognized. (,(rst-re 'lin-beg '(:grp bul-sta)) 1 rst-block-face) ;; `Enumerated Lists`_ (,(rst-re 'lin-beg '(:grp enmany-sta)) 1 rst-block-face) - ;; `Definition Lists`_ FIXME: missing + ;; `Definition Lists`_ + ;; FIXME: missing. ;; `Field Lists`_ (,(rst-re 'lin-beg '(:grp fld-tag) 'bli-sfx) 1 rst-external-face) @@ -3408,11 +3398,12 @@ '(:alt "$" (:seq hws-prt "\\{2\\}"))) 1 rst-block-face) ;; `Line Blocks`_ - ;; Only for lines containing no more bar - to distinguish from tables + ;; Only for lines containing no more bar - to distinguish from tables. (,(rst-re 'lin-beg '(:grp "|" bli-sfx) "[^|\n]*$") 1 rst-block-face) - ;; `Tables`_ FIXME: missing + ;; `Tables`_ + ;; FIXME: missing ;; All the `Explicit Markup Blocks`_ ;; `Footnotes`_ / `Citations`_ @@ -3434,11 +3425,11 @@ (,(rst-re 'lin-beg '(:grp "__") 'bli-sfx) 1 rst-definition-face) - ;; All `Inline Markup`_ - most of them may be multiline though this is - ;; uninteresting + ;; All `Inline Markup`_ + ;; Most of them may be multiline though this is uninteresting. ;; FIXME: Condition 5 preventing fontification of e.g. "*" not implemented - ;; `Strong Emphasis`_ + ;; `Strong Emphasis`_. (,(rst-re 'ilm-pfx '(:grp "\\*\\*" ilcast-tag "\\*\\*") 'ilm-sfx) 1 rst-emphasis2-face) ;; `Emphasis`_ @@ -3451,9 +3442,9 @@ (,(rst-re 'ilm-pfx '(:grp "_`" ilcbkq-tag "`") 'ilm-sfx) 1 rst-definition-face) ;; `Hyperlink References`_ - ;; FIXME: `Embedded URIs`_ not considered + ;; FIXME: `Embedded URIs`_ not considered. ;; FIXME: Directly adjacent marked up words are not fontified correctly - ;; unless they are not separated by two spaces: foo_ bar_ + ;; unless they are not separated by two spaces: foo_ bar_. (,(rst-re 'ilm-pfx '(:grp (:alt (:seq "`" ilcbkq-tag "`") (:seq "\\sw" (:alt "\\sw" "-") "+\\sw")) "__?") 'ilm-sfx) @@ -3470,19 +3461,20 @@ 1 rst-reference-face) ;; `Substitution References`_ ;; FIXME: References substitutions like |this|_ or |this|__ are not - ;; fontified correctly + ;; fontified correctly. (,(rst-re 'ilm-pfx '(:grp sub-tag) 'ilm-sfx) 1 rst-reference-face) ;; `Standalone Hyperlinks`_ - ;; FIXME: This takes it easy by using a whitespace as delimiter + ;; FIXME: This takes it easy by using a whitespace as delimiter. (,(rst-re 'ilm-pfx '(:grp uri-tag ":\\S +") 'ilm-sfx) 1 rst-definition-face) (,(rst-re 'ilm-pfx '(:grp sym-tag "@" sym-tag ) 'ilm-sfx) 1 rst-definition-face) - ;; Do all block fontification as late as possible so 'append works + ;; Do all block fontification as late as possible so 'append works. - ;; Sections_ / Transitions_ - for sections this is multiline + ;; Sections_ / Transitions_ + ;; For sections this is multiline. (,(rst-re 'ado-beg-2-1) (rst-font-lock-handle-adornment-matcher (rst-font-lock-handle-adornment-pre-match-form @@ -3495,13 +3487,14 @@ ;; FIXME: FACESPEC could be used instead of ordinary faces to set ;; properties on comments and literal blocks so they are *not* - ;; inline fontified; see (elisp)Search-based Fontification + ;; inline fontified. See (elisp)Search-based Fontification. ;; FIXME: And / or use `syntax-propertize` functions as in `octave-mod.el` - ;; and other V24 modes; may make `font-lock-extend-region` - ;; superfluous + ;; and other V24 modes. May make `font-lock-extend-region` + ;; superfluous. - ;; `Comments`_ - this is multiline + ;; `Comments`_ + ;; This is multiline. (,(rst-re 'lin-beg 'cmt-sta-1) (1 rst-comment-face) (rst-font-lock-find-unindented-line-match @@ -3517,9 +3510,9 @@ (0 rst-comment-face append))) ;; FIXME: This is not rendered as comment:: - ;; .. .. list-table:: - ;; :stub-columns: 1 - ;; :header-rows: 1 + ;; .. .. list-table:: + ;; :stub-columns: 1 + ;; :header-rows: 1 ;; FIXME: This is rendered wrong:: ;; @@ -3535,7 +3528,8 @@ ;; Indentation needs to be taken from the line with the ``::`` and not from ;; the first content line. - ;; `Indented Literal Blocks`_ - this is multiline + ;; `Indented Literal Blocks`_ + ;; This is multiline. (,(rst-re 'lin-beg 'lit-sta-2) (2 rst-block-face) (rst-font-lock-find-unindented-line-match @@ -3543,7 +3537,8 @@ nil (0 rst-literal-face append))) - ;; FIXME: `Quoted Literal Blocks`_ missing - this is multiline + ;; FIXME: `Quoted Literal Blocks`_ missing. + ;; This is multiline. ;; `Doctest Blocks`_ ;; FIXME: This is wrong according to the specification: @@ -3576,8 +3571,9 @@ (defvar font-lock-end) (defun rst-font-lock-extend-region () - "Extend the region `font-lock-beg' / `font-lock-end' iff it may -be in the middle of a multiline construct and return non-nil if so." + "Extend the font-lock region if it might be in a multi-line construct. +Return non-nil if so. Font-lock region is from `font-lock-beg' +to `font-lock-end'." (let ((r (rst-font-lock-extend-region-internal font-lock-beg font-lock-end))) (when r (setq font-lock-beg (car r)) @@ -3585,7 +3581,7 @@ t))) (defun rst-font-lock-extend-region-internal (beg end) - "Check the region BEG / END for being in the middle of a multiline construct. + "Check the region BEG / END for being in the middle of a multi-line construct. Return nil if not or a cons with new values for BEG / END" (let ((nbeg (rst-font-lock-extend-region-extend beg -1)) (nend (rst-font-lock-extend-region-extend end 1))) @@ -3593,7 +3589,8 @@ (cons (or nbeg beg) (or nend end))))) (defun rst-forward-line (&optional n) - "Like `forward-line' but always end up in column 0 and return accordingly." + "Like `forward-line' but always end up in column 0 and return accordingly. +Move N lines forward just as `forward-line'." (let ((moved (forward-line n))) (if (bolp) moved @@ -3616,41 +3613,41 @@ ;; ;; The second group consists of the adornment cases. (if (not (get-text-property pt 'font-lock-multiline)) - ;; Move only if we don't start inside a multiline construct already + ;; Move only if we don't start inside a multiline construct already. (save-excursion - (let (;; non-empty non-indented line, explicit markup tag or literal - ;; block tag + (let (;; Non-empty non-indented line, explicit markup tag or literal + ;; block tag. (stop-re (rst-re '(:alt "[^ \t\n]" (:seq hws-tag exm-tag) (:seq ".*" dcl-tag lin-end))))) - ;; The comments below are for dir == -1 / dir == 1 + ;; The comments below are for dir == -1 / dir == 1. (goto-char pt) (forward-line 0) (setq pt (point)) (while (and (not (looking-at stop-re)) (zerop (rst-forward-line dir)))) ; try previous / next - ; line if it exists + ; line if it exists. (if (looking-at (rst-re 'ado-beg-2-1)) ; may be an underline / - ; overline + ; overline. (if (zerop (rst-forward-line dir)) (if (looking-at (rst-re 'ttl-beg)) ; title found, i.e. ; underline / overline - ; found + ; found. (if (zerop (rst-forward-line dir)) (if (not (looking-at (rst-re 'ado-beg-2-1))) ; no ; overline / - ; underline + ; underline. (rst-forward-line (- dir)))) ; step back to title - ; / adornment - (if (< dir 0) ; keep downward adornment - (rst-forward-line (- dir))))) ; step back to adornment - (if (looking-at (rst-re 'ttl-beg)) ; may be a title + ; / adornment. + (if (< dir 0) ; keep downward adornment. + (rst-forward-line (- dir))))) ; step back to adornment. + (if (looking-at (rst-re 'ttl-beg)) ; may be a title. (if (zerop (rst-forward-line dir)) (if (not (looking-at (rst-re 'ado-beg-2-1))) ; no overline / - ; underline - (rst-forward-line (- dir)))))) ; step back to line + ; underline. + (rst-forward-line (- dir)))))) ; step back to line. (if (not (= (point) pt)) (point)))))) @@ -3676,20 +3673,21 @@ (when (< (point) limit) (setq beg (point)) (if (looking-at (rst-re 'lin-end)) - (setq cand (or cand beg)) ; An empty line is a candidate + (setq cand (or cand beg)) ; An empty line is a candidate. (move-to-column clm) ;; FIXME: No indentation [(zerop clm)] must be handled in some - ;; useful way - though it is not clear what this should mean at all + ;; useful way - though it is not clear what this should mean + ;; at all. (if (string-match (rst-re 'linemp-tag) (buffer-substring-no-properties beg (point))) - (setq cand nil) ; An indented line resets a candidate + (setq cand nil) ; An indented line resets a candidate. (setq fnd (or cand beg))))))) (goto-char (or fnd start)) fnd)) (defvar rst-font-lock-find-unindented-line-begin nil - "Beginning of the match if `rst-font-lock-find-unindented-line-end'") + "Beginning of the match if `rst-font-lock-find-unindented-line-end'.") (defvar rst-font-lock-find-unindented-line-end nil "End of the match as determined by `rst-font-lock-find-unindented-line-limit'. @@ -3700,7 +3698,7 @@ "Find the next unindented line relative to indentation at IND-PNT. Return this point, the end of the buffer or nil if nothing found. If IND-PNT is `next' take the indentation from the next line if -this is not empty and indented more than the current one. If +this is not empty and indented more than the current one. If IND-PNT is non-nil but not a number take the indentation from the next non-empty line if this is indented more than the current one." @@ -3708,34 +3706,34 @@ (setq rst-font-lock-find-unindented-line-end (save-excursion (when (not (numberp ind-pnt)) - ;; Find indentation point in next line if any + ;; Find indentation point in next line if any. (setq ind-pnt ;; FIXME: Should be refactored to two different functions ;; giving their result to this function, may be - ;; integrated in caller + ;; integrated in caller. (save-match-data (let ((cur-ind (current-indentation))) (if (eq ind-pnt 'next) (when (and (zerop (forward-line 1)) (< (point) (point-max))) - ;; Not at EOF + ;; Not at EOF. (setq rst-font-lock-find-unindented-line-begin (point)) (when (and (not (looking-at (rst-re 'lin-end))) (> (current-indentation) cur-ind)) - ;; Use end of indentation if non-empty line + ;; Use end of indentation if non-empty line. (looking-at (rst-re 'hws-tag)) (match-end 0))) - ;; Skip until non-empty line or EOF + ;; Skip until non-empty line or EOF. (while (and (zerop (forward-line 1)) (< (point) (point-max)) (looking-at (rst-re 'lin-end)))) (when (< (point) (point-max)) - ;; Not at EOF + ;; Not at EOF. (setq rst-font-lock-find-unindented-line-begin (point)) (when (> (current-indentation) cur-ind) - ;; Indentation bigger than line of departure + ;; Indentation bigger than line of departure. (looking-at (rst-re 'hws-tag)) (match-end 0)))))))) (when ind-pnt @@ -3744,9 +3742,11 @@ (point-max)))))) (defun rst-font-lock-find-unindented-line-match (limit) - "Set the match found by + "Set the match found earlier if match were found. +Match has been found by `rst-font-lock-find-unindented-line-limit' the first time called -or nil." +or no match is found. Return non-nil if match was found. LIMIT +is not used but mandated by the caller." (when rst-font-lock-find-unindented-line-end (set-match-data (list rst-font-lock-find-unindented-line-begin @@ -3754,7 +3754,7 @@ (put-text-property rst-font-lock-find-unindented-line-begin rst-font-lock-find-unindented-line-end 'font-lock-multiline t) - ;; Make sure this is called only once + ;; Make sure this is called only once. (setq rst-font-lock-find-unindented-line-end nil) t)) @@ -3768,8 +3768,8 @@ (defun rst-adornment-level (key) "Return section level for adornment KEY. KEY is the first element of the return list of -`rst-classify-adornment'. If KEY is not a cons return it. If KEY is found -in the hierarchy return its level. Otherwise return a level one +`rst-classify-adornment'. If KEY is not a cons return it. If KEY is found +in the hierarchy return its level. Otherwise return a level one beyond the existing hierarchy." (if (not (consp key)) key @@ -3783,15 +3783,16 @@ (defvar rst-font-lock-adornment-match nil "Storage for match for current adornment. -Set by `rst-font-lock-handle-adornment-pre-match-form'. Also used +Set by `rst-font-lock-handle-adornment-pre-match-form'. Also used as a trigger for `rst-font-lock-handle-adornment-matcher'.") (defun rst-font-lock-handle-adornment-pre-match-form (ado ado-end) - "Determine limit for adornments for font-locking section titles and transitions. -In fact determine all things necessary and put the result to + "Determine limit for adornments. +Determine all things necessary for font-locking section titles +and transitions and put the result to `rst-font-lock-adornment-match' and -`rst-font-lock-adornment-level'. ADO is the complete adornment -matched. ADO-END is the point where ADO ends. Return the point +`rst-font-lock-adornment-level'. ADO is the complete adornment +matched. ADO-END is the point where ADO ends. Return the point where the whole adorned construct ends. Called as a PRE-MATCH-FORM in the sense of `font-lock-keywords'." @@ -3802,16 +3803,19 @@ (setq rst-font-lock-adornment-level (rst-adornment-level (car ado-data))) (setq rst-font-lock-adornment-match (cdr ado-data)) - (goto-char (nth 1 ado-data)) ; Beginning of construct - (nth 2 ado-data)))) ; End of construct + (goto-char (nth 1 ado-data)) ; Beginning of construct. + (nth 2 ado-data)))) ; End of construct. (defun rst-font-lock-handle-adornment-matcher (limit) - "Set the match found by `rst-font-lock-handle-adornment-pre-match-form' -the first time called or nil. + "Set the match found earlier if match were found. +Match has been found by +`rst-font-lock-handle-adornment-pre-match-form' the first time +called or no match is found. Return non-nil if match was found. -Called as a MATCHER in the sense of `font-lock-keywords'." +Called as a MATCHER in the sense of `font-lock-keywords'. +LIMIT is not used but mandated by the caller." (let ((match rst-font-lock-adornment-match)) - ;; May run only once - enforce this + ;; May run only once - enforce this. (setq rst-font-lock-adornment-match nil) (when match (set-match-data match) @@ -3847,12 +3851,12 @@ ".pdf" nil) (s5 ,(if (executable-find "rst2s5.py") "rst2s5.py" "rst2s5") ".html" nil)) - "Table describing the command to use for each toolset. -An association list of the toolset to a list of the (command to use, + "Table describing the command to use for each tool-set. +An association list of the tool-set to a list of the (command to use, extension of produced filename, options to the tool (nil or a string)) to be used for converting the document." ;; FIXME: These are not options but symbols which may be referenced by - ;; `rst-compile-*-toolset` below + ;; `rst-compile-*-toolset` below. :type '(alist :options (html latex newlatex pseudoxml xml pdf s5) :key-type symbol :value-type (list :tag "Specification" @@ -3864,13 +3868,13 @@ :group 'rst :version "24.1") -;; FIXME: Must be `defcustom` +;; FIXME: Must be `defcustom`. (defvar rst-compile-primary-toolset 'html - "The default toolset for `rst-compile'.") + "The default tool-set for `rst-compile'.") -;; FIXME: Must be `defcustom` +;; FIXME: Must be `defcustom`. (defvar rst-compile-secondary-toolset 'latex - "The default toolset for `rst-compile' with a prefix argument.") + "The default tool-set for `rst-compile' with a prefix argument.") (defun rst-compile-find-conf () "Look for the configuration file in the parents of the current path." @@ -3900,7 +3904,7 @@ "Compile command to convert reST document into some output file. Attempts to find configuration file, if it can, overrides the options. There are two commands to choose from, with USE-ALT, -select the alternative toolset." +select the alternative tool-set." (interactive "P") ;; Note: maybe we want to check if there is a Makefile too and not do anything ;; if that is the case. I dunno. @@ -3934,13 +3938,15 @@ )) (defun rst-compile-alt-toolset () - "Compile command with the alternative toolset." + "Compile command with the alternative tool-set." (interactive) (rst-compile t)) (defun rst-compile-pseudo-region () - "Show the pseudo-XML rendering of the current active region, -or of the entire buffer, if the region is not selected." + "Show pseudo-XML rendering. +Rendering is done of the current active region, or of the entire +buffer, if the region is not selected." + ;; FIXME: The region should be given interactively. (interactive) (with-output-to-temp-buffer "*pseudoxml*" (shell-command-on-region @@ -3949,7 +3955,7 @@ (cadr (assq 'pseudoxml rst-compile-toolsets)) standard-output))) -;; FIXME: Should be `defcustom` +;; FIXME: Should be `defcustom`. (defvar rst-pdf-program "xpdf" "Program used to preview PDF files.") @@ -3966,7 +3972,7 @@ ;; output. )) -;; FIXME: Should be `defcustom` or use something like `browse-url` +;; FIXME: Should be `defcustom` or use something like `browse-url`. (defvar rst-slides-program "firefox" "Program used to preview S5 slides.") @@ -3987,10 +3993,9 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Generic text functions that are more convenient than the defaults. -;; FIXME: Unbound command - should be bound or removed +;; FIXME: Unbound command - should be bound or removed. (defun rst-replace-lines (fromchar tochar) - "Replace flush-left lines, consisting of multiple FROMCHAR characters, -with equal-length lines of TOCHAR." + "Replace flush-left lines of FROMCHAR with equal-length lines of TOCHAR." (interactive "\ cSearch for flush-left lines of char: cand replace with char: ") @@ -4005,14 +4010,14 @@ (insert-char tochar width))) (message (format "%d lines replaced." found))))) -;; FIXME: Unbound command - should be bound or removed +;; FIXME: Unbound command - should be bound or removed. (defun rst-join-paragraph () "Join lines in current paragraph into one line, removing end-of-lines." (interactive) - (let ((fill-column 65000)) ; some big number + (let ((fill-column 65000)) ; some big number. (call-interactively 'fill-paragraph))) -;; FIXME: Unbound command - should be bound or removed +;; FIXME: Unbound command - should be bound or removed. (defun rst-force-fill-paragraph () "Fill paragraph at point, first joining the paragraph's lines into one. This is useful for filling list item paragraphs." @@ -4021,14 +4026,14 @@ (fill-paragraph nil)) -;; FIXME: Unbound command - should be bound or removed +;; FIXME: Unbound command - should be bound or removed. ;; Generic character repeater function. ;; For sections, better to use the specialized function above, but this can ;; be useful for creating separators. (defun rst-repeat-last-character (use-next) - "Fill the current line up to the length of the preceding line (if not -empty), using the last character on the current line. If the preceding line is -empty, we use the `fill-column'. + "Fill the current line using the last character on the current line. +Fill up to the length of the preceding line or up to +`fill-column' if preceding line is empty. If USE-NEXT, use the next line rather than the preceding line. @@ -4058,18 +4063,19 @@ )) ) (end-of-line) (if (> (current-column) rightmost-column) - ;; shave characters off the end + ;; Shave characters off the end. (delete-region (- (point) (- (current-column) rightmost-column)) (point)) - ;; fill with last characters + ;; Fill with last characters. (insert-char (preceding-char) (- rightmost-column (current-column)))) )) (defun rst-portable-mark-active-p () - "A portable function that returns non-nil if the mark is active." + "Return non-nil if the mark is active. +This is a portable function." (cond ((fboundp 'region-active-p) (region-active-p)) ((boundp 'transient-mark-mode) (and transient-mark-mode mark-active)) @@ -4077,4 +4083,13 @@ (provide 'rst) -;;; rst.el ends here + +;; LocalWords: docutils http sourceforge rst html wp svn svnroot txt reST regex +;; LocalWords: regexes alist seq alt grp keymap abbrev overline overlines toc +;; LocalWords: XML PNT propertized referencable + +;; Local Variables: +;; sentence-end-double-space: t +;; End: + +;;; rst.el ends here. ------------------------------------------------------------ revno: 108424 committer: Ulf Jasper branch nick: trunk timestamp: Tue 2012-05-29 21:42:49 +0200 message: icalendar-tests: Fix Bug#11525 -- Add icalendar-import-format-uid 2012-05-29 Ulf Jasper * calendar/icalendar.el (icalendar-export-region): Export UID properly. 2012-05-29 Leo * calendar/icalendar.el (icalendar-import-format): Add `icalendar-import-format-uid' (Bug#11525). (icalendar-import-format-uid): New. (icalendar--parse-summary-and-rest, icalendar--format-ical-event): Export UID. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 14:28:02 +0000 +++ lisp/ChangeLog 2012-05-29 19:42:49 +0000 @@ -1,3 +1,15 @@ +2012-05-29 Ulf Jasper + + * calendar/icalendar.el + (icalendar-export-region): Export UID properly. + +2012-05-29 Leo + * calendar/icalendar.el (icalendar-import-format): Add + `icalendar-import-format-uid' (Bug#11525). + (icalendar-import-format-uid): New. + (icalendar--parse-summary-and-rest, icalendar--format-ical-event): + Export UID. + 2012-05-29 Stefan Monnier * emacs-lisp/pcase.el (pcase--expand): Accept different sets of vars in === modified file 'lisp/calendar/icalendar.el' --- lisp/calendar/icalendar.el 2012-03-13 06:54:37 +0000 +++ lisp/calendar/icalendar.el 2012-05-29 19:42:49 +0000 @@ -130,6 +130,7 @@ %s Summary, see `icalendar-import-format-summary' %t Status, see `icalendar-import-format-status' %u URL, see `icalendar-import-format-url' +%U UID, see `icalendar-import-format-uid' A formatting FUNCTION will be called with a VEVENT as its only argument. It must return a string. See @@ -179,6 +180,14 @@ :type 'string :group 'icalendar) +(defcustom icalendar-import-format-uid + "\n UID: %s" + "Format string defining how the UID element is formatted. +This applies only if the UID is not empty! `%s' is replaced by +the UID." + :type 'string + :group 'icalendar) + (defcustom icalendar-import-format-status "\n Status: %s" "Format string defining how the status element is formatted. @@ -1017,7 +1026,8 @@ (org (cdr (assoc 'org other-elements))) (sta (cdr (assoc 'sta other-elements))) (sum (cdr (assoc 'sum other-elements))) - (url (cdr (assoc 'url other-elements)))) + (url (cdr (assoc 'url other-elements))) + (uid (cdr (assoc 'uid other-elements)))) (if cla (setq contents (concat contents "\nCLASS:" cla))) (if des @@ -1031,10 +1041,12 @@ ;;(if sum ;; (setq contents (concat contents "\nSUMMARY:" sum))) (if url - (setq contents (concat contents "\nURL:" url)))) + (setq contents (concat contents "\nURL:" url))) - (setq header (concat "\nBEGIN:VEVENT\nUID:" - (icalendar--create-uid entry-full contents))) + (setq header (concat "\nBEGIN:VEVENT\nUID:" + (or uid + (icalendar--create-uid entry-full + contents))))) (setq result (concat result header contents "\nEND:VEVENT"))) ;; handle errors (error @@ -1098,7 +1110,8 @@ ;; can't do anything nil ;; split summary-and-rest - (let* ((s icalendar-import-format) + (let* ((case-fold-search nil) + (s icalendar-import-format) (p-cla (or (string-match "%c" icalendar-import-format) -1)) (p-des (or (string-match "%d" icalendar-import-format) -1)) (p-loc (or (string-match "%l" icalendar-import-format) -1)) @@ -1106,9 +1119,10 @@ (p-sum (or (string-match "%s" icalendar-import-format) -1)) (p-sta (or (string-match "%t" icalendar-import-format) -1)) (p-url (or (string-match "%u" icalendar-import-format) -1)) - (p-list (sort (list p-cla p-des p-loc p-org p-sta p-sum p-url) '<)) + (p-uid (or (string-match "%U" icalendar-import-format) -1)) + (p-list (sort (list p-cla p-des p-loc p-org p-sta p-sum p-url p-uid) '<)) (ct 0) - pos-cla pos-des pos-loc pos-org pos-sta pos-sum pos-url) + pos-cla pos-des pos-loc pos-org pos-sta pos-sum pos-url pos-uid) (dotimes (i (length p-list)) ;; Use 'ct' to keep track of current position in list (cond ((and (>= p-cla 0) (= (nth i p-list) p-cla)) @@ -1131,7 +1145,10 @@ (setq pos-sum (* 2 ct))) ((and (>= p-url 0) (= (nth i p-list) p-url)) (setq ct (+ ct 1)) - (setq pos-url (* 2 ct)))) ) + (setq pos-url (* 2 ct))) + ((and (>= p-uid 0) (= (nth i p-list) p-uid)) + (setq ct (+ ct 1)) + (setq pos-uid (* 2 ct)))) ) (mapc (lambda (ij) (setq s (icalendar--rris (car ij) (cadr ij) s t t))) (list @@ -1149,13 +1166,15 @@ (list "%t" (concat "\\(" icalendar-import-format-status "\\)??")) (list "%u" - (concat "\\(" icalendar-import-format-url "\\)??")))) + (concat "\\(" icalendar-import-format-url "\\)??")) + (list "%U" + (concat "\\(" icalendar-import-format-uid "\\)??")))) ;; Need the \' regexp in order to detect multi-line items (setq s (concat "\\`" (icalendar--rris "%s" "\\(.*?\\)" s nil t) "\\'")) (if (string-match s summary-and-rest) - (let (cla des loc org sta sum url) + (let (cla des loc org sta sum url uid) (if (and pos-sum (match-beginning pos-sum)) (setq sum (substring summary-and-rest (match-beginning pos-sum) @@ -1184,13 +1203,18 @@ (setq url (substring summary-and-rest (match-beginning pos-url) (match-end pos-url)))) + (if (and pos-uid (match-beginning pos-uid)) + (setq uid (substring summary-and-rest + (match-beginning pos-uid) + (match-end pos-uid)))) (list (if cla (cons 'cla cla) nil) (if des (cons 'des des) nil) (if loc (cons 'loc loc) nil) (if org (cons 'org org) nil) (if sta (cons 'sta sta) nil) ;;(if sum (cons 'sum sum) nil) - (if url (cons 'url url) nil)))))))) + (if url (cons 'url url) nil) + (if uid (cons 'uid uid) nil)))))))) ;; subroutines for icalendar-export-region (defun icalendar--convert-ordinary-to-ical (nonmarker entry-main) @@ -1864,6 +1888,7 @@ (if (functionp icalendar-import-format) (funcall icalendar-import-format event) (let ((string icalendar-import-format) + (case-fold-search nil) (conversion-list '(("%c" CLASS icalendar-import-format-class) ("%d" DESCRIPTION icalendar-import-format-description) @@ -1871,7 +1896,8 @@ ("%o" ORGANIZER icalendar-import-format-organizer) ("%s" SUMMARY icalendar-import-format-summary) ("%t" STATUS icalendar-import-format-status) - ("%u" URL icalendar-import-format-url)))) + ("%u" URL icalendar-import-format-url) + ("%U" UID icalendar-import-format-uid)))) ;; convert the specifiers in the format string (mapc (lambda (i) (let* ((spec (car i)) === modified file 'test/ChangeLog' --- test/ChangeLog 2012-05-21 00:44:34 +0000 +++ test/ChangeLog 2012-05-29 19:42:49 +0000 @@ -1,3 +1,15 @@ +2012-05-29 Ulf Jasper + + * automated/icalendar-tests.el (icalendar-tests--test-import): + Include UID in import tests (Bug#11525). + (icalendar-import-non-recurring, icalendar-import-rrule) + (icalendar-import-duration, icalendar-import-bug-6766): Adjust to + UID-import change. + (icalendar-import-with-uid): New. + (icalendar-tests--test-cycle, icalendar-tests--do-test-cycle): + Include UID in cycle tests. + (icalendar-cycle, icalendar-real-world): UID-import change. + 2012-05-21 Glenn Morris * automated/Makefile.in (setwins): Scrap superfluous subshell. === modified file 'test/automated/icalendar-tests.el' --- test/automated/icalendar-tests.el 2012-01-29 12:28:20 +0000 +++ test/automated/icalendar-tests.el 2012-05-29 19:42:49 +0000 @@ -682,7 +682,7 @@ (unless (eq (char-before) ?\n) (insert "\n")) (insert "END:VEVENT\nEND:VCALENDAR\n")) - (let ((icalendar-import-format "%s%d%l%o%t%u%c") + (let ((icalendar-import-format "%s%d%l%o%t%u%c%U") (icalendar-import-format-summary "%s") (icalendar-import-format-location "\n Location: %s") (icalendar-import-format-description "\n Desc: %s") @@ -690,6 +690,7 @@ (icalendar-import-format-status "\n Status: %s") (icalendar-import-format-url "\n URL: %s") (icalendar-import-format-class "\n Class: %s") + (icalendar-import-format-uid "\n UID: %s") calendar-date-style) (when expected-iso (setq calendar-date-style 'iso) @@ -751,14 +752,17 @@ "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien Status: TENTATIVE Class: PRIVATE + UID: 748f2da0-0d9b-11d8-97af-b4ec8686ea61 " "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien Status: TENTATIVE Class: PRIVATE + UID: 748f2da0-0d9b-11d8-97af-b4ec8686ea61 " "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien Status: TENTATIVE Class: PRIVATE + UID: 748f2da0-0d9b-11d8-97af-b4ec8686ea61 ") (icalendar-tests--test-import "UID @@ -782,13 +786,16 @@ " "&2004/11/23 14:00-14:30 folded summary Status: TENTATIVE - Class: PRIVATE\n" + Class: PRIVATE + UID: 04979712-3902-11d9-93dd-8f9f4afe08da\n" "&23/11/2004 14:00-14:30 folded summary Status: TENTATIVE - Class: PRIVATE\n" + Class: PRIVATE + UID: 04979712-3902-11d9-93dd-8f9f4afe08da\n" "&11/23/2004 14:00-14:30 folded summary Status: TENTATIVE - Class: PRIVATE\n") + Class: PRIVATE + UID: 04979712-3902-11d9-93dd-8f9f4afe08da\n") (icalendar-tests--test-import "UID @@ -810,13 +817,16 @@ " "&2004/11/23 14:45-15:45 another example Status: TENTATIVE - Class: PRIVATE\n" + Class: PRIVATE + UID: 6161a312-3902-11d9-b512-f764153bb28b\n" "&23/11/2004 14:45-15:45 another example Status: TENTATIVE - Class: PRIVATE\n" + Class: PRIVATE + UID: 6161a312-3902-11d9-b512-f764153bb28b\n" "&11/23/2004 14:45-15:45 another example Status: TENTATIVE - Class: PRIVATE\n")) + Class: PRIVATE + UID: 6161a312-3902-11d9-b512-f764153bb28b\n")) (ert-deftest icalendar-import-rrule () (icalendar-tests--test-import @@ -879,7 +889,6 @@ "DTSTART;VALUE=DATE:20040815 DTEND;VALUE=DATE:20040816 SUMMARY:Maria Himmelfahrt -UID:CC56BEA6-49D2-11D8-8833-00039386D1C2-RID RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=8 " "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt\n" @@ -982,11 +991,14 @@ CREATED:20041127T183329 " "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29)) Urlaub - Class: PUBLIC\n" + Class: PUBLIC + UID: 20041127T183329Z-18215-1001-4536-49109@andromeda\n" "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub - Class: PUBLIC\n" + Class: PUBLIC + UID: 20041127T183329Z-18215-1001-4536-49109@andromeda\n" "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub - Class: PUBLIC\n")) + Class: PUBLIC + UID: 20041127T183329Z-18215-1001-4536-49109@andromeda\n")) (ert-deftest icalendar-import-bug-6766 () ;;bug#6766 -- multiple byday values in a weekly rrule @@ -1016,20 +1028,26 @@ "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 2010 4 21)) 11:30-12:00 Scrum Status: CONFIRMED Class: PUBLIC + UID: 8814e3f9-7482-408f-996c-3bfe486a1262 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking Class: PUBLIC + UID: 8814e3f9-7482-408f-996c-3bfe486a1263 " "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum Status: CONFIRMED Class: PUBLIC + UID: 8814e3f9-7482-408f-996c-3bfe486a1262 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking Class: PUBLIC + UID: 8814e3f9-7482-408f-996c-3bfe486a1263 " "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum Status: CONFIRMED Class: PUBLIC + UID: 8814e3f9-7482-408f-996c-3bfe486a1262 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking Class: PUBLIC + UID: 8814e3f9-7482-408f-996c-3bfe486a1263 ")) (ert-deftest icalendar-import-multiple-vcalendars () @@ -1074,6 +1092,17 @@ "&23/7/2011 event-1\n&24/7/2011 event-2\n&25/7/2011 event-3a\n&25/7/2011 event-3b\n" "&7/23/2011 event-1\n&7/24/2011 event-2\n&7/25/2011 event-3a\n&7/25/2011 event-3b\n")) +(ert-deftest icalendar-import-with-uid () + "Perform import test with uid." + (icalendar-tests--test-import + "UID:1234567890uid +SUMMARY:non-recurring +DTSTART;VALUE=DATE-TIME:20030919T090000 +DTEND;VALUE=DATE-TIME:20030919T113000" + "&2003/9/19 09:00-11:30 non-recurring\n UID: 1234567890uid\n" + "&19/9/2003 09:00-11:30 non-recurring\n UID: 1234567890uid\n" + "&9/19/2003 09:00-11:30 non-recurring\n UID: 1234567890uid\n")) + ;; ====================================================================== ;; Cycle ;; ====================================================================== @@ -1089,14 +1118,15 @@ (unless (eq (char-before) ?\n) (insert "\n")) (insert "END:VEVENT\nEND:VCALENDAR\n")) - (let ((icalendar-import-format "%s%d%l%o%t%u%c") + (let ((icalendar-import-format "%s%d%l%o%t%u%c%U") (icalendar-import-format-summary "%s") (icalendar-import-format-location "\n Location: %s") (icalendar-import-format-description "\n Desc: %s") (icalendar-import-format-organizer "\n Organizer: %s") (icalendar-import-format-status "\n Status: %s") (icalendar-import-format-url "\n URL: %s") - (icalendar-import-format-class "\n Class: %s")) + (icalendar-import-format-class "\n Class: %s") + (icalendar-import-format-class "\n UID: %s")) (dolist (calendar-date-style '(iso european american)) (icalendar-tests--do-test-cycle))))) @@ -1120,8 +1150,8 @@ (save-excursion (find-file temp-ics) (goto-char (point-min)) - (when (re-search-forward "\nUID:.*\n" nil t) - (replace-match "\n")) + ;;(when (re-search-forward "\nUID:.*\n" nil t) + ;;(replace-match "\n")) (let ((cycled (buffer-substring-no-properties (point-min) (point-max)))) (should (string= org-input cycled))))) ;; clean up @@ -1134,14 +1164,17 @@ (delete-file temp-ics)))) (ert-deftest icalendar-cycle () - "Perform cycling tests." + "Perform cycling tests. +Take care to avoid auto-generated UIDs here." (icalendar-tests--test-cycle - "DTSTART;VALUE=DATE-TIME:20030919T090000 + "UID:dummyuid +DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 SUMMARY:Cycletest ") (icalendar-tests--test-cycle - "DTSTART;VALUE=DATE-TIME:20030919T090000 + "UID:blah +DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 SUMMARY:Cycletest DESCRIPTION:beschreibung! @@ -1149,7 +1182,8 @@ ORGANIZER:ulf ") (icalendar-tests--test-cycle - "DTSTART;VALUE=DATE:19190909 + "UID:4711 +DTSTART;VALUE=DATE:19190909 DTEND;VALUE=DATE:19190910 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=09 SUMMARY:and diary-anniversary @@ -1222,12 +1256,14 @@ Location: Cccc Organizer: MAILTO:aaaaaaa@aaaaaaa.com Status: CONFIRMED + UID: 040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000010000000DB823520692542408ED02D7023F9DFF9 " "&5/9/2003 10:30-15:30 On-Site Interview Desc: 10:30am - Blah Location: Cccc Organizer: MAILTO:aaaaaaa@aaaaaaa.com Status: CONFIRMED + UID: 040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000010000000DB823520692542408ED02D7023F9DFF9 ") ;; 2003-06-18 a @@ -1268,12 +1304,14 @@ Location: 555 or TN 555-5555 ID 5555 & NochWas (see below) Organizer: MAILTO:xxx@xxxxx.com Status: CONFIRMED + UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E " "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX Desc: 753 Zeichen hier radiert Location: 555 or TN 555-5555 ID 5555 & NochWas (see below) Organizer: MAILTO:xxx@xxxxx.com Status: CONFIRMED + UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E ") ;; 2003-06-18 b -- uses timezone (icalendar-tests--test-import @@ -1338,12 +1376,14 @@ Location: 123 or TN 123-1234 ID abcd & SonstWo (see below) Organizer: MAILTO:bbb@bbbbb.com Status: CONFIRMED + UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E " "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15 Desc: Viele Zeichen standen hier früher Location: 123 or TN 123-1234 ID abcd & SonstWo (see below) Organizer: MAILTO:bbb@bbbbb.com Status: CONFIRMED + UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E ") ;; export 2004-10-28 block entries (icalendar-tests--test-export @@ -1567,8 +1607,6 @@ PRODID :-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN BEGIN:VEVENT -UID - :04979712-3902-11d9-93dd-8f9f4afe08da SUMMARY :Jjjjj & Wwwww STATUS @@ -1587,8 +1625,6 @@ :20041118T013640Z END:VEVENT BEGIN:VEVENT -UID - :6161a312-3902-11d9-b512-f764153bb28b SUMMARY :BB Aaaaaaaa Bbbbb STATUS @@ -1605,8 +1641,6 @@ :20041118T013641Z END:VEVENT BEGIN:VEVENT -UID - :943a4d7e-3902-11d9-9ce7-c9addeadf928 SUMMARY :Hhhhhhhh STATUS @@ -1623,8 +1657,6 @@ :20041118T013831Z END:VEVENT BEGIN:VEVENT -UID - :fe53615e-3902-11d9-9dd8-9d38a155bf41 SUMMARY :MMM Aaaaaaaaa STATUS @@ -1645,8 +1677,6 @@ :20041118T014117Z END:VEVENT BEGIN:VEVENT -UID - :87c928ee-3901-11d9-b21f-b45042155024 SUMMARY :Rrrr/Cccccc ii Aaaaaaaa DESCRIPTION @@ -1669,8 +1699,6 @@ :20041118T014203Z END:VEVENT BEGIN:VEVENT -UID - :e8f331ae-3902-11d9-9948-dfdcb66a2872 SUMMARY :Wwww aa hhhh STATUS @@ -1790,11 +1818,13 @@ Desc: abcdef Status: CONFIRMED Class: PRIVATE + UID: b60d398e-1dd1-11b2-a159-cf8cb05139f4 " "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day Desc: abcdef Status: CONFIRMED Class: PRIVATE + UID: b60d398e-1dd1-11b2-a159-cf8cb05139f4 ") ;; 2005-03-01 lt @@ -1805,8 +1835,10 @@ DTSTAMP:20050118T210335Z DURATION:P7D" nil - "&%%(and (diary-block 17 2 2005 23 2 2005)) Hhhhhh Aaaaa ii Aaaaaaaa\n" - "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa\n") + "&%%(and (diary-block 17 2 2005 23 2 2005)) Hhhhhh Aaaaa ii Aaaaaaaa + UID: 6AFA7558-6994-11D9-8A3A-000A95A0E830-RID\n" + "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa + UID: 6AFA7558-6994-11D9-8A3A-000A95A0E830-RID\n") ;; 2005-03-23 lt (icalendar-tests--test-export ------------------------------------------------------------ revno: 108423 fixes bug(s): http://debbugs.gnu.org/9642 author: Troels Nielsen committer: Paul Eggert branch nick: trunk timestamp: Tue 2012-05-29 09:13:38 -0700 message: Do not avoid creating empty evaporating overlays (Bug#9642). * buffer.c (Fmove_overlay): Reinstate the earlier fix for Bug#9642, but explicitly check that the buffer the overlay would be moved to is live and rearrange lines to make sure that errors will not put the overlay in an inconsistent state. (Fdelete_overlay): Cosmetics. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-05-28 17:22:40 +0000 +++ src/ChangeLog 2012-05-29 16:13:38 +0000 @@ -1,3 +1,12 @@ +2012-05-29 Troels Nielsen + + Do not avoid creating empty evaporating overlays (Bug#9642). + * buffer.c (Fmove_overlay): Reinstate the earlier fix for + Bug#9642, but explicitly check that the buffer the overlay would + be moved to is live and rearrange lines to make sure that errors + will not put the overlay in an inconsistent state. + (Fdelete_overlay): Cosmetics. + 2012-05-28 Eli Zaretskii * w32term.c (my_bring_window_to_top): New function. === modified file 'src/buffer.c' --- src/buffer.c 2012-05-27 01:06:44 +0000 +++ src/buffer.c 2012-05-29 16:13:38 +0000 @@ -3676,10 +3676,10 @@ buffer. */) (Lisp_Object overlay, Lisp_Object beg, Lisp_Object end, Lisp_Object buffer) { - struct buffer *b, *ob; + struct buffer *b, *ob = 0; Lisp_Object obuffer; ptrdiff_t count = SPECPDL_INDEX (); - ptrdiff_t n_beg, n_end; + ptrdiff_t n_beg, n_end, o_beg IF_LINT (= 0), o_end IF_LINT (= 0); CHECK_OVERLAY (overlay); if (NILP (buffer)) @@ -3688,6 +3688,9 @@ XSETBUFFER (buffer, current_buffer); CHECK_BUFFER (buffer); + if (NILP (Fbuffer_live_p (buffer))) + error ("Attempt to move overlay to a dead buffer"); + if (MARKERP (beg) && ! EQ (Fmarker_buffer (beg), buffer)) error ("Marker points into wrong buffer"); @@ -3697,38 +3700,45 @@ CHECK_NUMBER_COERCE_MARKER (beg); CHECK_NUMBER_COERCE_MARKER (end); - n_beg = clip_to_bounds (PTRDIFF_MIN, XINT (beg), PTRDIFF_MAX); - n_end = clip_to_bounds (PTRDIFF_MIN, XINT (end), PTRDIFF_MAX); - - if (n_beg == n_end && ! NILP (Foverlay_get (overlay, Qevaporate))) - return Fdelete_overlay (overlay); - - if (n_beg > n_end) + + if (XINT (beg) > XINT (end)) { - ptrdiff_t temp; - temp = n_beg; n_beg = n_end; n_end = temp; + Lisp_Object temp; + temp = beg; beg = end; end = temp; } specbind (Qinhibit_quit, Qt); obuffer = Fmarker_buffer (OVERLAY_START (overlay)); b = XBUFFER (buffer); - ob = BUFFERP (obuffer) ? XBUFFER (obuffer) : (struct buffer *) 0; + + if (!NILP (obuffer)) + { + ob = XBUFFER (obuffer); + + o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); + o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); + + ob->overlays_before = + unchain_overlay (ob->overlays_before, XOVERLAY (overlay)); + ob->overlays_after = + unchain_overlay (ob->overlays_after, XOVERLAY (overlay)); + eassert (XOVERLAY (overlay)->next == NULL); + } + + /* Set the overlay boundaries, which may clip them. */ + Fset_marker (OVERLAY_START (overlay), beg, buffer); + Fset_marker (OVERLAY_END (overlay), end, buffer); + + n_beg = marker_position (OVERLAY_START (overlay)); + n_end = marker_position (OVERLAY_END (overlay)); /* If the overlay has changed buffers, do a thorough redisplay. */ if (!EQ (buffer, obuffer)) { /* Redisplay where the overlay was. */ - if (!NILP (obuffer)) - { - ptrdiff_t o_beg; - ptrdiff_t o_end; - - o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); - o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); - - modify_overlay (ob, o_beg, o_end); - } + if (ob) + modify_overlay (ob, o_beg, o_end); /* Redisplay where the overlay is going to be. */ modify_overlay (b, n_beg, n_end); @@ -3736,11 +3746,6 @@ else /* Redisplay the area the overlay has just left, or just enclosed. */ { - ptrdiff_t o_beg, o_end; - - o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); - o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); - if (o_beg == n_beg) modify_overlay (b, o_end, n_end); else if (o_end == n_end) @@ -3749,21 +3754,14 @@ modify_overlay (b, min (o_beg, n_beg), max (o_end, n_end)); } - if (!NILP (obuffer)) - { - ob->overlays_before - = unchain_overlay (ob->overlays_before, XOVERLAY (overlay)); - ob->overlays_after - = unchain_overlay (ob->overlays_after, XOVERLAY (overlay)); - eassert (XOVERLAY (overlay)->next == NULL); - } - - Fset_marker (OVERLAY_START (overlay), beg, buffer); - Fset_marker (OVERLAY_END (overlay), end, buffer); - - /* Put the overlay on the wrong list. */ - end = OVERLAY_END (overlay); - if (OVERLAY_POSITION (end) < b->overlay_center) + /* Delete the overlay if it is empty after clipping and has the + evaporate property. */ + if (n_beg == n_end && !NILP (Foverlay_get (overlay, Qevaporate))) + return unbind_to (count, Fdelete_overlay (overlay)); + + /* Put the overlay into the new buffer's overlay lists, first on the + wrong list. */ + if (n_end < b->overlay_center) { XOVERLAY (overlay)->next = b->overlays_after; b->overlays_after = XOVERLAY (overlay); @@ -3797,9 +3795,12 @@ b = XBUFFER (buffer); specbind (Qinhibit_quit, Qt); - b->overlays_before = unchain_overlay (b->overlays_before,XOVERLAY (overlay)); - b->overlays_after = unchain_overlay (b->overlays_after, XOVERLAY (overlay)); + b->overlays_before + = unchain_overlay (b->overlays_before, XOVERLAY (overlay)); + b->overlays_after + = unchain_overlay (b->overlays_after, XOVERLAY (overlay)); eassert (XOVERLAY (overlay)->next == NULL); + modify_overlay (b, marker_position (OVERLAY_START (overlay)), marker_position (OVERLAY_END (overlay))); ------------------------------------------------------------ revno: 108422 committer: Stefan Monnier branch nick: trunk timestamp: Tue 2012-05-29 10:28:02 -0400 message: Fix minor corner case bugs in byte compilation and pcase. * lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): Don't re-preprocess functions from byte-compile-function-environment. * lisp/emacs-lisp/bytecomp.el (byte-compile-constp): Treat #'v as a constant. (byte-compile-close-variables): Bind byte-compile--outbuffer here... (byte-compile-from-buffer): ...rather than here. * lisp/emacs-lisp/pcase.el (pcase--expand): Accept different sets of vars in different alternative patterns. (pcase-codegen): Be more careful to preserve identity. (pcase--u1): Don't forget to mark vars as used. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 12:22:49 +0000 +++ lisp/ChangeLog 2012-05-29 14:28:02 +0000 @@ -1,3 +1,17 @@ +2012-05-29 Stefan Monnier + + * emacs-lisp/pcase.el (pcase--expand): Accept different sets of vars in + different alternative patterns. + (pcase-codegen): Be more careful to preserve identity. + (pcase--u1): Don't forget to mark vars as used. + + * emacs-lisp/bytecomp.el (byte-compile-constp): Treat #'v as a constant. + (byte-compile-close-variables): Bind byte-compile--outbuffer here... + (byte-compile-from-buffer): ...rather than here. + + * emacs-lisp/byte-opt.el (byte-compile-inline-expand): Don't re-preprocess + functions from byte-compile-function-environment. + 2012-05-29 Troels Nielsen * window.el (window-deletable-p): Avoid deleting the root window === modified file 'lisp/emacs-lisp/byte-opt.el' --- lisp/emacs-lisp/byte-opt.el 2012-04-09 12:36:01 +0000 +++ lisp/emacs-lisp/byte-opt.el 2012-05-29 14:28:02 +0000 @@ -288,10 +288,14 @@ (push `(,(car binding) ',(cdr binding)) renv))) ((eq binding t)) (t (push `(defvar ,binding) body)))) - (let ((newfn (byte-compile-preprocess - (if (null renv) - `(lambda ,args ,@body) - `(lambda ,args (let ,(nreverse renv) ,@body)))))) + (let ((newfn (if (eq fn localfn) + ;; If `fn' is from the same file, it has already + ;; been preprocessed! + `(function ,fn) + (byte-compile-preprocess + (if (null renv) + `(lambda ,args ,@body) + `(lambda ,args (let ,(nreverse renv) ,@body))))))) (if (eq (car-safe newfn) 'function) (byte-compile-unfold-lambda `(,(cadr newfn) ,@(cdr form))) (byte-compile-log-warning === modified file 'lisp/emacs-lisp/bytecomp.el' --- lisp/emacs-lisp/bytecomp.el 2012-05-19 18:28:32 +0000 +++ lisp/emacs-lisp/bytecomp.el 2012-05-29 14:28:02 +0000 @@ -1478,40 +1478,46 @@ (defmacro byte-compile-constp (form) "Return non-nil if FORM is a constant." - `(cond ((consp ,form) (eq (car ,form) 'quote)) + `(cond ((consp ,form) (or (eq (car ,form) 'quote) + (and (eq (car ,form) 'function) + (symbolp (cadr ,form))))) ((not (symbolp ,form))) ((byte-compile-const-symbol-p ,form)))) +;; Dynamically bound in byte-compile-from-buffer. +;; NB also used in cl.el and cl-macs.el. +(defvar byte-compile--outbuffer) + (defmacro byte-compile-close-variables (&rest body) (declare (debug t)) - (cons 'let - (cons '(;; - ;; Close over these variables to encapsulate the - ;; compilation state - ;; - (byte-compile-macro-environment - ;; Copy it because the compiler may patch into the - ;; macroenvironment. - (copy-alist byte-compile-initial-macro-environment)) - (byte-compile-function-environment nil) - (byte-compile-bound-variables nil) - (byte-compile-const-variables nil) - (byte-compile-free-references nil) - (byte-compile-free-assignments nil) - ;; - ;; Close over these variables so that `byte-compiler-options' - ;; can change them on a per-file basis. - ;; - (byte-compile-verbose byte-compile-verbose) - (byte-optimize byte-optimize) - (byte-compile-dynamic byte-compile-dynamic) - (byte-compile-dynamic-docstrings - byte-compile-dynamic-docstrings) -;; (byte-compile-generate-emacs19-bytecodes -;; byte-compile-generate-emacs19-bytecodes) - (byte-compile-warnings byte-compile-warnings) - ) - body))) + `(let (;; + ;; Close over these variables to encapsulate the + ;; compilation state + ;; + (byte-compile-macro-environment + ;; Copy it because the compiler may patch into the + ;; macroenvironment. + (copy-alist byte-compile-initial-macro-environment)) + (byte-compile--outbuffer nil) + (byte-compile-function-environment nil) + (byte-compile-bound-variables nil) + (byte-compile-const-variables nil) + (byte-compile-free-references nil) + (byte-compile-free-assignments nil) + ;; + ;; Close over these variables so that `byte-compiler-options' + ;; can change them on a per-file basis. + ;; + (byte-compile-verbose byte-compile-verbose) + (byte-optimize byte-optimize) + (byte-compile-dynamic byte-compile-dynamic) + (byte-compile-dynamic-docstrings + byte-compile-dynamic-docstrings) + ;; (byte-compile-generate-emacs19-bytecodes + ;; byte-compile-generate-emacs19-bytecodes) + (byte-compile-warnings byte-compile-warnings) + ) + ,@body)) (defmacro displaying-byte-compile-warnings (&rest body) (declare (debug t)) @@ -1852,13 +1858,8 @@ (insert "\n")) ((message "%s" (prin1-to-string value))))))) -;; Dynamically bound in byte-compile-from-buffer. -;; NB also used in cl.el and cl-macs.el. -(defvar byte-compile--outbuffer) - (defun byte-compile-from-buffer (inbuffer) - (let (byte-compile--outbuffer - (byte-compile-current-buffer inbuffer) + (let ((byte-compile-current-buffer inbuffer) (byte-compile-read-position nil) (byte-compile-last-position nil) ;; Prevent truncation of flonums and lists as we read and print them @@ -1930,8 +1931,8 @@ ;; if the buffer contains multibyte characters. (and byte-compile-current-file (with-current-buffer byte-compile--outbuffer - (byte-compile-fix-header byte-compile-current-file))))) - byte-compile--outbuffer)) + (byte-compile-fix-header byte-compile-current-file)))) + byte-compile--outbuffer))) (defun byte-compile-fix-header (filename) "If the current buffer has any multibyte characters, insert a version test." === modified file 'lisp/emacs-lisp/pcase.el' --- lisp/emacs-lisp/pcase.el 2012-05-26 15:52:27 +0000 +++ lisp/emacs-lisp/pcase.el 2012-05-29 14:28:02 +0000 @@ -206,9 +206,12 @@ (setq vars (delq v vars)) (cdr v))) prevvars))) - (when vars ;New additional vars. - (error "The vars %s are only bound in some paths" - (mapcar #'car vars))) + ;; If some of `vars' were not found in `prevvars', that's + ;; OK it just means those vars aren't present in all + ;; branches, so they can be used within the pattern + ;; (e.g. by a `guard/let/pred') but not in the branch. + ;; FIXME: But if some of `prevvars' are not in `vars' we + ;; should remove them from `prevvars'! `(funcall ,res ,@args))))))) (main (pcase--u @@ -225,7 +228,10 @@ (pcase--let* defs main)))) (defun pcase-codegen (code vars) - `(let* ,(mapcar (lambda (b) (list (car b) (cdr b))) vars) + ;; Don't use let*, otherwise pcase--let* may merge it with some surrounding + ;; let* which might prevent the setcar/setcdr in pcase--expand's fancy + ;; codegen from later metamorphosing this let into a funcall. + `(let ,(mapcar (lambda (b) (list (car b) (cdr b))) vars) ,@code)) (defun pcase--small-branch-p (code) @@ -619,6 +625,7 @@ sym (apply-partially #'pcase--split-member elems) rest)) (then-rest (car splitrest)) (else-rest (cdr splitrest))) + (put sym 'pcase-used t) (pcase--if `(,(if memq-fine #'memq #'member) ,sym ',elems) (pcase--u1 matches code vars then-rest) (pcase--u else-rest))) ------------------------------------------------------------ revno: 108421 author: Troels Nielsen committer: Chong Yidong branch nick: trunk timestamp: Tue 2012-05-29 20:22:49 +0800 message: Fix active minibuffer case for window-deletable-p. * window.el (window-deletable-p): Avoid deleting the root window of a frame with an active minibuffer. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 12:21:45 +0000 +++ lisp/ChangeLog 2012-05-29 12:22:49 +0000 @@ -1,3 +1,8 @@ +2012-05-29 Troels Nielsen + + * window.el (window-deletable-p): Avoid deleting the root window + of a frame with an active minibuffer. + 2012-05-29 Martin Rudalics * simple.el (choose-completion): Use quit-window (Bug#11567). === modified file 'lisp/window.el' --- lisp/window.el 2012-05-04 23:16:47 +0000 +++ lisp/window.el 2012-05-29 12:22:49 +0000 @@ -2370,8 +2370,11 @@ (cond ((frame-root-window-p window) ;; WINDOW's frame can be deleted only if there are other frames - ;; on the same terminal. - (unless (eq frame (next-frame frame 0)) + ;; on the same terminal, and it does not contain the active + ;; minibuffer. + (unless (or (eq frame (next-frame frame 0)) + (let ((minibuf (active-minibuffer-window))) + (and minibuf (eq frame (window-frame minibuf))))) 'frame)) ((or ignore-window-parameters (not (eq (window-parameter window 'window-side) 'none)) ------------------------------------------------------------ revno: 108420 fixes bug(s): http://debbugs.gnu.org/11567 author: Martin Rudalics committer: Chong Yidong branch nick: trunk timestamp: Tue 2012-05-29 20:21:45 +0800 message: * lisp/simple.el (choose-completion): Use quit-window. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 11:51:19 +0000 +++ lisp/ChangeLog 2012-05-29 12:21:45 +0000 @@ -1,3 +1,7 @@ +2012-05-29 Martin Rudalics + + * simple.el (choose-completion): Use quit-window (Bug#11567). + 2012-05-29 Chong Yidong * whitespace.el (whitespace-cleanup): Fix usage of === modified file 'lisp/simple.el' --- lisp/simple.el 2012-05-29 09:09:38 +0000 +++ lisp/simple.el 2012-05-29 12:21:45 +0000 @@ -6203,16 +6203,7 @@ (unless (buffer-live-p buffer) (error "Destination buffer is dead")) - (select-window (posn-window (event-start event))) - (if (and (one-window-p t 'selected-frame) - (window-dedicated-p (selected-window))) - ;; This is a special buffer's frame - (iconify-frame (selected-frame)) - (or (window-dedicated-p (selected-window)) - (bury-buffer))) - (select-window - (or (get-buffer-window buffer 0) - owindow)) + (quit-window nil (posn-window (event-start event))) (with-current-buffer buffer (choose-completion-string ------------------------------------------------------------ revno: 108419 fixes bug(s): http://debbugs.gnu.org/11492 committer: Chong Yidong branch nick: trunk timestamp: Tue 2012-05-29 19:51:19 +0800 message: * whitespace.el (whitespace-cleanup): Fix whitespace-empty-at-bob-regexp usage. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 11:41:45 +0000 +++ lisp/ChangeLog 2012-05-29 11:51:19 +0000 @@ -1,3 +1,8 @@ +2012-05-29 Chong Yidong + + * whitespace.el (whitespace-cleanup): Fix usage of + whitespace-empty-at-bob-regexp (Bug#11492). + 2012-05-29 Aaron S. Hawley * vc/vc.el (vc-revert, vc-rollback): Dont kill vc-diff buffer on === modified file 'lisp/whitespace.el' --- lisp/whitespace.el 2012-01-19 07:21:25 +0000 +++ lisp/whitespace.el 2012-05-29 11:51:19 +0000 @@ -1533,8 +1533,7 @@ (when (memq 'empty whitespace-style) (let (overwrite-mode) ; enforce no overwrite (goto-char (point-min)) - (when (re-search-forward - (concat "\\`" whitespace-empty-at-bob-regexp) nil t) + (when (looking-at whitespace-empty-at-bob-regexp) (delete-region (match-beginning 1) (match-end 1))) (when (re-search-forward (concat whitespace-empty-at-eob-regexp "\\'") nil t) ------------------------------------------------------------ revno: 108418 fixes bug(s): http://debbugs.gnu.org/11488 author: Aaron S. Hawley committer: Chong Yidong branch nick: trunk timestamp: Tue 2012-05-29 19:41:45 +0800 message: * vc.el (vc-revert, vc-rollback): Dont kill vc-diff buffer on revert. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 09:46:06 +0000 +++ lisp/ChangeLog 2012-05-29 11:41:45 +0000 @@ -1,3 +1,8 @@ +2012-05-29 Aaron S. Hawley + + * vc/vc.el (vc-revert, vc-rollback): Dont kill vc-diff buffer on + revert (Bug#11488). + 2012-05-29 Juri Linkov * isearch.el (isearch-mode-map): Bind `M-s _' to === modified file 'lisp/vc/vc.el' --- lisp/vc/vc.el 2012-04-26 03:18:47 +0000 +++ lisp/vc/vc.el 2012-05-29 11:41:45 +0000 @@ -2285,7 +2285,7 @@ (if (= nfiles 1) "" "s")))))) (error "Revert canceled"))) (when diff-buffer - (quit-windows-on diff-buffer t))) + (quit-windows-on diff-buffer))) (dolist (file files) (message "Reverting %s..." (vc-delistify files)) (vc-revert-file file) @@ -2331,7 +2331,7 @@ ;; Display changes (unless (yes-or-no-p "Discard these revisions? ") (error "Rollback canceled")) - (quit-windows-on "*vc-diff*" t) + (quit-windows-on "*vc-diff*") ;; Do the actual reversions (message "Rolling back %s..." (vc-delistify files)) (with-vc-properties ------------------------------------------------------------ revno: 108417 fixes bug(s): http://debbugs.gnu.org/11381 committer: Juri Linkov branch nick: trunk timestamp: Tue 2012-05-29 12:46:06 +0300 message: * lisp/isearch.el (isearch-mode-map): Bind `M-s _' to `isearch-toggle-symbol'. Bind `M-s c' to `isearch-toggle-case-fold'. (search-map): Bind `M-s _' to `isearch-forward-symbol'. (isearch-forward): Add `M-s _' to the docstring. (isearch-forward-symbol, isearch-toggle-case-fold) (isearch-symbol-regexp): New functions. diff: === modified file 'etc/NEWS' --- etc/NEWS 2012-05-28 03:42:18 +0000 +++ etc/NEWS 2012-05-29 09:46:06 +0000 @@ -81,6 +81,12 @@ * Editing Changes in Emacs 24.2 +** Search changes + +*** Global `M-s _' starts a symbol (identifier) incremental search, +and `M-s _' in Isearch toggles symbol search mode. +`M-s c' in Isearch toggles search case-sensitivity. + ** M-x move-to-column, if called interactively with no prefix arg, now prompts for a column number. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 09:27:39 +0000 +++ lisp/ChangeLog 2012-05-29 09:46:06 +0000 @@ -1,5 +1,15 @@ 2012-05-29 Juri Linkov + * isearch.el (isearch-mode-map): Bind `M-s _' to + `isearch-toggle-symbol'. Bind `M-s c' to + `isearch-toggle-case-fold'. + (search-map): Bind `M-s _' to `isearch-forward-symbol'. + (isearch-forward): Add `M-s _' to the docstring. + (isearch-forward-symbol, isearch-toggle-case-fold) + (isearch-symbol-regexp): New functions. (Bug#11381) + +2012-05-29 Juri Linkov + * isearch.el (isearch-word): Add docstring. (Bug#11381) (isearch-occur, isearch-search-and-update): If `isearch-word' is a function, call it to get the regexp. === modified file 'lisp/isearch.el' --- lisp/isearch.el 2012-05-29 09:27:39 +0000 +++ lisp/isearch.el 2012-05-29 09:46:06 +0000 @@ -501,8 +501,10 @@ (define-key map "\M-r" 'isearch-toggle-regexp) (define-key map "\M-e" 'isearch-edit-string) + (define-key map "\M-sc" 'isearch-toggle-case-fold) (define-key map "\M-sr" 'isearch-toggle-regexp) (define-key map "\M-sw" 'isearch-toggle-word) + (define-key map "\M-s_" 'isearch-toggle-symbol) (define-key map [?\M-%] 'isearch-query-replace) (define-key map [?\C-\M-%] 'isearch-query-replace-regexp) @@ -531,11 +533,11 @@ (defvar isearch-forward nil) ; Searching in the forward direction. (defvar isearch-regexp nil) ; Searching for a regexp. (defvar isearch-word nil - "Regexp-based search mode for words. + "Regexp-based search mode for words/symbols. If t, do incremental search for a sequence of words, ignoring punctuation. -If the value is a function, it is called to convert the search string -to a regexp used by regexp search functions. The property -`isearch-message-prefix' put on this function specifies the +If the value is a function (e.g. `isearch-symbol-regexp'), it is called to +convert the search string to a regexp used by regexp search functions. +The property `isearch-message-prefix' put on this function specifies the prefix string displyed in the search message.") (defvar isearch-cmds nil @@ -622,6 +624,7 @@ (define-key global-map "\C-r" 'isearch-backward) (define-key esc-map "\C-r" 'isearch-backward-regexp) (define-key search-map "w" 'isearch-forward-word) +(define-key search-map "_" 'isearch-forward-symbol) ;; Entry points to isearch-mode. @@ -661,6 +664,7 @@ Type \\[isearch-toggle-case-fold] to toggle search case-sensitivity. Type \\[isearch-toggle-regexp] to toggle regular-expression mode. Type \\[isearch-toggle-word] to toggle word mode. +Type \\[isearch-toggle-symbol] to toggle symbol mode. Type \\[isearch-edit-string] to edit the search string in the minibuffer. Also supported is a search ring of the previous 16 search strings. @@ -728,6 +732,16 @@ (interactive "P\np") (isearch-mode t nil nil (not no-recursive-edit) (null not-word))) +(defun isearch-forward-symbol (&optional not-symbol no-recursive-edit) + "\ +Do incremental search forward for a symbol. +The prefix argument is currently unused. +Like ordinary incremental search except that your input is treated +as a symbol surrounded by symbol boundary constructs \\_< and \\_>. +See the command `isearch-forward' for more information." + (interactive "P\np") + (isearch-mode t nil nil (not no-recursive-edit) 'isearch-symbol-regexp)) + (defun isearch-backward (&optional regexp-p no-recursive-edit) "\ Do incremental search backward. @@ -1375,6 +1389,14 @@ (setq isearch-success t isearch-adjusted t) (isearch-update)) +(defun isearch-toggle-symbol () + "Toggle symbol searching on or off." + (interactive) + (setq isearch-word (unless (eq isearch-word 'isearch-symbol-regexp) + 'isearch-symbol-regexp)) + (setq isearch-success t isearch-adjusted t) + (isearch-update)) + (defun isearch-toggle-case-fold () "Toggle case folding in searching on or off." (interactive) @@ -1476,6 +1498,16 @@ (interactive "sWord search: ") (re-search-forward (word-search-regexp string t) bound noerror count)) +;; Symbol search + +(defun isearch-symbol-regexp (string &optional lax) + "Return a regexp which matches STRING as a symbol. +Creates a regexp where STRING is surrounded by symbol delimiters \\_< and \\_>. +If LAX is non-nil, the end of the string need not match a symbol boundary." + (concat "\\_<" (regexp-quote string) (unless lax "\\_>"))) + +(put 'isearch-symbol-regexp 'isearch-message-prefix "symbol ") + (defun isearch-query-replace (&optional delimited regexp-flag) "Start `query-replace' with string to replace from last search string. ------------------------------------------------------------ revno: 108416 fixes bug(s): http://debbugs.gnu.org/11381 committer: Juri Linkov branch nick: trunk timestamp: Tue 2012-05-29 12:27:39 +0300 message: * lisp/isearch.el (isearch-word): Add docstring. (isearch-occur, isearch-search-and-update): If `isearch-word' is a function, call it to get the regexp. (isearch-message-prefix): If `isearch-word' holds a symbol, use its property `isearch-message-prefix' instead of the string "word ". (isearch-search-fun-default): For the case of `isearch-word', return a lambda that calls re-search-forward/re-search-backward with a regexp returned by `word-search-regexp' or by the function in `isearch-word'. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 09:09:38 +0000 +++ lisp/ChangeLog 2012-05-29 09:27:39 +0000 @@ -1,5 +1,17 @@ 2012-05-29 Juri Linkov + * isearch.el (isearch-word): Add docstring. (Bug#11381) + (isearch-occur, isearch-search-and-update): If `isearch-word' is + a function, call it to get the regexp. + (isearch-message-prefix): If `isearch-word' holds a symbol, use its + property `isearch-message-prefix' instead of the string "word ". + (isearch-search-fun-default): For the case of `isearch-word', + return a lambda that calls re-search-forward/re-search-backward + with a regexp returned by `word-search-regexp' or by the function + in `isearch-word'. + +2012-05-29 Juri Linkov + * isearch.el (isearch-search-fun-default): New function. (isearch-search-fun): Move default part to the new function `isearch-search-fun-default'. === modified file 'lisp/isearch.el' --- lisp/isearch.el 2012-05-29 09:09:38 +0000 +++ lisp/isearch.el 2012-05-29 09:27:39 +0000 @@ -530,8 +530,13 @@ (defvar isearch-forward nil) ; Searching in the forward direction. (defvar isearch-regexp nil) ; Searching for a regexp. -(defvar isearch-word nil) ; Searching for words. -(defvar isearch-hidden nil) ; Non-nil if the string exists but is invisible. +(defvar isearch-word nil + "Regexp-based search mode for words. +If t, do incremental search for a sequence of words, ignoring punctuation. +If the value is a function, it is called to convert the search string +to a regexp used by regexp search functions. The property +`isearch-message-prefix' put on this function specifies the +prefix string displyed in the search message.") (defvar isearch-cmds nil "Stack of search status sets. @@ -592,6 +597,9 @@ ;; Accumulate here the overlays opened during searching. (defvar isearch-opened-overlays nil) +;; Non-nil if the string exists but is invisible. +(defvar isearch-hidden nil) + ;; The value of input-method-function when isearch is invoked. (defvar isearch-input-method-function nil) @@ -747,14 +755,14 @@ ;; "List of commands for which isearch-mode does not recursive-edit.") -(defun isearch-mode (forward &optional regexp op-fun recursive-edit word-p) +(defun isearch-mode (forward &optional regexp op-fun recursive-edit word) "Start Isearch minor mode. It is called by the function `isearch-forward' and other related functions." ;; Initialize global vars. (setq isearch-forward forward isearch-regexp regexp - isearch-word word-p + isearch-word word isearch-op-fun op-fun isearch-last-case-fold-search isearch-case-fold-search isearch-case-fold-search case-fold-search @@ -1534,6 +1542,8 @@ (interactive (let* ((perform-collect (consp current-prefix-arg)) (regexp (cond + ((functionp isearch-word) + (funcall isearch-word isearch-string)) (isearch-word (word-search-regexp isearch-string)) (isearch-regexp isearch-string) (t (regexp-quote isearch-string))))) @@ -1749,6 +1759,8 @@ (setq case-fold-search (isearch-no-upper-case-p isearch-string isearch-regexp))) (looking-at (cond + ((functionp isearch-word) + (funcall isearch-word isearch-string t)) (isearch-word (word-search-regexp isearch-string t)) (isearch-regexp isearch-string) (t (regexp-quote isearch-string))))) @@ -2329,7 +2341,11 @@ (< (point) isearch-opoint))) "over") (if isearch-wrapped "wrapped ") - (if isearch-word "word " "") + (if isearch-word + (or (and (symbolp isearch-word) + (get isearch-word 'isearch-message-prefix)) + "word ") + "") (if isearch-regexp "regexp " "") (if multi-isearch-next-buffer-current-function "multi " "") (or isearch-message-prefix-add "") @@ -2374,14 +2390,19 @@ "Return default functions to use for the search." (cond (isearch-word - ;; Use lax versions to not fail at the end of the word while - ;; the user adds and removes characters in the search string - ;; (or when using nonincremental word isearch) - (if (or isearch-nonincremental - (eq (length isearch-string) - (length (isearch-string-state (car isearch-cmds))))) - (if isearch-forward 'word-search-forward 'word-search-backward) - (if isearch-forward 'word-search-forward-lax 'word-search-backward-lax))) + (lambda (string &optional bound noerror count) + ;; Use lax versions to not fail at the end of the word while + ;; the user adds and removes characters in the search string + ;; (or when using nonincremental word isearch) + (let ((lax (not (or isearch-nonincremental + (eq (length isearch-string) + (length (isearch-string-state (car isearch-cmds)))))))) + (funcall + (if isearch-forward #'re-search-forward #'re-search-backward) + (if (functionp isearch-word) + (funcall isearch-word string lax) + (word-search-regexp string lax)) + bound noerror count)))) (isearch-regexp (if isearch-forward 're-search-forward 're-search-backward)) (t ------------------------------------------------------------ revno: 108415 fixes bug(s): http://debbugs.gnu.org/11381 committer: Juri Linkov branch nick: trunk timestamp: Tue 2012-05-29 12:09:38 +0300 message: * lisp/isearch.el (isearch-search-fun-default): New function. (isearch-search-fun): Move default part to the new function `isearch-search-fun-default'. (isearch-search-fun-function): Set the default value to `isearch-search-fun-default'. * lisp/comint.el (comint-history-isearch-end): Use `isearch-search-fun-default'. (comint-history-isearch-search): Use `isearch-search-fun-default' and remove spacial case for `isearch-word'. (comint-history-isearch-wrap): Remove spacial case for `isearch-word'. * lisp/hexl.el (hexl-isearch-search-function): Use `isearch-search-fun-default'. * lisp/info.el (Info-isearch-search): Use `isearch-search-fun-default'. Use `word-search-regexp' for `isearch-word'. * lisp/misearch.el (multi-isearch-search-fun): Use `isearch-search-fun-default'. * lisp/simple.el (minibuffer-history-isearch-search): Use `isearch-search-fun-default' and remove spacial case for `isearch-word'. (minibuffer-history-isearch-wrap): Remove spacial case for `isearch-word'. * lisp/textmodes/reftex-global.el (reftex-isearch-wrap-function): Remove spacial case for `isearch-word'. (reftex-isearch-isearch-search): Use `isearch-search-fun-default'. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-29 06:16:49 +0000 +++ lisp/ChangeLog 2012-05-29 09:09:38 +0000 @@ -1,3 +1,37 @@ +2012-05-29 Juri Linkov + + * isearch.el (isearch-search-fun-default): New function. + (isearch-search-fun): Move default part to the new function + `isearch-search-fun-default'. + (isearch-search-fun-function): Set the default value to + `isearch-search-fun-default'. (Bug#11381) + + * comint.el (comint-history-isearch-end): + Use `isearch-search-fun-default'. + (comint-history-isearch-search): Use `isearch-search-fun-default' + and remove spacial case for `isearch-word'. + (comint-history-isearch-wrap): Remove spacial case for + `isearch-word'. + + * hexl.el (hexl-isearch-search-function): + Use `isearch-search-fun-default'. + + * info.el (Info-isearch-search): Use `isearch-search-fun-default'. + Use `word-search-regexp' for `isearch-word'. + + * misearch.el (multi-isearch-search-fun): + Use `isearch-search-fun-default'. + + * simple.el (minibuffer-history-isearch-search): + Use `isearch-search-fun-default' and remove spacial case for + `isearch-word'. + (minibuffer-history-isearch-wrap): Remove spacial case for + `isearch-word'. + + * textmodes/reftex-global.el (reftex-isearch-wrap-function): + Remove spacial case for `isearch-word'. + (reftex-isearch-isearch-search): Use `isearch-search-fun-default'. + 2012-05-28 Agustín Martín Domingo Decrease XEmacs incompatibilities. === modified file 'lisp/comint.el' --- lisp/comint.el 2012-05-29 06:16:49 +0000 +++ lisp/comint.el 2012-05-29 09:09:38 +0000 @@ -1441,7 +1441,7 @@ (if comint-history-isearch-message-overlay (delete-overlay comint-history-isearch-message-overlay)) (setq isearch-message-prefix-add nil) - (setq isearch-search-fun-function nil) + (setq isearch-search-fun-function 'isearch-search-fun-default) (setq isearch-message-function nil) (setq isearch-wrap-function nil) (setq isearch-push-state-function nil) @@ -1463,67 +1463,59 @@ (defun comint-history-isearch-search () "Return the proper search function, for Isearch in input history." - (cond - (isearch-word - (if isearch-forward 'word-search-forward 'word-search-backward)) - (t - (lambda (string bound noerror) - (let ((search-fun - ;; Use standard functions to search within comint text - (cond - (isearch-regexp - (if isearch-forward 're-search-forward 're-search-backward)) - (t - (if isearch-forward 'search-forward 'search-backward)))) - found) - ;; Avoid lazy-highlighting matches in the comint prompt and in the - ;; output when searching forward. Lazy-highlight calls this lambda - ;; with the bound arg, so skip the prompt and the output. - (if (and bound isearch-forward (not (comint-after-pmark-p))) - (goto-char (process-mark (get-buffer-process (current-buffer))))) - (or - ;; 1. First try searching in the initial comint text - (funcall search-fun string - (if isearch-forward bound (comint-line-beginning-position)) - noerror) - ;; 2. If the above search fails, start putting next/prev history - ;; elements in the comint successively, and search the string - ;; in them. Do this only when bound is nil (i.e. not while - ;; lazy-highlighting search strings in the current comint text). - (unless bound - (condition-case nil - (progn - (while (not found) - (cond (isearch-forward - ;; Signal an error here explicitly, because - ;; `comint-next-input' doesn't signal an error. - (when (null comint-input-ring-index) - (error "End of history; no next item")) - (comint-next-input 1) - (goto-char (comint-line-beginning-position))) - (t - ;; Signal an error here explicitly, because - ;; `comint-previous-input' doesn't signal an error. - (when (eq comint-input-ring-index - (1- (ring-length comint-input-ring))) - (error "Beginning of history; no preceding item")) - (comint-previous-input 1) - (goto-char (point-max)))) - (setq isearch-barrier (point) isearch-opoint (point)) - ;; After putting the next/prev history element, search - ;; the string in them again, until comint-next-input - ;; or comint-previous-input raises an error at the - ;; beginning/end of history. - (setq found (funcall search-fun string - (unless isearch-forward - ;; For backward search, don't search - ;; in the comint prompt - (comint-line-beginning-position)) - noerror))) - ;; Return point of the new search result - (point)) - ;; Return nil on the error "no next/preceding item" - (error nil))))))))) + (lambda (string bound noerror) + (let ((search-fun + ;; Use standard functions to search within comint text + (isearch-search-fun-default)) + found) + ;; Avoid lazy-highlighting matches in the comint prompt and in the + ;; output when searching forward. Lazy-highlight calls this lambda + ;; with the bound arg, so skip the prompt and the output. + (if (and bound isearch-forward (not (comint-after-pmark-p))) + (goto-char (process-mark (get-buffer-process (current-buffer))))) + (or + ;; 1. First try searching in the initial comint text + (funcall search-fun string + (if isearch-forward bound (comint-line-beginning-position)) + noerror) + ;; 2. If the above search fails, start putting next/prev history + ;; elements in the comint successively, and search the string + ;; in them. Do this only when bound is nil (i.e. not while + ;; lazy-highlighting search strings in the current comint text). + (unless bound + (condition-case nil + (progn + (while (not found) + (cond (isearch-forward + ;; Signal an error here explicitly, because + ;; `comint-next-input' doesn't signal an error. + (when (null comint-input-ring-index) + (error "End of history; no next item")) + (comint-next-input 1) + (goto-char (comint-line-beginning-position))) + (t + ;; Signal an error here explicitly, because + ;; `comint-previous-input' doesn't signal an error. + (when (eq comint-input-ring-index + (1- (ring-length comint-input-ring))) + (error "Beginning of history; no preceding item")) + (comint-previous-input 1) + (goto-char (point-max)))) + (setq isearch-barrier (point) isearch-opoint (point)) + ;; After putting the next/prev history element, search + ;; the string in them again, until comint-next-input + ;; or comint-previous-input raises an error at the + ;; beginning/end of history. + (setq found (funcall search-fun string + (unless isearch-forward + ;; For backward search, don't search + ;; in the comint prompt + (comint-line-beginning-position)) + noerror))) + ;; Return point of the new search result + (point)) + ;; Return nil on the error "no next/preceding item" + (error nil))))))) (defun comint-history-isearch-message (&optional c-q-hack ellipsis) "Display the input history search prompt. @@ -1556,14 +1548,13 @@ "Wrap the input history search when search fails. Move point to the first history element for a forward search, or to the last history element for a backward search." - (unless isearch-word - ;; When `comint-history-isearch-search' fails on reaching the - ;; beginning/end of the history, wrap the search to the first/last - ;; input history element. - (if isearch-forward - (comint-goto-input (1- (ring-length comint-input-ring))) - (comint-goto-input nil)) - (setq isearch-success t)) + ;; When `comint-history-isearch-search' fails on reaching the + ;; beginning/end of the history, wrap the search to the first/last + ;; input history element. + (if isearch-forward + (comint-goto-input (1- (ring-length comint-input-ring))) + (comint-goto-input nil)) + (setq isearch-success t) (goto-char (if isearch-forward (comint-line-beginning-position) (point-max)))) (defun comint-history-isearch-push-state () === modified file 'lisp/hexl.el' --- lisp/hexl.el 2012-04-14 05:10:55 +0000 +++ lisp/hexl.el 2012-05-29 09:09:38 +0000 @@ -420,8 +420,7 @@ " \\(?: .+\n[a-f0-9]+: \\)?")) textre)) bound noerror count)) - (let ((isearch-search-fun-function nil)) - (isearch-search-fun)))) + (isearch-search-fun-default))) (defvar hexl-in-save-buffer nil) === modified file 'lisp/info.el' --- lisp/info.el 2012-05-26 21:23:28 +0000 +++ lisp/info.el 2012-05-29 09:09:38 +0000 @@ -1925,26 +1925,23 @@ (defun Info-isearch-search () (if Info-isearch-search (lambda (string &optional bound noerror count) - (if isearch-word - (Info-search (concat "\\b" (replace-regexp-in-string - "\\W+" "\\W+" - (replace-regexp-in-string - "^\\W+\\|\\W+$" "" string) - nil t) - ;; Lax version of word search - (if (or isearch-nonincremental - (eq (length string) - (length (isearch-string-state - (car isearch-cmds))))) - "\\b")) - bound noerror count - (unless isearch-forward 'backward)) - (Info-search (if isearch-regexp string (regexp-quote string)) - bound noerror count - (unless isearch-forward 'backward))) + (Info-search + (cond + (isearch-word + ;; Lax version of word search + (let ((lax (not (or isearch-nonincremental + (eq (length string) + (length (isearch-string-state + (car isearch-cmds)))))))) + (if (functionp isearch-word) + (funcall isearch-word string lax) + (word-search-regexp string lax)))) + (isearch-regexp string) + (t (regexp-quote string))) + bound noerror count + (unless isearch-forward 'backward)) (point)) - (let ((isearch-search-fun-function nil)) - (isearch-search-fun)))) + (isearch-search-fun-default))) (defun Info-isearch-wrap () (if Info-isearch-search === modified file 'lisp/isearch.el' --- lisp/isearch.el 2012-05-17 00:03:49 +0000 +++ lisp/isearch.el 2012-05-29 09:09:38 +0000 @@ -2356,8 +2356,8 @@ ;; Searching -(defvar isearch-search-fun-function nil - "Overrides the default `isearch-search-fun' behavior. +(defvar isearch-search-fun-function 'isearch-search-fun-default + "Non-default value overrides the behavior of `isearch-search-fun-default'. This variable's value should be a function, which will be called with no arguments, and should return a function that takes three arguments: STRING, BOUND, and NOERROR. @@ -2368,22 +2368,24 @@ (defun isearch-search-fun () "Return the function to use for the search. Can be changed via `isearch-search-fun-function' for special needs." - (if isearch-search-fun-function - (funcall isearch-search-fun-function) - (cond - (isearch-word - ;; Use lax versions to not fail at the end of the word while - ;; the user adds and removes characters in the search string - ;; (or when using nonincremental word isearch) - (if (or isearch-nonincremental - (eq (length isearch-string) - (length (isearch-string-state (car isearch-cmds))))) - (if isearch-forward 'word-search-forward 'word-search-backward) - (if isearch-forward 'word-search-forward-lax 'word-search-backward-lax))) - (isearch-regexp - (if isearch-forward 're-search-forward 're-search-backward)) - (t - (if isearch-forward 'search-forward 'search-backward))))) + (funcall (or isearch-search-fun-function 'isearch-search-fun-default))) + +(defun isearch-search-fun-default () + "Return default functions to use for the search." + (cond + (isearch-word + ;; Use lax versions to not fail at the end of the word while + ;; the user adds and removes characters in the search string + ;; (or when using nonincremental word isearch) + (if (or isearch-nonincremental + (eq (length isearch-string) + (length (isearch-string-state (car isearch-cmds))))) + (if isearch-forward 'word-search-forward 'word-search-backward) + (if isearch-forward 'word-search-forward-lax 'word-search-backward-lax))) + (isearch-regexp + (if isearch-forward 're-search-forward 're-search-backward)) + (t + (if isearch-forward 'search-forward 'search-backward)))) (defun isearch-search-string (string bound noerror) "Search for the first occurrence of STRING or its translation. === modified file 'lisp/misearch.el' --- lisp/misearch.el 2012-01-19 07:21:25 +0000 +++ lisp/misearch.el 2012-05-29 09:09:38 +0000 @@ -130,13 +130,7 @@ (lambda (string bound noerror) (let ((search-fun ;; Use standard functions to search within one buffer - (cond - (isearch-word - (if isearch-forward 'word-search-forward 'word-search-backward)) - (isearch-regexp - (if isearch-forward 're-search-forward 're-search-backward)) - (t - (if isearch-forward 'search-forward 'search-backward)))) + (isearch-search-fun-default)) found buffer) (or ;; 1. First try searching in the initial buffer === modified file 'lisp/simple.el' --- lisp/simple.el 2012-05-04 23:16:47 +0000 +++ lisp/simple.el 2012-05-29 09:09:38 +0000 @@ -1699,58 +1699,50 @@ (defun minibuffer-history-isearch-search () "Return the proper search function, for isearch in minibuffer history." - (cond - (isearch-word - (if isearch-forward 'word-search-forward 'word-search-backward)) - (t - (lambda (string bound noerror) - (let ((search-fun - ;; Use standard functions to search within minibuffer text - (cond - (isearch-regexp - (if isearch-forward 're-search-forward 're-search-backward)) - (t - (if isearch-forward 'search-forward 'search-backward)))) - found) - ;; Avoid lazy-highlighting matches in the minibuffer prompt when - ;; searching forward. Lazy-highlight calls this lambda with the - ;; bound arg, so skip the minibuffer prompt. - (if (and bound isearch-forward (< (point) (minibuffer-prompt-end))) - (goto-char (minibuffer-prompt-end))) - (or - ;; 1. First try searching in the initial minibuffer text - (funcall search-fun string - (if isearch-forward bound (minibuffer-prompt-end)) - noerror) - ;; 2. If the above search fails, start putting next/prev history - ;; elements in the minibuffer successively, and search the string - ;; in them. Do this only when bound is nil (i.e. not while - ;; lazy-highlighting search strings in the current minibuffer text). - (unless bound - (condition-case nil - (progn - (while (not found) - (cond (isearch-forward - (next-history-element 1) - (goto-char (minibuffer-prompt-end))) - (t - (previous-history-element 1) - (goto-char (point-max)))) - (setq isearch-barrier (point) isearch-opoint (point)) - ;; After putting the next/prev history element, search - ;; the string in them again, until next-history-element - ;; or previous-history-element raises an error at the - ;; beginning/end of history. - (setq found (funcall search-fun string - (unless isearch-forward - ;; For backward search, don't search - ;; in the minibuffer prompt - (minibuffer-prompt-end)) - noerror))) - ;; Return point of the new search result - (point)) - ;; Return nil when next(prev)-history-element fails - (error nil))))))))) + (lambda (string bound noerror) + (let ((search-fun + ;; Use standard functions to search within minibuffer text + (isearch-search-fun-default)) + found) + ;; Avoid lazy-highlighting matches in the minibuffer prompt when + ;; searching forward. Lazy-highlight calls this lambda with the + ;; bound arg, so skip the minibuffer prompt. + (if (and bound isearch-forward (< (point) (minibuffer-prompt-end))) + (goto-char (minibuffer-prompt-end))) + (or + ;; 1. First try searching in the initial minibuffer text + (funcall search-fun string + (if isearch-forward bound (minibuffer-prompt-end)) + noerror) + ;; 2. If the above search fails, start putting next/prev history + ;; elements in the minibuffer successively, and search the string + ;; in them. Do this only when bound is nil (i.e. not while + ;; lazy-highlighting search strings in the current minibuffer text). + (unless bound + (condition-case nil + (progn + (while (not found) + (cond (isearch-forward + (next-history-element 1) + (goto-char (minibuffer-prompt-end))) + (t + (previous-history-element 1) + (goto-char (point-max)))) + (setq isearch-barrier (point) isearch-opoint (point)) + ;; After putting the next/prev history element, search + ;; the string in them again, until next-history-element + ;; or previous-history-element raises an error at the + ;; beginning/end of history. + (setq found (funcall search-fun string + (unless isearch-forward + ;; For backward search, don't search + ;; in the minibuffer prompt + (minibuffer-prompt-end)) + noerror))) + ;; Return point of the new search result + (point)) + ;; Return nil when next(prev)-history-element fails + (error nil))))))) (defun minibuffer-history-isearch-message (&optional c-q-hack ellipsis) "Display the minibuffer history search prompt. @@ -1781,14 +1773,13 @@ "Wrap the minibuffer history search when search fails. Move point to the first history element for a forward search, or to the last history element for a backward search." - (unless isearch-word - ;; When `minibuffer-history-isearch-search' fails on reaching the - ;; beginning/end of the history, wrap the search to the first/last - ;; minibuffer history element. - (if isearch-forward - (goto-history-element (length (symbol-value minibuffer-history-variable))) - (goto-history-element 0)) - (setq isearch-success t)) + ;; When `minibuffer-history-isearch-search' fails on reaching the + ;; beginning/end of the history, wrap the search to the first/last + ;; minibuffer history element. + (if isearch-forward + (goto-history-element (length (symbol-value minibuffer-history-variable))) + (goto-history-element 0)) + (setq isearch-success t) (goto-char (if isearch-forward (minibuffer-prompt-end) (point-max)))) (defun minibuffer-history-isearch-push-state () === modified file 'lisp/textmodes/reftex-global.el' --- lisp/textmodes/reftex-global.el 2012-01-19 07:21:25 +0000 +++ lisp/textmodes/reftex-global.el 2012-05-29 09:09:38 +0000 @@ -350,9 +350,8 @@ ;; variable `multi-isearch-next-buffer-function'. (defun reftex-isearch-wrap-function () - (if (not isearch-word) - (switch-to-buffer - (funcall isearch-next-buffer-function (current-buffer) t))) + (switch-to-buffer + (funcall isearch-next-buffer-function (current-buffer) t)) (goto-char (if isearch-forward (point-min) (point-max)))) (defun reftex-isearch-push-state-function () @@ -364,14 +363,7 @@ (defun reftex-isearch-isearch-search (string bound noerror) (let ((nxt-buff nil) - (search-fun - (cond - (isearch-word - (if isearch-forward 'word-search-forward 'word-search-backward)) - (isearch-regexp - (if isearch-forward 're-search-forward 're-search-backward)) - (t - (if isearch-forward 'search-forward 'search-backward))))) + (search-fun (isearch-search-fun-default))) (or (funcall search-fun string bound noerror) (unless bound ------------------------------------------------------------ revno: 108414 committer: Paul Eggert branch nick: trunk timestamp: Mon 2012-05-28 23:16:49 -0700 message: Spelling fixes. diff: === modified file 'etc/ORG-NEWS' --- etc/ORG-NEWS 2012-04-27 02:15:51 +0000 +++ etc/ORG-NEWS 2012-05-29 06:16:49 +0000 @@ -20,7 +20,7 @@ :PROPERTIES: :OrgVersion: 7.4 :END: - + The variable =org-agenda-ndays= is obsolete - please use =org-agenda-span= instead. @@ -313,7 +313,7 @@ :OrgVersion: 7.5 :END: - You can now create links from messages. This is particularily + You can now create links from messages. This is particularly useful when the user wants to stored messages that he sends, for later check. Thanks to Ulf Stegemann for the patch. @@ -328,7 +328,7 @@ : Percent escaping is used in Org mode to escape certain characters : in links that would either break the parser (e.g. square brackets -: in link target oder description) or are not allowed to appear in +: in link target or description) or are not allowed to appear in : a particular link type (e.g. non-ascii characters in a http: : link). : === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-05-28 16:11:15 +0000 +++ lisp/ChangeLog 2012-05-29 06:16:49 +0000 @@ -906,7 +906,7 @@ 2012-05-03 Kenichi Handa * mail/rmailmm.el (rmail-show-mime): Catch an error caused by text - decoding, and show a warning message without signalling an error + decoding, and show a warning message without signaling an error (Bug#11282). 2012-05-03 Stefan Monnier === modified file 'lisp/ChangeLog.15' --- lisp/ChangeLog.15 2012-03-21 18:27:05 +0000 +++ lisp/ChangeLog.15 2012-05-29 06:16:49 +0000 @@ -9023,7 +9023,7 @@ * bookmark.el (bookmark-show-annotation): Use `when' instead of `if'. This is also from Thierry Volpiatto's patch in bug #6444. However, because it was extraneous to the functional change in that patch, - and causes a re-indendation, I am committing it separately. + and causes a re-indentation, I am committing it separately. 2010-07-13 Thierry Volpiatto === modified file 'lisp/ChangeLog.9' --- lisp/ChangeLog.9 2012-02-24 19:32:46 +0000 +++ lisp/ChangeLog.9 2012-05-29 06:16:49 +0000 @@ -17245,7 +17245,7 @@ (antlr-downcase-literals): New command. (antlr-upcase-literals): Ditto. - * antlr-mode.el: Minor changes: indendation, mode-name. + * antlr-mode.el: Minor changes: indentation, mode-name. (antlr-indent-line): Indent cpp directive at column 0. (antlr-mode): Use mode-name prefix "Antlr." instead of "Antlr/". === modified file 'lisp/comint.el' --- lisp/comint.el 2012-05-15 16:58:35 +0000 +++ lisp/comint.el 2012-05-29 06:16:49 +0000 @@ -2969,7 +2969,7 @@ Word constituents are considered to be those in WORD-CHARS, which is like the inside of a \"[...]\" (see `skip-chars-forward'), plus all non-ASCII characters." ;; FIXME: Need to handle "..." and '...' quoting in shell.el! - ;; This should be combined with pomplete-parsing somehow. + ;; This should be combined with completion parsing somehow. (save-excursion (let ((here (point)) giveup) === modified file 'lisp/gnus/ChangeLog.1' --- lisp/gnus/ChangeLog.1 2012-01-19 07:21:25 +0000 +++ lisp/gnus/ChangeLog.1 2012-05-29 06:16:49 +0000 @@ -2966,7 +2966,7 @@ 1997-11-25 Lars Magne Ingebrigtsen - * gnus-move.el (gnus-move-group-to-server): Protect agains + * gnus-move.el (gnus-move-group-to-server): Protect against nil-ness. 1997-11-25 Lars Magne Ingebrigtsen === modified file 'lisp/gnus/gnus-win.el' --- lisp/gnus/gnus-win.el 2012-05-25 14:58:17 +0000 +++ lisp/gnus/gnus-win.el 2012-05-29 06:16:49 +0000 @@ -275,7 +275,7 @@ (set-buffer buf)) ((eq t (window-dedicated-p)) ;; If the window is hard-dedicated, we have a problem because - ;; we just can't do what we're asked. But signalling an error, + ;; we just can't do what we're asked. But signaling an error, ;; like `switch-to-buffer' would do, is not an option because ;; it would prevent things like "^" (to jump to the *Servers*) ;; in a dedicated *Group*. === modified file 'lisp/image-mode.el' --- lisp/image-mode.el 2012-05-14 05:19:46 +0000 +++ lisp/image-mode.el 2012-05-29 06:16:49 +0000 @@ -663,7 +663,7 @@ ;; The following comment and code snippet are from ;; ImageMagick-6.7.4-4/magick/distort.c -;; /* Set the output image geometry to calculated 'bestfit'. +;; /* Set the output image geometry to calculated 'best fit'. ;; Yes this tends to 'over do' the file image size, ON PURPOSE! ;; Do not do this for DePolar which needs to be exact for virtual tiling. ;; */ === modified file 'lisp/net/soap-client.el' --- lisp/net/soap-client.el 2012-04-25 10:28:29 +0000 +++ lisp/net/soap-client.el 2012-05-29 06:16:49 +0000 @@ -1569,7 +1569,7 @@ (defun soap-encode-simple-type (xml-tag value type) "Encode inside XML-TAG the LISP VALUE according to TYPE." - ;; Validate VALUE agains the simple type's enumeration, than just encode it + ;; Validate VALUE against the simple type's enumeration, than just encode it ;; using `soap-encode-basic-type' (let ((enumeration (soap-simple-type-enumeration type))) === modified file 'lisp/net/soap-inspect.el' --- lisp/net/soap-inspect.el 2012-04-25 10:28:29 +0000 +++ lisp/net/soap-inspect.el 2012-05-29 06:16:49 +0000 @@ -67,7 +67,7 @@ (t (format "%s" (soap-basic-type-kind type))))) (defun soap-sample-value-for-simple-type (type) - "Provive a sample value for TYPE which is a simple type. + "Provide a sample value for TYPE which is a simple type. This is a specific function which should not be called directly, use `soap-sample-value' instead." (let ((enumeration (soap-simple-type-enumeration type))) === modified file 'lisp/org/org-agenda.el' --- lisp/org/org-agenda.el 2012-05-16 17:33:50 +0000 +++ lisp/org/org-agenda.el 2012-05-29 06:16:49 +0000 @@ -799,7 +799,7 @@ :group 'org-agenda-daily/weekly :version "24.1" :type '(choice - (const :tag "Alwas show prewarning" nil) + (const :tag "Always show prewarning" nil) (const :tag "Remove prewarning if entry is scheduled" t) (integer :tag "Restart prewarning N days before deadline"))) === modified file 'lisp/org/org-remember.el' --- lisp/org/org-remember.el 2012-01-19 07:21:25 +0000 +++ lisp/org/org-remember.el 2012-05-29 06:16:49 +0000 @@ -64,7 +64,7 @@ \\[universal-argument] \\[org-remember-finalize] to file the note. When this variable is nil, \\[org-remember-finalize] gives you the prompts, and -\\[universal-argument] \\[org-remember-finalize] triggers the fasttrack." +\\[universal-argument] \\[org-remember-finalize] triggers the fast track." :group 'org-remember :type 'boolean) === modified file 'lisp/org/org.el' --- lisp/org/org.el 2012-05-25 21:09:08 +0000 +++ lisp/org/org.el 2012-05-29 06:16:49 +0000 @@ -3031,7 +3031,7 @@ (const :tag "List them, indented with leading dots" indented))) (defcustom org-tags-sort-function nil - "When set, tags are sorted using this function as a comparator." + "When set, tags are sorted using this comparison function." :group 'org-tags :type '(choice (const :tag "No sorting" nil) === modified file 'lisp/progmodes/verilog-mode.el' --- lisp/progmodes/verilog-mode.el 2012-05-03 19:23:55 +0000 +++ lisp/progmodes/verilog-mode.el 2012-05-29 06:16:49 +0000 @@ -12105,7 +12105,7 @@ "Expand AUTOUNDEF statements, as part of \\[verilog-auto]. Take any `defines since the last AUTOUNDEF in the current file and create `undefs for them. This is used to insure that -file-local defines do not polute the global `define name space. +file-local defines do not pollute the global `define name space. Limitations: AUTOUNDEF presumes any identifier following `define is the @@ -12145,7 +12145,7 @@ (end-pt (point)) defs def) (save-excursion - ;; Scan from beginnng of file, or last AUTOUNDEF + ;; Scan from start of file, or last AUTOUNDEF (or (verilog-re-search-backward-quick "/\\*AUTOUNDEF\\>" end-pt t) (goto-char (point-min))) (while (verilog-re-search-forward-quick === modified file 'lisp/textmodes/rst.el' --- lisp/textmodes/rst.el 2012-05-14 09:31:08 +0000 +++ lisp/textmodes/rst.el 2012-05-29 06:16:49 +0000 @@ -446,7 +446,7 @@ which is shy-grouped (\"\\(?:...\\)\"). For the keyword `:grp' the results are concatenated and form a -referencable grouped (\"\\(...\\)\"). +referenceable grouped (\"\\(...\\)\"). After interpretation of ARGS the results are concatenated as for `:seq'. @@ -1066,11 +1066,11 @@ (beg-pnt (progn (forward-line 0) (point))) - (nxt-emp ; Next line inexistant or empty + (nxt-emp ; Next line nonexistent or empty (save-excursion (or (not (zerop (forward-line 1))) (looking-at (rst-re 'lin-end))))) - (prv-emp ; Previous line inexistant or empty + (prv-emp ; Previous line nonexistent or empty (save-excursion (or (not (zerop (forward-line -1))) (looking-at (rst-re 'lin-end))))) @@ -1917,7 +1917,7 @@ "Insert a new list item. User is asked to select the item style first, for example (a), i), +. Use TAB -for completition and choices. +for completion and choices. If user selects bullets or #, it's just added with position arranged by `rst-insert-list-pos'. @@ -2020,7 +2020,7 @@ 1. When inserting a new list: User is asked to select the item style first, for example (a), i), +. Use TAB -for completition and choices. +for completion and choices. (a) If user selects bullets or #, it's just added. (b) If user selects enumerations, a further prompt is given. User needs to @@ -2754,11 +2754,11 @@ ;; supported; comment lines with leading comment markup should be also ;; supported; may be a customizable option could control which style to prefer -(defgroup rst-indent nil "Settings for indendation in reStructuredText. +(defgroup rst-indent nil "Settings for indentation in reStructuredText. -In reStructuredText indendation points are usually determined by +In reStructuredText indentation points are usually determined by preceding lines. Sometimes the syntax allows arbitrary -indendation points such as where to start the first line +indentation points such as where to start the first line following a directive. These indentation widths can be customized here." :group 'rst @@ -2772,25 +2772,25 @@ :type '(integer)) (defcustom rst-indent-field 3 - "Default indendation for first line after a field or 0 to always indent for + "Default indentation for first line after a field or 0 to always indent for content." :group 'rst-indent :type '(integer)) (defcustom rst-indent-literal-normal 3 - "Default indendation for literal block after a markup on an own + "Default indentation for literal block after a markup on an own line." :group 'rst-indent :type '(integer)) (defcustom rst-indent-literal-minimized 2 - "Default indendation for literal block after a minimized + "Default indentation for literal block after a minimized markup." :group 'rst-indent :type '(integer)) (defcustom rst-indent-comment 3 - "Default indendation for first line of a comment." + "Default indentation for first line of a comment." :group 'rst-indent :type '(integer)) @@ -2810,7 +2810,7 @@ (save-match-data (unless (looking-at (rst-re 'lin-end)) (back-to-indentation) - ;; Current indendation is always the least likely tab + ;; Current indentation is always the least likely tab (let ((tabs (list (list (point) 0 nil)))) ; (POINT OFFSET INNER) ;; Push inner tabs more likely to continue writing (cond @@ -2863,7 +2863,7 @@ Search backwards from point PT to build the list of possible tabs. Return a list of tabs sorted by likeliness to continue writing like `rst-line-tabs'. Nearer lines have generally a -higher likeliness than farer lines. Return nil if no tab is found +higher likeliness than farther lines. Return nil if no tab is found in the text above." (save-excursion (goto-char pt) @@ -3452,7 +3452,7 @@ 1 rst-definition-face) ;; `Hyperlink References`_ ;; FIXME: `Embedded URIs`_ not considered - ;; FIXME: Directly adjacing marked up words are not fontified correctly + ;; FIXME: Directly adjacent marked up words are not fontified correctly ;; unless they are not separated by two spaces: foo_ bar_ (,(rst-re 'ilm-pfx '(:grp (:alt (:seq "`" ilcbkq-tag "`") (:seq "\\sw" (:alt "\\sw" "-") "+\\sw")) @@ -3610,7 +3610,7 @@ ;; ;; * literal blocks following "::" ;; - ;; which are both indented. Thus indendation is the first thing recognized + ;; which are both indented. Thus indentation is the first thing recognized ;; here. The second criteria is an explicit markup tag which may be a comment ;; or a double colon at the end of a line. ;; @@ -3697,7 +3697,7 @@ `rst-font-lock-find-unindented-line-match'.") (defun rst-font-lock-find-unindented-line-limit (ind-pnt) - "Find the next unindented line relative to indenation at IND-PNT. + "Find the next unindented line relative to indentation at IND-PNT. Return this point, the end of the buffer or nil if nothing found. If IND-PNT is `next' take the indentation from the next line if this is not empty and indented more than the current one. If