Coder Social home page Coder Social logo

dired-hacks's Introduction

dired-hacks Build Status Paypal logo Patreon

Collection of useful dired additions. I don't want this to become another dired+, so I'm splitting all the functionality into separate mutually independent packages. All shared functionality and helpers will be extracted into a single package dired-hacks-utils, so that will be the only dependence.

In addition, all the packages require dash.el

Please note that only the packages that are listed in this readme are "finished" (means in package repositories, with usable UI etc.). All the other files are work-in-progress packages you could probably use, but it would be a bit more painful.

Contribute!

If you want to support this project, you can do it in the following ways:

  • Contribute code. Since this collection comes from my own config, it mostly contains stuff I use or find useful. If you have an idea that is not yet implemented and will benefit this project, feel free to implement it and submit a pull request. If you have any concerns whether your contribution will be accepted, ask beforehand. You can email the author or start an issue on the tracker.
  • Contribute ideas. Even if you can't code Emacs Lisp, you can still contribute valuable ideas for other programmers to implement. Simply start new issue on the tracker and submit your suggestion.
  • You can make a financial donation through PayPal or Patreon. If you like dired-hacks and can spare a modest amount on a donation, feel free to do so. These donations are expressions of your gratitude and are used for my personal "rewards" (books, games, music etc.). You can also gift me a game on Steam or buy something on Amazon. Regardless of the donations, dired-hacks will always be free both as in beer and as in speech.

Packages

dired-hacks-utils

Set of utility functions used in all the dired-hacks packages.

This package also provides these interactive functions:

  • dired-hacks-next-file - go to next file, skipping empty and non-file lines
  • dired-hacks-previous-file - go to previous file, skipping empty and non-file lines
  • dired-utils-format-information-line-mode - Format the information (summary) line file sizes to be human readable (e.g. 1GB instead of 1048576).

dired-filter

The filtering system is designed after ibuffer: every dired buffer has associated "filter stack" where user can push filters (predicates). These filters are by default logically "anded", meaning, only the files satsifying all the predicates are shown.

Some filters take additional input from the user such as part of name, regexp or extension, other filters only use a predefined predicate such as "show only directories" or "omit dot files".

In addition, there are two "metafilters", the or filter and the not filter. These take other filters as arguments and change their logical interpretation. The or filter takes the two filters on top of the stack, pops them and pushes a filter that matches files satisfying one or the other (or both) filters. The not filter pops the top filter and pushes its logical negation.

To enable or disable the filters, toggle minor mode dired-filter-mode. Toggling this mode preserves the filter stack, so you can use it to quickly hide/unhide files filtered by the current filter setup.

All the provided interactive functions are available from dired-filter-map. You can customize dired-filter-prefix to set a prefix for this map or bind it manually to a prefix of your choice using:

(define-key dired-mode-map (kbd "some-key") dired-filter-map)

The bindings follow a convention where the filters are mapped on lower-case letters or punctuation, operators are mapped on symbols (such as !, |, * etc.) and group commands are mapped on upper-case letters. The exception to this is p which is bound to dired-filter-pop, which is a very common operation and warrants a quick binding.

In addition to filtering, you can also use the same predicates to only mark files without removing the rest. All the filtering functions of the form dired-filter-by-* have their marking counterpart dired-filter-mark-by-*. These are available from dired-filter-mark-map. You can customize dired-filter-mark-prefix a prefix for this map or bind it manually to a prefix of your choice using:

(define-key dired-mode-map (kbd "some-key") dired-filter-mark-map)

The marking operations are not placed on stack, instead, the marks are immediately updated by "OR"-ing them together. To remove marks that would otherwise be selected by a filter, use prefix argument (usually bound to C-u). To logically negate the meaning of the filter, you can call the function with a double prefix argument (usually C-u C-u)

You can use saved filters to mark files by calling dired-filter-mark-by-saved-filters.

Stack operations

To remove the filter from the stack, use dired-filter-pop or dired-filter-pop-all

To break a metafilter apart, you can use dired-filter-decompose to decompose the parts of the metafilter and push them back to the stack.

You can transpose the filters on the top of the stack using dired-filter-transpose

Built-in filters

Here's a list of built-in filters:

  • dired-filter-by-name
  • dired-filter-by-regexp
  • dired-filter-by-extension
  • dired-filter-by-dot-files
  • dired-filter-by-omit
  • dired-filter-by-garbage
  • dired-filter-by-predicate
  • dired-filter-by-file
  • dired-filter-by-directory
  • dired-filter-by-mode
  • dired-filter-by-symlink
  • dired-filter-by-executable

You can see their documentation by calling M-x describe-function.

Specifically, dired-filter-by-omit removes the files that would be removed by dired-omit-mode, so you should not need to use both---in fact it is discouraged, as it would make the read-in slower.

When called with negative prefix argument, some filters can read multiple values. The resulting predicate is often much faster than having the filter repeated with single argument. Read the documentation to learn more about the calling conventions. Currently, these filters support reading multiple arguments:

  • dired-filter-by-extension

To define your own filters, you can use the macro dired-filter-define. If you define some interesting filter, please consider contributing it to the upstream.

Saved filters

In addition to the built-in filters and your own custom filters, this package provides an option to save complex compound filters for later use. When you set up a filter stack you would like to save, call dired-filter-save-filters. You will be prompted for a name under which this stack will be saved.

The saved filter will be added to dired-filter-saved-filters variable, which you can also customize via the customize interface or manually add entries with push or add-to-list. If you use customize, calling dired-filter-save-filters will automatically save the new value into your customize file.

You can delete saved filters with dired-filter-delete-saved-filters.

To use a saved filter, you can use either dired-filter-add-saved-filters or dired-filter-load-saved-filters. The first pushes the saved filter on top of the currently active stack, the second clears current filter stack before loading the saved filter configuration.

An example use is to create filters for "logical groups" of files, such as media files, image files or files used when programming in certain environment (for example, show files with .h and .c extensions). Saved filters save you the time of setting up the filters each time you want this specific view.

As a concrete example of above, author uses a saved filter "media" with value:

(extension "ogg" "flv" "mpg" "avi" "mp4" "mp3")
;; show all files matching any of these extensions

Filter groups

Furthermore, instead of only filtering the dired buffer by removing lines you are not interested in, you can also group lines together by filters. That is, lines (files, directories...) satisfying a filter will be moved together under a common drawer. This mechanism works in analogy with ibuffer filter groups.

The variable dired-filter-group-saved-groups contains definitions of filter groups. You can create and save multiple filter groups (views) and switch between them by setting the dired-filter-group variable.

To enable or disable the filter groups toggle minor mode dired-filter-group-mode. Toggling this mode preserves the active filter group so you can use it to quickly group and ungroup the files.

Here is a screenshot with an active filter group. Notice that regular filtering works also with filter groups.

Filter group

Placing the point on the drawer header and hitting RET folds it. Hitting RET again expands it.

Folding

The dired-filter-group-saved-groups used in the above screenshot is the following:

(("default"
  ("PDF"
   (extension . "pdf"))
  ("LaTeX"
   (extension "tex" "bib"))
  ("Org"
   (extension . "org"))
  ("Archives"
   (extension "zip" "rar" "gz" "bz2" "tar"))))

You can of course be more imaginative and use filtering based on other criteria than just extensions ;)

Other features

You can clone the currently visible dired buffer by calling dired-filter-clone-filtered-buffer.

dired-avfs

Adds avfs support for seamless archive browsing. This extension therefore depends on the presence of avfsd on your system. In debian-derived distributions you can usually do

apt-get install avfs

avfs is probably also available for Mac OS. You're out of luck on Windows, sorry.

Once the daemon is installed, run it with mountavfs and everything "Should Just Work™".

dired-open

While emacs already has the auto-mode-alist, this is often insufficient. Many times, you want to open media files, pdfs or other documents with an external application. There's remedy for that too, namely dired-guess-shell-alist-user, but that is still not as convenient as just hitting enter.

This package adds a mechanism to add "hooks" to dired-find-file that will run before emacs tries its own mechanisms to open the file, thus enabling you to launch other application or code and suspend the default behaviour.

By default, two additional methods are enabled, dired-open-by-extension and dired-open-subdir.

This package also provides other convenient hooks:

  • dired-open-xdg - try to open the file using xdg-open
  • dired-open-guess-shell-alist - try to open the file by launching applications from dired-guess-shell-alist-user
  • dired-open-call-function-by-extension - call an elisp function based on extension.

These are not used by default.

You can customize the list of functions to try by customizing dired-open-functions.

To fall back to the default dired-find-file, you can provide the prefix argument (usually C-u) to the dired-open-file function. This is useful for example when you configure html files to be opened in browser and you want to edit the file instead of view it.

Note also that this package can handle calls when point is not on a line representing a file---an example hook is provided to open a subdirectory under point if point is on the subdir line, see dired-open-subdir.

If you write your own handler, make sure they do not throw errors but instead return nil if they can't proceed. Please, don't forget to submit interesting handlers!

dired-rainbow

This package adds more customizable highlighting for files in dired listings. The group dired-faces provides only nine faces and isn't very fine-grained.

The definitions are added by several macros, currently available are:

  • dired-rainbow-define - add face by file extension
  • dired-rainbow-define-chmod - add face by file permissions

You can display their documentation by calling (substituting the desired macro name):

M-x describe-function RET dired-rainbow-define RET

Here are some example uses:

(defconst my-dired-media-files-extensions
  '("mp3" "mp4" "MP3" "MP4" "avi" "mpg" "flv" "ogg")
  "Media files.")

(dired-rainbow-define html "#4e9a06" ("htm" "html" "xhtml"))
(dired-rainbow-define media "#ce5c00" my-dired-media-files-extensions)

; boring regexp due to lack of imagination
(dired-rainbow-define log (:inherit default
                           :italic t) ".*\\.log")

; highlight executable files, but not directories
(dired-rainbow-define-chmod executable-unix "Green" "-[rw-]+x.*")

Putting it all together, the following is a basic setup (essentially a pseudo-port of LS_COLORS obtained by inspecting a terminal and approximating colors with Tailwind CSS).

(use-package dired-rainbow
  :config
  (progn
    (dired-rainbow-define-chmod directory "#6cb2eb" "d.*")
    (dired-rainbow-define html "#eb5286" ("css" "less" "sass" "scss" "htm" "html" "jhtm" "mht" "eml" "mustache" "xhtml"))
    (dired-rainbow-define xml "#f2d024" ("xml" "xsd" "xsl" "xslt" "wsdl" "bib" "json" "msg" "pgn" "rss" "yaml" "yml" "rdata"))
    (dired-rainbow-define document "#9561e2" ("docm" "doc" "docx" "odb" "odt" "pdb" "pdf" "ps" "rtf" "djvu" "epub" "odp" "ppt" "pptx"))
    (dired-rainbow-define markdown "#ffed4a" ("org" "etx" "info" "markdown" "md" "mkd" "nfo" "pod" "rst" "tex" "textfile" "txt"))
    (dired-rainbow-define database "#6574cd" ("xlsx" "xls" "csv" "accdb" "db" "mdb" "sqlite" "nc"))
    (dired-rainbow-define media "#de751f" ("mp3" "mp4" "MP3" "MP4" "avi" "mpeg" "mpg" "flv" "ogg" "mov" "mid" "midi" "wav" "aiff" "flac"))
    (dired-rainbow-define image "#f66d9b" ("tiff" "tif" "cdr" "gif" "ico" "jpeg" "jpg" "png" "psd" "eps" "svg"))
    (dired-rainbow-define log "#c17d11" ("log"))
    (dired-rainbow-define shell "#f6993f" ("awk" "bash" "bat" "sed" "sh" "zsh" "vim"))
    (dired-rainbow-define interpreted "#38c172" ("py" "ipynb" "rb" "pl" "t" "msql" "mysql" "pgsql" "sql" "r" "clj" "cljs" "scala" "js"))
    (dired-rainbow-define compiled "#4dc0b5" ("asm" "cl" "lisp" "el" "c" "h" "c++" "h++" "hpp" "hxx" "m" "cc" "cs" "cp" "cpp" "go" "f" "for" "ftn" "f90" "f95" "f03" "f08" "s" "rs" "hi" "hs" "pyc" ".java"))
    (dired-rainbow-define executable "#8cc4ff" ("exe" "msi"))
    (dired-rainbow-define compressed "#51d88a" ("7z" "zip" "bz2" "tgz" "txz" "gz" "xz" "z" "Z" "jar" "war" "ear" "rar" "sar" "xpi" "apk" "xz" "tar"))
    (dired-rainbow-define packaged "#faad63" ("deb" "rpm" "apk" "jad" "jar" "cab" "pak" "pk3" "vdf" "vpk" "bsp"))
    (dired-rainbow-define encrypted "#ffed4a" ("gpg" "pgp" "asc" "bfe" "enc" "signature" "sig" "p12" "pem"))
    (dired-rainbow-define fonts "#6cb2eb" ("afm" "fon" "fnt" "pfb" "pfm" "ttf" "otf"))
    (dired-rainbow-define partition "#e3342f" ("dmg" "iso" "bin" "nrg" "qcow" "toast" "vcd" "vmdk" "bak"))
    (dired-rainbow-define vc "#0074d9" ("git" "gitignore" "gitattributes" "gitmodules"))
    (dired-rainbow-define-chmod executable-unix "#38c172" "-.*x.*")
    )) 

Note: the 256 color cheat sheet includes conversion from the Xterm colors used by LS_COLORS to the HEX codes used by dired-rainbow. Using that conversion an enterprising individual with a grasp of sed/awk could put together a real port of LS_COLORS to dired-rainbow.

Related packages

There is a related package called diredfl which extracts the extra fontification rules from Dired+ and packages them in a modern Emacsy way. They enhance things like the date face, permissions face and similar. Check it out!

dired-subtree

The basic command to work with subdirectories in dired is i, which inserts the subdirectory as a separate listing in the active dired buffer.

This package defines function dired-subtree-insert which instead inserts the subdirectory directly below its line in the original listing, and indent the listing of subdirectory to resemble a tree-like structure (somewhat similar to tree(1) except the pretty graphics). The tree display is somewhat more intuitive than the default "flat" subdirectory manipulation provided by i.

There are several presentation options and faces you can customize to change the way subtrees are displayed.

You can further remove the unwanted lines from the subtree by using k command or some of the built-in "focusing" functions, such as dired-subtree-only-* (see list below).

If you have the package dired-filter, you can additionally filter the subtrees with global or local filters.

A demo of basic functionality is available on youtube: https://www.youtube.com/watch?v=z26b8HKFsNE

Interactive functions

Here's a list of available interactive functions. You can read more about each one by using the built-in documentation facilities of emacs. It is adviced to place bindings for these into a convenient prefix key map, for example C-,

  • dired-subtree-insert
  • dired-subtree-remove
  • dired-subtree-toggle
  • dired-subtree-cycle
  • dired-subtree-revert
  • dired-subtree-narrow
  • dired-subtree-up
  • dired-subtree-down
  • dired-subtree-next-sibling
  • dired-subtree-previous-sibling
  • dired-subtree-beginning
  • dired-subtree-end
  • dired-subtree-mark-subtree
  • dired-subtree-unmark-subtree
  • dired-subtree-only-this-file
  • dired-subtree-only-this-directory

If you have package dired-filter, additional command dired-subtree-apply-filter is available.

dired-ranger

This package implements useful features present in the ranger file manager which are missing in dired.

Multi-stage copy/pasting of files

A feature present in most orthodox file managers is a "two-stage" copy/paste process. Roughly, the user first selects some files, "copies" them into a clipboard and then pastes them to the target location. This workflow is missing in dired.

In dired, user first marks the files, then issues the dired-do-copy command which prompts for the destination. The files are then copied there. The dired-dwim-target option makes this a bit friendlier---if two dired windows are opened, the other one is automatically the default target.

With the multi-stage operations, you can gather files from multiple dired buffers into a single "clipboard", then copy or move all of them to the target location. Another huge advantage is that if the target dired buffer is already opened, switching to it via ido or ibuffer is often faster than selecting the path.

Call dired-ranger-copy to add marked files (or the file under point if no files are marked) to the "clipboard". With non-nil prefix argument, add the marked files to the current clipboard.

Past clipboards are stored in dired-ranger-copy-ring so you can repeat the past pastes.

Call dired-ranger-paste or dired-ranger-move to copy or move the files in the current clipboard to the current dired buffer. With raw prefix argument (usually C-u), the clipboard is not cleared, so you can repeat the copy operation in another dired buffer.

Bookmarks

Use dired-ranger-bookmark to bookmark current dired buffer. You can later quickly revisit it by calling dired-ranger-bookmark-visit.

A bookmark name is any single character, letter, digit or a symbol.

A special bookmark with name dired-ranger-bookmark-LRU represents the least recently used dired buffer. Its default value is `. If you bind dired-ranger-bookmark-visit to the same keybinding, hitting `` will instantly bring you to the previously used dired buffer. This can be used to toggle between two dired buffers in a very fast way.

These bookmarks are not persistent. If you want persistent bookmarks use the bookmarks provided by emacs, see (info "(emacs) Bookmarks").

dired-narrow

This package provides live filtering of files in dired buffers. In general, after calling the respective narrowing function you type a filter string into the minibuffer. After each change the changes automatically reflect in the buffer. Typing C-g will cancel the narrowing and restore the original view, typing RET will exit the live filtering mode and leave the dired buffer in the narrowed state. To bring it back to the original view, you can call revert-buffer (usually bound to g).

During the filtering process, several special functions are available. You can customize the binding by changing dired-narrow-map.

  • dired-narrow-next-file (<down> or C-n) - move the point to the next file
  • dired-narrow-previous-file (<up> or C-p) - move the point to the previous file
  • dired-narrow-enter-directory (<right> or C-j) - descend into the directory under point and immediately go back to narrowing mode

You can customize what happens after exiting the live filtering mode by customizing dired-narrow-exit-action. dired-narrow-exit-action may be executed automatically, when there is only one file left while narrowing. In order to enable this feature, add (setq dired-narrow-exit-when-1-left t) to your config. It makes sense when you use find-file as your exit action, e.g. (setq dired-narrow-exit-action 'dired-narrow-find-file). A chosen file will be quickly highlighted before executing dired-narrow-exit-action. This behavior is controlled by variables dired-narrow-enable-blinking, dired-narrow-blink-time and by a face dired-narrow-blink.

These narrowing functions are provided:

  • dired-narrow
  • dired-narrow-regexp
  • dired-narrow-fuzzy

You can also create your own narrowing functions quite easily. To define new narrowing function, use dired-narrow--internal and pass it an apropriate filter. The filter should take one argument which is the filter string from the minibuffer. It is then called at each line that describes a file with point at the beginning of the file name. If the filter returns nil, the file is removed from the view. As an inspiration, look at the built-in functions mentioned above.

dired-list

Produce a file listing with a shell incantation and make a dired out of it!

This package provides one principal function, dired-list which can be used to produce dired buffers from shell programs outputing text roughly in the format of la -ls.

For most standard output formats the default filter and sentinel should work, but you can also provide your own if the situation requires it.

Most of the time you can pipe a zero-delimited list of files to ls through xargs(1) using

| xargs -I '{}' -0 ls -l '{}'

which creates a compatible listing. For more information read the documentation of dired-list, for example by invoking

C-h f dired-list RET

in emacs.

In addition to the generic interface this package implements common listings (patches and extensions welcome!), these are:

  • dired-list-mpc
  • dired-list-git-ls-files
  • dired-list-hg-locate
  • dired-list-locate
  • dired-list-find-file
  • dired-list-find-name
  • dired-list-grep

dired-collapse

Often times we find ourselves in a situation where a single file or directory is nested in a chain of nested directories with no other content. This is sometimes due to various mandatory layouts demanded by packaging tools or tools generating these deeply-nested "unique" paths to disambiguate architectures or versions (but we often use only one anyway). If the user wants to access these directories they have to quite needlessly drill-down through varying number of "uninteresting" directories to get to the content.

This minor mode is in main inspired by how GitHub renders these paths: if there is a chain of directories where each one only has one child, they are concatenated together and shown on the first level in this collapsed form. When the user clicks this collapsed directory they are immediately brought to the deepest directory with some actual content.

To enable or disable this functionality use dired-collapse-mode to toggle it for the current dired buffer.

If the deepest directory contains only a single file this file is displayed instead of the last directory. This way we can get directly to the file itself. This is often helpful with config files which are stored in their own directories, for example in ~/.config/foo/config and similar situations.

The files or directories re-inserted in this manner will also have updated permissions, file sizes and modification dates so they truly correspond to the properties of the file being shown.

The path to the deepest file is dimmed with the shadow face so that it does not distract but at the same time is still available for inspection.

The mode is integrated with dired-rainbow so the nested files are properly colored according to user's rules.

The directory without collapsed path might look something like this:

before

After collapsing:

after

dired-hacks's People

Contributors

aagon avatar boruch-baum avatar codeblake avatar danskarda avatar dsedivec avatar dvzubarev avatar francescelies avatar fuco1 avatar gallipo avatar godfrey-cw avatar igorepst avatar kushal-kumaran avatar marcowahl avatar markus1189 avatar matusgoljersaleschamp avatar mnewt avatar nnicandro avatar northgaard avatar oneness avatar protesilaos avatar ruijieyu avatar silex avatar stakemori avatar syohex avatar tarsius avatar terlar avatar thaodan avatar vkazanov avatar wi11dey avatar xuhdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dired-hacks's Issues

[dired-subtree] problems with symlinks to directories

Hi, I use emacs 24.5.1
Steps to reproduce a problem:

  1. go in dired to any symlink to a directory
  2. M-x dired-subtree-toggle opens the subdirectory
  3. M-x dired-subtree-toggle does not close the subdirectory but opens it another time, so there are two opened subdirectories

[filter] dired-filter-by-XXX should enable mode if needed

Hello,

dired-filter-by-file and friends don't do anything until you enable the minor mode.

When you use them without the minor mode enabled, they don't report there is a problem and the user is left wondering wth is going on.

"Multi-stage" or "curried" file movement/copying

This is a feature found in the terminal file manager ranger. It's quite useful when navigating the filesystem is faster than typing out a path with tab-complete, as it is in ranger.

The flow is this:

  1. Mark some files with spacebar.
  2. Copy them to the "clipboard" with yy.
  3. Navigate to another directory.
  4. Paste the files with p and they appear in that directory.

Moving the files instead of copying them can be done by using dd to cut instead of copy.

dired-narrow-map not work.

(require 'dired-narrow)
(add-hook 'dired-mode-hook
          '(lambda ()
             (define-key dired-narrow-map [(control n)] 'dired-narrow-next-file)
             (define-key dired-narrow-map [(control p)] 'dired-narrow-previous-file)
             ))

(define-key dired-narrow-map [(control n)] 'dired-narrow-next-file)
(define-key dired-narrow-map [(control p)] 'dired-narrow-previous-file)

When I enable dired-narrow by press filter string and then RET.
hotkey is no change.

Thanks.

dired-subtree does not work well in ubuntu 16.04

In ubuntu 16.04, dired-subtree-insert not work on the subtree inserted firstly, the ls version is 8.25.

Directory of the subtree is not highlighted, and when try to run dired-subtree-insert on an item, it will raise an error: ”dired-move-to-filename: Unrecognized line! Check directory-listing-before-filename-regexp“

filtering by multiple extensions error

When calling dired-filter-by-extension with a negative prefix argument, and feeding it pdf and docx followed by C-g, I get the following error:
Invalide function: "docx"

Failed to narrow after recovering from invisibility

Hi,
I use emacs 24.5.1 with spacemacs 0.105.9 on Ubuntu 15.10.
Steps to reproduce.
0. use (setq dired-narrow-exit-action 'dired-narrow-find-file)

  1. filter some directory out
  2. restore this directory
  3. select this directory and hit enter
    I got an empty screen and stay in the same directory.
    I have found that (dired-utils-goto-line dired-narrow--current-file) returns nil, so I thought that this caused by the remained properties.
    I replaced (remove-text-properties (point-min) (point-max) '(invisible)) (here) with (set-text-properties (point-min) (point-max) '())
    and it seems working now, but I do not know whether it is a good solution.

Readme doesn't render properly

Hey, just FYI, the readme is rendering really awkwardly on GitHub. A lot of text appears blue, as if linked, but it's not. Maybe something to do with the <a ... /> tags.

Have you considered doing the readme as an Org file? :)

minibuffer-keyboard-quit not found

Hi,
I use emacs 24.5.1 with spacemacs 0.105.9 on Ubuntu 15.10.
Steps to reproduce:

  1. M-x dired-narrow
  2. C-g
  3. I get an error "command-execute: Symbol's function definition is void: minibuffer-keyboard-quit"

Please consider adding an "umbrella" library `dired-hacks.el'

I have brought this up elsewhere but the context was confusing so I'll try again and go into more detail.

While some of the libraries in this repository are required by others, most of the libraries can be used independently of one another. Compared to other extensions to dired this is a big advantage of yours, as users can mix and match as they see fit. Never-the-less these libraries are closely related to one-another and so it makes a lot of sense to keep them in a single repository.

Most people nowadays install their elisp libraries using package.el. And because most users probably don't want all of these fine libraries they were split into separate packages which can be installed independently.

Others however prefer to install packages by adding them as submodules of their user-emacs-directory which they track in git. I do it for example, mostly because it makes it much easier to contribute back to the packages I use. I can instantly start doing so, the repository is already cloned and I do not need to fiddle with the load-path to ensure the version I am working on gets loaded.

That can be a problem when upstream puts unrelated things into the same repository. However that is not the case here. I think it is perfectly fine, or rather even preferable, to have all these libraries in the same repository. After all, just because they are on the load-path I don't have to actually load them.

So the suggestion I have to make is a rather cosmetic and not very important one.

The Emacsmirror collects Emacs packages, but the basic unit is the repository. When a repository contains unrelated stuff, then that is an issue. But in this case it is not because the libraries are related. I also extract metadata from all mirrored packages, I do not currently publish it because I am only just now getting back on track with the Emacsmirror and there's still a lot of cruft around. But I think that this will eventually be a quite useful resource.

Most of that metadata is extracted from the "main library", the entry point for users so to speak. Unfortunately because this repository contains libraries which can be used independently there's no such entry point. That these libraries do not needlessly depend on one-another is a good thing, but has the unfortunate side-effect that there is no standardized source to extract metadata. (The README does not qualify because, unlike library headers, it is basically free form).

As a result I have to somewhat randomly pick a library from which I extract metadata. I have picked dired-hacks-utils.el and as a result these libraries as a unit are now described as "Utilities and helpers for dired-hacks collection". Not really a big deal and if it hadn't come up in another conversation I would probably not even have mentioned it.

For that reason I would recommend that you add dired-hacks.el, add a header and copy the contents of the README into the Commentary. You could also require all the other libraries in this new umbrella library, so that users who want it all would only have to require this one library.

`dired-narrow` does not interact with `dired-hide-details-mode`

In Emacs 24.4 / 25:

In a dired buffer with dired-hide-details-mode enabled, as soon as I invoke one of the dired-narrow functions the dired details are shown again. If I call revert-buffer (g) then the filter is removed and the buffer is shown again with the details properly hidden.

dired-subtree displayed as empty when it contain only a file/folder

If (setq dired-listing-switches "-Al") is set with the switch -A witch hide . and .., when dired-subtree-insert is used on a folder containing only one file or one folder, a subtree of one empty line open in the buffer.
This doesn't appear when the switch used is -a, the name of the folder/file is correctly written.

Live narrowing not working with Emacs 24.4 / 25

Trying out dired-narrow, and I cannot get the live narrowing behavior to work. If I call one of the dired-narrow functions I can type a filter and hit return to apply it, but while I am typing the buffer is not updated in any way.

dired-subtree does not refresh when doing operations in dired

I use dired-subtree instead of the default dired-maybe-insert-subdir because it's much better. The only gripe I have is that operations which dired usually keeps up to date for do get reflected in the subtree. For example, if I have a file a/b/c and I open a in dired, and then use dired-subtree to display b inline, and then ask dired to delete or rename c, the listing is not updated until I press g. If I use the normal dired insert subdir, these kinds of changes are reflected immediately without pressing g.

Is there any way to persuade dired-subtrees to update when performing operations on their contents?

Thanks,

Tom

Filter groups break when reverting buffer with expanded subtrees

I've been running into the problem where filter groups do not get displayed after reverting the buffer and point is on a line that is contained within the region of a subtree.

It seems the culprit is that (ignore-errors (dired-next-subdir 0)) in dired-filter-group--apply evaluates to nil in the above scenario. I'm assuming because dired-next-subdir is not aware of subtree's.

I made a fix for this that just folds the subtrees, applies the filter groups, and then re-expands the subtrees again:

(defun dired-filter-group-subtree-hack (orig-fun filter-group)
  "Fold subtree's, apply filter groups, expand subtrees.

If `dired-subtree' is enabled, fold all of the expanded subtrees
before calling `dired-filter-group--apply' and re-expand them
after.

This avoids breaking the filter groups machinery when subtrees are
expanded and the buffer is reverted."
  (let* ((subtrees (and (featurep 'dired-subtree)
				     (let ((dired-filter-keep-expanded-subtrees t))
					(eval (dired-filter--mark-unmarked 't))
					(reverse dired-filter--expanded-dirs))))
		 (prefix (car subtrees)))
	;; fold all expanded subtrees
	(when subtrees
	  (dired-utils-goto-line prefix)
	  (dired-subtree-toggle)
	  (--each-while (cdr subtrees)
		  (unless (string-prefix-p prefix it) (setq prefix it))
		(save-excursion
		  (dired-utils-goto-line it)
		  (dired-subtree-toggle))))
	(funcall orig-fun filter-group)
	;; re-expand folded subtrees
	(when subtrees
	  (--each subtrees
		(save-excursion
		  (dired-utils-goto-line it)
		  (dired-subtree-insert))))))

(advice-add 'dired-filter-group--apply :around #'dired-filter-group-subtree-hack)

Another possible solution would be to remove and then re-apply the subtree overlays instead of having to re-insert the contents of all the subtrees.

It would be great to see if someone more familiar with the internals could see if there is a better option.

[filter] Add useful filters from % and * dired maps

In case someone wants to implement this, feel free to comment here and send a patch :)

  • (define-key map "**" 'dired-mark-executables)
  • (define-key map "*/" 'dired-mark-directories)
  • (define-key map "*@" 'dired-mark-symlinks)
  • (define-key map "*%" 'dired-mark-files-regexp)
  • (define-key map "*N" 'dired-number-of-marked-files)
  • (define-key map "*c" 'dired-change-marks)
  • (define-key map "*s" 'dired-mark-subdir-files)
  • (define-key map "*m" 'dired-mark)
  • (define-key map "*u" 'dired-unmark)
  • (define-key map "*?" 'dired-unmark-all-files)
  • (define-key map "*!" 'dired-unmark-all-marks)

live narrowing: allow the use of up/down/enter keys for interactions or maybe dired-narrowing-mode?

Hi Fuco
thx so much for your amazing packages, this finally lets me the opportunity to switch to dired full time as my file manager :)
one thing i really miss from worker/nutlius/spacefm/etc is the ability to quick narrow and choose files. currently in narrowing as far as i can tell i can quick narrow (filter) but then need to press Enter before i can interact with files. I would love the ability to use the up/down/enter keys to quick exe/interact with files without pressing enter?

Alternatively may i suggest a dired-narrow-mode, where one could enable it with a hotkey/enable at dired startup, where then entering keys would start narrowing mode. (i think sunrise commander has something like this)

thx so much again for all your amazing work

z

dired-subtree doesn't work in TRAMP

dired-subtree-insert is working when I'm in a dired buffer on my local host, but it isn't if I'm in a dired buffer via TRAMP. and get a "Beging of the buffer" in the modebar.

dired-subtree not compatible with dired-hide-details-mode from Emacs 24.4

Last Emacs version adds new capability to dired to hide file details (flags, owner and date).

dired-subtree is not compatible with dired-hide-details-mode when details are hidden.

I found more implementations of this feature (dired+, dired-details). I guess compatibility with Emacs 24.4 implementation would be enough.

dired-filter systematically fails with "Symbol's function definition is void: cadddr"

When in dired-mode with dired-filter-mode enabled, any function like / h or / . fails with the message “Symbol's function definition is void: cadddr” in the minibuffer.

I first got the issue with Emacs 24.4.1, then upgraded to Emacs 24.5.1 and got the same result.

Looking at Emacs manual, I got the concept of the built-in car and cdr functions. In my Emacs installation, the four cxxr forms are provided by subr.el. But the longer cxxxr forms can't be found by the help system: C-h f caddr fails with "no match", and the same goes for C-h f cadddr.

Google helped me to understand that those would be defined by cl.el.

So, the solution was: M-x load-library cl. Then dired-filter-mode started working like a charm!

When reading the lisp/emacs-lisp/cl.el file, the header line says: Compatibility aliases for the old CL library, and the end of the file suggest that this old CL library might have been deprecated in Emacs 24.4. So I guess the reason why cadddr is missing, is a recent evolution of Emacs.

Could you please patch your code to use expanded forms of cadddr (which would simply be a cadr of cddr) so that this compatibility issue doesn't arise anymore?

Regexp-searching c[ad]\{3,\}r in your code, I found 8 occurrences. Patching those (and moving away the .elc file) resolved the issue in a nice way, without requiring the compatibility library.

Hope this might help others!

dired-filter-by-predicate should offer variables like dired-mark-sexp

Hello, I think this one is self explanatory. Here is the doc string for dired-mark-sexp:

PREDICATE is a lisp sexp that can refer to the following variables:

    `mode'   [string]  file permission bits, e.g. "-rw-r--r--"
    `nlink'  [integer] number of links to file
    `size'   [integer] file size in bytes
    `uid'    [string]  owner
    `gid'    [string]  group (If the gid is not displayed by `ls',
                       this will still be set (to the same as uid))
    `time'   [string]  the time that `ls' displays, e.g. "Feb 12 14:17"
    `name'   [string]  the name of the file
    `sym'    [string]  if file is a symbolic link, the linked-to name,
                       else ""
    `inode'  [integer] the inode of the file (only for `ls -i' output)
    `blks'   [integer] the size of the file for `ls -s' output
                       (ususally in blocks or, with `-k', in Kbytes)
Examples:
  Mark zero-length files: `(equal 0 size)'
  Mark files last modified on Feb 2: `(string-match "Feb  2" time)'
  Mark uncompiled Emacs Lisp files (`.el' file without a `.elc' file):
     First, Dired just the source files: `dired *.el'.
     Then, use M-( with this sexp:
          (not (file-exists-p (concat name "c")))

I'll try to come up with a PR :)

[filter] marking vs filtering

Hello,

I just had this idea: there is some overlap with dired functions used for marking... e.g:

M-x dired-mark-directories followed by t k would be equivalent to dired-filter-by-directory.

On the other hand, one could implement dired-mark-directories with dired-filter-by-directory followed by t to have them marked and then / p to remove the filter.

Any thought on this? I'd like to avoid learning two systems if possible, but I'm not sure there's an elegant solution to this problem. What I fear is that some advanced marking will only be possible through dired-filter... so maybe it'd be neat to have a dired-filter-mark-mode which would mark instead of filter? I think I like this idea a lot :)

I use marks when renaming/copying with R or C.

[dired-narrow]-change cursor shape/color in filter mode?

Hi again

been using dired-narrow (and all of dired hacks) for months now and love it (TBH its what allowed me to move to dired as my full time FM :))

so one thing that makes life "tough" for me is that when in filter mode the cursor switches from my normal dired cursor (a blue line-- using hl-line-mode 1) to an empty blue box. here is a screenshot:

https://paste.xinu.at/5oR/

is there anyway to make filter mode keep the hl-line-mode to be 1)consistent with dired and 2)get better visual feedback on where the cursor is?

thx alot

Z

Add an option to pass faces to dired-rainbow-define

If the second argument is string, we use it as color, if it is a list, we use that as list of face properties. If we pass a symbol, make the new face inherit from the old.

This same thing can be achieved by passing (:inherit ...) but it will be simpler.

Activate column view?

This is not really an issue, just a question. In dired-column there are a lot of functions which (I suppose) are meant to create some kind of column view in dired, aren't they? But my question is: how I activate this views? (thanks for the hacks, btw!)

Edge cases in dired-subtree-previous|next-sibling

During implementation of recursive insert in #28 I found several edge cases in dired-subtree-previous/next-sibling, which does not work as expected. These issues also make dired-subtree-with-subtree unusable.

  • empty directories. Expanding empty directory leads to empty line. However next sibling does not handle new-lines well.
  • last sibling with subdirs. In following scenario cursor moves from current-directory to parent-sibling. The reason is that next line is a subdirectory. Function skips the subdirectory but it does not check if at the end of subdir is really sibling or sibling of its parent.
parent
   current-directory
      child1
         child2
parent-sibling

"This cannot happen" message

After I use dired-subtree-insert on a dir, when I call dired-do-redisplay (pressing l muliple times) I get the message
"dired-after-subdir-garbage: This cannot happen".

error in readme

(and as a result, in melpa's description)

(define-key dired-mode-map (kbd "some-key") dired-filter-map)

should have a quote on the function:

(define-key dired-mode-map (kbd "some-key") 'dired-filter-map)

Hide the bar of dired-filter-mode?

I currently use the use-package.

So dired-filter is configured as following:

(use-package dired-filter
    :defer 4
    :config
    (dired-filter-mode))

I would like to have it already active, when I open Dired. So I can always filter contents of Dired, if I want, without enabling it every time.

When starting Emacs, I noticed it added the bar " Active filters: [Omit]" to the top of my scratch buffer, after dired-filter-mode gets enabled. I would like to don't see that bar. Is there any way to prevent the bar to popping it up?

Dired ranger doesn't update the dired buffer, after paste action

When I copy a file with dired-ranger-copy and paste it into another directory in dired, with dired-ranger-paste, the file is pasted into the current directory. But I don't see the file appearing in Dired.
When checking it with another file manager, the copied file is now in the directory.

So my question is if Dired could automatically update the buffer after a paste or move action?

cant get dired-open to work

Hi again

im trying to use as many of the extensions you made as possible ;-)

while all other extensions worked as instructed i cant get my head around dired-open. its my understanding that when you configure dired-open (which i dont understand how yet) one could press enter on files and then based on specific file type/extension a user defined action would take place. such as pressing enter on an html file and then firefox opens up. is that correct? if so would you mind giving me a short example on how to configure that (for example the html>firefox thing)

thx!

Z

Cannot visit files under subtree

It shows this error:

dired-get-file-for-visit: No file on this line

Emacs version:

GNU Emacs 24.3.93.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8) of 2014-09-06 on tuhdo-MacBookAir

Questions

I have couple of questions about dired-rainbow.

  1. How to make it work with Ranger. It doesn't seem to be working in Deer or Ranger (I'm using Spacemacs)
  2. How can I tell it to gray out "dot files" - dirs and files that start with dot e.g. ".git"

Thank you

emacs elisp checker complains about dired-rainbow-define

Hi.

I'm using dired-rainbow package in my emacs init.el file, and I like the way I can play around with colours in dired listings thanks to it.

But, whenever I run my elisp-checker on my init.el file, I get the following error:

error Forgot to expand macro dired-rainbow-define (emacs-lisp)

I get this error for every line in my init.el using the dired-rainbow-define macro.

This one is the only macro that makes my elisp checker to give an error.
I use other macros, like defhydra, and I get not error at all.

Any idea on how can I get rid of this error?

Thanks a lot.
-Bob

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.