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

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

Re: Inserting at particular buffer position


From: Jean Louis
Subject: Re: Inserting at particular buffer position
Date: Sun, 4 Dec 2022 17:11:43 +0300
User-agent: Mutt/2.2.9+50 (c79959e) (2022-11-21)

* 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 via email to

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