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 12:19:32 +0100

Hell, I started doing like this.  Still a good exercise though.

(defun comblock (rg-beg rg-end)
   "TODO"
   (interactive "r")
   (if (use-region-p)
      (progn
         (goto-char rg-beg)
         (beginning-of-line)
         (setq myLine
            (buffer-substring-no-properties
               (line-beginning-position)
               (line-end-position) ))
         (message "region active"))
      (message "region not active"))
)



> Sent: Tuesday, November 10, 2020 at 12:10 PM
> From: tomas@tuxteam.de
> To: help-gnu-emacs@gnu.org
> Subject: Re: Adding String to Beginning of Lines
>
> On Tue, Nov 10, 2020 at 11:43:45AM +0100, Christopher Dimech wrote:
> > 
> > I have a paragraph and want to add a string to the beginning of each line 
> > after selecting
> > the paragraph region.
> > 
> > GNU is an operating system that is free software—that is, it respects 
> > users' freedom. The
> > GNU operating system consists of GNU packages (programs specifically 
> > released by the GNU 
> > Project) as well as free software released by third parties. The 
> > development of GNU made
> > it possible to use a computer without software that would trample your 
> > freedom.
> > 
> > Example, passing ';; + ' as argument to a function to get
> > 
> > ;; + GNU is an operating system that is free software—that is, it respects 
> > users' freedom. The
> > ;; + GNU operating system consists of GNU packages (programs specifically 
> > released by the GNU 
> > ;; + Project) as well as free software released by third parties. The 
> > development of GNU made
> > ;; + it possible to use a computer without software that would trample your 
> > freedom.
> 
>  - Select the region
>  - M-x query-replace-regexp "^" → ";; + "
>  - Profit!
> 
> Wrapping that up in a function is left as an exercise to the
> reader :-)
> 
> Cheers
> -- t
>



reply via email to

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