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 20:44:02 +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="9457"; 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 20:49:12 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 1kT8JM-0002Lt-DL for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 15 Oct 2020 20:49:12 +0200 Original-Received: from localhost ([::1]:48314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kT8JL-00018i-5j for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 15 Oct 2020 14:49:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kT8EU-0000OG-0t for help-gnu-emacs@gnu.org; Thu, 15 Oct 2020 14:44:10 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:36849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kT8ER-00077O-56 for help-gnu-emacs@gnu.org; Thu, 15 Oct 2020 14:44:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1602787443; bh=ttjhc7xkKRRsuHBv7+IKEZL8n5rpq6GoL3SK87+R+sw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=FHdta3qeOmCSNmCPe6J00eKOkSMj/9HIou4ZuuSp9bE2Pbx8U3H5XUXZUfLkKk9hW fg6C5o+VSc5f2dyXFuc6lGUKqqMEzRmERECp/Anh5jamn1Hb3kvp+mWJuiNx7qqw27 sx8WqTSngXhfR5P4cdvnU5xfL1EmOTCUtvPqHdNI= 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-bs05.server.lan [172.19.170.173]) (via HTTP); Thu, 15 Oct 2020 20:44:02 +0200 Importance: normal Sensitivity: Normal In-Reply-To: <1f7ecd80-f927-20c6-b711-d383abe81ca2@posteo.de> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:B3hydlIsbjt65npf8UQ93GorwpKbICw/A4NpE9SzE9Qc0+sO0MnORz1MlwrXN8DlA6UsB ql1UJK7OYczn/ivcw/atiHhR4uJBk+ptCrE/9COVmEE/XwBHFUTblRWbh9/eZr6uLqueuEUIoe9j 0xm/Yyo+AzYFfDohUm886xOF9TZi2TCbYC3U/eSQlTe9n85syQDpifzh61tNyEcP4xC8lkahRwiw PL5FlKFfXT//vR5dFARMb5H8GTtZkU6DqpLhOtbiJZMhUVZVHnocsqj5PP9K4urPXjjCjH4jwqvU 10= X-UI-Out-Filterresults: notjunk:1;V03:K0:pk3DqHljggw=:33y+xN99CuNSILIYhWDv1n Ox7v80pj/QVcp46IfnM9NWlQ17nhhTN+3DnRMEKOtLeedIFEM9ZXjSEBj+RY5xmqRjTcLimMW Xnni79CDy9qZ2WDQtOL8GABmznq7QvaBiGG+qTsTR23bU6xtIaccDO/uOeNN/OxNbxq2LY8H6 Y8T9KTCXjlht8Db/mLiLLMjcKMdfuVzvTh698jRlrIxLRShf34ShbuKHSKUM1XPndCLO6pFOz nuf/SRfm+nIEgyMl3jWB4nWyOalgkwOr1HO9RL4zPHlcbQRQlsveO/Wbs0Ysn8M0LC4hprhFo Av6k2/U2RL7m84NoaJPMBVRVW4fDWj3m/VzxXvYbv3VtPkCoW8J1FrEL9yXX0/cMQpnsSM9Hl t6TtZjLW59K3V3t9eNoTU19QtmPIE/12KNB6Y/XKLL9yht6MFg+9LflfcEh+/c3nNHQSH+bJ6 dEfkTCPfuw4lHKOs3XR0rKTcnVX8231ezKa71zp/NFS45sTzKUYugbHwHIhrreLmAPvwo7k4/ H34Rm66j7Lkr1RY1gL+eJwjmswjCxIJt8TitaK3oP8Qb+mWX1SsbdzBC5pFI1NMzw8+4dGdWv 3S/e7PJaEnMno= Received-SPF: pass client-ip=212.227.17.20; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/15 14:44:04 X-ACL-Warn: Detected OS = Linux 3.11 and newer [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:124470 Archived-At: 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. 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. (defun kill-spacword () (interactive) (if (looking-at "[ \t\n]") (let ((p (point))) ( re-search-forward "[^ \t\n]" nil :no-error ) ( backward-char ) ( kill-region p (point) ) ) ( progn (backward-char) (if (looking-at "[ \t\n]") (kill-word 1) ( progn (backward-word) (kill-word 1) ) ) ) ) ) Sent: Thursday, October 15, 2020 at 1:20 PM From: "Harald Jörg" To: "Christopher Dimech" , "Help Gnu Emacs" Subject: Re: Deleting a word using keybinding On 10/15/20 12:26 PM, Christopher Dimech wrote: > > I am trying to delete a word using keybinding string "C-" but the > Chord is still showing as undefined. > > I would like to delete a word even if I happen to be in the middle of > it., so I move backward. > > Here is the function > > ( global-set-key (kbd "C-" ) > ( lambda () (interactive) > ( (backward-word) > (kill-word 1) > ) > ) > ) If I get rid of one pair of parens, it works for me. ( global-set-key (kbd "C-" ) ( lambda () (interactive) (backward-word) (kill-word 1) ) ) With the extra parens in your code, I get 'Invalid function: (backward-word)'. Maybe this is why you don't see any effect? Also note that if your point happens to be on the first character of a word, this function deletes the _previous_ word. -- Cheers, haj