diff options
| author | Kim F. Storm | 2006-04-09 23:03:48 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2006-04-09 23:03:48 +0000 |
| commit | 398c9ffba6c6bbb593929e268bdae77bdfdc1288 (patch) | |
| tree | db1e632603a486342de4a28d3dda0ba458475d01 | |
| parent | e691d082f60d28aed73d3ec02ea9557794fa285a (diff) | |
| download | emacs-398c9ffba6c6bbb593929e268bdae77bdfdc1288.tar.gz emacs-398c9ffba6c6bbb593929e268bdae77bdfdc1288.zip | |
(filter-buffer-substring): Add NOPROPS arg, so
it can also replace buffer-substring-no-properties.
| -rw-r--r-- | lisp/simple.el | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 0b8ad7e4fb0..daf297d5fe2 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2332,7 +2332,7 @@ return value of `filter-buffer-substring'. | |||
| 2332 | 2332 | ||
| 2333 | If this variable is nil, no filtering is performed.") | 2333 | If this variable is nil, no filtering is performed.") |
| 2334 | 2334 | ||
| 2335 | (defun filter-buffer-substring (beg end &optional delete) | 2335 | (defun filter-buffer-substring (beg end &optional delete noprops) |
| 2336 | "Return the buffer substring between BEG and END, after filtering. | 2336 | "Return the buffer substring between BEG and END, after filtering. |
| 2337 | The buffer substring is passed through each of the filter | 2337 | The buffer substring is passed through each of the filter |
| 2338 | functions in `buffer-substring-filters', and the value from the | 2338 | functions in `buffer-substring-filters', and the value from the |
| @@ -2342,21 +2342,36 @@ is nil, the buffer substring is returned unaltered. | |||
| 2342 | If DELETE is non-nil, the text between BEG and END is deleted | 2342 | If DELETE is non-nil, the text between BEG and END is deleted |
| 2343 | from the buffer. | 2343 | from the buffer. |
| 2344 | 2344 | ||
| 2345 | If NOPROPS is non-nil, final string returned does not include | ||
| 2346 | text properties, while the string passed to the filters still | ||
| 2347 | includes text properties from the buffer text. | ||
| 2348 | |||
| 2345 | Point is temporarily set to BEG before calling | 2349 | Point is temporarily set to BEG before calling |
| 2346 | `buffer-substring-filters', in case the functions need to know | 2350 | `buffer-substring-filters', in case the functions need to know |
| 2347 | where the text came from. | 2351 | where the text came from. |
| 2348 | 2352 | ||
| 2349 | This function should be used instead of `buffer-substring' or | 2353 | This function should be used instead of `buffer-substring', |
| 2350 | `delete-and-extract-region' when you want to allow filtering to | 2354 | `buffer-substring-no-properties', or `delete-and-extract-region' |
| 2351 | take place. For example, major or minor modes can use | 2355 | when you want to allow filtering to take place. For example, |
| 2352 | `buffer-substring-filters' to extract characters that are special | 2356 | major or minor modes can use `buffer-substring-filters' to |
| 2353 | to a buffer, and should not be copied into other buffers." | 2357 | extract characters that are special to a buffer, and should not |
| 2354 | (save-excursion | 2358 | be copied into other buffers." |
| 2355 | (goto-char beg) | 2359 | (cond |
| 2356 | (let ((string (if delete (delete-and-extract-region beg end) | 2360 | ((or delete buffer-substring-filters) |
| 2357 | (buffer-substring beg end)))) | 2361 | (save-excursion |
| 2358 | (dolist (filter buffer-substring-filters string) | 2362 | (goto-char beg) |
| 2359 | (setq string (funcall filter string)))))) | 2363 | (let ((string (if delete (delete-and-extract-region beg end) |
| 2364 | (buffer-substring beg end)))) | ||
| 2365 | (dolist (filter buffer-substring-filters) | ||
| 2366 | (setq string (funcall filter string))) | ||
| 2367 | (if noprops | ||
| 2368 | (set-text-properties 0 (length string) nil string)) | ||
| 2369 | string))) | ||
| 2370 | (noprops | ||
| 2371 | (buffer-substring-no-properties beg end)) | ||
| 2372 | (t | ||
| 2373 | (buffer-substring beg end)))) | ||
| 2374 | |||
| 2360 | 2375 | ||
| 2361 | ;;;; Window system cut and paste hooks. | 2376 | ;;;; Window system cut and paste hooks. |
| 2362 | 2377 | ||
| @@ -3742,7 +3757,7 @@ If point reaches the beginning or end of buffer, it stops there. | |||
| 3742 | To ignore intangibility, bind `inhibit-point-motion-hooks' to t." | 3757 | To ignore intangibility, bind `inhibit-point-motion-hooks' to t." |
| 3743 | (interactive "p") | 3758 | (interactive "p") |
| 3744 | (or arg (setq arg 1)) | 3759 | (or arg (setq arg 1)) |
| 3745 | 3760 | ||
| 3746 | (let ((orig (point))) | 3761 | (let ((orig (point))) |
| 3747 | 3762 | ||
| 3748 | ;; Move by lines, if ARG is not 1 (the default). | 3763 | ;; Move by lines, if ARG is not 1 (the default). |