From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Harald_J=c3=b6rg?= Newsgroups: gmane.emacs.help Subject: Re: Deleting a word using keybinding Date: Thu, 15 Oct 2020 22:25:23 +0200 Message-ID: References: <1f7ecd80-f927-20c6-b711-d383abe81ca2@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34911"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 Cc: Help Gnu Emacs To: Christopher Dimech Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 15 22:26:10 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kT9pB-0008zf-QR for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 15 Oct 2020 22:26:09 +0200 Original-Received: from localhost ([::1]:41124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kT9pA-0000ut-Se for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 15 Oct 2020 16:26:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kT9oX-0000tF-I6 for help-gnu-emacs@gnu.org; Thu, 15 Oct 2020 16:25:29 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:33851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kT9oV-00037j-9s for help-gnu-emacs@gnu.org; Thu, 15 Oct 2020 16:25:29 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 402B42400FB for ; Thu, 15 Oct 2020 22:25:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1602793524; bh=xCv7OJHu2+MWSxuEp5Z3VK6zbvKDMxpoyquQwBZhK3s=; h=Subject:To:Cc:From:Date:From; b=o8fecPrZHDQj0uKKVBAFJrLTnGcsJAE/gUgsmORyO5Pv0Fjxhx36gXO6MUyx0paxZ ptrHEWw5WcfiTmQFrw/N81w2PznQtxp1XJl0xKoFsfYJsV8pJfOd6LcT0IBVd7ftfv oxIk25p7I68x3FlAQBI61BUxZ95nSxtREFiay0A+Wk3huPUAhrb/2EjtXFoiwp+6ZR xvaDt8udz0BWe269oe1VNI1wmwttx4AQ8eI7qpDs1YUyTGDgjSB05MAzwWMuZvaABt GOm07UW3uIb16RuzEVyO8Jh8MOu/a2XQd7eMVOI9rO0J8nG3HCF4gaZg9POZuffYy4 H7Jbfbj5TedDw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4CC14M50d9z6tpB; Thu, 15 Oct 2020 22:25:23 +0200 (CEST) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=185.67.36.66; envelope-from=haj@posteo.de; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/15 16:25:24 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 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, NICE_REPLY_A=-1.019, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124471 Archived-At: On 10/15/20 8:44 PM, Christopher Dimech wrote: > I have updated my function to kill words forward so that even if I am > in the middle of a word that word will be killed. I also consider that > if there are multiple spaces, I delete just the spaces spaces but not > next word. This isn't exactly what the function does: If there are two or more spaces between words, then only spaces to the right of point are deleted. Also, when you delete _all_ spaces, you merge two words into one. This is the cause for your observation: > I am finding a problem however when deleting part of a sentence by > contiuing to press C-- because when the point happens to be > between two words, I end up with the two words stuck together (the > previous and thn forward), which deletes the two words when I hit > C- again. It really pays off when you spend the effort to write down how you want the function to behave in all relevant situations. It is good practice to have a docstring for your command anyway, and you might detect contradictory requirements before you start writing the function. If point is before a whitespace character, you could either do nothing, or delete the previous, or delete the following word, all of them make some sense. Deleting whitespace seems somewhat unrelated. There still are cases where your function does not what you seem to expect: If the text in the buffer is "foo bar", and point is before the "a" in "bar", then executing M-x kill-spacword kills "foo". -- Cheers, haj