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.devel Subject: Re: bug#21072: Brave new mark-defun (and a testing tool) Date: Sun, 02 Apr 2017 18:56:46 -0400 Message-ID: <87k272wh8x.fsf@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 1491173744 24877 195.159.176.226 (2 Apr 2017 22:55:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 2 Apr 2017 22:55:44 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: Eli Zaretskii , 21072@debbugs.gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Marcin Borkowski Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 03 00:55:37 2017 Return-path: Envelope-to: ged-emacs-devel@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 1cuoPE-0005EW-Lo for ged-emacs-devel@m.gmane.org; Mon, 03 Apr 2017 00:55:32 +0200 Original-Received: from localhost ([::1]:56492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuoPH-00086T-FL for ged-emacs-devel@m.gmane.org; Sun, 02 Apr 2017 18:55:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuoPB-00086D-C4 for emacs-devel@gnu.org; Sun, 02 Apr 2017 18:55:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuoP8-0005BC-8L for emacs-devel@gnu.org; Sun, 02 Apr 2017 18:55:29 -0400 Original-Received: from mail-io0-x22b.google.com ([2607:f8b0:4001:c06::22b]:33114) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuoP8-0005AQ-28; Sun, 02 Apr 2017 18:55:26 -0400 Original-Received: by mail-io0-x22b.google.com with SMTP id f84so65411311ioj.0; Sun, 02 Apr 2017 15:55:25 -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=JF+LdX3UABepOIZUhFN5+GDrK9+5DyDSlNFLefZAY8YaPVBCG5FN+FNhWBGv5+ZHrV nNwjnXOG6tzk6kYMqw/0U9uPyIniBWhmsssrjBha82eO1rdAZX6xADbD7Zo+lIU0bb24 pH47G3THQFQ19gDsbsuu+WFpj4GP5TNMZ6koqnZsjQncPB6BkReUXF9OM5ooJPIAtKPR BIpj+MnzDOPj25tNpX3RWL49umaSSHZ6bAjX5+oTIDZBLlNaX5uVHXNeFBVZliaLMvzA Yc4miRkzyJrC0ZJgTgsPAb9Qtj8BhuDUbqnMOFKH10G5fPmSe5qLgfxmy4GjiMxJlN3R WyTg== X-Gm-Message-State: AFeK/H0TlC14x3M6WQJkqLoQBYaZ0TRLwUtZHXJQB8f+SWjQ/BcJlNrCsQwiLXW16w25AQ== 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-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c06::22b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:213603 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))