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 19:25:45 +0100 Message-ID: References: <20201110111024.GA15992@tuxteam.de> <87zh3pctr1.fsf@web.de> <87o8k5csqj.fsf@web.de> <874klxcn6k.fsf@web.de> <87imadb725.fsf@web.de> <87k0utay2i.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="9425"; 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 19:28:44 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 1kcYNo-0002Ko-3d for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 19:28:44 +0100 Original-Received: from localhost ([::1]:46140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcYNm-0004Lw-VN for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 13:28:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcYL2-0004Jn-VX for help-gnu-emacs@gnu.org; Tue, 10 Nov 2020 13:25:54 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:60173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcYKy-00012q-41 for help-gnu-emacs@gnu.org; Tue, 10 Nov 2020 13:25:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1605032745; bh=5SbslhjF51r44e2VSoSXrvPX5YR37yyUdCk7iMQeCSM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=W8VYTwZ+ayS/DcDL/BQk1HMkJFfOC3ObyI8wqcdXAXLvQLfaMPQga+7soSPy4D/Z4 2v5X2TyrT3IXxq8f0YC3gM99SPfln6VsKQXiglpp6FxdXAwaO4r8mdZU4CtP+p9VZ/ P2nHlfZg6IjGjNKeEnXcwApJbYIz9VswGZN+uMys= 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 19:25:45 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <87k0utay2i.fsf@web.de> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:LXKRmS33d9GrAsXMpE299lpTyTzKLhfQX5XN+AFT4TAnQTFVMDKONDEVE+WtHjV1Lp7K0 DQ3UctRTMvO80zatzT5P/NB5w/UDxkNX2nzz6MI0WuMUnNOSgPz7iBDGEhP8IkxslL9rQQVDDp/1 obpQYztr+6N8ttRpwUAeuUhvvlpe70VibxiMaVTSt7sBlWwPSX1SWjol9zpkj1xmBaTKKGvowrFW GvQHa2QMgy+xG/YwdvcfnEM5PFYD9/GMIs5d57NuBks9oKEtr/k8mjj5hJZsmXRgzVpNE4QL3owf dM= X-UI-Out-Filterresults: notjunk:1;V03:K0:ZZ7RxPaBU4A=:rhXUkITPbhSD8Nnqmctrp4 lDuOVAI6i/2syN34sD+698PgwpLsUgMn63dwwk4zzDKaLvG10faQfWc10qxw51Bsq6lZtWtJv HEAZHgsn8I65yGy3HLRM83Br56Y0Ekscq3Y7gAAUJFZytUGOIlNUDjOIoiu6Dqb/O8IhSmww0 iYJCH2XJ1Eeh2EDPSGhf802Q9nitEqMDx5EpcWLj7LeqIL+TLVJJ3gIy4gTJcopZCdrw9PaSv OGLwCEJIr3HgO3T5I+FXuJdIugpgrqIe8xaPd6ANpqu9phDCZPhQf97SUnL09el/6DjmCXAbD +TysLhreVOkMJ/mpGLvV9MNg8FRm0Em9dWRopzNIHRDpcI8eKFQeYVLfnis+3cpvoUce1DbKT pPi8pVlaezUd8RInAZGj8AZ+Jyk4/Y25qUTwMneo4+JRrO9dmmDXDnAjJ/ap3ve22SU4uC1KX we/FtVFt7aIaR9uNxdRv/pFBU8yiQxuJWd79jH2Vo4MNfKwmDHxxYzqC8ZNvMeMpYqwE02sJx FA/D9BljTRr67Cay38dNGk3OT2xPvPeZCNPp0Gt1PK0viE5xmYfmUvOe8VJf4gy38d7YSs1Xq oyFy06WpHYbvM= 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:125199 Archived-At: The update is still giving me trouble though. Could be a problem with pass= ing the arguments to rec-field-nwltok I have the following (defun rec-field-nwltok (beg end nwltok) (interactive (list (region-beginning) (region-end) (read-string "rec-field-nwltok: " nil nil ";; + "))) (replace-regexp "^" nwltok nil beg end) ) (add-hook 'emacs-lisp-mode-hook (defun myrec-field-nwltok () (define-key emacs-lisp-mode-map (kbd "H-z") #'rec-field-nwltok))) > Sent: Tuesday, November 10, 2020 at 7:03 PM > From: "Michael Heerdegen" > To: help-gnu-emacs@gnu.org > Subject: Re: Adding String to Beginning of Lines > > Christopher Dimech writes: > > > 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) > > Yeah, because it's, ehm, nonsense. > > You want to bind your key in a keymap, and do that in the hook, e.g. > > (add-hook 'emacs-lisp-mode-hook > (defun my-emacs-lisp-mode-hook-fun () > (define-key emacs-lisp-mode-map (kbd "H-z") #'rec-field-nwlt= ok))) > > Hooks contain functions. I use to use named functions because lambdas > cannot be identified should you reload your piece of code and thus get > added multiple times. If you don't care (i.e. if you know for sure you > don't reload your init file) a lambda also works. > > > Regards, > > Michael. > > >