emacs-devel
[Top][All Lists]
Advanced

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

Re: Changing of line format and undo


From: David Kastrup
Subject: Re: Changing of line format and undo
Date: Wed, 21 Jun 2006 18:31:18 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Lennart Borgman <address@hidden> writes:

> David Kastrup wrote:
>> Lennart Borgman <address@hidden> writes:
>>
>>   
>>> Eli Zaretskii wrote:
>>>     
>>>>> Date: Wed, 21 Jun 2006 00:15:17 +0200
>>>>> From: Lennart Borgman <address@hidden>
>>>>>
>>>>> If you change line endings this change is not saved to undo. Is
>>>>> this the expected behaviour?
>>>>>             
>>>> If you mean "C-x RET f", then it doesn't really change anything.  It
>>>> just sets a buffer-local variable to some value.  So there's nothing
>>>> to undo.
>>>>         
>>> That is an internal Emacs perpective. From a users point of view there
>>> is truly a change. If you for example change the line endings the file
>>> will be saved with this new line endings.
>>>
>>> BTW should not changes of this kind also set the buffer to modified?
>>>     
>>
>> What makes you think they don't?
>>
>>   
> Test this for example:
>
>    (defun test-set-eol()
>      (interactive)
>      (let* ((coding buffer-file-coding-system)
>             (new-coding (coding-system-change-eol-conversion coding 2)))
>        (setq buffer-file-coding-system new-coding)))

Very funny.  setq most certainly does not trigger effects like a
changed buffer modification flag.  But setq is not a user-level
command.  Here is one that is:

C-x RET f (translated from C-x <return> f) runs the command 
set-buffer-file-coding-system
   which is an interactive compiled Lisp function in `mule.el'.
It is bound to C-x RET f, <menu-bar> <options> <mule> 
<set-various-coding-system> <set-buffer-file-coding-system>.
(set-buffer-file-coding-system CODING-SYSTEM &optional FORCE NOMODIFY)

Set the file coding-system of the current buffer to CODING-SYSTEM.
This means that when you save the buffer, it will be converted
according to CODING-SYSTEM.  For a list of possible values of CODING-SYSTEM,
use M-x list-coding-systems.

If CODING-SYSTEM leaves the text conversion unspecified, or if it
leaves the end-of-line conversion unspecified, FORCE controls what to
do.  If FORCE is nil, get the unspecified aspect (or aspects) from the
buffer's previous `buffer-file-coding-system' value (if it is
specified there).  Otherwise, leave it unspecified.

This marks the buffer modified so that the succeeding M-x save-buffer
surely saves the buffer with CODING-SYSTEM.  From a program, if you
don't want to mark the buffer modified, specify t for NOMODIFY.
If you know exactly what coding system you want to use,
just set the variable `buffer-file-coding-system' directly.


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

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