From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Koning Newsgroups: gmane.emacs.bugs Subject: bug#41761: [PATCH] bug#41761: 28.0.50; M-x count-words counts words only up to a field boundary Date: Sun, 16 Aug 2020 14:04:14 -0500 Message-ID: References: <87y2oxwldi.fsf@gmail.com> <83imdllc2l.fsf@gnu.org> <834kp5kpj1.fsf@gnu.org> <838sefkh5t.fsf@gnu.org> <831rk7kdfo.fsf@gnu.org> <83pn7qiss9.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38242"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (darwin) Cc: stefan@marxist.se, 41761@debbugs.gnu.org, pipcet@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 16 21:05:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k7Nxu-0009mz-SH for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Aug 2020 21:05:10 +0200 Original-Received: from localhost ([::1]:56866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k7Nxt-0006yk-UY for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Aug 2020 15:05:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k7Nxm-0006yd-Gr for bug-gnu-emacs@gnu.org; Sun, 16 Aug 2020 15:05:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k7Nxm-0001sS-6n for bug-gnu-emacs@gnu.org; Sun, 16 Aug 2020 15:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k7Nxl-0005BO-W9 for bug-gnu-emacs@gnu.org; Sun, 16 Aug 2020 15:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Koning Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Aug 2020 19:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41761 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 41761-submit@debbugs.gnu.org id=B41761.159760467319884 (code B ref 41761); Sun, 16 Aug 2020 19:05:01 +0000 Original-Received: (at 41761) by debbugs.gnu.org; 16 Aug 2020 19:04:33 +0000 Original-Received: from localhost ([127.0.0.1]:58497 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k7NxJ-0005Ae-4u for submit@debbugs.gnu.org; Sun, 16 Aug 2020 15:04:33 -0400 Original-Received: from sender4-of-o56.zoho.com ([136.143.188.56]:21604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k7NxF-0005AU-Fo for 41761@debbugs.gnu.org; Sun, 16 Aug 2020 15:04:31 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1597604664; cv=none; d=zohomail.com; s=zohoarc; b=H6YmWykQjwxsbzl4uO7PVP6rxTqhzf88tYv74BbsiS0DkdzqxxnFTO38ea65bMK2vUOZ3LPt6WUIUBsBa2I8tLktFFmnarL7wtsoPF925pM2JFhDFdH1leqBSNVaROO6h1BhljcOsRyEHe9a4dqXKmOsIsTYga6r8xSO8L9LXSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597604664; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=4iImr6XAeald/cdJJuBzgEPU9FA8D72becseNeWe+Y0=; b=ExBycMxG1RxhD8vdlcbiAPtLRYAwDYkBS3cBBD8dGehXDdG9Z7yBPli6/nrApVqi/ksGauexitw+mHEv/lmLRKGGi54XJyxjumoCuveimiBQP+XitFdTnAkBJBwtnZnszuOjxeg9M6phuU+bwYxceJDokaR7kMUogDuPb/K5JWM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass smtp.mailfrom=dk@danielkoning.com; dmarc=pass header.from= header.from= Original-Received: from cornelius (112.157.239.35.bc.googleusercontent.com [35.239.157.112]) by mx.zohomail.com with SMTPS id 1597604661309337.5289904670534; Sun, 16 Aug 2020 12:04:21 -0700 (PDT) In-Reply-To: <83pn7qiss9.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 16 Aug 2020 17:12:22 +0300") X-ZohoMailClient: External X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:185334 Archived-At: Eli Zaretskii writes: >> I do think the prior behavior differs somewhat from the way you phrased >> it. I would write it as: >> >> Originally, when 'inhibit-field-text-motion' was nil, 'count-words' >> stopped counting words at the end of the field containing START. >> >> (It didn't ignore text inside fields, but rather text that was not >> inside one specific field.) > > I'm not sure I understand the "end of field containing START" part. > Supposed the region includes several fields, what would the previous > code do? It would only count the words between START and the next field boundary, no matter how many fields came after that. (For START, substitute "the beginning of the region" or "the beginning of the buffer" if it was called interactively.) Try reinstalling the old function definition and evaluating: ELISP> (with-temp-buffer (dotimes (i 9) (insert (propertize "4 words 22 characters " 'field i))) (insert "\n4 words 22 characters") (call-interactively #'count-words)) ; operates on whole buffer => "Buffer has 2 lines, 4 words, and 220 characters." That result arises because of how `count-words' generates its return value: it moves point to the beginning of the buffer (after narrowing the buffer to START and END if they were supplied), then repeatedly calls `forward-word-strictly' until that function returns nil, incrementing the running total each time. Before, if it ran into a field boundary, it would stop short, because `forward-word-strictly' doesn't jump field boundaries by default. I think the value of that form demonstrates why the old behavior was wrong. There does not exist any part of the temp buffer that "has 2 lines, 4 words, and 220 characters." It gives inconsistent results because the line count and character count use techniques which aren't affected by fields. Daniel