From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.bugs Subject: bug#31204: 25.3; Make word motion more customizable Date: Wed, 18 Apr 2018 15:55:16 +0700 Message-ID: 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 1524041646 11536 195.159.176.226 (18 Apr 2018 08:54:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 18 Apr 2018 08:54:06 +0000 (UTC) To: 31204@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 18 10:54:02 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1f8iqn-0002pG-S3 for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Apr 2018 10:54:02 +0200 Original-Received: from localhost ([::1]:42037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8ist-0004hb-1Y for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Apr 2018 04:56:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8isl-0004hD-Ny for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 04:56:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8isk-0002SZ-7B for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 04:56:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f8isk-0002S5-32 for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 04:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f8isj-00024n-Qz for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 04:56:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuri Khan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Apr 2018 08:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31204 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15240417507961 (code B ref -1); Wed, 18 Apr 2018 08:56:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Apr 2018 08:55:50 +0000 Original-Received: from localhost ([127.0.0.1]:58447 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8isY-00024K-6v for submit@debbugs.gnu.org; Wed, 18 Apr 2018 04:55:50 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33414) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8isW-000247-6f for submit@debbugs.gnu.org; Wed, 18 Apr 2018 04:55:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8isP-0002Ef-C7 for submit@debbugs.gnu.org; Wed, 18 Apr 2018 04:55:43 -0400 Original-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 ) id 1f8isP-0002EZ-8W for submit@debbugs.gnu.org; Wed, 18 Apr 2018 04:55:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8isN-0004cC-I5 for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 04:55:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8isM-0002DV-7J for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 04:55:39 -0400 Original-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 ) id 1f8isL-0002D6-W4 for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 04:55:38 -0400 Original-Received: by mail-oi0-x22d.google.com with SMTP id e123-v6so880533oih.13 for ; 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) Original-Received: by 10.74.186.8 with HTTP; Wed, 18 Apr 2018 01:55:16 -0700 (PDT) X-Google-Sender-Auth: zHOic5qdM_X4BaThpzhwSEVAr0o 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-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: 208.118.235.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:145562 Archived-At: 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))