[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding String to Beginning of Lines

From: Christopher Dimech
Subject: Re: Adding String to Beginning of Lines
Date: Tue, 10 Nov 2020 19:25:45 +0100

The update is still giving me trouble though. Could be a problem with passing 
the arguments
to rec-field-nwltok

I have the following

(defun rec-field-nwltok (beg end nwltok)
      (list (region-beginning)
            (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:
> 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-nwltok)))
> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]