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

Subtree toggle and cycle #28

Merged
merged 2 commits into from
Jan 9, 2015
Merged

Subtree toggle and cycle #28

merged 2 commits into from
Jan 9, 2015

Conversation

danskarda
Copy link
Contributor

The patch adds two features:

  • dired-subtree-toggle: show/hide directory subtree
  • dired-subtree-cycle: org-mode like cycling between hide, show and recursive show

@danskarda danskarda changed the title Implement subtree toggle and cycle Subtree toggle and cycle Jan 2, 2015
@Fuco1
Copy link
Owner

Fuco1 commented Jan 2, 2015

Very cool! I had this feature in my notes for a long time. I'll try to review it today evening.

Another cool thing would be to have an option to not expand certain directories, like .git, .hg or other similar "nonsense". I would imagine a customize variable where one can add filter functions taking the file path and deciding if we want to expand or not (say, if any of them returns true, we do not expand the directory).

We can then provide some filters (like "filter by name") but still leave the user option to add/remove their own filters.

Do you want to try to add such functionality to this PR? I'm merging it either way though, good job :)

@Fuco1
Copy link
Owner

Fuco1 commented Jan 2, 2015

So I've reviewed the patch and added a couple comments, mostly minor issues. Once you fix those I'll be happy to merge this in :).

@danskarda
Copy link
Contributor Author

I updated code to match your coding style and fixed few typos.

I also added support for ignored files (defaults to vc-directory-exclusion-list). User can expand ignored directories explicitely.

(when (and name (file-directory-p name)
(<= depth (or max-depth depth))
(or (= 1 depth)
(not (string-match dired-subtree-ignored-regexp
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use string-match-p, the non -p version modifies the global match-data which might interfere with other packages. It is always better to use this if you don't care about the match data. (also fix the indent level :)

@Fuco1
Copy link
Owner

Fuco1 commented Jan 4, 2015

Awesome, two more little issues and it's ready. Thanks a bunch.

@danskarda
Copy link
Contributor Author

Actually three issues. dired-subtree-cycle prefix was not working properly (fixed in last patch).

Should I squash patches?

@Fuco1
Copy link
Owner

Fuco1 commented Jan 4, 2015

Yes, please.

@danskarda
Copy link
Contributor Author

Ready.

@Fuco1
Copy link
Owner

Fuco1 commented Jan 4, 2015

I only get the expantion down to 1 level and hide, the recursive one is never hit in the cond. I think the checks need to be reordered somehow.

Also, the variable is called dired-subtree--cycle-expanded but dired-subtree--cycle-previous is used. Did you lose a commit somewhere? :P

@danskarda
Copy link
Contributor Author

You are right for the mismatch in variable name (typo).

About cycle not working. How do you execute dired-subtree-cycle?

I bound it to TAB and it works. Then I tried to execute it from helm-M-x (my default replacement for extended-command-execute) and it does not. It seems that Helm does not set properly last-command. This behavior is consistent with org-cycle which does not work either when executed from helm-M-x.

When I replaced helm-M-x with original extended-command-execute than dired-subtree-cycle works again.

Maybe you use helm-M-x or similar replacement which mishandles last-command?

@Fuco1
Copy link
Owner

Fuco1 commented Jan 5, 2015

I use smex but it is likely the same issue. Do you see some way to avoid using last-command?

There's some variable real-last-command, maybe we could investigate what it does.

@danskarda
Copy link
Contributor Author

Same results with real-last-command :(

Other way I can think of is to use set-transient-map which is used by text-scale-adjust. The downside is that keys are hardwired (in text-scale-adjust) and it does not work with extended-command-execute replacements either.

So do you think fixing is worth the effort? I cannot imagine somebody using dired-subtree-cyle without hotkey (except for testing). The bug should be fixed in helm/smex. We can mention it in command documentation.

@Fuco1
Copy link
Owner

Fuco1 commented Jan 5, 2015

Agreed. Okey, I think we've solved everything then.

Fuco1 added a commit that referenced this pull request Jan 9, 2015
@Fuco1 Fuco1 merged commit 606d33c into Fuco1:master Jan 9, 2015
@Fuco1
Copy link
Owner

Fuco1 commented Jan 9, 2015

Thanks again.

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.

None yet

2 participants