emacs-devel
[Top][All Lists]
Advanced

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

Re: Partial wdired (edit just filename at the point)


From: Arthur Miller
Subject: Re: Partial wdired (edit just filename at the point)
Date: Wed, 17 Mar 2021 14:58:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Never used 'before-change-function, so I didn't think about it :).
>>
>> Sure, as a strategy it sounds good indeed, but I am not sure I
>> understand how to apply that hook in this case. Docs says it is called
>> before any buffer mdification, but I am not sure what it means: before
>> every key-press in this case or what is ment with buffer modification here?
>
> Not "before a key press" because it can't know you're about to press
> a key, and even if it knows, it can't easily know what that command
> will do.

Well of course not; Emacs can't know when I am going to press a key, :-),
that is not what I ment.

I ment after a key is pressed Emacs will call it before the actuall
character is inserted into buffer. What I want to know is if it is going
to be called in context of every keypress, i.e. every insert, and from
your following statement it seems it will be.

The problem here is how aborting changes is implemented in wdired: undo
is disabled and original code just copies entire buffer and pastes it back
when changes are aborted. I do same strategy but just for the line in
question. Question is how to do this when multiple lines are edited. I
would like to skip copying entire buffer into buffer-string as wdired
does originally. I'll see if enabling undo stack can help; I think the
problem will be to keep away from editing certain part of lines
(timestamps and alike).

> Yes, I understand, but I think we can have our cake and eat it too: be
> super-fast when editing only a single line yet without having to tell
> Emacs in advance whether we plan to edit only a single line or all
> the lines.

I agree with you, but I am not sure how to implement it. My hack was
literally less than a 5 minute change, I just removed loops and changed
mode name so I can abort it properly.

It would be actually very trivial if wdired didn't manipulated text
properties for entire buffer; i.e. if we used only read-only property
for entire buffer, i.e. a "naive approach" where entire buffer is
guarded with just one variable. I understand original author choosed to
go via text properties for a good reason, I am not sure which one
though: just extra safety in case of accidental change, or is there some
other?







reply via email to

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