From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime Newsgroups: gmane.emacs.help Subject: Re: [External] : Getting text from next non-blank line Date: Fri, 19 Apr 2024 23:31:39 +0000 Message-ID: References: <-NcWr6V6uYcDio-D72eweQPC4nx1UypEOtbiY6bgBb0qLt9NeDKFi_XI4h7x8WoVI5z7wJRDiVk2XRjl7KrLJET8YX6pf1Up-GIp4SUfajw=@protonmail.com> <87le59kmh2.fsf@gmx.net> <7Ou37EYG6niAiFiWP2yGZNFYe0HiexEg92lGsJ0VlKJ2HXI8XL4HuPZMWDHVA6cKozv23b4pF0sVTowbggG5hdC8PHRcRvf6K3-irKQTDXc=@protonmail.com> <87h6fxkkuq.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7070"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Drew Adams , Heime via Users list for the GNU Emacs text editor To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 20 01:32:12 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 1rxxiG-0001YD-A5 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 20 Apr 2024 01:32:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxxhw-00036s-9I; Fri, 19 Apr 2024 19:31:52 -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 1rxxhu-00036g-1n for help-gnu-emacs@gnu.org; Fri, 19 Apr 2024 19:31:50 -0400 Original-Received: from mail-4324.protonmail.ch ([185.70.43.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxxhr-0006Hc-T6 for help-gnu-emacs@gnu.org; Fri, 19 Apr 2024 19:31:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1713569505; x=1713828705; bh=QNVLzbYhflgqCv1oKEyeVMpNCd+56/FZEcoulk6t/qQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=rXxjf7dJPXyM3IG2JkqvpUOfquA0IjIhpBjB0vZFpCMeMeM0EEw21FNtOS9nODZuB BFx5WWMuzDfJeFHMvrX2e4cEYMCjQxApUNNVdY46GVNsl79CqCA3c/J/X6cFGRABTF XtjpVWPH0WKNzIYFS0kflTafkQlmSfDkXLHPwyvAbXfbYkStuHkMhC6c2I4iKbEU1T LyD9yrHA/7bZqwf9i64+Wn062JYY427oaK6mUrR1y49RP8eiDdZY2v7aB+iTmVUCn6 Sa5J6Awsn49Xn4bc/pBgiG2/Mgdri4GWQhJz+A6zwDJe5AkQepr1Pz925dflTNkEPR 9fFWmmJ/HNrXQ== In-Reply-To: <87h6fxkkuq.fsf@gmx.net> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: ae8fa8bc26493bd78aad6a58bdf921d7b4b131ac Received-SPF: pass client-ip=185.70.43.24; envelope-from=heimeborgia@protonmail.com; helo=mail-4324.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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:146392 Archived-At: Sent with Proton Mail secure email. On Saturday, April 20th, 2024 at 11:12 AM, Stephen Berman wrote: > On Fri, 19 Apr 2024 23:00:30 +0000 Heime heimeborgia@protonmail.com wrote= : >=20 > > On Saturday, April 20th, 2024 at 10:37 AM, Stephen Berman > > stephen.berman@gmx.net wrote: > >=20 > > > On Fri, 19 Apr 2024 21:50:12 +0000 Heime heimeborgia@protonmail.com w= rote: > > >=20 > > > > Sent with Proton Mail secure email. > > > >=20 > > > > On Saturday, April 20th, 2024 at 9:04 AM, Drew Adams drew.adams@ora= cle.com wrote: > > > >=20 > > > > > > 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 wri= te > > > > > > their own text for the line. > > > > >=20 > > > > > ... > > > > >=20 > > > > > > (interactive "sString: ") > > > > >=20 > > > > > Don't use that, if you want to provide a > > > > > default value for the user input. > > > > >=20 > > > > > Instead, use a function that accepts a > > > > > default value. E.g., `read-string' or` completing-read'. > > > > >=20 > > > > > Read how to use `interactive' with a sexp as argument that return= s the list of args you want` interactive' to pass > > > > > to the function body. > > > > >=20 > > > > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-I= nteractive.html > > > >=20 > > > > Have started with this to get the non-blank text. But still no way = for > > > > use to use his own text. > > >=20 > > > 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?) > > >=20 > > > Steve Berman > >=20 > > If the next line after a blank line is also blank, I continue until > > I get to the first non-blank line. >=20 >=20 > What happens if the buffer ends in one or more blank lines? >=20 > > I have noticed the newline at the end of the line - I do not want that. > > Want to remove leading and trailing blanks as well. >=20 >=20 > string-trim string-trim should also handle the removal of the ending newline. =20 > Steve Berman >=20 > > My latest version follows. > >=20 > > (defun tema-mark () > > "Store a string with the line number in `my-alist`. > > If the current line is blank, move to the next non-blank line." > > (interactive) > >=20 > > (let* ((initial-line (thing-at-point 'line t)) > > (initial-line-number (line-number-at-pos)) > > (line (if (string-blank-p initial-line) > > (progn > > (forward-line) > > (while (string-blank-p (thing-at-point 'line t)) > > (forward-line)) > > (thing-at-point 'line t)) > > initial-line)) > > (lnum (line-number-at-pos)) > > (text (read-string "Enter text to store: " line))) > >=20 > > (setq-local tema-lugar > > (append tema-lugar > > (list (cons text lnum)))) ))