From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#21072: Brave new mark-defun (and a testing tool) Date: Sun, 02 Apr 2017 18:56:46 -0400 Message-ID: <87k272wh8x.fsf__26855.253466829$1491173774$gmane$org@users.sourceforge.net> 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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1491173774 3501 195.159.176.226 (2 Apr 2017 22:56:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 2 Apr 2017 22:56:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: emacs-devel@gnu.org, 21072@debbugs.gnu.org, monnier@iro.umontreal.ca To: Marcin Borkowski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 03 00:56: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 1cuoPo-0000NJ-MB for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Apr 2017 00:56:08 +0200 Original-Received: from localhost ([::1]:56493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuoPu-0008OU-Nq for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Apr 2017 18:56:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuoPm-0008Mr-1a for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2017 18:56:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuoPi-0005lz-Ve for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2017 18:56:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59674) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuoPi-0005lY-RA for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2017 18:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cuoPi-0002P4-Ej for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2017 18:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Apr 2017 22:56: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.14911737329202 (code B ref 21072); Sun, 02 Apr 2017 22:56:02 +0000 Original-Received: (at 21072) by debbugs.gnu.org; 2 Apr 2017 22:55:32 +0000 Original-Received: from localhost ([127.0.0.1]:57873 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuoPD-0002OM-Q1 for submit@debbugs.gnu.org; Sun, 02 Apr 2017 18:55:31 -0400 Original-Received: from mail-io0-f178.google.com ([209.85.223.178]:34085) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuoPC-0002O8-TE for 21072@debbugs.gnu.org; Sun, 02 Apr 2017 18:55:31 -0400 Original-Received: by mail-io0-f178.google.com with SMTP id b140so65682361iof.1 for <21072@debbugs.gnu.org>; Sun, 02 Apr 2017 15:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=YbfKk3uaZWCTN9uLgKhXYCI64qZq8o9DlmffiKBBYo0=; b=BMRI7yLSeEBaEyYTJx4+urqKx6XPun+dLHj9NkYYGiHyPTEa9gh8dopGFoH5LcHnSt ixfKLQIcbgb5D5oP+XsQgw12B03loTkWTac/eA98yrXbHNgMeMoczEUNBptyukfmGCed OsMQHwsIisaowoHfgVuT8jMHAQV0vzSD+8zu+b1JheCDgHii88j5oRbQCWplUaehnwgr faN7rs0ABwYfUW0PZUFZ73391J955sMW9Iyv0HEjHwK/g4oL44Utt/KPioWALi2edi4Z f5SRpL9OyunOSMd35IS3/5THzIwdPPXxvuJmtrmbb1Ouvp/jtd/FEBJ+/KMnDPlluWbF JDSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding; bh=YbfKk3uaZWCTN9uLgKhXYCI64qZq8o9DlmffiKBBYo0=; b=VbvhjT7dWWIutpXuoVl9RZjzz2hJGYziRvj3MIbldz3aShkzPFbu0aQs9+f4T0AO0g N7Ot/DlmDIMxejg5Zt2r4Ir2L164UR5W9MBh4pZXvMITDBcoiPZSmXsGLs4M4jKG8dLL +driKXfODGAKQ04axoJ1A+q6SmC6c5r2BOaky7tEkSH26pvDCWOEx2st0M9TqOJNimue 2kzbeD3k/2dh81j+s7SDT58FYsqIbRdLkwbud3W1P3U0EcTQrd4l0m5nJNQ02caNWMSZ xiAd8wQ1CosE2lhtU+frq1GCxEXhTkU0eInObIflJXpz/ofWBP6LMwca6f+MTe640lNu QBhg== X-Gm-Message-State: AFeK/H2jSmMdk3sKjmo1PJ0G1vtGYeM8YGHR0qTpImA8/+X4aXnwXfeOVfWXl0QNROZ5Xg== X-Received: by 10.107.165.212 with SMTP id o203mr13663877ioe.129.1491173725271; Sun, 02 Apr 2017 15:55:25 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id b25sm6823886iod.32.2017.04.02.15.55.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Apr 2017 15:55:24 -0700 (PDT) In-Reply-To: <87a881ofsu.fsf@jane> (Marcin Borkowski's message of "Fri, 31 Mar 2017 13:18:25 +0200") 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:131233 Archived-At: Marcin Borkowski writes: > > OK, I pushed the branch "fix-bug-21072". Can anyone confirm that it's > ok and either merge it into master or tell me that I can do it? > > +** New macro 'elisp-tests-with-temp-buffer' > +which helps writing tests for functions that should change buffers in > +specific ways or manipulate point or mark positions. > + > +--- I don't this should be documented in NEWS since the macro is being added to a test file, so it's not part of Emacs' libraries. Also, the format of the NEWS entry is wrong in the same way as the next one (see below). > +With a prefix argument, it marks that many defuns or extends the > +region by the appropriate number of defuns. With negative prefix > +argument it marks defuns in the opposite direction and also changes > +the direction of selecting for subsequent uses of @code{mark-defun}. This doesn't say what exactly happens with zero as argument. The code seems to do something odd. Perhaps it should just be a user-error instead? Or maybe just a nop. > modified etc/NEWS > @@ -363,6 +363,15 @@ words where first character is upper rather than tit= le case, e.g., > "=C7=84ungla" instead of "=C7=85ungla". >=20=20 > > +** New behavior of 'mark-defun' implemented > +Prefix argument selects that many (or that many more) defuns. > +Negative prefix arg flips the direction of selection. Also, > +'mark-defun' between defuns correctly selects N following defuns (or > +-N previous for negative arguments). Finally, comments preceding the > +defun are selected unless they are separated from the defun by a blank > +line. > + > ++++ > * Changes in Specialized Modes and Packages in Emacs 26.1 >=20 This entry should go before the page separator, and the "+++" should go on the line just above the entry, not after it. > +(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)) > +(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))