From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Small improvements to ruby-mode Date: Tue, 02 Jul 2013 22:38:10 +0400 Message-ID: <51D31E12.7060002@yandex.ru> References: <2A6700DEDCA640EF92B326002717596D@gmail.com> <87txkrm46t.fsf@yandex.ru> <6EF2AEF8D67840A2AF1C908AA3D0725F@gmail.com> <51C5A67A.2020002@yandex.ru> <51C6EA5F.2040408@yandex.ru> <51D1CB5A.2060900@yandex.ru> <51D1F98D.3060900@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1372790303 21337 80.91.229.3 (2 Jul 2013 18:38:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Jul 2013 18:38:23 +0000 (UTC) Cc: emacs-devel To: Bozhidar Batsov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 02 20:38:23 2013 Return-path: Envelope-to: ged-emacs-devel@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 1Uu5T5-0005FY-E5 for ged-emacs-devel@m.gmane.org; Tue, 02 Jul 2013 20:38:23 +0200 Original-Received: from localhost ([::1]:35349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu5T5-0002BE-19 for ged-emacs-devel@m.gmane.org; Tue, 02 Jul 2013 14:38:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu5Sy-0002AN-5P for emacs-devel@gnu.org; Tue, 02 Jul 2013 14:38:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uu5St-0000qX-Ad for emacs-devel@gnu.org; Tue, 02 Jul 2013 14:38:16 -0400 Original-Received: from mail-la0-x22e.google.com ([2a00:1450:4010:c03::22e]:39060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu5St-0000qF-3h for emacs-devel@gnu.org; Tue, 02 Jul 2013 14:38:11 -0400 Original-Received: by mail-la0-f46.google.com with SMTP id eg20so5953847lab.19 for ; Tue, 02 Jul 2013 11:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-antivirus:x-antivirus-status; bh=/pYmOiY7LWogzOXX1eV96nHbQD1Ot6wLycqbJuSBh5s=; b=Y+3ogGOk1hgAEm7KZOFq8XZ6DEgiTgOaRNO/m9Hy9NmhkT39MGf7/XteUVsD/p6BTF YUWGS41KUJUkp/04iN0EI1aDiPrcATZ5RrA91hhggFwMn6Q+uu76eojETs5RSh/Fs8TS /pUPM83WKSfjY0kzeF9d7NzXDOppTwKNfFa2d166w/tMcCgUEnNaYmieJ6YvfGBzjov2 3Nyld3VtOY6jSyhKDzj13FLTdww44FM/TZ0YQ2Obpx20DbQjgl0851SNp4SkdHkDO/BZ HeFM+gBScF56MzMSIMOwR+fpJuON/46hRZ952weZ9MHjNLbeqbRzKbf0sbXZB2ZZVYs3 FcDg== X-Received: by 10.152.44.225 with SMTP id h1mr14543321lam.90.1372790289617; Tue, 02 Jul 2013 11:38:09 -0700 (PDT) Original-Received: from [127.0.0.1] ([178.252.98.87]) by mx.google.com with ESMTPSA id 8sm9290558lbq.4.2013.07.02.11.38.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Jul 2013 11:38:08 -0700 (PDT) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: X-Antivirus: avast! (VPS 130702-0, 02.07.2013), Outbound message X-Antivirus-Status: Clean X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:161449 Archived-At: Hmm, I don't see either of these problems with the current trunk. Have you checked for stale ruby-mode.elc or a rogue ruby-mode.el installed via ELPA? I did encounter the following semi-known issue: Putting the cursor on one of the 4 lines after "elsif" in the second example and pressing `C-M-p' moves it to the "add_offence" line. And pressing `C-M-n' after that moves it to the "end" closing the "operands.each" block. Pressing `C-M-p' or `C-M-n' on the `elsif' line misbehaves similarly. I'll see about fixing that. On 02.07.2013 19:46, Bozhidar Batsov wrote: > Here's a bit of code: > > operands.each do |op| > if LITERALS.include?(op.type) > add_offence(:warning, op.loc.expression, > format(MSG, op.loc.expression.source)) > > end > end > > Placing the cursor somewhere in the `if` yields totally crazy results > (or even errors from time to time - "setq: Wrong type argument: > number-or-marker-p, nil") when calling `ruby-beginning-of-block` and > `ruby-end-of-block`. I'd expect `ruby-beginning-of-block` to go to the > `each` line and `ruby-beginning-of-block` to go to the `end` of the > block in question. There's also the question if constructs ending with > an `end` should be treated as blocks as well - that might be useful to > develop scope highlighting tools without a lot of custom code. def-end, if-end, etc, are already treated as blocks. > Regarding the other problem I mentioned - mark defun doesn't always work > correctly: > > def check_for_literal(node) > cond, = *node > > # if the code node is literal we obviously have a problem > if LITERALS.include?(cond.type) > add_offence(:warning, cond.loc.expression, > format(MSG, cond.loc.expression.source)) > elsif [:and, :or].include?(cond.type) > # alternatively we have to consider a logical node with a > # literal argument > *operands = *cond > operands.each do |op| > if LITERALS.include?(op.type) > add_offence(:warning, op.loc.expression, > format(MSG, op.loc.expression.source)) > > end > end > end > end > > Place the cursor inside the innermost `if` near the end of the defun and > try `C-M-h` there - you'll see that only a portion of the defun will be > marked. `mark-defun' call `beginning-of-defun' and `end-of-defun', and they work pretty reliably here.