dabbrev-friend-buffer-function is a variable defined in `dabbrev.el'.
Its value is

  • This variable may be risky if used as a file-local variable.

A function to decide whether dabbrev should search OTHER-BUFFER.
The function should take one argument, OTHER-BUFFER, and return
non-nil if that buffer should be searched. Have a look at
`dabbrev--same-major-mode-p' for an example.

The value of `dabbrev-friend-buffer-function' has an effect only if
the value of `dabbrev-select-buffers-function' uses it. The function
`dabbrev--select-buffers' is one function you can use here.

A mode setting this variable should make it buffer local.

You can customize this variable.