kickingvegas / casual-dired

Casual Dired - An opinionated Transient user interface for Emacs file manager Dired.
GNU General Public License v3.0
124 stars 2 forks source link

[[https://melpa.org/#/casual-dired][file:https://melpa.org/packages/casual-dired-badge.svg]]

[[file:docs/images/casual-dired-screenshot.png]]

** Goals

** Non-Goals

Casual Dired has been verified with the following configuration.

The Casual Dired /Sort By/ feature relies on the installation of GNU ~ls~ which must be configured (typically via ~PATH~) so it is available to Emacs. There is no checking by Casual Dired to verify that GNU ~ls~ is installed.

Users with earlier versions of GNU coreutils may still be able to use Casual Dired.

If you use ~use-package~, here is the recipe for installing it.

+begin_src elisp :lexical no

(use-package casual-dired :ensure t :bind (:map dired-mode-map ("C-o" . #'casual-dired-tmenu) ("s" . #'casual-dired-sort-by-tmenu) ("/" . #'casual-dired-search-replace-tmenu)))

+end_src

In addition to binding the main menu ~casual-dired-tmenu~, the user can also bind the sort-by menu ~casual-dired-sort-by-tmenu~ and the search & replace menu ~casual-dired-search-replace-tmenu~.

Included is a standard keymap for Dired sorting commands (~casual-dired-sort-menu~) which can be included in a context menu for a mouse-driven workflow. An example of this is shown below:

+begin_src elisp :lexical no

(require 'casual-dired)

(defun casual-dired-context-menu-addons (menu click) "Customize context MENU with CLICK event." (easy-menu-add-item menu nil casual-dired-sort-menu) menu)

(add-hook 'context-menu-functions #'casual-dired-context-menu-addons) (add-hook 'dired-mode-hook 'context-menu-mode)

+end_src

For users running on Microsoft Windows, use [[https://www.gnu.org/software/emacs/manual/html_node/efaq-w32/Dired-ls.html][this guidance]] to configure GNU ~ls~ for running with Dired.

Casual requires Emacs 29.1+.

* Enhanced Sorting Casual Dired offers enhanced sorting capabilities through GNU ~ls~. Use this to sort your Dired buffer to preference. Filter dot files (.) by disabling the ~--all~ option is available here.

[[file:docs/images/casual-dired-sort-by-screenshot.png]]

With the Sort By menu raised, one can save the switch settings for future use via the binding ~C-x C-s~ (~transient-save~). Note this is a global setting and will apply to all future calls to the Sort By menu.

** Search & Replace Search and replace in multiple marked files using the ~/~ /Search & Replace/ menu item. This will raise a menu of Dired commands that will work on marked files.

[[file:docs/images/casual-dired-search-replace.png]]

While most Dired commands use Emacs-style [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Regular-Expressions.html][regular expression syntax]], there are two commands that instead take instead grep-style syntax:

The grep-style syntax is dependent on the ~grep~ implementation that is installed and used by Emacs.

* Bulk Dired Operations Casual Dired organizes a number of Dired commands that work on a set of marked files. These commands are presented in the Utils* menu.

[[file:docs/images/casual-dired-utils-screenshot.png]]

As Dired has been around for a long time, the different ways of configuring it are myriad. Described below is a configuration used by the author that is consistent with the bindings used in Casual Dired.

** Initialization

+begin_src elisp :lexical no

(require 'dired) (require 'dired-x) (require 'wdired) (require 'hl-line) (require 'mouse) (require 'image-dired) (require 'image-dired-dired) (require 'casual-dired)

(keymap-set dired-mode-map "C-o" #'casual-dired-tmenu) (keymap-set dired-mode-map "s" #'casual-dired-sort-by-tmenu) (keymap-set dired-mode-map "/" #'casual-dired-search-replace-tmenu)

(add-hook 'dired-mode-hook 'hl-line-mode) (add-hook 'dired-mode-hook 'context-menu-mode) (add-hook 'dired-mode-hook 'dired-async-mode) (add-hook 'dired-mode-hook (lambda () (setq-local mouse-1-click-follows-link 'double)))

(keymap-set dired-mode-map "M-o" #'dired-omit-mode) (keymap-set dired-mode-map "E" #'wdired-change-to-wdired-mode) (keymap-set dired-mode-map "M-n" #'dired-next-dirline) (keymap-set dired-mode-map "M-p" #'dired-prev-dirline) (keymap-set dired-mode-map "]" #'dired-next-subdir) (keymap-set dired-mode-map "[" #'dired-prev-subdir) (keymap-set dired-mode-map "A-M-" #'browse-url-of-dired-file) (keymap-set dired-mode-map "" #'dired-prev-subdir) (keymap-set dired-mode-map "TAB" #'dired-next-subdir) (keymap-set dired-mode-map "M-j" #'dired-goto-subdir) (keymap-set dired-mode-map ";" #'image-dired-dired-toggle-marked-thumbs)

(keymap-set image-dired-thumbnail-mode-map "n" #'image-dired-display-next) (keymap-set image-dired-thumbnail-mode-map "p" #'image-dired-display-previous)

+end_src

** Variables

Casual Dired offers a settings menu to customize a set of commonly used Dired variables. Use this to customize your Dired behavior to taste.

[[file:docs/images/casual-dired-settings-screenshot.png]]

If you have GNU ~ls~ installed and configured, use the ~l~ key to set the variable ~dired-use-ls-dired~ to ~t~ ("Use GNU ‘ls’ with --dired"). Otherwise this should be disabled.

** Unicode Symbol Support

By enabling “Use Unicode Symbols” from the Settings menu, Casual Dired will use Unicode symbols as appropriate in its menus. An example is shown below.

[[file:docs/images/casual-dired-screenshot-unicode.png]]

To ensure proper layout and spacing, your default typeface should be fixed-width or monospace and must support the Unicode symbols used.

Each menu item has a /key/ and a /label/. The /key/ is what is typed by the user to select the menu item. A key can be prefixed with a meta (M-) or control (C-) key. Labels ending with a ~>~ character indicates that it will open another menu.

Dismissing a menu regardless of how deep you are in sub-menus can be done by entering ~C-q~. A menu can also be dismissed by entering ~C-g~, but this will return you to the parent menu.

If a mouse is available, a menu item can be selected by moving the mouse cursor over its label and pressing down button 1.

Pressing the ~?~ key will toggle help for all the menu items. Press the key of interest to get help for it.

Some menus (in particular the /Sort By/ menu) have arguments (example ~--all~) which you can set. You can persist these settings by typing ~C-x C-s~.

When a Transient menu is raised, a prefix argument (~C-u~) can be entered before selecting a menu item.

** Menu item notation The following conventions are used to denote menu items.

If the label ends with a ~›~, it is a sub-menu.

If the label ends with an ~…~, the command will prompt you for an input value.

[[https://www.buymeacoffee.com/kickingvegas][file:docs/images/default-yellow.png]]

To get all current and future Casual user interfaces, please install [[https://github.com/kickingvegas/casual-suite][Casual Suite]] from [[https://melpa.org/#/casual-suite][MELPA]].

User Interfaces currently supported by Casual are listed below:

Users who prefer finer grained control over package installation can install each user interface above individually.