Assuming you are talking about dabbrev-expand ( M- / is a normal binding), then there are many options depending on your requirements.
To search for only a specific buffer whitelist, the easiest way is to set the dabbrev-search-these-buffers-only variable:
"If non-nil, a list of buffers which dabbrev should search. If this variable is non-nil, dabbrev will only look in these buffers. It will not even look in the current buffer if it is not a member of this list."
Here is an example from my own mode (I am reinstalling M-/ to this function for this mode)
(defun tks-dabbrev-expand (arg) "Expand either aliases or descriptions, depending on context." (interactive "*P") (let* ((candidates (if (looking-back "^\\S-+") " *tks-aliases*" " *tks-descriptions*")) (dabbrev-search-these-buffers-only (list (get-buffer candidates)))) (dabbrev-expand arg)))
Note that there are several other ways that you can filter the list of buffers that dabbrev will look for internally. The dabbrev configuration group has detailed information:
Mx customize-group RET dabbrev RET
phils source share