all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* is insert(backspace and overwrite character) possible?
@ 2010-05-08 20:01 Merciadri Luca
  2010-05-09  0:41 ` Barry Margolin
  0 siblings, 1 reply; 5+ messages in thread
From: Merciadri Luca @ 2010-05-08 20:01 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

In some definition, I have

==
(insert "-- \n")
==

Let's say that the text is

==
dummy text

==

It then writes
==
dummy text
- --

==

That's nice, but my text is not that one, unfortunately. Let's say
that the text is

==
dummy text
- - --
==

How can I make an `insert' to overwrite the first `-' and the related
space? With

==
dummy text
- - --
==

I would like to have

==
dummy text
- --
==

by simply calling insert. Is it possible? I know that this is possible
in C language.

Thanks.

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

Love is real only when a person can sacrifice himself for
 another. (Leo Tolstoy)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkvlwv8ACgkQM0LLzLt8MhwHeQCgjYZbaJA62oMpmrFrT0kqsZO1
f9cAniHdrebw41a9y19RHChCP4JpD3IF
=SH+W
-----END PGP SIGNATURE-----


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

* Re: is insert(backspace and overwrite character) possible?
  2010-05-08 20:01 is insert(backspace and overwrite character) possible? Merciadri Luca
@ 2010-05-09  0:41 ` Barry Margolin
  2010-05-09  6:58   ` Merciadri Luca
  0 siblings, 1 reply; 5+ messages in thread
From: Barry Margolin @ 2010-05-09  0:41 UTC (permalink / raw)
  To: help-gnu-emacs

In article <87r5lm6u4g.fsf@merciadriluca-station.MERCIADRILUCA>,
 Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> In some definition, I have
> 
> ==
> (insert "-- \n")
> ==
> 
> Let's say that the text is
> 
> ==
> dummy text
> 
> ==
> 
> It then writes
> ==
> dummy text
> - --
> 
> ==
> 
> That's nice, but my text is not that one, unfortunately. Let's say
> that the text is
> 
> ==
> dummy text
> - - --
> ==
> 
> How can I make an `insert' to overwrite the first `-' and the related
> space? With
> 
> ==
> dummy text
> - - --
> ==
> 
> I would like to have
> 
> ==
> dummy text
> - --
> ==
> 
> by simply calling insert. Is it possible? I know that this is possible
> in C language.

You can't do it just with insert, and I don't know how you would do it 
in C, either.  You need to write a conditional, like

(if (looking-at "- ")
    (delete-char 2))

before doing the insert.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


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

* Re: is insert(backspace and overwrite character) possible?
  2010-05-09  0:41 ` Barry Margolin
@ 2010-05-09  6:58   ` Merciadri Luca
  2010-05-09 10:19     ` Andreas Politz
  0 siblings, 1 reply; 5+ messages in thread
From: Merciadri Luca @ 2010-05-09  6:58 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Barry Margolin <barmar@alum.mit.edu> writes:

> You can't do it just with insert, and I don't know how you would do it 
> in C, either.  You need to write a conditional, like
>
> (if (looking-at "- ")
>     (delete-char 2))
>
> before doing the insert.

Thanks. I do not remember for the C, but I am pretty sure that I had
already used it (in the past).
- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

It is possible to be born an aristocrat without ever becoming a
 gentleman. (Nicholas Ridley)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkvmXQEACgkQM0LLzLt8MhzyRgCeLUA/4zGAnGtrkd19y6A984aa
P88AoI5OXweV6myXwfZ4mvEYevoIcJ0f
=E/t0
-----END PGP SIGNATURE-----


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

* Re: is insert(backspace and overwrite character) possible?
  2010-05-09  6:58   ` Merciadri Luca
@ 2010-05-09 10:19     ` Andreas Politz
  2010-05-09 12:20       ` Merciadri Luca
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Politz @ 2010-05-09 10:19 UTC (permalink / raw)
  To: help-gnu-emacs

Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> writes:

> Barry Margolin <barmar@alum.mit.edu> writes:
>
>> You can't do it just with insert, and I don't know how you would do it
>> in C, either.  You need to write a conditional, like
>>
>> (if (looking-at "- ")
>>     (delete-char 2))
>>
>> before doing the insert.
>
> Thanks. I do not remember for the C, but I am pretty sure that I had
> already used it (in the past).

You are probably thinking of carriage return.

    printf("foo\rbar\n");

will print 'bar'.

Anyway, we can create a overwriting `insert' variant.

(defun insert-overwrite (&rest args)
  (let ((pos (point)))
    (apply 'insert args)
    (delete-region (point) (min (point-at-eol)
                                (+ (point)
                                   (- (point) pos))))))

But my guess is, that you actually want something like this.

(defun replace-line (&rest args)
  (delete-region (point-at-bol) (point-at-eol))
  (apply 'insert args))


-ap


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

* Re: is insert(backspace and overwrite character) possible?
  2010-05-09 10:19     ` Andreas Politz
@ 2010-05-09 12:20       ` Merciadri Luca
  0 siblings, 0 replies; 5+ messages in thread
From: Merciadri Luca @ 2010-05-09 12:20 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andreas Politz <politza@fh-trier.de> writes:

> Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> writes:
>
>> Barry Margolin <barmar@alum.mit.edu> writes:
>>
>>> You can't do it just with insert, and I don't know how you would do it
>>> in C, either.  You need to write a conditional, like
>>>
>>> (if (looking-at "- ")
>>>     (delete-char 2))
>>>
>>> before doing the insert.
>>
>> Thanks. I do not remember for the C, but I am pretty sure that I had
>> already used it (in the past).
>
> You are probably thinking of carriage return.
>
>     printf("foo\rbar\n");
>
> will print 'bar'.
>
> Anyway, we can create a overwriting `insert' variant.
>
> (defun insert-overwrite (&rest args)
>   (let ((pos (point)))
>     (apply 'insert args)
>     (delete-region (point) (min (point-at-eol)
>                                 (+ (point)
>                                    (- (point) pos))))))
>
> But my guess is, that you actually want something like this.
>
> (defun replace-line (&rest args)
>   (delete-region (point-at-bol) (point-at-eol))
>   (apply 'insert args))
Thanks. Actually, it could do the trick. As you might see in my
signature, the delimiters are not standard: I am having `- --' at the
place of `--'. This should be due to many facts in my .gnus:

* I have set
==
(setq gnus-signature-separator '("^--$"))
==

* I have defined a command which adds a quirk like this:

==
(defun psig ()
  "Insert the signature for a personal posting on a newsgroup, including a saying."
  (interactive)
  (goto-char (point-max))
  (or (= (char-after (- (point) 1)) ?\n)
      (newline 1))
  (insert "-- \n")
  (let ((saying ""))
    (save-window-excursion
      (find-file "~/Sayings")
      (goto-char (point-min))
      (search-forward "#")
      (delete-char -1)
      (setq fill-prefix nil)
      (mark-paragraph)
      (setq saying (buffer-substring (region-beginning) (region-end)))
      (exchange-point-and-mark)
      (if (eobp) (goto-char (1+ (point-min))))
      ;(insert "#")
      (save-buffer))
    (insert saying)
    )) 
==

* I am using Mailcrypt (but I do not want to change).

Do you have any idea of what could be causing this problematic
signature?

Thanks.


- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

Big thunder. Little rain.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkvmqJkACgkQM0LLzLt8MhzdyQCgjKmBE69mo0pjaHrJtCZPrVCM
hPUAn0j2fivhx+PeACaw8WYOjLCyuLH+
=6wkS
-----END PGP SIGNATURE-----


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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-08 20:01 is insert(backspace and overwrite character) possible? Merciadri Luca
2010-05-09  0:41 ` Barry Margolin
2010-05-09  6:58   ` Merciadri Luca
2010-05-09 10:19     ` Andreas Politz
2010-05-09 12:20       ` Merciadri Luca

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.