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 15:49:24 +0100 Message-ID: References: <20201110111024.GA15992@tuxteam.de> <87zh3pctr1.fsf@web.de> <87o8k5csqj.fsf@web.de> <20201110224507.GA10842@tuxteam.de> <87v9ecdty8.fsf@web.de> <20201111140732.GA14577@tuxteam.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="35141"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: tomas@tuxteam.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 11 15:51:42 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 1kcrTJ-00092y-KY for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 11 Nov 2020 15:51:41 +0100 Original-Received: from localhost ([::1]:58678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcrTI-0002RB-GD for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 11 Nov 2020 09:51:40 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcrRF-0002R2-Tz for help-gnu-emacs@gnu.org; Wed, 11 Nov 2020 09:49:33 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:53945) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcrRD-0001kB-MI for help-gnu-emacs@gnu.org; Wed, 11 Nov 2020 09:49:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1605106164; bh=HzVk4aoFjuCAzvcgzOTSlFILoGAv0j7ppQUdIN4hbnM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=P9n91s8D/MZXhaTCRgyIU/mM4fckcbDVmWroqx2whtVuZzQpGSovtzCFUDa3X8q6c W3ykYd4hJZv9bMv5f5swub/YbvUswo0fPndh/iAgqeDo5WFnrUuzHHcOV6XbtjO98/ py1cYnz3wYooGkeCLB+RUnCcPxj0nJ92osx38BVo= 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 15:49:24 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <20201111140732.GA14577@tuxteam.de> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:XjeF+6erBYvBCfzbdZJFZQ7S6kDVJ+Zbc4+5rpO1e1zgfkvHWbF7lfM5gEQDotII5o6JX KKrkIhz+XpArGZmEY20zhXXYZ2zSkxxR4e94jPjAHEQ6yhWYAhNPm5UtPVvySdUliKZOH8+4EyyI Yw6VvrbO8kI2aAQJLf8xg9dO5eP0gwmSAuEiWl08WM1JpUukP1VJQERPpy8dysFeZFNWgb4JVujI 1w1xsZAjn6xk0YPksfaAJ54rcWsBKET9ks3q3RxwSedDl4CjEJ0JfuHE1w9nzrBQ61QJfrufyK17 jA= X-UI-Out-Filterresults: notjunk:1;V03:K0:VDv3emII+6k=:jZUi0FywXCxbFSfPDhss1y 812lg4QmLfPzb+hJNPV3GamDBVvylZpLAP3j9LIw36M3s6kUfp0/mAXVWOM1MNG2GRpVsrnUt xxZQV6JfbNfrBaxMGaiaE2SztRcK/RNsoxmXxk+Z49OrZi5gZUo3yG8KH2KywLEqVote768+e TyWsga+pXYMqQ//eeFi/xzAn7Wa3hE9bMBLciIS9Rkzctp2rLCG77e5/F9DQP+ywrBC+DB1sI 1FgguOg0LIL/jSI8yi9YE1qYdjUdTkZoEEB0JK1Vuh/x2sKz2PCsicB3tQTPdQTBNNFXTlJH4 ULtntdlYmAlvqD+99X4XL3/+47Yqiqq+qilk1bRTbsHbXlS/y/zriircRt6aJs0NtDagiuTIt qI4XvPT2HRkvtwOCt2yQQ50utlqC9VfJ7L6qfRfv+oIWcfDL7RWF6ZRy/B2v0inG22FSXbOZz zNc4fHm+C6FlIODkfknovBubEoyD/yYZPpBKhzU1CS5zllAaH+WH9nK3c98BJIDSxjlLfx3cZ KuNTHdUNwfHa9YdNTenT034hGHl3VUE2rOQFoQZCUmBUi5SVE6+VxPjp4hKRPPLq9GedqQPgl 9JoO0SCd+ve7M= Received-SPF: pass client-ip=212.227.15.15; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/11 09:49:30 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:125229 Archived-At: > Sent: Wednesday, November 11, 2020 at 3:07 PM > From: tomas@tuxteam.de > To: help-gnu-emacs@gnu.org > Subject: Re: Adding String to Beginning of Lines > > On Wed, Nov 11, 2020 at 02:22:44PM +0100, Christopher Dimech wrote: > > > > > 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 sequen= ces > > > > (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 u= se > > > 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 > > > > That's what I started doing at the beginning. Should we revert to thi= s > > or continue with replace-regexp. Have now removed the confusingly cal= led > > `regex' and it is currently called nwltok. > > If it's always the beginning of line you're inserting at, your first > approach seems to make more sense. > > Something like > > (beginning-of-line) ; if you aren't already there, see below > (insert "foo") > > should do what you're after. Correct. Always at beginning of line > The beginning-of-line isn't necessary if your advance function > puts you already there. Note that (beginning-of-line 2) will > put you at the beginning of the /next/ line. > > Cheers > - t >