How to adjust dired-omit-mode

[Origin]: https://emacs.stackexchange.com/questions/19558/how-to-adjust-dired-omit-mode

Goal:

  • When dired is opened by default hidden files should be hidden.
  • When the user clicks “M-q” hidden files must be shown except for “.” and “..”

I tried the following:

;don't show hidden files
(setq dired-omit-files "^\\..*$")
(defun swap-omit-files ()
  "Show/hide hidden files except . and .."
  (interactive)
  (if (string= dired-omit-files "^\\..*$")
      (setq dired-omit-files "^\\.\\.?$")
    (setq dired-omit-files "^\\..*$")
    )
  )

(add-hook 'dired-mode-hook
          (lambda ()
            (setq dired-omit-mode t)
            (define-key dired-mode-map (kbd "M-q") 'swap-omit-files)
            ))
Hidden file are indeed hidden by default, but something is wrong with swap-omit-files --- the hidden files are not shown.

How to fix?

shareimprove this question

 

This worked. We needed to revert-buffer after changing dired-omit-files:

(defun swap-omit-files ()
  "Show/hide hidden files except . and .."
  (interactive)
  (if (string= dired-omit-files "^\\..*$")
      (setq dired-omit-files "^\\.\\.?$")
    (setq dired-omit-files "^\\..*$")
    )
  (revert-buffer)
  )
shareimprove this answer
Advertisements

After enabling ivy-mode, `dired-create-directory’ does not allow me to choose an entry not in the completion list

[origin]: https://emacs.stackexchange.com/questions/28982/after-enabling-ivy-mode-dired-create-directory-does-not-allow-me-to-choose-an/28983

Yes, obviously.

There are 2 cases. The name you want to create doesn’t match anything in the completion list, or when it does.

When it doesn’t, you can just do the totally obvious thing, type in the name and press enter.

If it does match, then pressing enter will get ivy to expand the name to the completion. Here you want to call ivy-immediate-done which is bound to C-M-j by default after you have typed the name.

shareimprove this answer

Emacs Dired rename many files

[From]: http://stackoverflow.com/questions/15881776/emacs-dired-rename-many-files

This can easily be done using dired:

  1. Enter a dired view of your directory
  2. Switch to writable dired mode (wdired-change-to-wdired-mode): C-xC-q
  3. Edit the file names listing as if it were a normal buffer (for example using a keyboard macro or a rectangular selection or query-replace). Here is a regexp-based solution:

    C-M-%\(VAR.\)_\(..\)RET\2_\1RET

  4. Finish editing (wdired-finish-edit): C-xC-s or C-cC-c

You’re done!

shareedit

Emacs: Rename Files Interactively

From http://ergoemacs.org/emacs/rename_file_pattern.html

Emacs: Rename Files Interactively

Buy Xah Emacs Tutorial. Master emacs benefits for life.

This pages shows you how to rename multiple files in emacs.

Go to the directory first, by calling dired. 〔➤ Emacs: File Management (dired tutorial)

When in dired, call dired-toggle-read-onlyCtrl+x Ctrl+q】.

Then, just edit the file names.

When done, do one of:

  • wdired-finish-editCtrl+c Ctrl+c】 to commit the changes.
  • wdired-abort-changesCtrl+c Ctrl+k】 to abort the changes.

How to quickly copy/move file in Emacs Dired?

http://emacs.stackexchange.com/questions/5603/how-to-quickly-copy-move-file-in-emacs-dired

From the documentation:

dired-dwim-target is a variable defined in `dired.el’. Its value is nil

Documentation: If non-nil, Dired tries to guess a default target directory. This means: if there is a Dired buffer displayed in the next window, use its current directory, instead of this Dired buffer’s current directory.

The target is used in the prompt for file copy, rename etc.

Put this in your init file: (setq dired-dwim-target t). Then, go to dired, split your window, split-window-vertically & go to another dired directory. When you will press C to copy, the other dir in the split pane will be default destination.

shareimprove this answer