help-gnu-emacs
[Top][All Lists]
Advanced

[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 18:52:04 +0100

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" <michael_heerdegen@web.de>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Adding String to Beginning of Lines
>
> Christopher Dimech <dimech@gmx.com> writes:
>
> > Correct,  the replacement.  Because in .el files, the replacement will be
> > ";; + ", in other languages, it is dependent on the symbol for comments
> > (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.
>



reply via email to

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