Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show all possible candidates after filtering #14

Open
Ambrevar opened this issue Feb 14, 2018 · 4 comments
Open

Show all possible candidates after filtering #14

Ambrevar opened this issue Feb 14, 2018 · 4 comments

Comments

@Ambrevar
Copy link
Member

By default, helm-system-packages-candidate-limit is 1000.
Let's consider we have more than 1000 packages in the database.

If we disable the display of, say, uninstalled packages (M-N by default), it leaves room for more packages of the other categories to be displayed.
Sadly, the list won't be displayed unless a pattern is entered.

This issue makes it impossible to list all packages of specific categories.

The problem essentially lies in that Helm System Packages makes use of buffers and not lists.
I'm not sure how to solve that. @thierryvolpiatto?

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Feb 15, 2018 via email

@Ambrevar
Copy link
Member Author

Ambrevar commented Feb 15, 2018

Well, the original helm-gentoo and helm-apt had the same issue if I'm not mistaken.

I'm not using filtered-candidate-transformer nor helm-force-update.

  • filtered-candidate-transformer: I don't think that's approprioate. From the
    doc: "While ‘candidate-transformer’ is run only once, it is run every time the
    input pattern is changed."

  • helm-force-update: I tried the following:

      (defun helm-system-packages-toggle-uninstalled ()
        (interactive)
        (with-helm-alive-p
          (setq helm-system-packages--show-uninstalled-p (not helm-system-packages--show-uninstalled-p))
          (helm-force-update)))
    

    It does not help with the issue, but that was to be expected; see below.

Allow me to sum up:

The list of package names and descriptions is generated once, then cached.
The init function simply uses those cache variables as a buffer source:

(helm-init-candidates-in-buffer
'global
(if helm-system-packages-show-descriptions-p
helm-system-packages--descriptions
helm-system-packages--names))

The buffer source has the following properties:

(helm-build-in-buffer-source helm-system-packages--source-name
    :init 'helm-system-packages-xbps-init
    :candidate-transformer 'helm-system-packages-xbps-transformer
    :candidate-number-limit helm-system-packages-candidate-limit
    :display-to-real 'helm-system-packages-extract-name
		...

Then the transformer only filters out the unwanted packages, e.g.

(defun helm-system-packages-xbps-transformer (packages)
(let (res (pkglist (reverse packages)))
	(dolist (p pkglist res)
  	(let ((face (cdr (assoc (helm-system-packages-extract-name p) helm-system-packages--display-lists))))
    	(cond
     	((and (not face) helm-system-packages--show-uninstalled-p)
      	(push p res))
     	((or
       	(and helm-system-packages--show-explicit-p (memq 'helm-system-packages-explicit face))
       	(and helm-system-packages--show-dependencies-p (memq 'helm-system-packages-dependencies face))
					; ...
      	(push (propertize p 'face (car face)) res))))))))

The issue here is that candidate-number-limit is used before the transformer does its filtering, thus the filtered result length cannot be updated according to the candidate limit.

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Feb 16, 2018 via email

@Ambrevar
Copy link
Member Author

Ambrevar commented Feb 16, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants