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

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

Re: Why is there no selected region in the second case


From: Decebal
Subject: Re: Why is there no selected region in the second case
Date: Wed, 1 Oct 2008 00:42:15 -0700 (PDT)
User-agent: G2/1.0

On Sep 30, 7:00 pm, Nikolaj Schumacher <address@hidden> wrote:
> Decebal <address@hidden> wrote:
> > The first push-mark works and I can delete with delete-region. But the
> > second does not work. There is no region selected after the last two
> > statements. What am I doing wrong?
>
> Actually the second one works, too.  However, in Emacs, the region is
> visually highlighted only when the mark is "active".
>
> Are you sure you want to activate the mark, though?  Normally you would
> save the position in a variable, something like this:
>
> (save-excursion
>   (goto-char (point-min))
>   (let ((beg (point)))
>     (re-search-forward "^=" nil t)
>     (forward-line 2)
>     (delete-region beg (point))))

That is much better yes. I allready did something like that:
  (goto-char (point-min))
  (re-search-forward "^=" nil nil)
  (forward-line 2)
  (delete-region (point-min) (point))
  (re-search-forward "^=" nil nil)
  (beginning-of-line)
  (delete-region (point) (point-max))

Because the buffer has to be deleted from the beginning, I do not need
to save the point. But otherwise it should be done offcourse.

Thanks for the info.


reply via email to

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