From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#12169: [PATCH] Merge changes from upstream ruby-mode Date: Sat, 11 Aug 2012 02:15:21 +0400 Message-ID: <502587F9.7090201@yandex.ru> References: <50245771.6060109@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050904080204070102030608" X-Trace: dough.gmane.org 1344636954 19553 80.91.229.3 (10 Aug 2012 22:15:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Aug 2012 22:15:54 +0000 (UTC) Cc: 12169@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 11 00:15:54 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SzxUn-0004du-ND for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Aug 2012 00:15:53 +0200 Original-Received: from localhost ([::1]:48672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzxUm-0001jQ-36 for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Aug 2012 18:15:52 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:32907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzxUi-0001jL-Rj for bug-gnu-emacs@gnu.org; Fri, 10 Aug 2012 18:15:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzxUf-0000A5-JC for bug-gnu-emacs@gnu.org; Fri, 10 Aug 2012 18:15:48 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzxUf-00009y-EM for bug-gnu-emacs@gnu.org; Fri, 10 Aug 2012 18:15:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Szxcg-0002O4-7g for bug-gnu-emacs@gnu.org; Fri, 10 Aug 2012 18:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 22:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12169 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 12169-submit@debbugs.gnu.org id=B12169.13446374269153 (code B ref 12169); Fri, 10 Aug 2012 22:24:02 +0000 Original-Received: (at 12169) by debbugs.gnu.org; 10 Aug 2012 22:23:46 +0000 Original-Received: from localhost ([127.0.0.1]:47677 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzxcP-0002Na-DJ for submit@debbugs.gnu.org; Fri, 10 Aug 2012 18:23:46 -0400 Original-Received: from forward12.mail.yandex.net ([95.108.130.94]:46320) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzxcK-0002NO-O8 for 12169@debbugs.gnu.org; Fri, 10 Aug 2012 18:23:43 -0400 Original-Received: from smtp13.mail.yandex.net (smtp13.mail.yandex.net [95.108.130.68]) by forward12.mail.yandex.net (Yandex) with ESMTP id 0F03DC21516; Sat, 11 Aug 2012 02:15:21 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1344636921; bh=oV84FMq2dvZcdG9riGWr2BwY79EkolUlXY/FqSpWC9Y=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type; b=bY99sTJd/Z7RqzT0LIxqznU31uyMzKekculdQxAf/o+CS+DOblp3x93clL5S8rKU4 QjVXE6NROZuELp5+Wo5NQx13tIcjeZFCbMYgs2x0mSfaBVMtbUQvRN2pqUHnx2fov7 FN+ich222znjIkemFYM+eyJIIxYlHj8FTsPso+cI= Original-Received: from smtp13.mail.yandex.net (localhost [127.0.0.1]) by smtp13.mail.yandex.net (Yandex) with ESMTP id D24BAE4021C; Sat, 11 Aug 2012 02:15:20 +0400 (MSK) Original-Received: from 5x164x92x232.dynamic.spb.ertelecom.ru (5x164x92x232.dynamic.spb.ertelecom.ru [5.164.92.232]) by smtp13.mail.yandex.net (nwsmtp/Yandex) with ESMTP id FHGOYi5A-FKGaTlbH; Sat, 11 Aug 2012 02:15:20 +0400 X-Yandex-Rcpt-Suid: monnier@IRO.UMontreal.CA X-Yandex-Rcpt-Suid: 12169@debbugs.gnu.org X-Yandex-Rcpt-Suid: rgm@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1344636920; bh=oV84FMq2dvZcdG9riGWr2BwY79EkolUlXY/FqSpWC9Y=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type; b=SPTcvLB8BovQ/FMlA7jymq6sZRBXKPr/pkDOU/6TzEcYcSn2FT7+3AaH/GzaL6CVi qQOVSQqCjGtWBAA3zd99A6b+/O/oAxiWnD/7WymOr+L6gZIk0D+BGyjBcQNyXQW0js 5GgpmuSz7lxgTtT4wXZ4NATsV7d3YFA1Oey9Z0sI= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:63022 Archived-At: This is a multi-part message in MIME format. --------------050904080204070102030608 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 10.08.2012 19:54, Glenn Morris wrote: > Are you also the upstream author? Nope. Thanks for the reminder. On 11.08.2012 0:28, Stefan Monnier wrote: > I've installed your patch, but please fix the ChangeLog authorship as > pointed out by Glenn (just include the changes in a subsequent patch). Included. >> Here's part 2, in which I'm skipping the next 3 commits: >> https://github.com/ruby/ruby/commit/85df40e9ab4559cd4ddde3f106ab56c76a808cc8 >> https://github.com/ruby/ruby/commit/6b0dc7fd81b25bc66681548b8b82f38258f7e08c >> https://github.com/ruby/ruby/commit/862048e28d26112af1e67205cfd1c16564590bce For completeness, this later commit is directly related to the above 3: https://github.com/ruby/ruby/commit/d9e6b7d6a5e81afb588d79ef923b70890cdec4ba I also don't include it, and we can see that the relevant test passes fine. > I also added that patch. I presume that you're also trying to convince > Ruby's maintainers to undo those changes? Not really, no. I will open an issue on Redmine since you asked, but nobody seems to be interested in pulling our changes back anyway, and as long as we're doing it in one direction, cherry-picking should be fine. Here's a recent example: http://bugs.ruby-lang.org/issues/5140 A year-old bug, fixed in Emacs trunk, a user posted that information there with a patch 4 months ago, and... nothing. > Same as before: please provide a subsequent patch which corrects the > authorship attribution. In my not-a-lawyer opinion, the example code in tests is not copyrightable, but okay, I mentioned the original author there too. --Dmitry --------------050904080204070102030608 Content-Type: text/plain; charset=windows-1251; name="ruby-upstream-3.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ruby-upstream-3.diff" diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 38379cd..2d63ab6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,17 +1,29 @@ -2012-08-09 Dmitry Gutov +2012-08-10 Nobuyoshi Nakada - Merge stuff from upsteam ruby-mode, part 1. + * progmodes/ruby-mode.el (ruby-mode-map): Remove unnecessary + binding for `newline'. + (ruby-move-to-block): When moving backward, stop at block opening, + not indentation. + * progmodes/ruby-mode.el (ruby-brace-to-do-end) + (ruby-do-end-to-brace, ruby-toggle-block): New functions. + * progmodes/ruby-mode.el (ruby-mode-map): Add binding for + `ruby-toggle-block'. + +2012-08-09 Dmitry Gutov - * progmodes/ruby-mode.el (ruby-mode-map): Remove deprecated - binding (use `M-;' instead). (ruby-expr-beg, ruby-parse-partial): ?, _, and : are symbol constituents, ! is not (but kinda should be). - (ruby-singleton-class-p): New function. - (ruby-expr-beg, ruby-in-here-doc-p) - (ruby-syntax-propertize-heredoc): Use it. + (ruby-syntax-propertize-heredoc): Use `ruby-singleton-class-p'. (ruby-syntax-propertize-function): Adjust for changes in `ruby-syntax-propertize-heredoc'. +2012-08-09 Nobuyoshi Nakada + + * progmodes/ruby-mode.el (ruby-mode-map): Remove deprecated + binding (use `M-;' instead). + (ruby-singleton-class-p): New function. + (ruby-expr-beg, ruby-in-here-doc-p) Use it. + 2012-08-07 Andreas Schwab * calc/calc-prog.el (math-do-defmath): Use backquote forms. Fix diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 68abaff..c430c99 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -150,7 +150,7 @@ This should only be called after matching against `ruby-here-doc-beg-re'." (define-key map (kbd "M-C-q") 'ruby-indent-exp) (define-key map (kbd "C-M-h") 'backward-kill-word) (define-key map (kbd "C-j") 'reindent-then-newline-and-indent) - (define-key map (kbd "C-m") 'newline) + (define-key map (kbd "C-c {") 'ruby-toggle-block) map) "Keymap used in Ruby mode.") @@ -881,7 +881,7 @@ or blocks containing the current block." ;; TODO: Make this work for n > 1, ;; make it not loop for n = 0, ;; document body - (let (start pos done down) + (let (start pos done down (orig (point))) (setq start (ruby-calculate-indent)) (setq down (looking-at (if (< n 0) ruby-block-end-re (concat "\\<\\(" ruby-block-beg-re "\\)\\>")))) @@ -907,8 +907,18 @@ or blocks containing the current block." (save-excursion (back-to-indentation) (if (looking-at (concat "\\<\\(" ruby-block-mid-re "\\)\\>")) - (setq done nil)))))) - (back-to-indentation)) + (setq done nil))))) + (back-to-indentation) + (when (< n 0) + (let ((eol (point-at-eol)) state next) + (if (< orig eol) (setq eol orig)) + (setq orig (point)) + (while (and (setq next (apply 'ruby-parse-partial eol state)) + (< (point) eol)) + (setq state next)) + (when (cdaadr state) + (goto-char (cdaadr state))) + (backward-word))))) (defun ruby-beginning-of-block (&optional arg) "Move backward to the beginning of the current block. @@ -1116,6 +1126,47 @@ See `add-log-current-defun-function'." (if mlist (concat mlist mname) mname) mlist))))) +(defun ruby-brace-to-do-end () + (when (looking-at "{") + (let ((orig (point)) (end (progn (ruby-forward-sexp) (point)))) + (when (eq (char-before) ?\}) + (delete-char -1) + (if (eq (char-syntax (char-before)) ?w) + (insert " ")) + (insert "end") + (if (eq (char-syntax (char-after)) ?w) + (insert " ")) + (goto-char orig) + (delete-char 1) + (if (eq (char-syntax (char-before)) ?w) + (insert " ")) + (insert "do") + (when (looking-at "\\sw\\||") + (insert " ") + (backward-char)) + t)))) + +(defun ruby-do-end-to-brace () + (when (and (or (bolp) + (not (memq (char-syntax (char-before)) '(?w ?_)))) + (looking-at "\\ + + Original tests in test_ruby_mode.rb in upstream (author). 2012-08-09 Dmitry Gutov diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index f91b6e4..df51aa0 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el @@ -191,6 +191,32 @@ VALUES-PLIST is a list with alternating index and value elements." | end |")) +(ert-deftest ruby-move-to-block-stops-at-opening () + (with-temp-buffer + (insert "def f\nend") + (beginning-of-line) + (ruby-mode) + (ruby-move-to-block -1) + (should (looking-at "f$")))) + +(ert-deftest ruby-toggle-block-to-do-end () + (with-temp-buffer + (insert "foo {|b|\n}\n") + (ruby-mode) + (search-backward "{") + (ruby-toggle-block) + (should (string= "foo do |b|\nend\n" (buffer-substring-no-properties + (point-min) (point-max)))))) + +(ert-deftest ruby-toggle-block-to-brace () + (with-temp-buffer + (insert "foo do |b|\nend\n") + (ruby-mode) + (search-backward "do") + (ruby-toggle-block) + (should (string= "foo {|b|\n}\n" (buffer-substring-no-properties + (point-min) (point-max)))))) + (provide 'ruby-mode-tests) ;;; ruby-mode-tests.el ends here --------------050904080204070102030608--