* Inserting at particular buffer position
@ 2022-12-04 1:12 Heime
2022-12-04 7:24 ` Eli Zaretskii
2022-12-04 13:21 ` Jean Louis
0 siblings, 2 replies; 18+ messages in thread
From: Heime @ 2022-12-04 1:12 UTC (permalink / raw)
To: Heime via Users list for the GNU Emacs text editor
The function "insert", inserts characters into the current buffer, at point, moving point forward.
But how can I insert at a particular position (row column).
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 1:12 Inserting at particular buffer position Heime
@ 2022-12-04 7:24 ` Eli Zaretskii
2022-12-04 8:04 ` Heime
2022-12-04 13:21 ` Jean Louis
1 sibling, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2022-12-04 7:24 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sun, 04 Dec 2022 01:12:52 +0000
> From: Heime <heimeborgia@protonmail.com>
>
>
> The function "insert", inserts characters into the current buffer, at point, moving point forward.
> But how can I insert at a particular position (row column).
You need to move point there first. For example, with goto-char (if you
know the buffer position), or with forward-line followed by move-to-column
(of you know the line and column).
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 7:24 ` Eli Zaretskii
@ 2022-12-04 8:04 ` Heime
2022-12-04 10:01 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Heime @ 2022-12-04 8:04 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
------- Original Message -------
On Sunday, December 4th, 2022 at 7:24 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Sun, 04 Dec 2022 01:12:52 +0000
> > From: Heime heimeborgia@protonmail.com
> >
> > The function "insert", inserts characters into the current buffer, at point, moving point forward.
> > But how can I insert at a particular position (row column).
>
>
> You need to move point there first. For example, with goto-char (if you
> know the buffer position), or with forward-line followed by move-to-column
> (of you know the line and column).
A problem that I encounter is that if the position (row col) is not available,
point does not switch to the correct position.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 8:04 ` Heime
@ 2022-12-04 10:01 ` Eli Zaretskii
2022-12-04 11:16 ` Heime
2022-12-04 13:22 ` Jean Louis
2022-12-04 13:30 ` Jean Louis
2 siblings, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2022-12-04 10:01 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sun, 04 Dec 2022 08:04:03 +0000
> From: Heime <heimeborgia@protonmail.com>
> Cc: help-gnu-emacs@gnu.org
>
> ------- Original Message -------
> On Sunday, December 4th, 2022 at 7:24 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>
> > > Date: Sun, 04 Dec 2022 01:12:52 +0000
> > > From: Heime heimeborgia@protonmail.com
> > >
> > > The function "insert", inserts characters into the current buffer, at point, moving point forward.
> > > But how can I insert at a particular position (row column).
> >
> >
> > You need to move point there first. For example, with goto-char (if you
> > know the buffer position), or with forward-line followed by move-to-column
> > (of you know the line and column).
>
> A problem that I encounter is that if the position (row col) is not available,
> point does not switch to the correct position.
What do you mean by "position not available"?
How do you compute that position's row and column, if it isn't available?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 10:01 ` Eli Zaretskii
@ 2022-12-04 11:16 ` Heime
2022-12-04 11:49 ` Eli Zaretskii
0 siblings, 1 reply; 18+ messages in thread
From: Heime @ 2022-12-04 11:16 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
------- Original Message -------
On Sunday, December 4th, 2022 at 10:01 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Sun, 04 Dec 2022 08:04:03 +0000
> > From: Heime heimeborgia@protonmail.com
> > Cc: help-gnu-emacs@gnu.org
> >
> > ------- Original Message -------
> > On Sunday, December 4th, 2022 at 7:24 AM, Eli Zaretskii eliz@gnu.org wrote:
> >
> > > > Date: Sun, 04 Dec 2022 01:12:52 +0000
> > > > From: Heime heimeborgia@protonmail.com
> > > >
> > > > The function "insert", inserts characters into the current buffer, at point, moving point forward.
> > > > But how can I insert at a particular position (row column).
> > >
> > > You need to move point there first. For example, with goto-char (if you
> > > know the buffer position), or with forward-line followed by move-to-column
> > > (of you know the line and column).
> >
> > A problem that I encounter is that if the position (row col) is not available,
> > point does not switch to the correct position.
>
>
> What do you mean by "position not available"?
>
> How do you compute that position's row and column, if it isn't available?
Suppose I insert in the current buffer, to a line larger than the greatest line
where the cursor can go. Nothing gets printed after that. And if I try to print
to a column which is larger than available whitespace, things do not get printed.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 11:16 ` Heime
@ 2022-12-04 11:49 ` Eli Zaretskii
2022-12-04 12:10 ` Eli Zaretskii
2022-12-04 12:27 ` Heime
0 siblings, 2 replies; 18+ messages in thread
From: Eli Zaretskii @ 2022-12-04 11:49 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sun, 04 Dec 2022 11:16:47 +0000
> From: Heime <heimeborgia@protonmail.com>
> Cc: help-gnu-emacs@gnu.org
>
> > > A problem that I encounter is that if the position (row col) is not available,
> > > point does not switch to the correct position.
> >
> >
> > What do you mean by "position not available"?
> >
> > How do you compute that position's row and column, if it isn't available?
>
> Suppose I insert in the current buffer, to a line larger than the greatest line
> where the cursor can go. Nothing gets printed after that. And if I try to print
> to a column which is larger than available whitespace, things do not get printed.
Insert enough newlines where you lack lines, and insert enough SPC
characters to have the column you want.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 11:49 ` Eli Zaretskii
@ 2022-12-04 12:10 ` Eli Zaretskii
2022-12-04 12:27 ` Heime
1 sibling, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2022-12-04 12:10 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sun, 04 Dec 2022 13:49:39 +0200
> From: Eli Zaretskii <eliz@gnu.org>
>
> > Date: Sun, 04 Dec 2022 11:16:47 +0000
> > From: Heime <heimeborgia@protonmail.com>
> > Cc: help-gnu-emacs@gnu.org
> >
> > > > A problem that I encounter is that if the position (row col) is not available,
> > > > point does not switch to the correct position.
> > >
> > >
> > > What do you mean by "position not available"?
> > >
> > > How do you compute that position's row and column, if it isn't available?
> >
> > Suppose I insert in the current buffer, to a line larger than the greatest line
> > where the cursor can go. Nothing gets printed after that. And if I try to print
> > to a column which is larger than available whitespace, things do not get printed.
>
> Insert enough newlines where you lack lines, and insert enough SPC
> characters to have the column you want.
Also, the function move-to-column can optionally insert SPC characters if
the line is shorter than the column to which you want to get.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 11:49 ` Eli Zaretskii
2022-12-04 12:10 ` Eli Zaretskii
@ 2022-12-04 12:27 ` Heime
2022-12-04 12:38 ` Eli Zaretskii
1 sibling, 1 reply; 18+ messages in thread
From: Heime @ 2022-12-04 12:27 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
------- Original Message -------
On Sunday, December 4th, 2022 at 11:49 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Sun, 04 Dec 2022 11:16:47 +0000
> > From: Heime heimeborgia@protonmail.com
> > Cc: help-gnu-emacs@gnu.org
> >
> > > > A problem that I encounter is that if the position (row col) is not available,
> > > > point does not switch to the correct position.
> > >
> > > What do you mean by "position not available"?
> > >
> > > How do you compute that position's row and column, if it isn't available?
> >
> > Suppose I insert in the current buffer, to a line larger than the greatest line
> > where the cursor can go. Nothing gets printed after that. And if I try to print
> > to a column which is larger than available whitespace, things do not get printed.
>
>
> Insert enough newlines where you lack lines, and insert enough SPC
> characters to have the column you want.
I want to make a buffer with the respective text inserted automatically, without
any inputs from the user.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 12:27 ` Heime
@ 2022-12-04 12:38 ` Eli Zaretskii
0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2022-12-04 12:38 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sun, 04 Dec 2022 12:27:05 +0000
> From: Heime <heimeborgia@protonmail.com>
> Cc: help-gnu-emacs@gnu.org
>
> ------- Original Message -------
> On Sunday, December 4th, 2022 at 11:49 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>
> > > Date: Sun, 04 Dec 2022 11:16:47 +0000
> > > From: Heime heimeborgia@protonmail.com
> > > Cc: help-gnu-emacs@gnu.org
> > >
> > > > > A problem that I encounter is that if the position (row col) is not available,
> > > > > point does not switch to the correct position.
> > > >
> > > > What do you mean by "position not available"?
> > > >
> > > > How do you compute that position's row and column, if it isn't available?
> > >
> > > Suppose I insert in the current buffer, to a line larger than the greatest line
> > > where the cursor can go. Nothing gets printed after that. And if I try to print
> > > to a column which is larger than available whitespace, things do not get printed.
> >
> >
> > Insert enough newlines where you lack lines, and insert enough SPC
> > characters to have the column you want.
>
> I want to make a buffer with the respective text inserted automatically, without
> any inputs from the user.
I meant your Lisp program should make these insertions, not the user.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 1:12 Inserting at particular buffer position Heime
2022-12-04 7:24 ` Eli Zaretskii
@ 2022-12-04 13:21 ` Jean Louis
2022-12-04 15:52 ` Dr Rainer Woitok
1 sibling, 1 reply; 18+ messages in thread
From: Jean Louis @ 2022-12-04 13:21 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
* Heime <heimeborgia@protonmail.com> [2022-12-04 04:14]:
> The function "insert", inserts characters into the current buffer,
> at point, moving point forward. But how can I insert at a
> particular position (row column).
I have Deja Vu.
(defun goto-x-y (x y)
"Goto to line X, char Y."
(goto-line x)
(goto-char (point-at-bol))
(forward-char y))
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 8:04 ` Heime
2022-12-04 10:01 ` Eli Zaretskii
@ 2022-12-04 13:22 ` Jean Louis
2022-12-04 13:52 ` Heime
2022-12-04 13:30 ` Jean Louis
2 siblings, 1 reply; 18+ messages in thread
From: Jean Louis @ 2022-12-04 13:22 UTC (permalink / raw)
To: Heime; +Cc: help-gnu-emacs
* Heime <heimeborgia@protonmail.com> [2022-12-04 11:06]:
> A problem that I encounter is that if the position (row col) is not
> available, point does not switch to the correct position.
Good point, so make sure you have enough empty spaces.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 8:04 ` Heime
2022-12-04 10:01 ` Eli Zaretskii
2022-12-04 13:22 ` Jean Louis
@ 2022-12-04 13:30 ` Jean Louis
2022-12-05 6:21 ` Heime
2 siblings, 1 reply; 18+ messages in thread
From: Jean Louis @ 2022-12-04 13:30 UTC (permalink / raw)
To: Heime; +Cc: help-gnu-emacs
* Heime <heimeborgia@protonmail.com> [2022-12-04 11:06]:
> A problem that I encounter is that if the position (row col) is not
> available, point does not switch to the correct position.
Fill it with spaces.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 13:22 ` Jean Louis
@ 2022-12-04 13:52 ` Heime
2022-12-04 14:11 ` Jean Louis
0 siblings, 1 reply; 18+ messages in thread
From: Heime @ 2022-12-04 13:52 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs
------- Original Message -------
On Sunday, December 4th, 2022 at 1:22 PM, Jean Louis <bugs@gnu.support> wrote:
> * Heime heimeborgia@protonmail.com [2022-12-04 11:06]:
>
> > A problem that I encounter is that if the position (row col) is not
> > available, point does not switch to the correct position.
>
>
> Good point, so make sure you have enough empty spaces.
>
> --
> Jean
What can one do to get a new line and go to the beginning of the new line?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 13:52 ` Heime
@ 2022-12-04 14:11 ` Jean Louis
0 siblings, 0 replies; 18+ messages in thread
From: Jean Louis @ 2022-12-04 14:11 UTC (permalink / raw)
To: Heime; +Cc: help-gnu-emacs
* Heime <heimeborgia@protonmail.com> [2022-12-04 16:53]:
> What can one do to get a new line and go to the beginning of the new line?
By advise of Eli, using `move-to-column' that insert spaces if
necessary:
(defun goto-x-y-unconditionally (x y)
"Goto to line X, char Y unconditionally."
(let ((lines (count-lines (point-min) (point-max))))
(when (< lines x)
(goto-char (point-max))
(insert "\n" (make-string (- x lines) ?\n)))
(goto-line x)
(goto-char (point-at-bol))
(move-to-column y t)))
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 13:21 ` Jean Louis
@ 2022-12-04 15:52 ` Dr Rainer Woitok
2022-12-04 20:04 ` Heime
0 siblings, 1 reply; 18+ messages in thread
From: Dr Rainer Woitok @ 2022-12-04 15:52 UTC (permalink / raw)
To: Heime; +Cc: help-gnu-emacs
On Sunday, 2022-12-04 16:21:41 +0300, Jean Louis wrote:
> * Heime <heimeborgia@protonmail.com> [2022-12-04 04:14]:
> > The function "insert", inserts characters into the current buffer,
> > at point, moving point forward. But how can I insert at a
> > particular position (row column).
>
> I have Deja Vu.
>
> (defun goto-x-y (x y)
> "Goto to line X, char Y."
> (goto-line x)
> (goto-char (point-at-bol))
> (forward-char y))
Heime,
a week or so ago you flabbergasted me (and probably others) with your
claim that programming is neither engineering nor science, but rather
sports. This claim made me gasp at first, but gradually I am getting
your point. While what makes up the Art of Programming can be looked-up
in Donald Knuth's book, what makes up the Sports of Programming can be
looked-up in your mails: just stubbornly nag people with sometimes very
imprecise questions, assumptions and allegations, and sooner or later
good-natured people like Jean Louis and plenty of others fall victim to
your tactics and start writing you the programmes you need.
You have meanwhile got so many code snippets to solve your problems that
with a little additional manual reading, thinking, testing and adapting
your programme(s) should almost be working.
I take this as a Proof of Concept that programming is sports. Congratu-
lations :-)
Sincerely,
Rainer
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 15:52 ` Dr Rainer Woitok
@ 2022-12-04 20:04 ` Heime
0 siblings, 0 replies; 18+ messages in thread
From: Heime @ 2022-12-04 20:04 UTC (permalink / raw)
To: Dr Rainer Woitok; +Cc: help-gnu-emacs
Sent with Proton Mail secure email.
------- Original Message -------
On Sunday, December 4th, 2022 at 3:52 PM, Dr Rainer Woitok <rainer.woitok@gmail.com> wrote:
> On Sunday, 2022-12-04 16:21:41 +0300, Jean Louis wrote:
>
> > * Heime heimeborgia@protonmail.com [2022-12-04 04:14]:
> >
> > > The function "insert", inserts characters into the current buffer,
> > > at point, moving point forward. But how can I insert at a
> > > particular position (row column).
> >
> > I have Deja Vu.
> >
> > (defun goto-x-y (x y)
> > "Goto to line X, char Y."
> > (goto-line x)
> > (goto-char (point-at-bol))
> > (forward-char y))
>
>
> Heime,
>
> a week or so ago you flabbergasted me (and probably others) with your
> claim that programming is neither engineering nor science, but rather
> sports. This claim made me gasp at first, but gradually I am getting
> your point. While what makes up the Art of Programming can be looked-up
> in Donald Knuth's book, what makes up the Sports of Programming can be
> looked-up in your mails: just stubbornly nag people with sometimes very
> imprecise questions, assumptions and allegations, and sooner or later
> good-natured people like Jean Louis and plenty of others fall victim to
> your tactics and start writing you the programmes you need.
Sounds like an episode from "Our Gang", Doctor.
> You have meanwhile got so many code snippets to solve your problems that
> with a little additional manual reading, thinking, testing and adapting
> your programme(s) should almost be working.
>
> I take this as a Proof of Concept that programming is sports. Congratu-
> lations :-)
I'll invite you to the party for sure.
> Sincerely,
> Rainer
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-04 13:30 ` Jean Louis
@ 2022-12-05 6:21 ` Heime
2022-12-05 18:59 ` Jean Louis
0 siblings, 1 reply; 18+ messages in thread
From: Heime @ 2022-12-05 6:21 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs
------- Original Message -------
On Sunday, December 4th, 2022 at 1:30 PM, Jean Louis <bugs@gnu.support> wrote:
> * Heime heimeborgia@protonmail.com [2022-12-04 11:06]:
>
> > A problem that I encounter is that if the position (row col) is not
> > available, point does not switch to the correct position.
>
>
> Fill it with spaces.
>
> --
> Jean
I want to track the buffer position of five things. Could store them in an list.
How could I set the list up?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Inserting at particular buffer position
2022-12-05 6:21 ` Heime
@ 2022-12-05 18:59 ` Jean Louis
0 siblings, 0 replies; 18+ messages in thread
From: Jean Louis @ 2022-12-05 18:59 UTC (permalink / raw)
To: Heime; +Cc: help-gnu-emacs
* Heime <heimeborgia@protonmail.com> [2022-12-05 09:22]:
> I want to track the buffer position of five things. Could store
> them in an list. How could I set the list up?
Do you mean five buffer positions like five chars in a buffer?
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2022-12-05 18:59 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-04 1:12 Inserting at particular buffer position Heime
2022-12-04 7:24 ` Eli Zaretskii
2022-12-04 8:04 ` Heime
2022-12-04 10:01 ` Eli Zaretskii
2022-12-04 11:16 ` Heime
2022-12-04 11:49 ` Eli Zaretskii
2022-12-04 12:10 ` Eli Zaretskii
2022-12-04 12:27 ` Heime
2022-12-04 12:38 ` Eli Zaretskii
2022-12-04 13:22 ` Jean Louis
2022-12-04 13:52 ` Heime
2022-12-04 14:11 ` Jean Louis
2022-12-04 13:30 ` Jean Louis
2022-12-05 6:21 ` Heime
2022-12-05 18:59 ` Jean Louis
2022-12-04 13:21 ` Jean Louis
2022-12-04 15:52 ` Dr Rainer Woitok
2022-12-04 20:04 ` Heime
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).