From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#21072: Brave new mark-defun (and a testing tool) Date: Fri, 7 Apr 2017 10:41:26 -0400 Message-ID: References: <87o9ydrzkr.fsf@mbork.pl> <87mvdriuss.fsf@mbork.pl> <87bmu6icea.fsf@mbork.pl> <87wpctgieu.fsf@mbork.pl> <52e67f43-edcf-09e3-5fd6-6079763fd234@yandex.ru> <87tw7wh9sf.fsf@mbork.pl> <87k28sdka6.fsf@jane> <87efyze00g.fsf@jane> <87bmu2eoji.fsf@jane> <87wpcpw61w.fsf@jane> <83o9xdghmc.fsf@gnu.org> <87o9wkoald.fsf@jane> <87a881ofsu.fsf@jane> <87k272wh8x.fsf@users.sourceforge.net> <871st4aal7.fsf@jane> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1491576258 19689 195.159.176.226 (7 Apr 2017 14:44:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 7 Apr 2017 14:44:18 +0000 (UTC) Cc: 21072@debbugs.gnu.org, Stefan Monnier To: Marcin Borkowski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 07 16:44:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwV7N-0003sR-3E for geb-bug-gnu-emacs@m.gmane.org; Fri, 07 Apr 2017 16:44:05 +0200 Original-Received: from localhost ([::1]:51255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwV7T-0007k5-3X for geb-bug-gnu-emacs@m.gmane.org; Fri, 07 Apr 2017 10:44:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwV5S-0005wg-F3 for bug-gnu-emacs@gnu.org; Fri, 07 Apr 2017 10:42:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwV5O-0007QD-CN for bug-gnu-emacs@gnu.org; Fri, 07 Apr 2017 10:42:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38462) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cwV5O-0007Q7-90 for bug-gnu-emacs@gnu.org; Fri, 07 Apr 2017 10:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cwV5O-0000fm-3E for bug-gnu-emacs@gnu.org; Fri, 07 Apr 2017 10:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Apr 2017 14:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21072 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21072-submit@debbugs.gnu.org id=B21072.14915760942552 (code B ref 21072); Fri, 07 Apr 2017 14:42:02 +0000 Original-Received: (at 21072) by debbugs.gnu.org; 7 Apr 2017 14:41:34 +0000 Original-Received: from localhost ([127.0.0.1]:36661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwV4w-0000f5-AU for submit@debbugs.gnu.org; Fri, 07 Apr 2017 10:41:34 -0400 Original-Received: from mail-oi0-f46.google.com ([209.85.218.46]:33701) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwV4v-0000et-0X for 21072@debbugs.gnu.org; Fri, 07 Apr 2017 10:41:33 -0400 Original-Received: by mail-oi0-f46.google.com with SMTP id b187so88318148oif.0 for <21072@debbugs.gnu.org>; Fri, 07 Apr 2017 07:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=g36BdyzYm0VMyeF8JGFtg2iqauOhVPzriMSz8JLEoiA=; b=KQOdsN+sByFSjwa2H5ylQIrx35XqQMn/Fdq+GDc8k7Xe+OctEYBK2cmCigoteG4CSR 95BXBTaelfubWAOYdu2m5dA1H/+73wg38ZDImTW5hNmhvME3cer8jOI7kti3UXpDvkWl KqLKwQSZcPwKqgqF51fbWi4p31XfvCV0bw+cEcrqK+U4Yc5kd/V5fMjHuHLrFgXarxT3 7/QBLxwT2BjxMa0lH0hUDSEF5mLf+4YvIc0SWiiqNtCISnulUx865cQPsqz1mhI2peU0 FWujFPYKmbz5COsk6jPVSiuP/D0q+SC40phOZtHBbPL49AE8mEg8cPZ6IWQO//JGmt3Z IzMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=g36BdyzYm0VMyeF8JGFtg2iqauOhVPzriMSz8JLEoiA=; b=TMcJ+PhVvl/tcPIk6BSf5KhLHhxxoSYvIpz0QcEEV8pVK8kIa0aqsJBkhvRDfjFET8 fmrt6eT6MjMNucx3vsQSs3VJVFCx8iN5Ori+JpawqFVJYm2izkFjkKd8GMlEoVzfgxBo y3kkd5aw3xTwVbuZkjSr72bQ6b9MtApWL00I9ptNv2UfuQYRbObHy1Gh0ZrT+x0MdB0n QcpCr3zBmyZeLkWZV335NiVcccHffwmOD6X0cQp4EWSyt4sbachb0w0TjUMyxXcHwx9a frKJGL+8BH69RkNZZDNArdp1ILo8nPMk4m9v3g1pXFos2pPLMZnZ0MuM0PgqmfvxUA9m yZqA== X-Gm-Message-State: AFeK/H18AlREroG68f++RzhWxX3bJLwUkCGjenjjbBp82d91fYfmHXIdTVlq9hPtsiJHybD3DBt44OLco4th6g== X-Received: by 10.202.74.87 with SMTP id x84mr23014343oia.187.1491576087037; Fri, 07 Apr 2017 07:41:27 -0700 (PDT) Original-Received: by 10.157.80.133 with HTTP; Fri, 7 Apr 2017 07:41:26 -0700 (PDT) In-Reply-To: <871st4aal7.fsf@jane> X-Google-Sender-Auth: bH5H33ifFjofkLVf9VT7uhvMSOo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:131335 Archived-At: On Fri, Apr 7, 2017 at 4:25 AM, Marcin Borkowski wrote: >>> +** New behavior of 'mark-defun' implemented [...] >>> +line. >>> + >>> ++++ >>> * Changes in Specialized Modes and Packages in Emacs 26.1 >>> >> >> This entry should go before the page separator, and the "+++" should go >> on the line just above the entry, not after it. > > That one I do not understand. This means that "+++" goes essentially > _to the previous entry_, which doesn't seem to make sense (especially > when viewing NEWS folded, which I assume everyone does, right?). Hmm, no, I wasn't really aware of folding (you mean via `outline-hide-sublevels', right?). I guess the convention wasn't made with folding in mind, but the "+++" and "---" markup is just temporary anyway. > >>> +(defun beginning-of-defun-comments (&optional arg) >> >>> + (let (nbobp) >>> + (while (progn >>> + (setq nbobp (zerop (forward-line -1))) >>> + (and (not (looking-at "^\\s-*$")) >>> + (beginning-of-defun--in-emptyish-line-p) >>> + nbobp))) >>> + (when nbobp >>> + (forward-line 1)))) >> >> >> The looking-at call is redundant, right? Anyway, can't that all be >> replaced by just >> >> (forward-comment (- (point))) >> (unless (bolp) >> (forward-line 1)) > > My tests say no. Oh, right, I thought it was doing backward-comment, but the difference is that it stops at blank lines, thus the *non-redundant* looking-at call. I wonder if that's a sensible thing to do for languages that have multiline comments though, e.g. Javascript: /* This function returns 0 */ function foo () { return 0; } Although we might say that such comments should have "*" on the empty lines. > >>> +(defun mark-defun (&optional arg) >> >>> + (let (nbobp) >>> + (while (progn >>> + (setq nbobp (zerop (forward-line -1))) >>> + (and (looking-at "^\\s-*$") >>> + nbobp))) >>> + (when nbobp >>> + (forward-line 1)))) >> >> I think this can be just >> >> (skip-chars-backward "[:space:]\n") >> (unless (bolp) >> (forward-line 1)) > > This OTOH does pass my tests, though I guess it would be clearer to > replace (bolp) with (bobp) in the above code (if I understand correctly, > in this situation they should be equivalent). WDYT? Yes, I believe they are equivalent. I guess using bobp would explain better when this happens, though I feel bolp better explains why we're doing forward-line. I don't think it matters very much either way, go with whichever you like best.