all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Why is there no selected region in the second case
@ 2008-09-29 16:30 Decebal
  2008-09-30 17:00 ` Nikolaj Schumacher
       [not found] ` <mailman.20263.1222794037.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Decebal @ 2008-09-29 16:30 UTC (permalink / raw
  To: help-gnu-emacs

I have made the folowing function:
#####
(defun do-make-tab-seperated-file ()
  (goto-char (point-min))
  (push-mark (point) t t)
  (re-search-forward "^=" nil t)
  (beginning-of-line)
  (next-line 2)
  (delete-region (region-beginning) (region-end))
  (re-search-forward "^=" nil t)
  (beginning-of-line)
  (push-mark (point) t t)
  (goto-char (point-max))
)
#####

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?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why is there no selected region in the second case
  2008-09-29 16:30 Why is there no selected region in the second case Decebal
@ 2008-09-30 17:00 ` Nikolaj Schumacher
       [not found] ` <mailman.20263.1222794037.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolaj Schumacher @ 2008-09-30 17:00 UTC (permalink / raw
  To: Decebal; +Cc: help-gnu-emacs

Decebal <CLDWesterhof@gmail.com> 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))))


regards,
Nikolaj Schumacher




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why is there no selected region in the second case
       [not found] ` <mailman.20263.1222794037.18990.help-gnu-emacs@gnu.org>
@ 2008-10-01  7:42   ` Decebal
  0 siblings, 0 replies; 3+ messages in thread
From: Decebal @ 2008-10-01  7:42 UTC (permalink / raw
  To: help-gnu-emacs

On Sep 30, 7:00 pm, Nikolaj Schumacher <m...@nschum.de> wrote:
> Decebal <CLDWester...@gmail.com> 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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-01  7:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-29 16:30 Why is there no selected region in the second case Decebal
2008-09-30 17:00 ` Nikolaj Schumacher
     [not found] ` <mailman.20263.1222794037.18990.help-gnu-emacs@gnu.org>
2008-10-01  7:42   ` Decebal

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.