aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2006-04-09 23:03:48 +0000
committerKim F. Storm2006-04-09 23:03:48 +0000
commit398c9ffba6c6bbb593929e268bdae77bdfdc1288 (patch)
treedb1e632603a486342de4a28d3dda0ba458475d01
parente691d082f60d28aed73d3ec02ea9557794fa285a (diff)
downloademacs-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.el41
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
2333If this variable is nil, no filtering is performed.") 2333If 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.
2337The buffer substring is passed through each of the filter 2337The buffer substring is passed through each of the filter
2338functions in `buffer-substring-filters', and the value from the 2338functions in `buffer-substring-filters', and the value from the
@@ -2342,21 +2342,36 @@ is nil, the buffer substring is returned unaltered.
2342If DELETE is non-nil, the text between BEG and END is deleted 2342If DELETE is non-nil, the text between BEG and END is deleted
2343from the buffer. 2343from the buffer.
2344 2344
2345If NOPROPS is non-nil, final string returned does not include
2346text properties, while the string passed to the filters still
2347includes text properties from the buffer text.
2348
2345Point is temporarily set to BEG before calling 2349Point 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
2347where the text came from. 2351where the text came from.
2348 2352
2349This function should be used instead of `buffer-substring' or 2353This 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'
2351take place. For example, major or minor modes can use 2355when you want to allow filtering to take place. For example,
2352`buffer-substring-filters' to extract characters that are special 2356major or minor modes can use `buffer-substring-filters' to
2353to a buffer, and should not be copied into other buffers." 2357extract characters that are special to a buffer, and should not
2354 (save-excursion 2358be 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.
3742To ignore intangibility, bind `inhibit-point-motion-hooks' to t." 3757To 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).