all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Inserting some text in a working buffer
@ 2021-05-08  6:28 michael-franzese
  2021-05-08  8:22 ` michael-franzese
  0 siblings, 1 reply; 6+ messages in thread
From: michael-franzese @ 2021-05-08  6:28 UTC (permalink / raw)
  To: Help Gnu Emacs

Is it possible to insert some text in a working buffer starting flom the
beginning of the line.





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

* Re: Inserting some text in a working buffer
  2021-05-08  6:28 Inserting some text in a working buffer michael-franzese
@ 2021-05-08  8:22 ` michael-franzese
  2021-05-08 18:02   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 6+ messages in thread
From: michael-franzese @ 2021-05-08  8:22 UTC (permalink / raw)
  To: michael-franzese; +Cc: Help Gnu Emacs

Have done this to write to the working buffer.  But if there is not enough space
till the end of the buffer, continuing to call "insert-text" will not insert.

(defun insert-text (text)
  "Inserts text frem beginning of line located at cursor point."
  (interactive)

  (with-current-buffer (buffer-name)
    (goto-char (point))
    (insert text)
    (next-line)) )





> Sent: Saturday, May 08, 2021 at 6:28 PM
> From: michael-franzese@gmx.com
> To: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Inserting some text in a working buffer
>
> Is it possible to insert some text in a working buffer starting flom the
> beginning of the line.
>
>
>
>



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

* Re: Inserting some text in a working buffer
  2021-05-08  8:22 ` michael-franzese
@ 2021-05-08 18:02   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-05-09  3:59     ` michael-franzese
  0 siblings, 1 reply; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-05-08 18:02 UTC (permalink / raw)
  To: help-gnu-emacs

michael-franzese wrote:

> (defun insert-text (text)
>   "Inserts text frem beginning of line located at cursor point."
>   (interactive)
>   (with-current-buffer (buffer-name)
>     (goto-char (point))
>     (insert text)
>     (next-line)) )

Hahaha :)

"(with-current-buffer (buffer-name)" - you are already in that
buffer...

and "(goto-char (point))" - you are already there!

"(next-line)" - see the help, one should use `forward-line'...

There is nothing in the code to do it "frem" beginning of line
but you can use `beginning-of-line' for that...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Inserting some text in a working buffer
  2021-05-08 18:02   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-05-09  3:59     ` michael-franzese
  2021-05-09  4:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 6+ messages in thread
From: michael-franzese @ 2021-05-09  3:59 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs


Thank you Emanuel, glad you found the post amusing.

Apart further into giggles, I would  like to insert the text starting from the current
point to column position 62.  But with the following code, the text is being inserted
before (point) rather than at (point).


(defun text-insert (text)
  "Inserts text starting at cursor point."
  (interactive)

  (message "[text-insert] p %d" (point))
  (insert text)
  (forward-line) )

(defun bifurc ()
  "Insert text at point"
  (interactive)

  (message "(line-beginning-position) (point) %d %d"
	   (line-beginning-position) (point))

  (setq-local d (- (point) (line-beginning-position)))
  (setq-local n (- 63 d))
  (setq-local m (- 69 d))
  (message "[bifurc] (m,n) %d %d %d" m n d)

  (setq-local s (make-string n ?\;))

  (text-insert s) )







> Sent: Sunday, May 09, 2021 at 6:02 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Inserting some text in a working buffer
>
> michael-franzese wrote:
>
> > (defun insert-text (text)
> >   "Inserts text frem beginning of line located at cursor point."
> >   (interactive)
> >   (with-current-buffer (buffer-name)
> >     (goto-char (point))
> >     (insert text)
> >     (next-line)) )
>
> Hahaha :)
>
> "(with-current-buffer (buffer-name)" - you are already in that
> buffer...
>
> and "(goto-char (point))" - you are already there!
>
> "(next-line)" - see the help, one should use `forward-line'...
>
> There is nothing in the code to do it "frem" beginning of line
> but you can use `beginning-of-line' for that...
>
> --
> underground experts united
> https://dataswamp.org/~incal
>
>
>



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

* Re: Inserting some text in a working buffer
  2021-05-09  3:59     ` michael-franzese
@ 2021-05-09  4:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-05-09  7:12         ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-05-09  4:11 UTC (permalink / raw)
  To: help-gnu-emacs

michael-franzese wrote:

> Thank you Emanuel, glad you found the post amusing.
>
> Apart further into giggles, I would like to insert the text
> starting from the current point to column position 62.
> But with the following code, the text is bei= ng inserted
> before (point) rather than at (point).

(defun insert-char-to-col (char col)
  "Insert CHAR to COL."
  (interactive "cchar: \nncol: ")
  (let*((len (- col (current-column)))
        (str (make-string len char)) )
    (insert str) ))

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Inserting some text in a working buffer
  2021-05-09  4:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-05-09  7:12         ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2021-05-09  7:12 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sun, 09 May 2021 06:11:21 +0200
> From:  Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
> 
> (defun insert-char-to-col (char col)
>   "Insert CHAR to COL."
>   (interactive "cchar: \nncol: ")
>   (let*((len (- col (current-column)))
>         (str (make-string len char)) )
>     (insert str) ))

This seems to assume that each character takes just one column.  But
some characters, called "double-width characters", take 2 columns, not
1.  So using make-string here is not TRT, because its LENGTH argument
counts characters, not columns.



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

end of thread, other threads:[~2021-05-09  7:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-08  6:28 Inserting some text in a working buffer michael-franzese
2021-05-08  8:22 ` michael-franzese
2021-05-08 18:02   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09  3:59     ` michael-franzese
2021-05-09  4:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09  7:12         ` Eli Zaretskii

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.