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

%f = %c ("The current file under the cursor.") instead of "All of the selected files." in :! #132

Closed
aleksejrs opened this issue Nov 22, 2015 · 12 comments
Assignees
Labels
Milestone

Comments

@aleksejrs
Copy link
Contributor

It does "All of the selected files." in "command!" lines in vifmrc.

It is so in 0.8, and I think it was so in 0.7.8.

@aleksejrs
Copy link
Contributor Author

Incorrect testcase (see #132 (comment) for a corrected one):

:mkdir to
:touch a b c
fat
fc
!cp %f to/
!ls to %m

shows "c" (where the cursor was) instead of "a" (which was tagged).

@xaizek
Copy link
Member

xaizek commented Nov 22, 2015

Can't reproduce this with 0.7.8, 0.8 or current version, could you try reproducing it in vifm --no-configs to make sure it's not something in configuration file? You might want to quit that session with :q! afterwards to do not loose contents of vifminfo file.

@aleksejrs
Copy link
Contributor Author

Reproduced (0.8) with --no-configs by following the testcase exactly.

@xaizek
Copy link
Member

xaizek commented Nov 22, 2015

Still no luck. Also tried on Debian in VM with 0.7.8 from repository and 0.8 build from sources, it's always file a that is copied. After fat is pressed when it says 1 file selected I don't see what could change state of internal structures so that wrong file is used. It appears as if selection is reset right before :! command is executed, but I don't see why would it be reset. I'll check it again later, maybe I'm missing something.

@aleksejrs
Copy link
Contributor Author

Reproduced with 0.7.8 from Debian.

@xaizek
Copy link
Member

xaizek commented Nov 23, 2015

Then we must be doing something differently. Here's how I do it:

  • Navigating to empty directory.
  • Copying this and inserting it via Shift-Insert into terminal:
:mkdir to
:touch a b c
fatfc:!cp %f to/
:!ls to %m
  • Now there is a in the menu.

@aleksejrs
Copy link
Contributor Author

Indeed, your version works.
In my case, I entered "!!" (which gives ":.!") and not ":!".

:mkdir to
:touch a b c
fatfc!!cp %f to/
!!ls to %m

An equivalent with ":.!":

:mkdir to
:touch a b c
fatfc:.!cp %f to/
:.!ls to %m

@aleksejrs
Copy link
Contributor Author

The above testcase gives "c".

@xaizek
Copy link
Member

xaizek commented Nov 23, 2015

Well, the meaning of . range is exactly "current file", and as command range naturally has precedence over selection in a view (range itself defines new selection) that's what %f expands to. So it's not an issue (except maybe documentation could be improved), you need to type :! instead of !!, the latter one is a shortcut for composing ranges for :commands (!j, !4k, !G, etc.).

@aleksejrs
Copy link
Contributor Author

I guess I confused “!!” with “:!! same as :!, but pauses before returning.” after reading http://q2a.vifm.info/1/is-it-possible-to-get-a-shell-prompt-in-vifm-like-mc-has

@aleksejrs
Copy link
Contributor Author

Why do commands beginning with “:.!” not add the file name automatically?

@xaizek
Copy link
Member

xaizek commented Nov 25, 2015

Why do commands beginning with “:.!” not add the file name automatically?

Because it can lead to unexpected results. Different commands accept files in different position and only user can know for sure where to put file name argument. :file[x]type has this implicit file name, but it's partly historically and generally reasonable as :file[x]type command is meant to be used to open a file. While on command-line one can execute arbitrary commands. I'm not sure if it's safe to assume that if range is specified, list of files is expected to be added implicitly (you mention :.!, but it's not really different from :5,$!, :'a,+10!, etc.).

@xaizek xaizek self-assigned this Dec 9, 2015
@xaizek xaizek added the support label Dec 9, 2015
@xaizek xaizek added this to the 0.8.1 release milestone Dec 9, 2015
@xaizek xaizek closed this as completed Dec 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants