summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2022-09-19 16:54:19 +0200
committerStefan Kangas <stefankangas@gmail.com>2022-09-19 16:55:55 +0200
commita7c65fc6660878e244432a5b25fb3a4ff20e8604 (patch)
treebc562122343f6c2901ea58385fd89978dd9292cb /lisp
parentba0e989c11ebe05bb519845a6d3ab5af1e2715d8 (diff)
downloademacs-a7c65fc6660878e244432a5b25fb3a4ff20e8604.tar.gz
emacs-a7c65fc6660878e244432a5b25fb3a4ff20e8604.tar.bz2
emacs-a7c65fc6660878e244432a5b25fb3a4ff20e8604.zip
Allow nil value for filter-buffer-substring-function
* lisp/simple.el (filter-buffer-substring): Support a nil value to be more resilient. (filter-buffer-substring-function): Doc fix; improve and update for above change.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/simple.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 1b9bf9fa6d8..40df5695c35 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5363,7 +5363,10 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]."
The function is called with the same 3 arguments (BEG END DELETE)
that `filter-buffer-substring' received. It should return the
buffer substring between BEG and END, after filtering. If DELETE is
-non-nil, it should delete the text between BEG and END from the buffer.")
+non-nil, it should delete the text between BEG and END from the buffer.
+
+The default value is `buffer-substring--filter', and nil means
+the same as the default.")
(defun filter-buffer-substring (beg end &optional delete)
"Return the buffer substring between BEG and END, after filtering.
@@ -5379,7 +5382,9 @@ Use `filter-buffer-substring' instead of `buffer-substring',
you want to allow filtering to take place. For example, major or minor
modes can use `filter-buffer-substring-function' to exclude text properties
that are special to a buffer, and should not be copied into other buffers."
- (funcall filter-buffer-substring-function beg end delete))
+ (funcall (or filter-buffer-substring-function
+ #'buffer-substring--filter)
+ beg end delete))
(defun buffer-substring--filter (beg end &optional delete)
"Default function to use for `filter-buffer-substring-function'.