how to restrict the numbers of chars in a buffer/file

Stephen J. Turnbull stephen at xemacs.org
Wed Aug 2 13:19:02 EDT 2006


>>>>> "Uwe" == Uwe Brauer <oub at mat.ucm.es> writes:

    Uwe> Hello Is there any possibility that a given buffer/file only
    Uwe> admits say 150 chars but not more?

Yes.  See the variables `write-file-hooks' and
`local-write-file-hooks'.  You would put something like

(lambda () (> (buffer-size) 150))

on `local-write-file-hook' with `add-hook'.  The function for
`write-file-hooks' would have to be more complex, as it would need to
check which buffers it applies to somehow.  You might also want to
call `set-buffer-modified-p' appropriately, and probably `warn' or
`error' to tell the user that the maximum file size had been exceeded.

I'd need to know more about the use case to say more about what you
*should* do (which hook to use, how to make it convenient, etc), but
that should give you an idea of *how* to do it.


-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.




More information about the XEmacs-Beta mailing list