From: Richard M. Stallman Date: Tue, 29 Mar 2005 21:08:37 +0000 (+0000) Subject: (Buffer Contents): Add filter-buffer-substring and buffer-substring-filters. X-Git-Tag: ttn-vms-21-2-B4~1374 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8e669bbd42c254c32e3fffa489f4d97d48d9bd76;p=emacs.git (Buffer Contents): Add filter-buffer-substring and buffer-substring-filters. --- diff --git a/etc/NEWS b/etc/NEWS index c3134d08880..8e85c86dde8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2435,6 +2435,17 @@ coding system. * New modes and packages in Emacs 22.1 ++++ +** The new package longlines.el provides a minor mode for editing text +files composed of long lines, based on the `use-hard-newlines' +mechanism. The long lines are broken up by inserting soft newlines, +which are automatically removed when saving the file to disk or +copying into the kill ring, clipboard, etc. By default, Longlines +mode inserts soft newlines automatically during editing, a behavior +referred to as "soft word wrap" in other text editors. This is +similar to Refill mode, but more reliable. To turn the word wrap +feature off, set `longlines-auto-wrap' to nil. + +++ ** The new package conf-mode.el handles thousands of configuration files, with varying syntaxes for comments (;, #, //, /* */ or !), assignment (var = value, @@ -2711,6 +2722,17 @@ the command `undefined'. (In earlier Emacs versions, it used * Lisp Changes in Emacs 22.1 ++++ +** The new function `filter-buffer-substring' extracts a buffer +substring, passes it through a set of filter functions, and returns +the filtered substring. It is used instead of `buffer-substring' or +`delete-and-extract-region' when copying text into a user-accessible +data structure, like the kill-ring, X clipboard, or a register. The +list of filter function is specified by the new variable +`buffer-substring-filters'. For example, Longlines mode uses +`buffer-substring-filters' to remove soft newlines from the copied +text. + +++ ** An element of buffer-undo-list can now have the form (apply FUNNAME . ARGS), where FUNNAME is a symbol other than t or nil. That stands diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e2cdac00334..2ff35b7344d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,18 @@ +2005-03-29 Richard M. Stallman + + * simple.el (idle-update-delay): Move definition up. + +2005-03-29 Chong Yidong + + * longlines.el: New file. + + * simple.el (buffer-substring-filters): New variable. + (filter-buffer-substring): New function. + (kill-region, copy-region-as-kill): Use it. + + * register.el (copy-to-register, append-to-register) + (prepend-to-register): Use filter-buffer-substring. + 2005-03-30 Nick Roberts * progmodes/gud.el (gdb): (Re)-initialise gud-filter-pending-text. diff --git a/lispref/ChangeLog b/lispref/ChangeLog index 232e992e658..7f22ad2e485 100644 --- a/lispref/ChangeLog +++ b/lispref/ChangeLog @@ -1,3 +1,8 @@ +2005-03-29 Chong Yidong + + * text.texi (Buffer Contents): Add filter-buffer-substring and + buffer-substring-filters. + 2005-03-26 Chong Yidong * anti.texi (Antinews): Mention `G' interactive code. diff --git a/lispref/text.texi b/lispref/text.texi index e300b345454..1d4dc0fce8a 100644 --- a/lispref/text.texi +++ b/lispref/text.texi @@ -207,6 +207,41 @@ This is like @code{buffer-substring}, except that it does not copy text properties, just the characters themselves. @xref{Text Properties}. @end defun +@defun filter-buffer-substring start end &optional delete +This function passes the buffer text between @var{start} and @var{end} +through the filter functions specified by the variable +@code{buffer-substring-filters}, and returns the value from the last +filter function. If @code{buffer-substring-filters} is @code{nil}, +the value is the unaltered text from the buffer, what +@code{buffer-substring} would return. + +If @var{delete} is non-@code{nil}, this function deletes the text +between @var{start} and @var{end} after copying it, like +@code{delete-and-extract-region}. + +Lisp code should use this function instead of @code{buffer-substring} +or @code{delete-and-extract-region} when copying into user-accessible +data structures such as the kill-ring, X clipboard, and registers. +Major and minor modes can add functions to +@code{buffer-substring-filters} to alter such text as it is copied out +of the buffer. +@end defun + +@defvar buffer-substring-filters +This variable should be a list of functions that accept a single +argument, a string, and return a string. +@code{filter-buffer-substring} passes the buffer substring to the +first function in this list, and the return value of each function is +passed to the next function. The return value of the last function is +used as the return value of @code{filter-buffer-substring}. + +As a special convention, point is set to the start of the buffer text +being operated on (i.e., the @var{start} argument for +@code{filter-buffer-substring}) before these functions are called. + +If this variable is @code{nil}, no filtering is performed. +@end defvar + @defun buffer-string This function returns the contents of the entire accessible portion of the current buffer as a string. It is equivalent to diff --git a/man/ChangeLog b/man/ChangeLog index ec6fbbdcced..c67256c5ec9 100644 --- a/man/ChangeLog +++ b/man/ChangeLog @@ -1,3 +1,10 @@ +2005-03-29 Chong Yidong + + * text.texi (Refill): Refer to Long Lines Mode. + (Longlines): New node. + (Auto Fill): Don't index "word wrap" here. + (Filling): Add Longlines to menu. + 2005-03-29 Richard M. Stallman * xresources.texi: Minor fixes.