[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dabbrev-select-buffers-function project aware.
From: |
Ergus |
Subject: |
Re: dabbrev-select-buffers-function project aware. |
Date: |
Mon, 17 Jan 2022 19:55:46 +0100 |
On Mon, Jan 17, 2022 at 06:59:46PM +0100, Ergus wrote:
Hi:
I am trying to limit dabbrev to know about current project context qhen
there is project-root.
I am trying to implement a function to substitute
`dabbrev--same-major-mode-p`, to add an extra condition to check if both
buffers are in the same project. But some time in the past I reported
some performance issue that was fixed, but I am wondering if this
addition may worst instead of improve performance for dabbrev
completion.
Do we recommend anything special?
Best,
Ergus
Somehow in reply to myself, this is what I did, maybe someone could
suggest an improvement.
```
(defun my/dabbrev--select-project-buffers ()
"Dabbrev list of buffers in the same project and apply the filters."
(dabbrev-filter-elements
buffer (project-buffers (project-current t))
(and (not (eq (current-buffer) buffer))
(not (dabbrev--ignore-buffer-p buffer))
(boundp 'dabbrev-friend-buffer-function)
(funcall dabbrev-friend-buffer-function buffer))))
(setq-default dabbrev-check-all-buffers nil
dabbrev-ignored-buffer-regexps "^[ *]"
dabbrev-select-buffers-function
#'my/dabbrev--select-project-buffers)
```
If we want to add such functionality to dabbrev itself maybe we could
consider adding a variable like dabbrev-list-buffers that we can set to
#'list-buffers, (project-buffers (project-current t)) or anything like
that. I am wondering because setting dabbrev-friend-buffer-function
impacted performance negatively when using tramp like used to happen
project.el some months ago.
BTW: I am wondering that `project-buffers` does not filter the buffers
list, so the user gets all the ^[ *].+* buffers as "project's"
buffers. I understand this is less restrictive, but I don't know if it
is conceptually correct to get *Packages* or *Help* as project's
buffers for example.