Mercurial > emacs
comparison lisp/simple.el @ 69899:6626190949c3
(filter-buffer-substring): Add NOPROPS arg, so
it can also replace buffer-substring-no-properties.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Sun, 09 Apr 2006 23:03:48 +0000 |
parents | a4e59f3e040c |
children | c8e4a9156d18 81f2d90dee68 c156f6a9e7b5 |
comparison
equal
deleted
inserted
replaced
69898:601830ae280c | 69899:6626190949c3 |
---|---|
2330 the next. The return value of the last function is used as the | 2330 the next. The return value of the last function is used as the |
2331 return value of `filter-buffer-substring'. | 2331 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 |
2339 last filter function is returned. If `buffer-substring-filters' | 2339 last filter function is returned. If `buffer-substring-filters' |
2340 is nil, the buffer substring is returned unaltered. | 2340 is nil, the buffer substring is returned unaltered. |
2341 | 2341 |
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 |
2363 (defvar interprogram-cut-function nil | 2378 (defvar interprogram-cut-function nil |
2364 "Function to call to make a killed region available to other programs. | 2379 "Function to call to make a killed region available to other programs. |
3740 With argument ARG not nil or 1, move forward ARG - 1 lines first. | 3755 With argument ARG not nil or 1, move forward ARG - 1 lines first. |
3741 If point reaches the beginning or end of buffer, it stops there. | 3756 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). |
3749 (if (/= arg 1) | 3764 (if (/= arg 1) |
3750 (line-move (1- arg) t)) | 3765 (line-move (1- arg) t)) |