From: C K Kashyap <ckkashyap@gmail.com>
To: Jambunathan K <kjambunathan@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: narrow-to-region for a rectangle
Date: Wed, 5 Jun 2013 12:04:30 +0530 [thread overview]
Message-ID: <CAGdT1gpOOvrnvADLCqkSQWQ4844SpzeOxC+zbHYJ3x-9x4Ge5A@mail.gmail.com> (raw)
In-Reply-To: <CAGdT1gqH4oi_R4=btT6XttqX3gfx6NTsv3rzOv91um4TLTLn2A@mail.gmail.com>
This is what I've come up with. I'd really appreciate some feedback.
(defun k-quotes (beg end st en)
(interactive "r*\nsStart Pattern: \nsEnd Pattern: \n")
(save-excursion
(save-restriction
(string-rectangle beg end st)
(move-end-of-line nil)
(setq newEnd (point))
(goto-char beg)
(replace-regexp "$" en nil beg newEnd)
(replace-regexp (concat en "$") "")
)))
Regards,
Kashyap
On Tue, Jun 4, 2013 at 6:23 PM, C K Kashyap <ckkashyap@gmail.com> wrote:
> The function below takes in a region and surrounds each line with input
> strings -
>
> (defun k-quotes (beg end st en)
> (interactive "r*\nsStart Pattern: \nsEnd Pattern: \n")
> (save-excursion
> (save-restriction
> (narrow-to-region beg end)
> (goto-char beg)
> (replace-regexp "\\(.*\\)" (concat st "\\1" en))
> )))
>
> I'd like this function to be able to restrict to a rectangle instead of a
> region. While on the first line it restricts "^" to match whereever I
> started the mark from - on the rest of the lines, its the beginning of the
> line.
>
> Regards,
> Kashyap
>
>
> On Tue, Jun 4, 2013 at 6:10 PM, Jambunathan K <kjambunathan@gmail.com>wrote:
>
>> C K Kashyap <ckkashyap@gmail.com> writes:
>>
>> > Hi,
>> > Is there a function that restricts the modifiable area to the rectangle
>> > rather than the region?
>>
>> If such a thing is available, what will you do with it? Give an
>> example.
>>
>> > Regards,
>> > Kashyap
>>
>
>
next prev parent reply other threads:[~2013-06-05 6:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-04 12:23 narrow-to-region for a rectangle C K Kashyap
2013-06-04 12:40 ` Jambunathan K
2013-06-04 12:53 ` C K Kashyap
2013-06-05 6:34 ` C K Kashyap [this message]
2013-06-05 6:50 ` Jambunathan K
2013-06-06 6:06 ` C K Kashyap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGdT1gpOOvrnvADLCqkSQWQ4844SpzeOxC+zbHYJ3x-9x4Ge5A@mail.gmail.com \
--to=ckkashyap@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=kjambunathan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).