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

[Feature Request] Ability to pin files or directories to the top #1008

Open
aksr opened this issue Jul 27, 2024 · 11 comments
Open

[Feature Request] Ability to pin files or directories to the top #1008

aksr opened this issue Jul 27, 2024 · 11 comments

Comments

@aksr
Copy link

aksr commented Jul 27, 2024

One thing I often had a need for is an ability to pin some files or directories to the top.

Since filters (:filter, =, ...) are fairly inexpensive, I have hundreds (thousands etc.) of files of different type etc. in one (e.g. home) directory, and, usually, no need (at least not for a long time and depending on the work I do at the moment) to hierarchically structure them.

Sometimes, after many days or much time spent on a specific thing, some other thing cames up to which I need to pay attention, it gets lost down the files (I have ":set sort=-ctime,dir" by default)

I would propose, if it's feasible and doesn't require too much complex coding,
to add an ability to pin files or directories (e.g. [dD]ownloads) to the top.

Every new pinned file could go to the top of the list of pinned files
(pinned files would be immune to the sorting by default, we could have this settable by option (e.g. :set sortpinned..)).
If a pinned file is again pinned, it could go to the top of the pinned files.

We could, maybe latter, generalize this further...

@xaizek
Copy link
Member

xaizek commented Jul 27, 2024

The previous time it came up I suggested to use 'sortgroups' option as a workaround, but it has its limitations.

Providing this as a builtin functionality requires some more analysis. I'm not sure I fully understand how pinned items would relate to sorting. At the moment it sounds like they would just ignore it completely (including reversing of sort order), so it wouldn't be a modification of name sorting key in 'sort' but a modification of processing 'sort' overall (this makes a difference for when you don't sort by name). I guess in tree-view pinned items still respect tree structure but bubble up within corresponding level, and similarly for ls-like view.

Also, items are to be pinned within a specific path, right?

@aksr
Copy link
Author

aksr commented Aug 2, 2024

I somehow missed you responded to this request.

Anyway, you're right: in general, sorting would be ignored and the items would be pinned within a specific path.
Since you mentioned it, I could easily see a use case for some files to be pinned across multiple (all and/or specific) directories.

Maybe we could have two kinds of pinning: one within a specific path and the other across all directories.
Also, rules could be defined for the second one in vifmrc.

Thank you for your effort and I appreciate very much how your answers are devoid of any cynicism or such.

@xaizek
Copy link
Member

xaizek commented Aug 3, 2024

Thanks, things are clearer now.

Maybe we could have two kinds of pinning: one within a specific path and the other across all directories.

If path matching for pinning is done via patterns, then there is no distinction because patterns can match either file names or paths. However, that might be too much for pinning where something more specialized could suffice.

Also, rules could be defined for the second one in vifmrc.

If there is some kind of :pin command, it might as well do any kind of pinning regardless of the used syntax.

Order of pinned files can probably match relative order of corresponding patterns/paths so that reordering them would result in different file order.

@aksr
Copy link
Author

aksr commented Aug 5, 2024

Something like, for example: :pin hard would never change its place, :pin soft would be influenced by sorting etc. In general, :pin hard would be more important, and more than one pinned hard file would be like LIFO stack.
Command could be mapped as [...]map [...] :pin hard %c.

Only thing which could be more thought about are default keybindings for both hard and soft pinning
(if they are needed at all, or mnemonically inuitive).

@xaizek
Copy link
Member

xaizek commented Aug 5, 2024

:pin soft would be influenced by sorting etc.

In other words, not pinned? Is that supposed to unpin things?

@aksr
Copy link
Author

aksr commented Aug 6, 2024

:pin hard would be unmovable, not influenced by sort etc., but :pin soft would be movable (meaning effected by sort). Of course, :unpin would unpin files.

@xaizek
Copy link
Member

xaizek commented Aug 7, 2024

:pin soft would be movable (meaning effected by sort).

If the purpose of pinning is for entries to not be affected by sorting, then how come this is pinning?

@aksr
Copy link
Author

aksr commented Aug 8, 2024

If the purpose of pinning is for entries to not be affected by sorting, then how come this is pinning?

I'm proposing a specific kind of pinning, something like: move-to-the-top-and-then-pin-it-there.
Pinning by itself is not very useful, if the file pinned is, for example, 103rd...

If :pin hard is used, file would be not effected by sorting, basically ignored.
When some sorted option is used, :pin soft-ed files could be sorted between themselves at the top — stay at the top, but be effected by sorting.

In structure, this would be actually three separate lists maintained as one list: two pinned lists at the top, and the rest of the files which would have the first two filtered out. (We could work out the details how hard and soft list would be between themselves.)

Maybe we could, for the moment, only implement :pin hard, which would be LIFO-stack-like list.
A file would always be in the same position at the top, but if some other file is :pin-ed hard , it would go down the list. And if the same file is again pinned, it would go to the absolute top of the (:pin-ed hard) list.

This could all seem like a over-engineering, but it's actually very ordinary:
think about pin board, some things we don't move, but some other we sort or impose some kind of structure on them.

And, in the end, maybe we should not call this specific kind of option pinning.

@aksr
Copy link
Author

aksr commented Aug 9, 2024

Since we have something like this in forums (sticky posts/threads), name could be :stick hard/soft.

@aksr
Copy link
Author

aksr commented Oct 2, 2024

(I just noticed...) In the post above, pun not intended. Having that in mind, pin is a better name.

@xaizek Have you started on a prototype and/or made some kind of progress to implement this?

@xaizek
Copy link
Member

xaizek commented Oct 3, 2024

Have you started on a prototype and/or made some kind of progress to implement this?

No, don't expect it in the next release. It's already rather late and I still have long list of things to do for it.

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

No branches or pull requests

2 participants