GithubHelp home page GithubHelp logo

dired-hide-dotfiles's People

Contributors

mattiasb avatar xuchunyang 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

Watchers

 avatar  avatar  avatar  avatar

dired-hide-dotfiles's Issues

When turn on `global-auto-revert-mode`, it keeps showing message in echo area

description

It keeps showing following messages in echo area even though when not in dired buffer when global-auto-revert-mode is turned on:

Marking matching files...
6 matching files marked
Killed 6 lines.

(defun dired-hide-dotfiles--hide ()
"Hide all dot-files in the current `dired' buffer."
(when dired-hide-dotfiles-mode
(dired-mark-files-regexp "^\\.")
(dired-do-kill-lines)))

(add-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide)

This becomes annoying when you have lots of dired buffer opened in the background especially when you are editing your files.

The steps to reproduce:

## TODO: should rewrite the scripts into run.sh file
git clone https://github.com/mattiasb/dired-hide-dotfiles /tmp/dired-hide-dotfiles
\rm -rf /tmp/playground && \mkdir -p /tmp/playground
## TODO: should rewrite into debug.el file
\emacs -Q -nw --eval="(custom-set-faces '(default ((t (:family \"Source Code Pro\" :foundry \"ADBO\" :slant normal :weight normal :height 233 :width normal)))))" \
       -l "/tmp/dired-hide-dotfiles/dired-hide-dotfiles.el" \
       --eval="(setq global-auto-revert-non-file-buffers t)" \
       --eval="(global-auto-revert-mode)" \
       --eval="(add-hook 'dired-mode-hook #'dired-hide-dotfiles-mode)" \
       /tmp/playground

Then switch to other buffer like *scratch*, and runs $ touch /tmp/playground/new-file in the command line.

This will result in the dired buffer /tmp/playground runs revert-buffer which runs the hook dired-after-readin-hook.

possible solution

(defun dired-hide-dotfiles--hide ()
  "Hide all dot-files in the current `dired' buffer."

  (when dired-hide-dotfiles-mode
    (let ((inhibit-message t))
      (dired-mark-files-regexp "^\\.")
      (dired-do-kill-lines))))
inhibit-message is a variable defined in C source code.

Documentation
Non-nil means calls to message are not displayed.

They are still logged to the *Messages* buffer.

Directions for setting '.' key does not work in Emacs 29.1

When adding your suggested lines to my init.el I get the following warning from Emacs, and it fails to load the remainder of the init.el file:

⛔ Warning (initialization): An error occurred while loading ‘/Users/mok/.emacs.d/init.el’:

Symbol's value as variable is void: dired-mode-map

README.md example config to hide dotfiles does not work

description

Comment below code from file dired-hide-dotfiles.el first:

;;; (add-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide)

```elisp
(defun my-dired-mode-hook ()
"My `dired' mode hook."
;; To hide dot-files by default
(dired-hide-dotfiles-mode)
;; To toggle hiding
(define-key dired-mode-map "." #'dired-hide-dotfiles-mode))
(add-hook 'dired-mode-hook #'my-dired-mode-hook)
```

This always results in the following messages when open new dired buffer:

Marking matching files...
0 matching files marked
Killed 0 lines.

NOTE: 0 matching files marked, even when there are dotfiles exist.

reproduce

  1. Comment below code from file dired-hide-dotfiles.el:
;;; (add-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide)
  1. File debug.el
(custom-set-faces
 '(default ((t (
                :family "Source Code Pro"
                :foundry "ADBO"
                :slant normal
                :weight normal
                :height 233
                :width normal)))))

(load "/tmp/dired-hide-dotfiles/dired-hide-dotfiles.el")
(add-hook 'dired-mode-hook #'dired-hide-dotfiles-mode)
  1. File debug-emacs.sh
#!/usr/bin/env bash

cd "$(dirname $0)" || exit 1

lab="/tmp/debug-emacs-playground"

git clone https://github.com/mattiasb/dired-hide-dotfiles /tmp/dired-hide-dotfiles

rm -rf "$lab"
mkdir -p "$lab"

touch "$lab/.abc"
emacs -Q -nw --load "debug.el" "$lab"
  1. ./debug-emacs.sh

You should see that file .abc is not hidden in dired buffer /tmp/debug-emacs-playground.

possible solution

The funcction dired-hide-dotfiles-mode should be called by dired-after-readin-hook instead of dired-mode-hook.

(add-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide)

To fix it, simply remove

   ;; To hide dot-files by default 
   (dired-hide-dotfiles-mode)

from my-dired-mode-hook.

Typo on message

Hi! I was using the package and noticed a small typo on the final message of hidden files: the format string contains a spare s so the final message is often Hid X dotfiless. I would make a PR with this fix, but I noticed 1 more thing I would like to discuss.

The dired-plural-s function used to put the plural s on the message checks only if the number of elements is 1, therefore when no files are hidden, the message is Hid 0 dotfiles (with the plural s). Should this case be left as-is (like normal dired) or reimplement a plural function that checks 0 and 1?

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.