[Top][All Lists]

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

Re: Adding String to Beginning of Lines

From: Jean Louis
Subject: Re: Adding String to Beginning of Lines
Date: Tue, 10 Nov 2020 17:03:39 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Christopher Dimech <> [2020-11-10 15:06]:
> Have used the following
> (defun compfx ()
>   (interactive "r")
>   (query-replace-regexp "^" ";; + "))

You can also record keyboard macros for repeated work.

See Emacs Lisp manual where it speaks about macros.

You would do:

F3 to start recording macro, then you do necessary actions like
commenting the page.

Press F4 to save macro.

Apply F4 in any buffer you wish.

Use `C-x C-k n' to name the last recorded macro.

Then you can save the macro into buffer and then into file:

(fset 'comment
   (kmacro-lambda-form [?\M-< ?\M-x ?r ?e ?p ?l ?a ?c tab ?r ?e ?g ?e tab 
return ?^ return ?\; ?\; ?  return] 0 "%d"))

That is what I did above for commenting first lines with ;; and named
the macro comment.

If you evaluate the above or load it from init.el or other file, you
can then invoke macro with:

M-x comment RET and it will do what you wanted.


reply via email to

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