GNU bug report logs - #31204
25.3; Make word motion more customizable

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Yuri Khan <yuri.v.khan@HIDDEN>; Keywords: wontfix moreinfo; Done: Lars Ingebrigtsen <larsi@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
bug closed, send any further explanations to 31204 <at> debbugs.gnu.org and Yuri Khan <yuri.v.khan@HIDDEN> Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 31204 <at> debbugs.gnu.org:


Received: (at 31204) by debbugs.gnu.org; 15 Jun 2022 15:03:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 15 11:03:30 2022
Received: from localhost ([127.0.0.1]:39405 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o1UYL-0008WJ-V9
	for submit <at> debbugs.gnu.org; Wed, 15 Jun 2022 11:03:30 -0400
Received: from quimby.gnus.org ([95.216.78.240]:35688)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1o1UYK-0008W3-0L
 for 31204 <at> debbugs.gnu.org; Wed, 15 Jun 2022 11:03:28 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID
 :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=u7KuRo2v4ruZmIolDvsyrb4LDtZifFy0hUzLWZ20+0Y=; b=Z+6iDJQ2uZ1VXymdbJ7cIzJZdl
 7D+Sqnx0KtG53YpM8B6n9C9R0+H0Y7GeyRwFyqtaDK9W6tg8BvVeATVbIv1+ij3Qy5mteZkOoZKRo
 /7mIoYLHMSGfM0uA/sqmMgDyj4MbAjRtvyw+hSmtB3Gpo3Rr8pvEDmN3kkTM0e64OJhs=;
Received: from [84.212.220.105] (helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1o1UYA-0003wC-Qy; Wed, 15 Jun 2022 17:03:21 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Yuri Khan <yuri.v.khan@HIDDEN>
Subject: Re: bug#31204: 25.3; Make word motion more customizable
References: <CAP_d_8UvVdeVngKSe1A2_mB5p5wHhhhWLzTP7VnAs=jZQqOxpg@HIDDEN>
 <875ym3dp41.fsf@HIDDEN>
X-Now-Playing: The Wake's _Harmony & Singles_: "Here Comes Everybody"
Date: Wed, 15 Jun 2022 17:03:16 +0200
In-Reply-To: <875ym3dp41.fsf@HIDDEN> (Lars Ingebrigtsen's message of "Wed,
 18 May 2022 14:03:42 +0200")
Message-ID: <87o7yugea3.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 
 Content preview:  Lars Ingebrigtsen <larsi@HIDDEN> writes: >> As an illustration
    (where ‘|’ specifies word motion stops when going >> left to right):
   >> >> foo| ***| +++| (|bar|)| [...] 
 
 Content analysis details:   (-2.9 points, 5.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
                             [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 31204
Cc: 31204 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Lars Ingebrigtsen <larsi@HIDDEN> writes:

>> As an illustration (where =E2=80=98|=E2=80=99 specifies word motion stop=
s when going
>> left to right):
>>
>>     foo| ***| +++| (|bar|)|

[...]

> I think this sounds like it could be useful.  If we added such a hook to
> `forward-word', what would the rest of the code look like to make
> `C-<right>' work this way?

I've played a bit at the patch below, but I tend to think that this is
going about things the wrong way.  That is, for something like this to
work meaningfully, it would require a lot of setup (because
Vfind_word_boundary_function_table) would also have to be altered in
conjunction with this.

I.e., it's really about changing the definition of what a "word" is, and
in that case, I think it would be easier to just do that in a syntax
table, and then everything would work automatically.

(Or by advising the functions here.)

So I don't think it'd be worth it to proceed with something like the
below, and I'm therefore closing this bug report.

diff --git a/src/syntax.c b/src/syntax.c
index f9022d18d2..02d4dd4b9a 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1462,20 +1462,33 @@ scan_words (ptrdiff_t from, EMACS_INT count)
=20
   while (count > 0)
     {
-      while (true)
+      if (!NILP (Vfind_word_start_function))
 	{
-	  if (from =3D=3D end)
+	  Lisp_Object np =3D call2 (Vfind_word_start_function,
+				  make_fixnum (from), make_fixnum (end));
+	  if (!FIXNUMP (np))
 	    return 0;
-	  UPDATE_SYNTAX_TABLE_FORWARD (from);
+	  from =3D XFIXNUM (np);
+	  from_byte =3D CHAR_TO_BYTE (from);
 	  ch0 =3D FETCH_CHAR_AS_MULTIBYTE (from_byte);
-	  code =3D SYNTAX (ch0);
-	  inc_both (&from, &from_byte);
-	  if (words_include_escapes
-	      && (code =3D=3D Sescape || code =3D=3D Scharquote))
-	    break;
-	  if (code =3D=3D Sword)
-	    break;
-	  rarely_quit (from);
+	}
+      else
+	{
+	  while (true)
+	    {
+	      if (from =3D=3D end)
+		return 0;
+	      UPDATE_SYNTAX_TABLE_FORWARD (from);
+	      ch0 =3D FETCH_CHAR_AS_MULTIBYTE (from_byte);
+	      code =3D SYNTAX (ch0);
+	      inc_both (&from, &from_byte);
+	      if (words_include_escapes
+		  && (code =3D=3D Sescape || code =3D=3D Scharquote))
+		break;
+	      if (code =3D=3D Sword)
+		break;
+	      rarely_quit (from);
+	    }
 	}
       /* Now CH0 is a character which begins a word and FROM is the
          position of the next character.  */
@@ -3792,6 +3805,12 @@ syms_of_syntax (void)
 In both cases, LIMIT bounds the search. */);
   Vfind_word_boundary_function_table =3D Fmake_char_table (Qnil, Qnil);
=20
+  DEFVAR_LISP ("find-word-start-function",
+	       Vfind_word_start_function,
+	       doc: /* Function called to find the start of a word.
+It's called with two parameters, POS and LIMIT.  */);
+  Vfind_word_start_function =3D Qnil;
+
   DEFVAR_BOOL ("comment-end-can-be-escaped", comment_end_can_be_escaped,
                doc: /* Non-nil means an escaped ender inside a comment doe=
sn't end the comment.  */);
   comment_end_can_be_escaped =3D false;


--=20
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#31204; Package emacs. Full text available.
Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 31204 <at> debbugs.gnu.org:


Received: (at 31204) by debbugs.gnu.org; 18 May 2022 12:03:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed May 18 08:03:56 2022
Received: from localhost ([127.0.0.1]:59229 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nrIPD-0007x7-Lt
	for submit <at> debbugs.gnu.org; Wed, 18 May 2022 08:03:56 -0400
Received: from quimby.gnus.org ([95.216.78.240]:38374)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1nrIPB-0007ws-7F
 for 31204 <at> debbugs.gnu.org; Wed, 18 May 2022 08:03:54 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID
 :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=9BBGHnDSAzb++c4NsNE+v+Pqe0eJFs5UkNfAbmCpOPg=; b=lSNAVzqJlmxqSUQ338GhxYvMeR
 lFNCAh++/7+yleq2knL1GsGUQSRMCsm6gocRTm3KjzOg/A8wUH6AEcBHN9LT9J1IdByN7yAn3lELp
 5gOh8P3LTqJwIzKrEgrtUtJcKoy0SEyHyrPm8XOTrOGSUJqauX+PXaBW8G8O2ZvNJMGU=;
Received: from [84.212.220.105] (helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1nrIP1-0006vf-G3; Wed, 18 May 2022 14:03:46 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Yuri Khan <yuri.v.khan@HIDDEN>
Subject: Re: bug#31204: 25.3; Make word motion more customizable
References: <CAP_d_8UvVdeVngKSe1A2_mB5p5wHhhhWLzTP7VnAs=jZQqOxpg@HIDDEN>
X-Now-Playing: Richard and Linda Thompson's _Hard Luck Stories (5): The
 Madness of Love: Live 1975 & 1977_: "The Madness Of Love (Live At The
 Theatre Royal, London 01.05.1977)"
Date: Wed, 18 May 2022 14:03:42 +0200
In-Reply-To: <CAP_d_8UvVdeVngKSe1A2_mB5p5wHhhhWLzTP7VnAs=jZQqOxpg@HIDDEN>
 (Yuri Khan's message of "Wed, 18 Apr 2018 15:55:16 +0700")
Message-ID: <875ym3dp41.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Yuri Khan <yuri.v.khan@HIDDEN> writes: > While trying to
 make word motion commands (Ctrl+left/right, M-f/b) more > similar to that
 implemented in other editors: > >
 http://lists.gnu.org/archive/html/help-gnu-emacs/2018-04/msg00230.html
 > > [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 31204
Cc: 31204 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Yuri Khan <yuri.v.khan@HIDDEN> writes:

> While trying to make word motion commands (Ctrl+left/right, M-f/b) more
> similar to that implemented in other editors:
>
> http://lists.gnu.org/archive/html/help-gnu-emacs/2018-04/msg00230.html
>
> I encountered a difficulty.

[...]

> Step 1, on the other hand, is not customizable at all.
>
> The specific behavior that I was trying to implement was to find the
> nearest transition:
>
> * from a word character to a non-word character, OR
> * from a non-word non-whitespace character to a word character, OR
> * from a non-word non-whitespace character to a whitespace character.
>
> As an illustration (where =E2=80=98|=E2=80=99 specifies word motion stops=
 when going
> left to right):
>
>     foo| ***| +++| (|bar|)|
>        ^

[...]

> Perhaps it would be nice to have an optional hook for step 1 of
> =E2=80=98forward-word=E2=80=99, a function that would take two arguments =
POS and LIMIT,
> and returning the starting word boundary position from which step 2 would
> then work.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I think this sounds like it could be useful.  If we added such a hook to
`forward-word', what would the rest of the code look like to make
`C-<right>' work this way?

--=20
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#31204; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Apr 2018 08:55:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 18 04:55:50 2018
Received: from localhost ([127.0.0.1]:58447 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1f8isY-00024K-6v
	for submit <at> debbugs.gnu.org; Wed, 18 Apr 2018 04:55:50 -0400
Received: from eggs.gnu.org ([208.118.235.92]:33414)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yurivkhan@HIDDEN>) id 1f8isW-000247-6f
 for submit <at> debbugs.gnu.org; Wed, 18 Apr 2018 04:55:48 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <yurivkhan@HIDDEN>) id 1f8isP-0002Ef-C7
 for submit <at> debbugs.gnu.org; Wed, 18 Apr 2018 04:55:43 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:32942)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <yurivkhan@HIDDEN>) id 1f8isP-0002EZ-8W
 for submit <at> debbugs.gnu.org; Wed, 18 Apr 2018 04:55:41 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52590)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <yurivkhan@HIDDEN>) id 1f8isN-0004cC-I5
 for bug-gnu-emacs@HIDDEN; Wed, 18 Apr 2018 04:55:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <yurivkhan@HIDDEN>) id 1f8isM-0002DV-7J
 for bug-gnu-emacs@HIDDEN; Wed, 18 Apr 2018 04:55:39 -0400
Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:47008)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <yurivkhan@HIDDEN>) id 1f8isL-0002D6-W4
 for bug-gnu-emacs@HIDDEN; Wed, 18 Apr 2018 04:55:38 -0400
Received: by mail-oi0-x22d.google.com with SMTP id e123-v6so880533oih.13
 for <bug-gnu-emacs@HIDDEN>; Wed, 18 Apr 2018 01:55:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:sender:from:date:message-id:subject:to
 :content-transfer-encoding;
 bh=soiIjgzG6EAAFOdLcIbeo70NB2h4Z/thJm8GZZFaxwc=;
 b=hyHe9alp1uM3Qsr998HR55B56Jx5ZJk44rBYaRm7apR0PSAAlpS+gpMTc90+YH/QZF
 pcNP8IMMKp9M2IvBD6N6CYu4DwchkZZCzbXiUM2+Q3Izyp7xEJY/0Lf23n7Bnr91W7Q/
 ZoSFXCaRPDEd2q4SJ0u6bcd6pgO4UAYCdlyPYs01F5MQoDVanq7KhARdueSEX7q7Q4Ly
 Dnuvk4qT81gm17dpcvjrW/u4tK2z9Gr4Dk63/PAjzHq+RiN4obooggog5kmFACiBq/Bs
 LJA8VvMN9SLmYSDY0uXCaINesN+p2lLEJSviZoID8Z9a2kEcilCrAFeyiHMhkaFxe6DC
 J28w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:sender:from:date:message-id:subject
 :to:content-transfer-encoding;
 bh=soiIjgzG6EAAFOdLcIbeo70NB2h4Z/thJm8GZZFaxwc=;
 b=uCanRYywu5+UtsojKqR4a8/XZjQt4kBwyuO8034kXiIZnD7MpCSNf01/llPLgvr5Ef
 x7yHYASmqCRMtcm1dWQ6tpAu1EdWuLk92VH6zha7jRq8nUCKNXN0iwNrDVp3RoavU9vL
 /AzrcFkJyXJGRCFKKzm5wXvf9n5zk4rkDDsiz1SqtGH2kR0ix2Gd34qvsrpksiIwZTTW
 FnaorKjl98tH2WUreIWulDUuB9usXBdw26GLeAqP4HbnkVEQabFPfw+N9EFpEZky7w0R
 Nss/AUmrpnGmmG2/DPiM8+K/DPog1z3a9Z208R/V1WMo4jgqILnHtWJfFLdBWeSk8Jou
 ROKw==
X-Gm-Message-State: ALQs6tC80Dl8flYPSxUqM0PL5XEIhOR7cG7MamZ1Nz4X9b1JqhgN06D+
 wCnNiiddSqtiTQC4aFqtCrnCN51QN9Fp0hsx8iqSPg==
X-Google-Smtp-Source: AIpwx48lNqzQYyt6mKlUJ7FErsCoNL6KlrQP2v2+Sx3Q9804+30a28THfW9FHyGoRufx8XDuIjXc9ZmFQMwuooiukAk=
X-Received: by 2002:aca:f03:: with SMTP id 3-v6mr643706oip.191.1524041736945; 
 Wed, 18 Apr 2018 01:55:36 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.74.186.8 with HTTP; Wed, 18 Apr 2018 01:55:16 -0700 (PDT)
From: Yuri Khan <yuri.v.khan@HIDDEN>
Date: Wed, 18 Apr 2018 15:55:16 +0700
X-Google-Sender-Auth: zHOic5qdM_X4BaThpzhwSEVAr0o
Message-ID: <CAP_d_8UvVdeVngKSe1A2_mB5p5wHhhhWLzTP7VnAs=jZQqOxpg@HIDDEN>
Subject: 25.3; Make word motion more customizable
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

While trying to make word motion commands (Ctrl+left/right, M-f/b) more
similar to that implemented in other editors:

http://lists.gnu.org/archive/html/help-gnu-emacs/2018-04/msg00230.html

I encountered a difficulty.

The function =E2=80=98forward-word=E2=80=99 behaves as follows:

1. Skip to the nearest character having word constituent syntax.
2. Skip to the nearest word boundary.

Step 2, by default, finds:

* a non-word-constituent character, OR
* a transition between two adjacent characters of different scripts
  (subject to exceptions controlled by =E2=80=98word-combining-categories=
=E2=80=99 and
  =E2=80=98word-separating-categories=E2=80=99),

whichever comes first.

Step 2 can also be customized by modifying
=E2=80=98find-word-boundary-function-table=E2=80=99. This enables various u=
seful
behaviors such as =E2=80=98subword-mode=E2=80=99, =E2=80=98superword-mode=
=E2=80=99, and possibly CJK
word breaking rules.

Step 1, on the other hand, is not customizable at all.


The specific behavior that I was trying to implement was to find the
nearest transition:

* from a word character to a non-word character, OR
* from a non-word non-whitespace character to a word character, OR
* from a non-word non-whitespace character to a whitespace character.

As an illustration (where =E2=80=98|=E2=80=99 specifies word motion stops w=
hen going
left to right):

    foo| ***| +++| (|bar|)|
       ^

When cursor is after =E2=80=98foo=E2=80=99, step 1 of =E2=80=98forward-word=
=E2=80=99 skips to directly
before =E2=80=98bar=E2=80=99, missing two stops.

As a result, implementing the desired behavior requires either:

* defining separate functions =E2=80=98my-forward-word=E2=80=99, =E2=80=98m=
y-backward-word=E2=80=99,
  =E2=80=98my-left-word=E2=80=99, =E2=80=98my-right-word=E2=80=99, =E2=80=
=98my-kill-word=E2=80=99,
  =E2=80=98my-backward-kill-word=E2=80=99, and possibly more, and remapping=
 their key
  bindings; OR

* advising =E2=80=98forward-word=E2=80=99 with an :override.


Perhaps it would be nice to have an optional hook for step 1 of
=E2=80=98forward-word=E2=80=99, a function that would take two arguments PO=
S and LIMIT,
and returning the starting word boundary position from which step 2 would
then work.


In GNU Emacs 25.3.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2017-09-13 built on lcy01-32
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description:    Ubuntu 16.04.4 LTS

Configured using:
 'configure --build=3Dx86_64-linux-gnu --prefix=3D/usr
 '--includedir=3D${prefix}/include' '--mandir=3D${prefix}/share/man'
 '--infodir=3D${prefix}/share/info' --sysconfdir=3D/etc --localstatedir=3D/=
var
 --disable-silent-rules '--libdir=3D${prefix}/lib/x86_64-linux-gnu'
 '--libexecdir=3D${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
 --disable-dependency-tracking --prefix=3D/usr --sharedstatedir=3D/var/lib
 --program-suffix=3D25 --with-modules --with-x=3Dyes --with-x-toolkit=3Dgtk=
3
 'CFLAGS=3D-g -O2 -fstack-protector-strong -Wformat
 -Werror=3Dformat-security' 'CPPFLAGS=3D-Wdate-time -D_FORTIFY_SOURCE=3D2'
 'LDFLAGS=3D-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

Important settings:
  value of $LC_MONETARY: en_US.UTF-8
  value of $LC_NUMERIC: en_US.UTF-8
  value of $LC_TIME: en_DK.utf8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode easymenu
cl-loaddefs pcase cl-lib mail-prsvr mail-utils time-date mule-util
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind inotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 86338 5928)
 (symbols 48 19769 0)
 (miscs 40 49 121)
 (strings 32 14363 4733)
 (string-bytes 1 409522)
 (vectors 16 11755)
 (vector-slots 8 430899 3852)
 (floats 8 166 64)
 (intervals 56 231 0)
 (buffers 976 18)
 (heap 1024 33279 1050))




Acknowledgement sent to Yuri Khan <yuri.v.khan@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#31204; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 15 Jun 2022 15:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.