mattiasb / dired-hide-dotfiles Goto Github PK
View Code? Open in Web Editor NEWHide dotfiles in dired.
License: GNU General Public License v3.0
Hide dotfiles in dired.
License: GNU General Public License v3.0
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.
dired-hide-dotfiles/dired-hide-dotfiles.el
Lines 59 to 63 in b715f64
This becomes annoying when you have lots of dired
buffer opened in the background especially when you are editing your files.
## 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
.
(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.
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
Comment below code from file dired-hide-dotfiles.el
first:
;;; (add-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide)
Lines 20 to 30 in b715f64
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.
dired-hide-dotfiles.el
:;;; (add-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide)
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)
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"
./debug-emacs.sh
You should see that file .abc
is not hidden in dired
buffer /tmp/debug-emacs-playground
.
The funcction dired-hide-dotfiles-mode
should be called by dired-after-readin-hook
instead of dired-mode-hook
.
To fix it, simply remove
;; To hide dot-files by default
(dired-hide-dotfiles-mode)
from my-dired-mode-hook
.
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?
(use-package dired
:bind
(:map dired-mode-map ("." . dired-omit-mode))
:config
(setq dired-omit-files (rx (seq bol ".")))
;; To hide dot-files by default
:hook
(dired-mode . dired-omit-mode))
Hi.
I found this in the "emacs weekly news" and just want to point out that there already is a solution in the dired-filter
package (https://github.com/Fuco1/dired-hacks#dired-filter), which on top of the "dotfile" filter provdes dozens of others.
If this is just a "training" package, no harm done, but I think we should try to lower the duplication (the Emacs community suffers from this problem a lot).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.