From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tatsu Takamaro Newsgroups: gmane.emacs.help Subject: Re: [External] : Q3 - how to delete by words, not cut? Date: Fri, 20 Dec 2024 03:19:08 +0300 Message-ID: <0004b28d-9f74-bc89-45db-d4a286d2a81a@gmail.com> References: <53671653-5c61-334b-c638-c70bdada6cd5@gmail.com> <45329ea1-7976-9dae-120f-3ddb23384a45@gmail.com> <0484167b-e189-9d97-7513-355d1b3c96f1@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4561"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 To: Drew Adams , "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 20 01:20:05 2024 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 1tOQkO-0000y7-Ku for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 20 Dec 2024 01:20:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOQjf-0002Ai-2l; Thu, 19 Dec 2024 19:19:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOQjd-0002AU-MO for help-gnu-emacs@gnu.org; Thu, 19 Dec 2024 19:19:17 -0500 Original-Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOQjb-0002pm-6P for help-gnu-emacs@gnu.org; Thu, 19 Dec 2024 19:19:17 -0500 Original-Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-435f8f29f8aso10119585e9.2 for ; Thu, 19 Dec 2024 16:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734653953; x=1735258753; darn=gnu.org; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=hqj5NU3KAlwHsErMGO6KOUMxXpaheDsov9SbyDe66sA=; b=UhcWOdV7poGyr6JkEX/4MAWvM4T45fQDJptOJ4sqAVdqnBy6MOfv2LW/ze9IRbJKNn gopg1Oc77ayz9lFxwWTm3+FHSNzLEx9hH7w5PjENLpuGuBYVreCXqbruhAECicEyBSGo 1xpvR2RMYO8+EeHz7z8A8tTJ1Zwam7OyYXdFEOkbG3I9PfKd4RTrAPDkR+g2azq/Z16S mjkDVLFDdJyFGc6hT3pWaJ4TiBuXzdAsRTnCqM3Hmrwc/QERdCn0vPTCH27nOCFRdmBt 8KGXw5eThZ1WiT1D+08zPiLhjdo49aJqo7lvQQoiNWmQWSztl4rBo8Jc53UOxoKO/jQZ aHxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734653953; x=1735258753; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=hqj5NU3KAlwHsErMGO6KOUMxXpaheDsov9SbyDe66sA=; b=u9NLMohKXzj8azU25i2SDAtOLG68ASF5ctFjPF6RAZituJnNNNDHOSwgzyA9z/Tj58 cbfsGxL/0hjCURQY+Gog4oXgSGWA9tDNHj1639vShP7L6zrvzHwd5Vpq1NIvL5wTU3NO 6pNZnXoLOX5qfxUqPrNZC8++CwatuS4vvzEY9CRE+SrRTG9KgiRZRrmS63CDfLxmVfEc /Lj2jmA36HeAEnyoppGjLO9sIZyoGY5aIsnNuDChdLPLssCoDon0YXd07C2Gk3dNHbtu Wa/Jzba80+7gS8WWzhhNlue0GuQEzGPo6pTouSCB6OoAln5+HcIPqphu6axPAseXDLou XWPQ== X-Forwarded-Encrypted: i=1; AJvYcCVSF7FqwFk8HQDxkuHJThTEGc0rVHXlyO+raFK3M74Bt+zCtYWzSV9OtK9nPMeYNDcGn0U+W9bHwl/c/c+tEA==@gnu.org X-Gm-Message-State: AOJu0YzJr2hcJeJwWJn2fRoszw7tMPH9LScaLG6eMwyVi155TxauZe1j TqRgqw2xb7qk463ATEky0DozS0Sr6PSuvRxa/q/rWvCB7zBttd/V X-Gm-Gg: ASbGncte0tDqC8cZZVAOCl163Gm7Mej2FNrcevErtkoaomm1PGdAdlfEaKr0SFpC0kV sloNtHD/DiFeE3i8ULMu6hLlunkeWZ0aFWCD56KAn/Gt7/MKPQCDvO0ISBfdqn/onbBlWApJeb/ Wi5FhnYwYurgCisIW+x3VH2wM0pyM/nAZvunCaFfxcdf0P2rb6wLglLeKGtkI7+IfkaVomIM3Sk G/tQ/BDAB2UDJiPO5ueZZVmNI5Z8a4iXie5jjV5NGJULJ81xFq9kartTc9Nbf6R3d3Drg8zT09N 2Ms70RPoB8xqofQHQCDPAAjo1VDVrKeVlM5Aq54vn+kvz1tXOZQw X-Google-Smtp-Source: AGHT+IEWQtuZOOIWxZiTRWdM0lNvs/EIPqaS+Dn6h3iPc2LlEp91TueBkRkl/BEKLn7mMouBUDEzfw== X-Received: by 2002:a05:600c:3b02:b0:434:f609:1af7 with SMTP id 5b1f17b1804b1-43668547462mr5680455e9.4.1734653952710; Thu, 19 Dec 2024 16:19:12 -0800 (PST) Original-Received: from [192.168.1.120] (broadband-37-110-24-126.ip.moscow.rt.ru. [37.110.24.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43661219a7csm30595285e9.24.2024.12.19.16.19.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Dec 2024 16:19:11 -0800 (PST) Content-Language: ru In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=tatsu.takamaro@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, NICE_REPLY_A=-2.107, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148884 Archived-At: Got it! Just needed to use a function name that I defined in the first line of "defun..." "C-S-" #'tt-delword-backward "C-S-" #'tt-delword-forward So easy! I entangled myself trying to find out "some way to bind a whole piece of code to a key". * * *>>You need to read up on `interactive'. * Yes, you're right. The word "interactive" played a trick on me first. English is not my native and the docs could be tricky sometimes. I learned Lisp (it was Scheme (script fu), a dialect of Lisp to create plugins for GIMP) many years ago, rather unusual language and that's what makes it interesting. Thanks for your patience in explaining! I'm grateful to you and to all who has been answering! So, now there is only one question stays unanswered. I posted it under title "Q4 - the bottom edge of Emacs doesn't stick to the taskbar", no answers for now. чт, 19.12.2024 5:31, Drew Adams пишет: >>> Did you try the `my-backward-delete-word' command I defined for you? >> Sorry, I didn't try it before. Because I didn't understand it >> by that time (and I have a habbit not to run any code until I >> understand it good enough). > A good habit! No reason to be sorry for that. > >> But now I dived into it and got it... >> Though the function logic is clear, the key binding won't work. >> I tried different keys. Here is the current state: >> >> (defun tt-delword-backward (arg) >> "Delete backward arg words. (default 1)" >> (interactive "C-;") ; <============== >>   (let ((opt  (point))) >>   (backward-word arg) >>   (delete-region opt (point)))) >> >> (defun tt-delword-forward (arg) >> "Delete forward arg words. (default 1)" >> (interactive "C-'") ; <============== >>   (let ((opt  (point))) >> (forward-word arg) >>   (delete-region opt (point)))) >> >> I tried to set (interactive "b") and (interactive "f") >> for backward and forward respectively. > No. You need to read up on `interactive'. > This is what I suggested: > > (defun my-backward-delete-word (arg) > "Delete backard ARG words. > ARG is the numeric prefix arg (default 1)." > (interactive "p") > (let ((opt (point))) > (backward-word arg) > (delete-region opt (point)))) > > The "p" arg for `interactive' passes the current > numeric prefix arg that a user supplies as the > argument (ARG). That defaults to 1, if the user > doesn't explicitly provide any prefix arg. > > So with no arg it deletes one word (backward). > With `M-1' it does the same thing. With `M-2' > it deletes two words, etc. > > This is common for Emacs commands that act on > things from the cursor position - you can use > the same command and key binding to act on N > things by using `C-u N' (or `M-n' for small #s). > >> When "C-;" is set the minibuffers says it's undefined, when letters are set it just type letters. The call by M-x doesn't do the job either. > Fix your `interactive' argument. It's not a > key description. `interactive' has nothing to > do with any key binding. It specifies how > arguments (in this case argument ARG) are > provided when the function's invoked interactively. > > I followed that command definition with this: > > Bind it to some key. > > IOW: you define a command and you bind that > command to a key (if you want). If not bound > to a key you can still invoke it, with `M-x'. > > The Elisp manual is your friend... > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Commands.html > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Interactive.html > >