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: Tue, 10 Nov 2020 18:52:04 +0100 Message-ID: References: <20201110111024.GA15992@tuxteam.de> <87zh3pctr1.fsf@web.de> <87o8k5csqj.fsf@web.de> <874klxcn6k.fsf@web.de> <87imadb725.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="12282"; 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 Tue Nov 10 18:54:50 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 1kcXr0-00038E-Jp for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 18:54:50 +0100 Original-Received: from localhost ([::1]:57894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcXqz-0000nl-FY for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 12:54:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcXoP-0000nb-AZ for help-gnu-emacs@gnu.org; Tue, 10 Nov 2020 12:52:09 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:43001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcXoN-0006RG-4T for help-gnu-emacs@gnu.org; Tue, 10 Nov 2020 12:52:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1605030725; bh=Ox5sdwbMLqo2CrXkmk2dFvYQmwHiZR44b2Pw2FABOQA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=lsJILwLeW2HB6TdzVmDPWvgIA4Bgi9SpzahUh71yxHEXqdV18dUex6SnWup13cW+n WFyV+0Fl4YpT11YUgkT9GpMXQljd9X+E1YBLGfzbtBfXZOCJQCqn4ZV+pkVECsJ0/1 EDd0+4IjFGmT3Oarkw+6gulU8ce8fPy+vEMdUNSs= 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-bs15.server.lan [172.19.170.183]) (via HTTP); Tue, 10 Nov 2020 18:52:04 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <87imadb725.fsf@web.de> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:SY9JajNjimKBaFS2y2zlNQiEtsj5huuJi/NK7mGauaBDrwV1rtE0Tw8kQ3kEsdnB986gA 8OybmyZJHlz+Z245Uw8WAyeYM6liU+t2c8x6L/XHXw5gKwJPjh/bU+E2u9V5cK0Zy0GBK6i9vUPG DttNEmPfe+/TJUY9xsWFZS7T69k0pM6YLotPfg6jpOSkIVOwJz98a9O1igbxtjq6fa57eczzxpfM +JaHg1ayshT3MVlem9APgU9UDfn7YK+nd8xW3h1NjeGwLtCY49BmnV3OT/WPvdVniNPnMtY3LEVa mY= X-UI-Out-Filterresults: notjunk:1;V03:K0:zrjEUqgQPrA=:g2UpRRwYT6j6W/qaOr6caR HaU4U2gw15W7R2uDUBRMN55oHZQ8iyyO0fkF/Wo5ffyJIpC4G3axyqdvCub1R6k4hVnVTSLwR e+WZAkCnHPI9bPOYohCdpDJgBSd7w+DGbRxKSQqD3g8n6kFDcPNdrp8tdMy9OrO9AXjg1fa36 aHJa5SOuDodG9L+NAVsiVsNQsDqmPhdayx9f4pqSh0qHHBuBo6efaORhYlT6EZC8YTMiYysr2 EpbEi/Z8b7VUg+JkZxH7yXA7PmZ/cmCKPpnveNwgEeCRrDTguzFkMkkt7b/cWJLah1M5I6QFE +zuT7z1P4ene4iNKXADTAClwDWC+xVVmSz4Wwkdbjv5i1twjbRVVH4gWFGJycxih9F19kiXrb XzMuDTB1vAvDkPEw3MpXjtKD3cYM80l8ycSNUv1fW9kijtXPxQJ+9XL+IhbzEqvkE9QmeAaM7 1QEfVFycxQg9i2zsO8+/hPtJO0Mi2lGfnzmZeYMdBIiX3JM3jvfXOsqPpZ5iUBXsIWIrEXaf8 c9yqzV0RiXLH3r+U2L2szSyVIzBpi6zCfo1mE4PJIT74l7Bu+IujwjYLXVWWQzq85quJak8GU L8Uw4E99q9Wn8= Received-SPF: pass client-ip=212.227.15.18; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 12:52:05 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:125197 Archived-At: Have tried to add a keybinding for the function, but after pressing the keyseq, I am getting "H-z is undefined". (define-key emacs-lisp-mode-hook (kbd "H-z") 'rec-field-nwltok) > Sent: Tuesday, November 10, 2020 at 3:49 PM > From: "Michael Heerdegen" > To: "Christopher Dimech" > Cc: help-gnu-emacs@gnu.org > Subject: Re: Adding String to Beginning of Lines > > Christopher Dimech writes: > > > Correct, the replacement. Because in .el files, the replacement will= be > > ";; + ", in other languages, it is dependent on the symbol for comment= s > > (e.g. "!! +" for fortran code .f) > > Ok. > > If you prefer to have `interactive' return the default, then: a > not-stringish sexp as interactive spec is evaluated normally, and > expected to return the list of arguments. So you could use something > like: > > (defun rec-cont (beg end s) > (interactive (list (region-beginning) > (region-end) > (read-string "Prefix: " nil nil "your-default"))) > (replace-regexp "^" s nil beg end)) > > You can also use an expression to provide a default depending on the > current mode, e.g. > > (if comment-start (concat comment-start " +") ";; +") > > instead of a constant string "your-default". > > > Michael. >