unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Heime <heimeborgia@protonmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Inserting at particular buffer position
Date: Sun, 4 Dec 2022 17:11:43 +0300	[thread overview]
Message-ID: <Y4yqn1msv94a5D4D@protected.localdomain> (raw)
In-Reply-To: <HPSE0aYju6Y8UcCdoGpEh_Cp0fiom9JDYs1slfmtzjyQKs2ADswh0FuNFFyphEt8_vOe5HjLcEWwGIeglTH0NBoVrh4OQWGdO25mfkcj5Cs=@protonmail.com>

* 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/



  reply	other threads:[~2022-12-04 14:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=Y4yqn1msv94a5D4D@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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).