From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Drummond Newsgroups: gmane.emacs.help Subject: Understanding Word Boundaries Date: Wed, 16 Jun 2010 11:44:41 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016e6d26595f1f70604892369ab X-Trace: dough.gmane.org 1276718916 14689 80.91.229.12 (16 Jun 2010 20:08:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 16 Jun 2010 20:08:36 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 16 22:08:34 2010 connect(): No such file or directory Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OOyuV-0004XO-GC for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Jun 2010 22:08:31 +0200 Original-Received: from localhost ([127.0.0.1]:33321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOyfr-00025n-OD for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Jun 2010 15:53:24 -0400 Original-Received: from [140.186.70.92] (port=55865 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOq7I-0006w0-81 for help-gnu-emacs@gnu.org; Wed, 16 Jun 2010 06:45:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOq7G-00034N-6c for help-gnu-emacs@gnu.org; Wed, 16 Jun 2010 06:45:08 -0400 Original-Received: from mail-yw0-f187.google.com ([209.85.211.187]:62041) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOq7F-00034B-UK for help-gnu-emacs@gnu.org; Wed, 16 Jun 2010 06:45:06 -0400 Original-Received: by ywh17 with SMTP id 17so588951ywh.1 for ; Wed, 16 Jun 2010 03:45:01 -0700 (PDT) Original-Received: by 10.101.10.16 with SMTP id n16mr6877609ani.92.1276685101168; Wed, 16 Jun 2010 03:45:01 -0700 (PDT) Original-Received: by 10.100.96.19 with HTTP; Wed, 16 Jun 2010 03:44:41 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Mailman-Approved-At: Wed, 16 Jun 2010 15:52:17 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:73903 Archived-At: --0016e6d26595f1f70604892369ab Content-Type: text/plain; charset=ISO-8859-1 I have been an Emacs users for a few years now so definitely still a newbie! While initially I struggled to control its power, I eventually came round. Every issue I've had so far I've been able to fix by a quick search in EmacsWiki, except for one frustrating and re-occurring problem that has plagued me for years - word boundaries. Before Emacs I used Vim exclusively and the word boundary behaviour in Vim *just worked* - I didn't even have to think about it. No matter what language I used I could navigate and manipulate words without thinking about it. The way word boundaries work in Vim is elegant and I have spent a lot of time trying to find some elisp to replicate the behaviour in Emacs but to no avail. I could write some elisp myself but I am still very new to it so it will take a while - it's something I would like to do but I don't have time at the moment. Regardless, an elisp solution to the problem is not the point of this post. I want to understand why word boundaries behave the way they do in Vanilla Emacs and I would greatly appropriate some views on this from some Emacs Gurus! Every time I notice the word boundary behaviour when hacking in Emacs I wonder to myself - "I must be missing something here. Surely, experienced Emacs users don't just *put up* with this! Yet every forum response, blog post, mailing-list post I have read suggests they do. This is atypical of the Emacs community in my experience. Usually when something behaves wrong in Emacs, it's easy to find some elisp that just fixes the problem full stop. Yet with word-boundaries all I can find is suggestions that fix a particular gripe but nothing that provides a general solution. I have loads of examples but I will mentioned just a few here to hopefully kick-start further discussion. ** Example 1 I use org-mode for my journal and today I hit the word-boundary problem while entering my morning journal entry - here's a contrived example of what I entered: ** [10:27] Understanding Word Boundaries in Emacs ^ With point at the end of the word "Understanding" I hit C-w (which I bind to backward-kill-word) and the word "Understanding" is killed as expected. But when I hit C-w again, the point kills to the colon. Why? Why is colon a word-boundary but the closing square bracket isn't? ** Example 2 When editing C++ files I often need to delete the "ClassName::" part when declaring functions in the header: void ClassName::function(); ^ With point at the start of ClassName I want to press M-d twice to delete ClassName and :: but "::" isn't recognised as a word. In Vim I just type "dw" twice and it *just works*. ** Example 3 I have loads of problems when deleting and navigating words over multiple lines. In the following C++ code for instance: Page *page = new _Page(this); page.load(); ^ When point is after "page", before the dot on the second line and I hit M-b (backward-word) point ends up at the first opening bracket of "Page(" !!! Again, vim does the right thing here - pressing 'b' takes the point to the closing bracket of Page(this) so it doesn't recognise the semi-colon as a bracket which is intuitive and what I would expect. This is really the point I am trying to make. I have never taken the time to understand the behaviour of word boundaries in Vim because *it just works*. In Emacs I am forced to think about word boundaries because Emacs keeps surprising me with its weird behaviour! Note: My examples happen to be C++ but I use lots of other languages too including elisp, Clojure, JavaScript, Python and Java and the word-boundaries seem to be wrong for all of them. I have tried several different elisp solutions but each one has at least one feature that isn't quite right. Here are some links I kept, I've tried many other solutions but don't have the links to hand: http://stackoverflow.com/questions/2078855/about-the-forward-and-backward-a-word-behaviour-in-emacs http://stackoverflow.com/questions/1771102/changing-emacs-forward-word-behaviour/1772365#1772365 So to wrap up, the point of this post is to kick-start a discussion about why the word boundaries in Vanilla Emacs (specifically GNU Emacs 23.1.50.1 in my case) seem to be so awkward and unintuitive. Regards, Paul Drummond --0016e6d26595f1f70604892369ab Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I have been an Emacs users for a few years now so definitely still a newbie= !=A0 While initially I struggled to control its power, I eventually came ro= und.=A0 Every issue I've had so far I've been able to fix by a quic= k search in EmacsWiki, except for one frustrating and re-occurring problem = that has plagued me for years - word boundaries.

Before Emacs I used Vim exclusively and the word boundary behaviour in = Vim *just worked* - I didn't even have to think about it.=A0 No matter = what language I used I could navigate and manipulate words without thinking= about it.=A0 The way word boundaries work in Vim is elegant and I have spe= nt a lot of time trying to find some elisp to replicate the behaviour in Em= acs but to no avail.

I could write some elisp myself but I am still very new to it so it wil= l take a while - it's something I would like to do but I don't have= time at the moment.=A0 Regardless, an elisp solution to the problem is not= the point of this post.=A0 I want to understand why word boundaries behave= the way they do in Vanilla Emacs and I would greatly appropriate some view= s on this from some Emacs Gurus!

Every time I notice the word boundary behaviour when hacking in Emacs I= wonder to myself - "I must be missing something here.=A0 Surely, expe= rienced Emacs users don't just *put up* with this!=A0 Yet every forum r= esponse, blog post, mailing-list post I have read suggests they do.=A0 This= is atypical of the Emacs community in my experience.=A0 Usually when somet= hing behaves wrong in Emacs, it's easy to find some elisp that just fix= es the problem full stop.=A0 Yet with word-boundaries all I can find is sug= gestions that fix a particular gripe but nothing that provides a general so= lution.

I have loads of examples but I will mentioned just a few here to hopefu= lly kick-start further discussion.=A0

** Example 1

I use org= -mode for my journal and today I hit the word-boundary problem while enteri= ng my morning journal entry - here's a contrived example of what I ente= red:

** [10:27] Understanding Word Boundaries in Emacs
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 ^
With point at the end of the word "Un= derstanding" I hit C-w (which I bind to backward-kill-word) and the wo= rd "Understanding" is killed as expected.=A0 But when I hit C-w a= gain, the point kills to the colon.=A0 Why?=A0 Why is colon a word-boundary= but the closing square bracket isn't?

** Example 2

When editing C++ files I often need to delete the &= quot;ClassName::" part when declaring functions in the header:

= void ClassName::function();
=A0=A0=A0=A0=A0=A0 ^

With point at th= e start of ClassName I want to press M-d twice to delete ClassName and :: b= ut "::" isn't recognised as a word.=A0 In Vim I just type &qu= ot;dw" twice and it *just works*.

** Example 3

I have loads of problems when deleting and navigati= ng words over multiple lines.=A0 In the following C++ code for instance:
=A0=A0=A0 Page *page =3D new _Page(this);
=A0=A0=A0 page.load();=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ^ =A0=A0=A0=A0=A0=A0=A0=A0

When point is after "page", before the dot on the second line= and I hit M-b (backward-word) point ends up at the first opening bracket o= f "Page(" !!!

Again, vim does the right thing here - pressing 'b' takes the p= oint to the closing bracket of Page(this) so it doesn't recognise the s= emi-colon as a bracket which is intuitive and what I would expect.=A0 This = is really the point I am trying to make.=A0 I have never taken the time to = understand the behaviour of word boundaries in Vim because *it just works*.= =A0 In Emacs I am forced to think about word boundaries because Emacs keeps= surprising me with its weird behaviour!

Note: My examples happen to be C++ but I use lots of other languages to= o including elisp, Clojure, JavaScript, Python and Java and the word-bounda= ries seem to be wrong for all of them.

I have tried several differen= t elisp solutions but each one has at least one feature that isn't quit= e right.=A0 Here are some links I kept, I've tried many other solutions= but don't have the links to hand:

http://stackoverflow.com/questions= /2078855/about-the-forward-and-backward-a-word-behaviour-in-emacs
http://stackoverflow.com/questions/177110= 2/changing-emacs-forward-word-behaviour/1772365#1772365

So to wrap up, the point of this post is to kick-start a discussion abo= ut why the word boundaries in Vanilla Emacs (specifically GNU Emacs 23.1.50= .1 in my case) seem to be so awkward and unintuitive.

Regards,
Paul Drummond
--0016e6d26595f1f70604892369ab--