From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: [External] : Getting text from next non-blank line Date: Sat, 20 Apr 2024 00:37:45 +0200 Message-ID: <87le59kmh2.fsf@gmx.net> References: <-NcWr6V6uYcDio-D72eweQPC4nx1UypEOtbiY6bgBb0qLt9NeDKFi_XI4h7x8WoVI5z7wJRDiVk2XRjl7KrLJET8YX6pf1Up-GIp4SUfajw=@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27314"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Drew Adams , Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 20 00:38:32 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 1rxwsK-0006yH-BF for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 20 Apr 2024 00:38:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxwrn-0000Y1-6K; Fri, 19 Apr 2024 18:37:59 -0400 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 1rxwrk-0000Xk-CT for help-gnu-emacs@gnu.org; Fri, 19 Apr 2024 18:37:56 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxwri-000686-Cc for help-gnu-emacs@gnu.org; Fri, 19 Apr 2024 18:37:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1713566267; x=1714171067; i=stephen.berman@gmx.net; bh=X7JePaiL58XC2UBKIVcrMwY3A8kJpyBhRJrLy0MvtjY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=pSi3GUR6D5xELYDi6hbanXjaG0b0b06vOPUIfGXpKZ2nw+P93+pf1NOKyQNvk+3H f6HBEhKhHwan2kvGdLYGbeRWSsn0Nq9KSGPpGHfrs68SxS8MwtIaRmn3hlO7LlJRa YftnzEW1oNRnvLBxnO1sJbC2uwfqRBiMDEE/UiyoJOKj2fj+kToMKZNMK1SVk73jg eU6ioaVpGN7wHWuSxgKsuznqwOfaINXyG4+7i78OcOizJ6oDoFr4XixZOjw044wmq CIEjcGWjQlAd/0kGd0y4MuAFCSyEN/ggY8MKpV73pyMRnVrpjExVEheVeLiH1gE5N Qh/QPCPNXWE/hocTEw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs ([88.130.50.216]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MbzuB-1sa2tx3lrL-00dWPr; Sat, 20 Apr 2024 00:37:47 +0200 In-Reply-To: (Heime's message of "Fri, 19 Apr 2024 21:50:12 +0000") X-Provags-ID: V03:K1:UUWPqsJdB4iBlDc0tciANPpnr9U+ipkVdFxwKhIXePTndJcWv5Q g147riaKQPjxWSk/EV200CN4o/VPur6jGSL2KAxZ3UgGiz67L4O+xDRcOEWfRTIuYlEIqjd Ws4inONhnk8VsBf5zhcGfRH2m1XWf1fKL9aPu1gYgiktWmXsk/NMQEgqxa2jtWscrlTt1BM Qk6/7MmY1YABm9KbJDnSA== UI-OutboundReport: notjunk:1;M01:P0:gtRIspd5sD0=;wgDis/KL8LW8uxdH4bayXfkIjOG 4TnLwHfEVtKJYbPlsE4MgFdnVk9TmzTsX/CAojJQDSjg1KgSTdKTIZHfjou3cKrgOyPkOo9rz gaxTKlPhi61AwCpBf/KqGLmSuREsd33kCP1DdhwZ1fUncwlu3r0eCgQkZzRR4ohhkzGwkjUpX BKMzmNSYx9BBg87BWtx/VBybpMGjSMz2HkYNivNA28sKnVq5+k4/TwTQeAg7Fg2mdlXdqTytM 93L023fRPzM1Z8un+fcQdv/eYcOJyMuKrMAyS24vjoihPsO/Rd9iD7rNgotN98qhH9uVT7ceu sw1Dnbi/a/vg/wrGz6QLi+/CSZP7tbbX5nfPNAT6t31yNopAAJcZDZKbtqlyzCiBNIIuKh4vL tKgST5ctsY7DfIQETOP63vLy4XuByWVWwh46ZcQILXYB6xYKZ8UidDq181MeZrUs5zLcPX/Ly V2alDUFJiBV6Al/ikdP1KNVEyt+nowonU9WW/KRreSigZW24imAwD/vMG6LurcdTeucUJOyMv 1vFB9GT5SiWiPWKtXCSChyYHY1wChqrILUod7BemKWJtyRknAT/QcBksKozltUbr3jmU0bwcV px1IvP01ixxA6S1cYdduTM6fFvNMTC17Xox7Rj1TEB9NrDhsPUMuF7hazzcq4n0UroPzlL6rF EDai9hq5+4PhDcFkJIaxcQWrAiiQ7/ThA3AYdA0RAFXTaNuzcJNAEGV0zB4HJYR63+3cOCtQ/ i+7xuSmt5m8gBBxSsS6nJhqwhb/+r7zgh2z2xhiAPxjiaSzyUnsxTuLgtyCAJvIYwrRsYy+J Received-SPF: pass client-ip=212.227.17.20; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, 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-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:146388 Archived-At: On Fri, 19 Apr 2024 21:50:12 +0000 Heime wrot= e: > Sent with Proton Mail secure email. > > On Saturday, April 20th, 2024 at 9:04 AM, Drew Adams wrote: > >> > This interactive function requests the user to input a string >> > associated with the current line number. I want to change it so >> > that the function picks out the text on the current line or the >> > text of the next non-blank line. But also allow the user to write >> > their own text for the line. >> >> ... >> >> > (interactive "sString: ") >> >> >> Don't use that, if you want to provide a >> default value for the user input. >> >> Instead, use a function that accepts a >> default value. E.g., `read-string' or` completing-read'. >> >> Read how to use `interactive' with a sexp as argument that returns the = list >> of args you want` interactive' to pass >> to the function body. >> >> https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Interac= tive.html > > Have started with this to get the non-blank text. But still no way for > use to use his own text. Follow Drew's advice, e.g. use read-string with your if-sexp as the default value. (But what if the next line after a blank line is also blank? And the string (thing-at-point 'line t) returns includes the newline at the end of the line; do you want that?) Steve Berman > (defun tema-mark (text) > "Associate line number at cursor position with text." > > (interactive > (list (if (string-blank-p (thing-at-point 'line t)) > (progn (forward-line) > (thing-at-point 'line t)) > (thing-at-point 'line t)))) > > (let ( (line-number (line-number-at-pos)) ) > (setq-local tema-lugar > (append tema-lugar > (list (cons text line-number)))) > ))