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

Allow multiple values in `org-ql-view-buffers-files' #311

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ahmed-shariff
Copy link

@ahmed-shariff ahmed-shariff commented Nov 21, 2022

This is a revisit to the #228, apologize for not being able to get back to this sooner.
That PR had started trying to fix the init-value of the completing-read (#227) and wound up doing alot of other things.

The goal of the PR is as follows:

  • From the org-ql-view allow setting the org-ql-view-buffers-files using completing-read-multiple

This entails the following fixes:

  • Ensure the values from expanding completing-read-multiple are correct and don't have duplicates
  • Ensure the contraction of the values of org-ql-view-buffers-files are handled correctly
  • The org-ql-view--complete-buffers-files uses the correct contracted form, also respect any functions set it's instead.

What I have here also had an interesting side-effect on the link-safety tests:

  • Incorrect values to buffers-or-files would cause the org-ql-view--expand-buffers-files signal an error at
    (org-ql-view--expand-buffers-files (read it))
    as opposed to to being signaled at
    (error "CAUTION: Link not opened because unsafe buffers-files parameter detected: %s" buffers-files))

    I could have caught the error in the former and let the latter signal the error, but that didn't feel right to me

commit d8f2922
Author: Ahmed Shariff <[email protected]>
Date:   Fri Sep 24 15:47:38 2021 -0500

    Abstract buffers-files being flattened to a list of strings

commit 2d49745
Author: Ahmed Shariff <[email protected]>
Date:   Fri Sep 17 17:53:21 2021 -0500

    Fix: \w duplicates & func's with buffers/names with expand/contract

commit 576f9d3
Author: Ahmed Shariff <[email protected]>
Date:   Thu Sep 16 18:42:32 2021 -0500

    Handling support for functions \w functions using completing-read-multiple

commit cea1651
Author: Ahmed Shariff <[email protected]>
Date:   Thu Sep 16 16:49:19 2021 -0500

    Cleaning up functions and improvements for clarity.

commit aa9c6cc
Author: Ahmed Shariff <[email protected]>
Date:   Wed Sep 15 17:56:19 2021 -0500

    Adding `comma separated` instruction to readme

commit 564d491
Author: Ahmed Shariff <[email protected]>
Date:   Mon Sep 13 17:05:14 2021 -0500

    Fixes for using mulitiple values and related test suite improvements

commit ffaebcb
Merge: 788951a 94f9e6f
Author: Ahmed Shariff <[email protected]>
Date:   Mon Sep 13 13:15:57 2021 -0500

    Merge branch 'master' of https://github.com/alphapapa/org-ql

commit 788951a
Author: Ahmed Shariff <[email protected]>
Date:   Mon Sep 13 11:01:55 2021 -0500

    Replacing org-ql-view--expand-buffers-files

commit cabf88e
Author: Ahmed Shariff <[email protected]>
Date:   Mon Jul 19 00:19:52 2021 -0500

    removing duplcates when expanding buffers-files

commit b68d836
Author: Ahmed Shariff <[email protected]>
Date:   Sun Jul 18 23:49:54 2021 -0500

    Using completing-read-multiple for org-ql-view--complete-buffers-files

commit 06bdfc7
Author: Ahmed Shariff <[email protected]>
Date:   Sun Jul 4 23:32:08 2021 -0500

    Fn always promts for buffer/files; handle buffer obj and list

    Fn: org-ql-view--complete-buffers-files
    With buffers, org-ql-view--contract-buffers-files return the buffer
    name.
    When org-ql-view-buffers-files is a list, just dumpt it as a string
    and check if completion-read returns the same value, if so return the
    original value of org-ql-view-buffers-files

commit cc6e22d
Author: Ahmed Shariff <[email protected]>
Date:   Sun Jul 4 23:31:31 2021 -0500

    Allow reading buffer names for buffers-or-names

commit 89b8476
Author: Ahmed Shariff <[email protected]>
Date:   Sat Jul 3 21:25:10 2021 -0500

    Test cases for all org-ql-view--*-buffers-files functions

commit 7120b63
Author: Ahmed Shariff <[email protected]>
Date:   Sat Jul 3 02:17:33 2021 -0500

    Refactor of org-ql-view--complete-buffers-files

    Handles the different values `org-ql-view-buffers-files` can hold.
    Use completing-read only if `org-ql-view-buffers-files` is nil or the
    contracted form of `org-ql-view-buffers-files` is a string.

commit 7b990e5
Author: Ahmed Shariff <[email protected]>
Date:   Wed Jun 30 18:01:49 2021 -0500

    Fix for issue with initial-input in org-ql-view--complete-buffers-files
@alphapapa
Copy link
Owner

Hi again,

After skimming through #228 again, I feel like quoting my last comment:

I realize that you've put a lot of work into this patch, and that you've been very patient with my requested changes, so I don't want to discard your work. Would you be willing to consider starting this process over, defining the problems more explicitly in an issue, then addressing them in one or more new PRs, which could reuse the code from this one? I think this is a case where some degree of test-driven development would be helpful--at least, for me, as I try to understand the problems we're trying to solve and exactly how we're trying to do it.

For example, I'd like to first have the problems clearly described in one or more issues, then have a PR for each one, each of which should start by adding a failing test that should be fixed by later commits. I'm trying to develop this package in a more organized way to ensure that it remains reliable and robust, but that does sometimes mean more overhead for contributions. As well, since I work on this in spare time, it sometimes takes a while to review and integrate patches.

In other words, this still feels like too much to review, and we still lack carefully written problem statements which can be clearly and simply addressed.

I do appreciate your work on this PR, and I especially noticed how much you put into the test cases. But, again, with this kind of issue--especially one that could present a security vulnerability--we need to be methodical.

In the end, this may be an issue that I need to solve myself, when I have time, because I have to take responsibility for the solution, so I need to thoroughly understand its implementation. So I can't promise to use any code you submit. If you want to keep working on this, I don't object, but please proceed without any expectations.

@ahmed-shariff
Copy link
Author

I completely understand your concerns. I couldn't think of a better way to break this down to smaller chunks; as the contraction and expansion functions are very much related. For now, I'll leave this here for now. I myself am using this for my daily tasks. If you need any help with the issues, please feel free to ping me. I'm more than happy to help, I enjoy hacking stuff anywho :)

@alphapapa
Copy link
Owner

Thank you, that's very kind. You're right that it's not easy to atomize these concerns.

It may be a while before I have time to visit this issue seriously. When I do, I'll study your code more carefully. The tests especially may be a good model.

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

Successfully merging this pull request may close these issues.

Use of :initial-input in org-ql-view--expand-buffers-files conflicting with completing-read
2 participants