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: Adding String to Beginning of Lines Date: Wed, 11 Nov 2020 18:20:01 +0100 Message-ID: References: <20201110111024.GA15992@tuxteam.de> <87zh3pctr1.fsf@web.de> <87o8k5csqj.fsf@web.de> <20201110224507.GA10842@tuxteam.de> <87v9ecdty8.fsf@web.de> 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="28283"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 11 18:23:00 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 1kctpj-0007ED-Iq for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 11 Nov 2020 18:22:59 +0100 Original-Received: from localhost ([::1]:35690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kctpd-0005rf-Vs for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 11 Nov 2020 12:22:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kctmv-0005iu-Gh for help-gnu-emacs@gnu.org; Wed, 11 Nov 2020 12:20:06 -0500 Original-Received: from mout.gmx.net ([212.227.17.21]:51069) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kctmt-0004eL-5n for help-gnu-emacs@gnu.org; Wed, 11 Nov 2020 12:20:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1605115201; bh=mK3GcFi1EOHxgjPBFbJqUzzUxbAttUIA0j0rv47ozAc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=k4YwPRazahtbynkWuFT2MB6p5odic/cDDvlBVWhzKmT5p1QeOakmhnG/mdRmg7os9 v8B6uCLaiMEhXZJJL/GrAiCQHKLZvDs3iXmmwhh8waCFrHBPIlZpe4s/QJQAFByhmQ cSeDA20HeTRzYg2EYyEqxOi5GFpEaYy5Lp9JT8NE= 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); Wed, 11 Nov 2020 18:20:01 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <87v9ecdty8.fsf@web.de> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:XrO7pm8AC+DbZj5JPwS8SgYFz6H4NSC7NVXZgwmubdRlPdKQ3ClgrFaYfSdTbqoGncLhV ddA8MW42yQxk2ubyr/RwhwGpHIQuZ+dYMfAb+LGoQmXdjZVtTyXlyKWXGps2TFKDsU2Y8ZD4uERh rG1sCaCeZ3BduOWOwJwlT33oQ18uTnf0IhT4hjAn/Z0OFMxTlDaBAh2dHjB+yF4X0EQwU4CDjzJX RhOIAuJzWuRnGKyQczzisO4rZ0b+3bUTuz8kXS99ywwvtXQLpLlxq38cma53YPGcEwFNOQlSG6Xv QM= X-UI-Out-Filterresults: notjunk:1;V03:K0:6n0BVGU3zIo=:ZpY++cz4VbaKLdIqZbk6Q4 N6VYd4F7qcMu1ZGPTwGyFejGsQhVbhwUOVbT14TqnqNzbGFVEiV7qu7NqSs2BS10UXwamKNPC rdf9UifTyHhpoGkgPJNmGLA6SwChlHuoNFAz6abdHegxVcqmUMkwDUAqonKBiaN33Wnj6yTv0 YaBK6GIlW8aj/qzxqV+pHfgKWUECX0O4pzcwFMg13eFK6xJiGtnozKMi7xyANaE2XJh+LlL+5 jVHBD72poDEX9Xtt/pkwkPMYxLj1euXQCLQcpXXi1Eh627KBJdP9nAlKxGD97K948O8pf0CSh 7qCojrfnZj5YXtB2KDUr/+Em7o561SEWETJVt/3BZU4vEQgB5jSsVJndiZet2Bc2EM3T3cPmE cu7nO/VRSyZTQqbPvar/vBArpyi/VByYHBrBprY2olmUk0s3jSwrKslVWMN/iYbum6cmXFwKp bcuEX2O6wWbxGzxDJ85t2TwX+r1SGV6hnFK1EKNEmjgg9/fjs6zdgfI19JedFteyKlPy7c7ZN 0eREbkRr+vHihwahxoLKJJYYq/78ggiZaJ5FMK5uEbcMNdIgS2BYBlt6aMByRQgQGVyFEIJF0 t/ps3O9AP2Zic= Received-SPF: pass client-ip=212.227.17.21; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/11 12:15:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-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.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:125234 Archived-At: Have put the following, bet the insert is not progressing to the last line of the selected region. I started my selected region on the first character of 'RFrec-field-nwltok' and ended my selected region on the last character of 'insert'. > > (defun RFrec-field-nwltok (beg end nwltok) > "rec-field-nwltok adds a newline token for a recutils field." > (interactive > (list (region-beginning) > (region-end) > (read-string "rec-field-nwltok: " nil nil ";; + ") )) > (save-excursion > (let (rz lpos) > (setq rz (region-end)) > (goto-char (region-beginning)) > (beginning-of-line) > > (while (and (< (point) rz) > (not (eobp))) > (insert nwltok) > (forward-line 1)) ) > (deactivate-mark) )) > > Sent: Wednesday, November 11, 2020 at 12:16 PM > From: "Michael Heerdegen" > To: help-gnu-emacs@gnu.org > Subject: Re: Adding String to Beginning of Lines > > writes: > > > But watch out: the replacement string (confusingly called `regex' here= , > > others have already pointed that out) might contain special sequences > > (e.g. "\\&") which have a meaning in this context. > > Indeed, an important objection. > > I would suggest to avoid using any query-replace at all and rather use > something like > > #+begin_src emacs-lisp > (save-excursion > (while (and (<=3D (point) end) > (not (eobp))) > (insert my-string) > (forward-line +1)) > (deactivate-mark)) > #+end_src > > > Cheers > > Ebenso! > > > Regards, > > Michael. > > >