unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ergus <spacibba@aol.com>
To: emacs-devel@gnu.org
Subject: Re: dabbrev-select-buffers-function project aware.
Date: Mon, 17 Jan 2022 19:55:46 +0100	[thread overview]
Message-ID: <20220117185546.jvoqxmttxzyooiwc@Ergus> (raw)
In-Reply-To: <87czkq5jli.fsf@Ergus.mail-host-address-is-not-set>

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.



      reply	other threads:[~2022-01-17 18:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220117185546.jvoqxmttxzyooiwc@Ergus \
    --to=spacibba@aol.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).