From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Dimech Newsgroups: gmane.emacs.help Subject: Re: Deleting a word using keybinding Date: Thu, 15 Oct 2020 22:59:29 +0200 Message-ID: References: <1f7ecd80-f927-20c6-b711-d383abe81ca2@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33077"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: =?UTF-8?Q?Harald_J=C3=B6rg?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 15 23:03:01 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 1kTAOr-0008TG-9w for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 15 Oct 2020 23:03:01 +0200 Original-Received: from localhost ([::1]:60270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTAOp-0002dC-HB for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 15 Oct 2020 17:02:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTALW-0002c8-Jp for help-gnu-emacs@gnu.org; Thu, 15 Oct 2020 16:59:34 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:58477) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTALU-0007He-EW for help-gnu-emacs@gnu.org; Thu, 15 Oct 2020 16:59:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1602795569; bh=WiWfNmNtjVN6B2QQLfuGX/21azxbEt8cVndwFQLHwwk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ZsbSNxbyo+VQ7++hu0pK9upeJ/M1a2g8oP+FWrkIaxymeahrDMuFdyVgzdGBgyGFg Ad0izgv9OpFpRjGYIlx5FSHOIC9+Gvb7mRWW84VzTOYk5y6BVoxvRO8tA4YLnrw1aq t34AlGdPQtTPz54LRAHrx9jUZPNRZ2UnEam2zk8o= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs01.server.lan [172.19.170.58]) (via HTTP); Thu, 15 Oct 2020 22:59:29 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:H7OKBiuyJNhxAXlJI34rSx1vs9XQ2Gv2pAYb9eVSLpGW3cZJgH+FFZyKrat5dvV5mjVOv NqPaDOrS7VR0askCPEtFtfzvBKgg6J6XmH9n8LUw04dqCq+SL/pxfdnsBOz2eYdBSRQuYVeSAaK0 Z7A53PWX/ObP/89RO9/AcAUYP2gRUtdoi5G/caN9Nin4CoB1AlG8XWgGvKilcmPr37S5C3nPQfNn jI7PBst068MfMz5Ull3knjspjVf4OsvKLXNrJGCzk350WnlOSVXyU3Eh+TtU0j7Z+xuC2BpFVGtN kQ= X-UI-Out-Filterresults: notjunk:1;V03:K0:RblZCQ0acTI=:8bMdGf+D3fxwNYmlTpdnQn o6v9nz9p6iDiVr2+JBC1JnmHexx5EzAJRUUMEsCwFHJgtupcGKJssXl21F8MDzLMxHZYDUziC u24tws/xyisIwGAU766pUXU/VUzyvJnx/5CjaQ4azY0F5yQ8A1X241Vnn8PWC6VrZPoueHLFs 0f8lsavCqgWbJXwuhWu8zg1GkfSxyu0avm0qmtRZTZdlp5VEpXZB5kKZs/e7RP+NRKVDMUdNT Z6ZIGXPxqKLRH7T9aUGjgFp71xQQx1m0hm6cxrsztiwQXxE1BI6uj5lvACFi4BciSaOLLVH1T VwfPZIXrnfFq7d5CBdsRINSBOotYMzB7EvC7BWSrmMip73gAZNy9ArkMiKDKSBslf0oXtFq5r eoiUToKMVOcdTv616Ab0qJBSkqI8eI7k+8xw8zEuKU2KbeW8ZWI/7N69aNPcC2WuRyekbCd28 zmK9z3z4oKLki1gL4VskSulH5UIWPL+qMxGJ9WujMCDkiMZBVGYngJRiO9Oj6sqIMLWI4OcvN Dh9qqFIhJQAAkNEtRaXG+1YZQRQSMHwC4INonVbhNgElXjXP9tY+heeCga42e7TbP5Bgy3Gd3 2b5K0szfpxbUo= Received-SPF: pass client-ip=212.227.17.22; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/15 14:57:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, MIME_HTML_ONLY=0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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:124472 Archived-At: I want it to behave as C-, except that I want to delete the current word if the cursor happens to be within a word. For instance, consider the following sentence. I want that if the cursor point in on the character w of the word Brown, the word Brown is also deleted, rather than deleting the word fromw onwards. The Brown Fox Jumped a Fence I also would like that when there are multiple space, I first delete the spaces and leave just one space rather than deleting the next word. Sent: Thursday, October 15, 2020 at 10:25 PM From: "Harald Jörg" To: "Christopher Dimech" Cc: "Help Gnu Emacs" Subject: Re: Deleting a word using keybinding 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