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

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

Re: is insert(backspace and overwrite character) possible?


From: Andreas Politz
Subject: Re: is insert(backspace and overwrite character) possible?
Date: Sun, 09 May 2010 12:19:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

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


reply via email to

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