------------------------------------------------------------ revno: 114622 committer: Paul Eggert branch nick: trunk timestamp: Thu 2013-10-10 23:32:29 -0700 message: * lisp.h (eassume): New macro. Also, include , for 'assume'. * alloc.c (bool_vector_payload_bytes, Fmake_bool_vector) (vroundup, vector_nbytes): * data.c (bool_vector_spare_mask, bool_vector_binop_driver) (Fbool_vector_not, Fbool_vector_count_matches) (Fbool_vector_count_matches_at): Use eassume, not eassert. * casetab.c (set_identity, shuffle): * composite.c (composition_gstring_put_cache): * dispnew.c (update_frame_1): * ftfont.c (ftfont_shape_by_flt): * image.c (gif_load): * intervals.c (offset_intervals): * macfont.m (macfont_shape): Remove calls to 'assume' that are no longer needed, because --enable-gcc-warnings no longer generates bogus warnings when these calls are removed. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-10-11 03:55:26 +0000 +++ src/ChangeLog 2013-10-11 06:32:29 +0000 @@ -1,3 +1,24 @@ +2013-10-11 Paul Eggert + + * lisp.h (eassume): New macro. + Also, include , for 'assume'. + * alloc.c (bool_vector_payload_bytes, Fmake_bool_vector) + (vroundup, vector_nbytes): + * data.c (bool_vector_spare_mask, bool_vector_binop_driver) + (Fbool_vector_not, Fbool_vector_count_matches) + (Fbool_vector_count_matches_at): + Use eassume, not eassert. + * casetab.c (set_identity, shuffle): + * composite.c (composition_gstring_put_cache): + * dispnew.c (update_frame_1): + * ftfont.c (ftfont_shape_by_flt): + * image.c (gif_load): + * intervals.c (offset_intervals): + * macfont.m (macfont_shape): + Remove calls to 'assume' that are no longer needed, because + --enable-gcc-warnings no longer generates bogus warnings + when these calls are removed. + 2013-10-11 Dmitry Antipov * xdisp.c (deep_copy_glyph_row): Remove unused locals. === modified file 'src/alloc.c' --- src/alloc.c 2013-10-08 17:49:20 +0000 +++ src/alloc.c 2013-10-11 06:32:29 +0000 @@ -2027,7 +2027,7 @@ ptrdiff_t exact_needed_bytes; ptrdiff_t needed_bytes; - eassert (nr_bits >= 0); + eassume (nr_bits >= 0); exact_needed_bytes = ROUNDUP ((size_t) nr_bits, CHAR_BIT) / CHAR_BIT; needed_bytes = ROUNDUP ((size_t) nr_bits, BITS_PER_BITS_WORD) / CHAR_BIT; @@ -2064,8 +2064,8 @@ total_payload_bytes = bool_vector_payload_bytes (XFASTINT (length), &exact_payload_bytes); - eassert (exact_payload_bytes <= total_payload_bytes); - eassert (0 <= exact_payload_bytes); + eassume (exact_payload_bytes <= total_payload_bytes); + eassume (0 <= exact_payload_bytes); needed_elements = ROUNDUP ((size_t) ((bool_header_size - header_size) + total_payload_bytes), @@ -2622,7 +2622,7 @@ /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */ #define vroundup_ct(x) ROUNDUP ((size_t) (x), roundup_size) /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at runtime. */ -#define vroundup(x) (assume ((x) >= 0), vroundup_ct (x)) +#define vroundup(x) (eassume ((x) >= 0), vroundup_ct (x)) /* Rounding helps to maintain alignment constraints if USE_LSB_TAG. */ @@ -2820,7 +2820,7 @@ ptrdiff_t payload_bytes = bool_vector_payload_bytes (bv->size, NULL); - eassert (payload_bytes >= 0); + eassume (payload_bytes >= 0); size = bool_header_size + ROUNDUP (payload_bytes, word_size); } else === modified file 'src/casetab.c' --- src/casetab.c 2013-09-22 09:31:55 +0000 +++ src/casetab.c 2013-10-11 06:32:29 +0000 @@ -205,7 +205,6 @@ from = to = XINT (c); to++; - assume (to <= MAX_CHAR + 1); for (; from < to; from++) CHAR_TABLE_SET (table, from, make_number (from)); } @@ -232,7 +231,6 @@ from = to = XINT (c); to++; - assume (to <= MAX_CHAR + 1); for (; from < to; from++) { Lisp_Object tem = Faref (table, elt); === modified file 'src/composite.c' --- src/composite.c 2013-09-24 06:43:20 +0000 +++ src/composite.c 2013-10-11 06:32:29 +0000 @@ -674,7 +674,6 @@ len = j; } - assume (len <= TYPE_MAXIMUM (ptrdiff_t) - 2); copy = Fmake_vector (make_number (len + 2), Qnil); LGSTRING_SET_HEADER (copy, Fcopy_sequence (header)); for (i = 0; i < len; i++) === modified file 'src/data.c' --- src/data.c 2013-10-08 04:25:33 +0000 +++ src/data.c 2013-10-11 06:32:29 +0000 @@ -2969,7 +2969,7 @@ static bits_word bool_vector_spare_mask (ptrdiff_t nr_bits) { - eassert (nr_bits > 0); + eassume (nr_bits > 0); return (((bits_word) 1) << (nr_bits % BITS_PER_BITS_WORD)) - 1; } @@ -3019,7 +3019,7 @@ nr_bits = min (nr_bits, XBOOL_VECTOR (dest)->size); } - eassert (nr_bits >= 0); + eassume (nr_bits >= 0); nr_words = ROUNDUP (nr_bits, BITS_PER_BITS_WORD) / BITS_PER_BITS_WORD; adata = (bits_word *) XBOOL_VECTOR (dest)->data; @@ -3185,7 +3185,7 @@ bdata = (bits_word *) XBOOL_VECTOR (b)->data; adata = (bits_word *) XBOOL_VECTOR (a)->data; - eassert (nr_bits >= 0); + eassume (nr_bits >= 0); for (i = 0; i < nr_bits / BITS_PER_BITS_WORD; i++) bdata[i] = ~adata[i]; @@ -3220,7 +3220,7 @@ match = NILP (b) ? -1 : 0; adata = (bits_word *) XBOOL_VECTOR (a)->data; - eassert (nr_bits >= 0); + eassume (nr_bits >= 0); for (i = 0; i < nr_bits / BITS_PER_BITS_WORD; ++i) count += popcount_bits_word (adata[i] ^ match); @@ -3262,7 +3262,7 @@ adata = (bits_word *) XBOOL_VECTOR (a)->data; - assume (nr_bits >= 0); + eassume (nr_bits >= 0); nr_words = ROUNDUP (nr_bits, BITS_PER_BITS_WORD) / BITS_PER_BITS_WORD; pos = XFASTINT (i) / BITS_PER_BITS_WORD; === modified file 'src/dispnew.c' --- src/dispnew.c 2013-10-08 20:04:40 +0000 +++ src/dispnew.c 2013-10-11 06:32:29 +0000 @@ -4480,7 +4480,6 @@ } } - assume (0 <= FRAME_LINES (f)); pause_p = 0 < i && i < FRAME_LINES (f) - 1; /* Now just clean up termcap drivers and set cursor, etc. */ === modified file 'src/ftfont.c' --- src/ftfont.c 2013-09-22 09:31:55 +0000 +++ src/ftfont.c 2013-10-11 06:32:29 +0000 @@ -2425,7 +2425,6 @@ } len = i; - assume (len <= STRING_BYTES_BOUND); if (with_variation_selector) { === modified file 'src/image.c' --- src/image.c 2013-10-10 19:15:33 +0000 +++ src/image.c 2013-10-11 06:32:29 +0000 @@ -7571,10 +7571,7 @@ y++, row += interlace_increment[pass]) { while (subimg_height <= row) - { - assume (pass < 3); - row = interlace_start[++pass]; - } + row = interlace_start[++pass]; for (x = 0; x < subimg_width; x++) { === modified file 'src/intervals.c' --- src/intervals.c 2013-10-09 17:56:58 +0000 +++ src/intervals.c 2013-10-11 06:32:29 +0000 @@ -1404,10 +1404,7 @@ adjust_intervals_for_insertion (buffer_intervals (buffer), start, length); else - { - assume (- TYPE_MAXIMUM (ptrdiff_t) <= length); - adjust_intervals_for_deletion (buffer, start, -length); - } + adjust_intervals_for_deletion (buffer, start, -length); } /* Merge interval I with its lexicographic successor. The resulting === modified file 'src/lisp.h' --- src/lisp.h 2013-10-09 17:52:38 +0000 +++ src/lisp.h 2013-10-11 06:32:29 +0000 @@ -31,6 +31,7 @@ #include #include +#include INLINE_HEADER_BEGIN @@ -113,28 +114,48 @@ /* Extra internal type checking? */ -/* Define an Emacs version of 'assert (COND)'. COND should be free of - side effects; it may be evaluated zero or more times. */ +/* Define Emacs versions of 's 'assert (COND)' and 's + 'assume (COND)'. COND should be free of side effects, as it may or + may not be evaluated. + + 'eassert (COND)' checks COND at runtime if ENABLE_CHECKING is + defined and suppress_checking is false, and does nothing otherwise. + Emacs dies if COND is checked and is false. The suppress_checking + variable is initialized to 0 in alloc.c. Set it to 1 using a + debugger to temporarily disable aborting on detected internal + inconsistencies or error conditions. + + In some cases, a good compiler may be able to optimize away the + eassert macro even if ENABLE_CHECKING is true, e.g., if XSTRING (x) + uses eassert to test STRINGP (x), but a particular use of XSTRING + is invoked only after testing that STRINGP (x) is true, making the + test redundant. + + eassume is like eassert except that it also causes the compiler to + assume that COND is true afterwards, regardless of whether runtime + checking is enabled. This can improve performance in some cases, + though it can degrade performance in others. It's often suboptimal + for COND to call external functions or access volatile storage. */ + #ifndef ENABLE_CHECKING # define eassert(cond) ((void) (0 && (cond))) /* Check that COND compiles. */ +# define eassume(cond) assume (cond) #else /* ENABLE_CHECKING */ extern _Noreturn void die (const char *, const char *, int); -/* The suppress_checking variable is initialized to 0 in alloc.c. Set - it to 1 using a debugger to temporarily disable aborting on - detected internal inconsistencies or error conditions. - - In some cases, a good compiler may be able to optimize away the - eassert macro altogether, e.g., if XSTRING (x) uses eassert to test - STRINGP (x), but a particular use of XSTRING is invoked only after - testing that STRINGP (x) is true, making the test redundant. */ extern bool suppress_checking EXTERNALLY_VISIBLE; # define eassert(cond) \ (suppress_checking || (cond) \ ? (void) 0 \ : die (# cond, __FILE__, __LINE__)) +# define eassume(cond) \ + (suppress_checking \ + ? assume (cond) \ + : (cond) \ + ? (void) 0 \ + : die (# cond, __FILE__, __LINE__)) #endif /* ENABLE_CHECKING */ === modified file 'src/macfont.m' --- src/macfont.m 2013-10-02 18:52:34 +0000 +++ src/macfont.m 2013-10-11 06:32:29 +0000 @@ -2817,7 +2817,6 @@ } len = i; - assume (len <= TYPE_MAXIMUM (EMACS_INT) - 2); if (INT_MAX / 2 < len) memory_full (SIZE_MAX); ------------------------------------------------------------ revno: 114621 committer: Dmitry Antipov branch nick: trunk timestamp: Fri 2013-10-11 07:55:26 +0400 message: * xdisp.c (deep_copy_glyph_row): Remove unused locals. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-10-10 21:42:38 +0000 +++ src/ChangeLog 2013-10-11 03:55:26 +0000 @@ -1,3 +1,7 @@ +2013-10-11 Dmitry Antipov + + * xdisp.c (deep_copy_glyph_row): Remove unused locals. + 2013-10-10 Stefan Monnier * fileio.c (Fsubstitute_in_file_name): Use substitute-env-in-file-name. === modified file 'src/xdisp.c' --- src/xdisp.c 2013-10-10 19:26:13 +0000 +++ src/xdisp.c 2013-10-11 03:55:26 +0000 @@ -20589,7 +20589,6 @@ static void deep_copy_glyph_row (struct glyph_row *to, struct glyph_row *from) { - int area, i; struct glyph *pointers[1 + LAST_AREA]; /* Save glyph pointers of TO. */ ------------------------------------------------------------ revno: 114620 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2013-10-10 23:28:31 -0400 message: * lisp/progmodes/sh-script.el: Provide simpl(e|istic) completion. (explicit-shell-file-name): Declare. (sh--vars-before-point, sh--cmd-completion-table): New functions. (sh-completion-at-point-function): New function. (sh-mode): Use it. (sh-smie--keyword-p): Remove unused argument. (sh-smie-sh-backward-token, sh-smie-rc-backward-token): Remove unused vars. (sh-set-shell): Always setup SMIE, even if we use the old indentation code. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-10-11 02:11:37 +0000 +++ lisp/ChangeLog 2013-10-11 03:28:31 +0000 @@ -1,3 +1,16 @@ +2013-10-11 Stefan Monnier + + * progmodes/sh-script.el: Provide simpl(e|istic) completion. + (explicit-shell-file-name): Declare. + (sh--vars-before-point, sh--cmd-completion-table): New functions. + (sh-completion-at-point-function): New function. + (sh-mode): Use it. + (sh-smie--keyword-p): Remove unused argument. + (sh-smie-sh-backward-token, sh-smie-rc-backward-token): Remove unused + vars. + (sh-set-shell): Always setup SMIE, even if we use the + old indentation code. + 2013-10-11 Dmitry Gutov * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Split the === modified file 'lisp/progmodes/sh-script.el' --- lisp/progmodes/sh-script.el 2013-09-10 20:38:52 +0000 +++ lisp/progmodes/sh-script.el 2013-10-11 03:28:31 +0000 @@ -1,4 +1,4 @@ -;;; sh-script.el --- shell-script editing commands for Emacs +;;; sh-script.el --- shell-script editing commands for Emacs -*- lexical-binding:t -*- ;; Copyright (C) 1993-1997, 1999, 2001-2013 Free Software Foundation, Inc. @@ -1469,9 +1469,11 @@ ;; inferior shell interaction ;; TODO: support multiple interactive shells -(defvar sh-shell-process nil +(defvar-local sh-shell-process nil "The inferior shell process for interaction.") -(make-variable-buffer-local 'sh-shell-process) + +(defvar explicit-shell-file-name) + (defun sh-shell-process (force) "Get a shell process for interaction. If FORCE is non-nil and no process found, create one." @@ -1616,6 +1618,8 @@ (setq-local defun-prompt-regexp (concat "^\\(function[ \t]\\|[[:alnum:]]+[ \t]+()[ \t]+\\)")) (setq-local add-log-current-defun-function #'sh-current-defun-name) + (add-hook 'completion-at-point-functions + #'sh-completion-at-point-function nil t) ;; Parse or insert magic number for exec, and set all variables depending ;; on the shell thus determined. (sh-set-shell @@ -1674,6 +1678,41 @@ "Function to get better fontification including keywords and builtins." (sh-font-lock-keywords-1 t)) +;;; Completion + +(defun sh--vars-before-point () + (save-excursion + (let ((vars ())) + (while (re-search-backward "^[ \t]*\\([[:alnum:]_]+\\)=" nil t) + (push (match-string 1) vars)) + vars))) + +;; (defun sh--var-completion-table (string pred action) +;; (complete-with-action action (sh--vars-before-point) string pred)) + +(defun sh--cmd-completion-table (string pred action) + (let ((cmds + (append (when (fboundp 'imenu--make-index-alist) + (mapcar #'car (imenu--make-index-alist))) + (mapcar (lambda (v) (concat v "=")) + (sh--vars-before-point)) + (locate-file-completion-table + exec-path exec-suffixes string pred t) + '("if" "while" "until" "for")))) + (complete-with-action action cmds string pred))) + +(defun sh-completion-at-point-function () + (save-excursion + (skip-chars-forward "[:alnum:]_") + (let ((end (point)) + (_ (skip-chars-backward "[:alnum:]_")) + (start (point))) + (cond + ((eq (char-before) ?$) + (list start end (sh--vars-before-point))) + ((sh-smie--keyword-p) + (list start end #'sh--cmd-completion-table)))))) + ;;; Indentation and navigation with SMIE. (require 'smie) @@ -1685,8 +1724,10 @@ (defvar sh-use-smie nil "Whether to use the SMIE code for navigation and indentation.") -(defun sh-smie--keyword-p (tok) - "Non-nil if TOK (at which we're looking) really is a keyword." +(defun sh-smie--keyword-p () + "Non-nil if we're at a keyword position. +A keyword position is one where if we're looking at something that looks +like a keyword, then it is a keyword." (let ((prev (funcall smie-backward-token-function))) (if (zerop (length prev)) (looking-back "\\s(" (1- (point))) @@ -1784,7 +1825,7 @@ "Non-nil if TOK (at which we're looking) really is a keyword." (if (equal tok "in") (sh-smie--sh-keyword-in-p) - (sh-smie--keyword-p tok))) + (sh-smie--keyword-p))) (defun sh-smie-sh-forward-token () (if (and (looking-at "[ \t]*\\(?:#\\|\\(\\s|\\)\\|$\\)") @@ -1834,8 +1875,7 @@ (line-beginning-position))))) (defun sh-smie-sh-backward-token () - (let ((bol (line-beginning-position)) - pos tok) + (let ((bol (line-beginning-position))) (forward-comment (- (point))) (cond ((and (bolp) (not (bobp)) @@ -2033,14 +2073,13 @@ (not (save-excursion (goto-char pos) - (sh-smie--keyword-p tok)))) + (sh-smie--keyword-p)))) " word ") (t tok))))))) (defun sh-smie-rc-backward-token () ;; FIXME: Code duplication with sh-smie-sh-backward-token. - (let ((bol (line-beginning-position)) - pos tok) + (let ((bol (line-beginning-position))) (forward-comment (- (point))) (cond ((and (bolp) (not (bobp)) @@ -2072,7 +2111,7 @@ ;; ((equal tok ")") "case-)") ((and tok (string-match "\\`[a-z]" tok) (assoc tok smie-grammar) - (not (save-excursion (sh-smie--keyword-p tok)))) + (not (save-excursion (sh-smie--keyword-p)))) " word ") (t tok))))))) @@ -2209,14 +2248,14 @@ (sh-feature sh-indent-supported)) (progn (message "Setting up indent for shell type %s" sh-shell) - (if sh-use-smie - (let ((mksym (lambda (name) - (intern (format "sh-smie-%s-%s" - sh-indent-supported-here name))))) - (smie-setup (symbol-value (funcall mksym "grammar")) - (funcall mksym "rules") - :forward-token (funcall mksym "forward-token") - :backward-token (funcall mksym "backward-token"))) + (let ((mksym (lambda (name) + (intern (format "sh-smie-%s-%s" + sh-indent-supported-here name))))) + (smie-setup (symbol-value (funcall mksym "grammar")) + (funcall mksym "rules") + :forward-token (funcall mksym "forward-token") + :backward-token (funcall mksym "backward-token"))) + (unless sh-use-smie (setq-local parse-sexp-lookup-properties t) (setq-local sh-kw-alist (sh-feature sh-kw)) (let ((regexp (sh-feature sh-kws-for-done))) ------------------------------------------------------------ revno: 114619 committer: Dmitry Gutov branch nick: trunk timestamp: Fri 2013-10-11 05:11:37 +0300 message: * lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Split the cases of ? and =. (ruby-smie-rules): Simplify the "do" rule. The cases when the predicate would return nil are almost non-existent. (ruby-smie--redundant-do-p): Include "until" and "for" statements. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-10-11 00:45:03 +0000 +++ lisp/ChangeLog 2013-10-11 02:11:37 +0000 @@ -1,5 +1,11 @@ 2013-10-11 Dmitry Gutov + * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Split the + cases of ? and =. + (ruby-smie-rules): Simplify the "do" rule. The cases when the + predicate would return nil are almost non-existent. + (ruby-smie--redundant-do-p): Include "until" and "for" statements. + * emacs-lisp/smie.el (smie--matching-block-data): Invalidate the cache also after commands that modify the buffer but don't move point. === modified file 'lisp/progmodes/ruby-mode.el' --- lisp/progmodes/ruby-mode.el 2013-10-09 03:18:01 +0000 +++ lisp/progmodes/ruby-mode.el 2013-10-11 02:11:37 +0000 @@ -292,10 +292,11 @@ '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\)) ;; Make sure it's not the end of a regexp. (not (eq (car (syntax-after (1- (point)))) 7))) - (and (memq (char-before) '(?\? ?=)) - (let ((tok (save-excursion (ruby-smie--backward-token)))) - (or (equal tok "?") - (string-match "\\`\\s." tok)))) + (and (eq (char-before) ?\?) + (equal (save-excursion (ruby-smie--backward-token)) "?")) + (and (eq (char-before) ?=) + (string-match "\\`\\s." (save-excursion + (ruby-smie--backward-token)))) (and (eq (car (syntax-after (1- (point)))) 2) (equal (save-excursion (ruby-smie--backward-token)) "iuwu-mod")) @@ -306,7 +307,7 @@ (defun ruby-smie--redundant-do-p (&optional skip) (save-excursion (if skip (backward-word 1)) - (member (nth 2 (smie-backward-sexp ";")) '("while")))) + (member (nth 2 (smie-backward-sexp ";")) '("while" "until" "for")))) (defun ruby-smie--opening-pipe-p () (save-excursion @@ -423,19 +424,7 @@ (when (smie-rule-hanging-p) (smie-backward-sexp 'halfsexp) (smie-indent-virtual))) (`(:after . ,(or "=" "iuwu-mod")) 2) - (`(:before . "do") - (when (or (smie-rule-hanging-p) - (save-excursion - (forward-word 1) ;Skip "do" - (skip-chars-forward " \t") - (and (equal (save-excursion (ruby-smie--forward-token)) - "opening-|") - (save-excursion (forward-sexp 1) - (skip-chars-forward " \t") - (or (eolp) - (looking-at comment-start-skip)))))) - ;; `(column . ,(smie-indent-virtual)) - (smie-rule-parent))) + (`(:before . "do") (smie-rule-parent)) (`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0) (`(:before . ,(or `"when")) (if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level === modified file 'test/indent/ruby.rb' --- test/indent/ruby.rb 2013-10-09 03:18:01 +0000 +++ test/indent/ruby.rb 2013-10-11 02:11:37 +0000 @@ -151,6 +151,10 @@ foo if bar +if foo? + bar +end + # Examples below still fail with `ruby-use-smie' on: foo + ------------------------------------------------------------ revno: 114618 committer: Dmitry Gutov branch nick: trunk timestamp: Fri 2013-10-11 03:45:03 +0300 message: * lisp/emacs-lisp/smie.el (smie--matching-block-data): Invalidate the cache also after commands that modify the buffer but don't move point. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-10-10 21:42:38 +0000 +++ lisp/ChangeLog 2013-10-11 00:45:03 +0000 @@ -1,3 +1,9 @@ +2013-10-11 Dmitry Gutov + + * emacs-lisp/smie.el (smie--matching-block-data): Invalidate the + cache also after commands that modify the buffer but don't move + point. + 2013-10-10 Stefan Monnier * env.el (substitute-env-in-file-name): New function. === modified file 'lisp/emacs-lisp/smie.el' --- lisp/emacs-lisp/smie.el 2013-10-07 16:56:51 +0000 +++ lisp/emacs-lisp/smie.el 2013-10-11 00:45:03 +0000 @@ -1062,10 +1062,12 @@ (defun smie--matching-block-data (orig &rest args) "A function suitable for `show-paren-data-function' (which see)." (if (or (null smie-closer-alist) - (eq (point) (car smie--matching-block-data-cache))) + (equal (cons (point) (buffer-chars-modified-tick)) + (car smie--matching-block-data-cache))) (or (cdr smie--matching-block-data-cache) (apply orig args)) - (setq smie--matching-block-data-cache (list (point))) + (setq smie--matching-block-data-cache + (list (cons (point) (buffer-chars-modified-tick)))) (unless (nth 8 (syntax-ppss)) (condition-case nil (let ((here (smie--opener/closer-at-point))) @@ -1108,7 +1110,7 @@ (nth 1 there) (nth 2 there) (not (nth 0 there))))))) (scan-error nil)) - (goto-char (car smie--matching-block-data-cache))) + (goto-char (caar smie--matching-block-data-cache))) (apply #'smie--matching-block-data orig args))) ;;; The indentation engine. ------------------------------------------------------------ revno: 114617 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2013-10-10 17:43:47 -0400 message: * test/automated/ruby-mode-tests.el (ruby-with-temp-buffer): Move before first use. (ruby-should-indent): Use indent-according-to-mode. (ruby-deftest-move-to-block): Use `declare'. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-10-10 02:33:35 +0000 +++ test/ChangeLog 2013-10-10 21:43:47 +0000 @@ -1,3 +1,10 @@ +2013-10-10 Stefan Monnier + + * automated/ruby-mode-tests.el (ruby-with-temp-buffer): Move before + first use. + (ruby-should-indent): Use indent-according-to-mode. + (ruby-deftest-move-to-block): Use `declare'. + 2013-10-07 Dmitry Gutov * indent/ruby.rb: Fix a spurious change, add more failing examples. === modified file 'test/automated/ruby-mode-tests.el' --- test/automated/ruby-mode-tests.el 2013-10-09 03:18:01 +0000 +++ test/automated/ruby-mode-tests.el 2013-10-10 21:43:47 +0000 @@ -24,10 +24,17 @@ (require 'ert) (require 'ruby-mode) +(defmacro ruby-with-temp-buffer (contents &rest body) + (declare (indent 1) (debug t)) + `(with-temp-buffer + (insert ,contents) + (ruby-mode) + ,@body)) + (defun ruby-should-indent (content column) "Assert indentation COLUMN on the last line of CONTENT." (ruby-with-temp-buffer content - (ruby-indent-line) + (indent-according-to-mode) (should (= (current-indentation) column)))) (defun ruby-should-indent-buffer (expected content) @@ -38,13 +45,6 @@ (indent-region (point-min) (point-max)) (should (string= (ruby-test-string expected) (buffer-string))))) -(defmacro ruby-with-temp-buffer (contents &rest body) - (declare (indent 1) (debug t)) - `(with-temp-buffer - (insert ,contents) - (ruby-mode) - ,@body)) - (defun ruby-test-string (s &rest args) (apply 'format (replace-regexp-in-string "^[ \t]*|" "" s) args)) @@ -471,6 +471,7 @@ |end")) (defmacro ruby-deftest-move-to-block (name &rest body) + (declare (indent defun)) `(ert-deftest ,(intern (format "ruby-move-to-block-%s" name)) () (with-temp-buffer (insert ruby-block-test-example) @@ -478,8 +479,6 @@ (goto-char (point-min)) ,@body))) -(put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun) - (ruby-deftest-move-to-block works-on-do (forward-line 10) (ruby-end-of-block)