From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mO2nNnM8uF5zFgAA0tVLHw (envelope-from ) for ; Sun, 10 May 2020 17:40:03 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id eD1xH4E8uF6DLgAAbx9fmQ (envelope-from ) for ; Sun, 10 May 2020 17:40:17 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2336B940F47 for ; Sun, 10 May 2020 17:40:14 +0000 (UTC) Received: from localhost ([::1]:42230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXpvx-0001u1-Fz for larch@yhetil.org; Sun, 10 May 2020 13:40:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXpvV-0001tX-7e for emacs-orgmode@gnu.org; Sun, 10 May 2020 13:39:45 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:49621) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXpvS-00009Y-H6 for emacs-orgmode@gnu.org; Sun, 10 May 2020 13:39:44 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6AF7B4FF; Sun, 10 May 2020 13:39:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 10 May 2020 13:39:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imapmail.org; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm3; bh=NycbrC0kDVCa+Jig8JndKGBltb +BQzFBPcD5coKF40s=; b=TAigB9ZrSIcBRhyw/S3zkwXPucHyheibKdVfDuxfVB yo55aoCTTYuJAYjYNBOdvSIfhUj4FDY1HYNIOtS4C1AmYBq/RWL4FfT3TfeDRwgk XvQ9t6VIqtq7/28eZWuRhiPghjrhtfsTdTt746G1Gqgty6cuUdPedB0jxR4Wt8Wz lUa9e9TEBCeXFl/PZIQAGxnzv+tj/hoYvN9xgXgMJ76pWli2esCXNJ7nllv9rd85 9E4FzUx8fHx0mkIbvE31dUKdBc/g7ZHSoRiMNycPVfnLVkf9r0SOc201OqDiM3p3 BEIjk994xAqaQz2wzoyiM0lxTP++EVpS14D98jxCXjxQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=NycbrC 0kDVCa+Jig8JndKGBltb+BQzFBPcD5coKF40s=; b=s1KNkWMoCRV6ZHwsFj0CML INqvB+GzQp2TOTL4KOgSDM0M0ZdGQxe6YLiCedbndAEtOVbcTBNA7ByqPJmcw2dv /q3ra3AIZcnAseE/OU771BwGkatYSIxY4rhQEUBYgsa3NxvPhHZFiInvz9mSJMwD 6IBXz1h63ZjMNR+6bkZ11cYor45hNdI2+lZ6SUhCSthr66mSqr1DfowfRWvQhD8U Cl0KghjWWEBjg6/TI4ow1zWRjd2bQHuDjT2xJidMzIHsYN4nqc7Oq9LFOFEphWe2 KUz26ZPC4gMFCJVNuxSadza2m85zEt+RbKrzhM4aZJhUWXaO439wzVQr8zIivZvA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrkeekgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufgjfhffkfggtgesthdtredttddttdenucfhrhhomhepofgrthhthhgv ficunfhunhguihhnuceomhgulhesihhmrghpmhgrihhlrdhorhhgqeenucggtffrrghtth gvrhhnpeevffegjeffhedvgfevgfelvddvjeeigeffgfevuedvleekiedvgffggfegueeh heenucfkphepjeeirdduiedrudefhedrudduleenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmughlsehimhgrphhmrghilhdrohhrgh X-ME-Proxy: Received: from localhost (c-76-16-135-119.hsd1.il.comcast.net [76.16.135.119]) by mail.messagingengine.com (Postfix) with ESMTPA id 6E3BF3280063; Sun, 10 May 2020 13:39:38 -0400 (EDT) From: Matthew Lundin To: Nicolas Goaziou Subject: Re: [PATCH] Fix moving cursor in org-set-tags-command In-Reply-To: <87ftca6ewc.fsf@nicolasgoaziou.fr> References: <871rnvi8g6.fsf@fastmail.fm> <87ftca6ewc.fsf@nicolasgoaziou.fr> Date: Sun, 10 May 2020 12:39:37 -0500 Message-ID: <87o8qvaduu.fsf@fastmail.fm> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=64.147.123.20; envelope-from=mdl@imapmail.org; helo=wout4-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 13:39:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org Mode List Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: -1.71 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=imapmail.org header.s=fm3 header.b=TAigB9Zr; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=s1KNkWMo; dmarc=pass (policy=none) header.from=imapmail.org; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.71 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.53895336153207]; DWL_DNSWL_FAIL(0.00)[209.51.188.17:server fail,imapmail.org:server fail]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; FREEMAIL_FROM(0.00)[imapmail.org]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.08), country: US(-0.00), ip: 209.51.188.17(-0.54)]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[imapmail.org,none]; DKIM_TRACE(0.00)[imapmail.org:+,messagingengine.com:+]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[76.16.135.119:received]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[mdl@imapmail.org,emacs-orgmode-bounces@gnu.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[imapmail.org:s=fm3,messagingengine.com:s=fm2]; URIBL_BLOCKED(0.00)[messagingengine.com:dkim,nicolasgoaziou.fr:email,imapmail.org:dkim]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; DNSWL_BLOCKED(0.00)[209.51.188.17:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.51.188.17:from]; RCVD_COUNT_SEVEN(0.00)[7]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: eLuAI93rydOd Nicolas Goaziou writes: > >> - (when (save-excursion (skip-chars-backward "*") (bolp)) >> - (forward-char)))) >> + (and (looking-at " ") >> + (string-match "\\*+" (buffer-substring (point-at-bol) (point))) >> + (forward-char)))) > > Please replace `and' with `when' if side-effects are involved. > Thanks, this is really helpful to know for future patches. And thanks so much for the fixes you and Kyle made. > Also, note that > > (save-excursion (skip-chars-backward "*") (bolp)) > > is faster and more accurate than > > (string-match "\\*+" (buffer-substring (point-at-bol) (point))) > > because the latter matches, e.g., > > ab*|c > > where "|" is point. Oops, yes I see the problem in the string-match there! > Besides, I don't understand how this is related to empty headlines > since, AFAICT, this part of code is supposed to fix the issue on empty > headlines. Thanks. What I meant was fixing a very specific circumstance "when the cursor is at the beginning of an empty headline." This is the scenario affected by the original bug. The earlier patches (450452de4b and 44ec473c1) introduced a more general logic of moving the cursor forward at any point before the beginning of an empty headline (including when positioned on an asterisk). I see the commit has already been made, so hopefully this email will serve as clarification. Best, Matt