all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dabbrev-select-buffers-function project aware.
       [not found] <87czkq5jli.fsf.ref@Ergus.mail-host-address-is-not-set>
@ 2022-01-17 17:59 ` Ergus
  2022-01-17 18:55   ` Ergus
  0 siblings, 1 reply; 2+ messages in thread
From: Ergus @ 2022-01-17 17:59 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dabbrev-select-buffers-function project aware.
  2022-01-17 17:59 ` dabbrev-select-buffers-function project aware Ergus
@ 2022-01-17 18:55   ` Ergus
  0 siblings, 0 replies; 2+ messages in thread
From: Ergus @ 2022-01-17 18:55 UTC (permalink / raw)
  To: emacs-devel

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.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-17 18:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <87czkq5jli.fsf.ref@Ergus.mail-host-address-is-not-set>
2022-01-17 17:59 ` dabbrev-select-buffers-function project aware Ergus
2022-01-17 18:55   ` Ergus

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.