From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Sam Halliday Newsgroups: gmane.emacs.bugs Subject: bug#35119: 26.1; narrow-to-region loses word-start/symbol-start information at end Date: Wed, 3 Apr 2019 13:30:40 +0100 Message-ID: References: <87y34r1glv.fsf@gmail.com> <83a7h7e3ex.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="99821"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 35119@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 03 14:31:30 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBf3A-000PhF-8K for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Apr 2019 14:31:28 +0200 Original-Received: from localhost ([127.0.0.1]:33561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBf39-0004lJ-3N for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Apr 2019 08:31:27 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBf2l-0004hc-B5 for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2019 08:31:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBf2k-0008Lh-9n for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2019 08:31:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hBf2k-0008LL-2w for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2019 08:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hBf2j-0004rK-UK for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2019 08:31:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sam Halliday Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Apr 2019 12:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35119 X-GNU-PR-Package: emacs Original-Received: via spool by 35119-submit@debbugs.gnu.org id=B35119.155429465918670 (code B ref 35119); Wed, 03 Apr 2019 12:31:01 +0000 Original-Received: (at 35119) by debbugs.gnu.org; 3 Apr 2019 12:30:59 +0000 Original-Received: from localhost ([127.0.0.1]:42154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hBf2h-0004r4-3a for submit@debbugs.gnu.org; Wed, 03 Apr 2019 08:30:59 -0400 Original-Received: from mail-vs1-f51.google.com ([209.85.217.51]:46115) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hBf2f-0004qo-6D for 35119@debbugs.gnu.org; Wed, 03 Apr 2019 08:30:57 -0400 Original-Received: by mail-vs1-f51.google.com with SMTP id e2so9125465vsc.13 for <35119@debbugs.gnu.org>; Wed, 03 Apr 2019 05:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IxGE2bTvttQOgQRJTrfLBKnLrqIJH/yzmTAbwTIRPzs=; b=VPrlomgr1t2mdrTr2q4Bd7NIKh4s6nTdTgf3GK8lOwGk8BQ308SuzBQXOI+B/V7/OU IXaBDJSPO2ssYg4/vTySo452qx34vN1KOC6cXQJPWer4pqeFD8PxVFF4Jv5pJ/aMBM0N dPi38dbbq9qXTDmXqqwI/WP1K657BSzhPqQbpCj6eZj3YntjJGjJ1TXYvgX7FJmcilBD FzOnjBXQr4cvFe97QGmr2ALvKiToN69jrgUBVRXMBY9sMstSMS336OmpJTw+uZZo+0oh py8YN0ojL20EF8y3IaGu7gWYeObsJ8EOIqbRZf68M3dI0GKJhYCrL7gWOvzMZ2Tfnj9t RNHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IxGE2bTvttQOgQRJTrfLBKnLrqIJH/yzmTAbwTIRPzs=; b=jLFg+J+4DT5Z6MvAFuyn1aB8scSArZ05gWbZpBU2LWGBzBmc21hRGVP1fpDGRV25KA jrHT/QkGhSEPcUIh1aZiddmbUKhIueAKVfLHB3k8IGYPLlc5nqyz3Nk3ygny9biRPicd AgrMN9xvNO30trpvyAjqW9TL+VDJTxFLM2C0eWZoGiHxaLL1UtkieUeh/nFVvnFrNx9O ntwPIT5GNLQVCcHleDlSpcwLoIM9YHHOJxk2uF+V7o1nUqgf6BhYpoEiL29ktxhy2ry7 KNpiCW8/sG00lWn/HlUTPd6EqfYj/NZorMhY2CZQm3mIlROKeFJW+s7gAwhQjr40EVP6 73nw== X-Gm-Message-State: APjAAAXMpPfHwTNtDyRh18mXOJ08WNE557EFPYKSL+K47F23wVjPQkiH kT9ZBT/2KQKa412RoPR2WS0XCXXAf9Do+zUA5b8= X-Google-Smtp-Source: APXvYqw/3QHRiw019w2aVkM5bq+FPMHP0GtbUmzDSFZAaAyI7NlarB+vn39/WA5ThPgl9odv83p/DF4gFxZAxycBSDg= X-Received: by 2002:a05:6102:3c2:: with SMTP id n2mr45294562vsq.41.1554294651400; Wed, 03 Apr 2019 05:30:51 -0700 (PDT) In-Reply-To: <83a7h7e3ex.fsf@gnu.org> 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: 209.51.188.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:157119 Archived-At: Hi Eli, Sorry that was a terrible bug report. This impacts me in `looking-back'. Here's an interactive snippet to demonstrate the problem (not minimised to`narrow-to-region'): (defun look-for-35119 () (interactive) (if (looking-back (rx (: word-end ":" word-start)) ;;(rx (: word-end ":")) (- (point) 1) 't) (message "hit") (message "miss"))) in emacs-lisp-mode, which defines : as non-word, interactively evaluate look-for-35119 when the point is just after the colon in this example text wibble:wobble I would expect to see "hit", but we get "miss". To demonstrate that the word-start is the cause of the problem, try the commented regexp and try again, you'll get "hit" but of course this regexp is not what is intended. For example, it would also match in between :: in the following: wibble::wobble The cause is that the `narrow-to-region' call inside `looking-back' is dropping the word-start zero length match at the beginning of wobble. This may or may not be a bug in narrow-to-region, but I'm quite sure it's a bug in `looking-back'. There is most likely a similar example demonstrating that the zero lengths are missing at the start as well as the end. I've tried playing around with multiple alternative implementations of `looking-back' but none are working for me. Probably the best workaround I can think of is to extend the `narrow-to-region' call by one more character at the start and the end. Dealing with the start is easy, we just goto-char limit+1, but dealing with the end is difficult as we need to put an anychar \\. matcher in the doctored regexp and then the match-end is off-by-one from what the user expects, so then we have to doctor that, and then all hell breaks loose. Does that make sense? On Wed, 3 Apr 2019 at 12:25, Eli Zaretskii wrote: > > > From: Sam Halliday > > Date: Wed, 03 Apr 2019 12:19:08 +0100 > > > > If the function `narrow-to-region' (as it is in `looking-back') is used > > to restrict the region prior to an invocation of re-search-forward or > > looking-at, then zero length regexp patterns are lost at the boundaries. > > Could you please provide a recipe to reproduce the issue? I'm not > sure I understand what is the problem you are describing. > > Thanks.