Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not seeing anything when I M-x dired-rainbow ... #148

Open
godfrey-cw opened this issue Mar 25, 2019 · 18 comments
Open

Not seeing anything when I M-x dired-rainbow ... #148

godfrey-cw opened this issue Mar 25, 2019 · 18 comments
Labels

Comments

@godfrey-cw
Copy link
Contributor

godfrey-cw commented Mar 25, 2019

Installed dired-rainbow via MELPA with the package manager, along with most of the other dired-hacks packages. All the others are working fine but when I hit M-x dired-rainbow-define or M-x describe-function ENTER dired-rainbow-define I'm not getting anything. When I use dired-rainbow in my init it doesn't run to completion.

Anyway, it seems like my emacs isn't finding the dired-rainbow functions. Any help in this matter would be appreciated!

@dieggsy
Copy link
Contributor

dieggsy commented Mar 26, 2019

@godfrey-cw could you show the relevant part of your config pertaining to dired-rainbow ?

@Fuco1
Copy link
Owner

Fuco1 commented Mar 26, 2019

The functions are not interactive so you won't be able to run them with M-x.

@Fuco1
Copy link
Owner

Fuco1 commented Mar 26, 2019

This is an example from my config

(use-package dired-rainbow
  :config
  (progn
    (dired-rainbow-define html "#4e9a06" ("htm" "html" "xhtml"))
    (dired-rainbow-define xml "#b4fa70" ("xml" "xsd" "xsl" "xslt" "wsdl"))

    (dired-rainbow-define document font-lock-function-name-face ("doc" "docx" "odt" "pdb" "pdf" "ps" "rtf" "djvu" "epub"))
    (dired-rainbow-define excel "#3465a4" ("xlsx"))
    (dired-rainbow-define media "#ce5c00" my-dired-media-files-extensions)
    (dired-rainbow-define image "#ff4b4b" ("jpg" "png" "jpeg" "gif"))

    (dired-rainbow-define log "#c17d11" ("log"))
    (dired-rainbow-define sourcefile "#fcaf3e" ("py" "c" "cc" "h" "java" "pl" "rb" "R" "php"))

    (dired-rainbow-define executable "#8cc4ff" ("exe" "msi"))
    (dired-rainbow-define compressed "#ad7fa8" ("zip" "bz2" "tgz" "txz" "gz" "xz" "z" "Z" "jar" "war" "ear" "rar" "sar" "xpi" "apk" "xz" "tar"))
    (dired-rainbow-define packaged "#e6a8df" ("deb" "rpm"))
    (dired-rainbow-define encrypted "LightBlue" ("gpg" "pgp"))

    (dired-rainbow-define-chmod executable-unix "Green" "-.*x.*")
    ))

@godfrey-cw
Copy link
Contributor Author

godfrey-cw commented Mar 26, 2019

Awesome, many thanks that's very helpful. I just basically copy-pasted from the readme, and was adding stuff like

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

But without any use-package or :config. Sorry, still kind of an emacs newbie here!

UPDATE: The example you just posted works great -- in my newbie fashion I'll just cautiously tweak that. Thanks for all the dired-hacks!

@godfrey-cw
Copy link
Contributor Author

godfrey-cw commented Mar 26, 2019

FWIW I just spent 20 minutes tweaking your example into a pseudo-port of LS_COLORS (didn't actually figure out how to turn ls colors into hex, just used inspection of my terminal and Tailwind CSS colors to find approximations. I skipped extensions I had never heard of and amalgamated where it made sense to me (e.g. grouping xlsx and csv ...). It'd be cool if someone did a better port of an extensive LS_COLORS setup than this, but I'm content with the below.

(use-package dired-rainbow
  :config
  (progn
    (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.*")
    ))

Not sure if you'd consider including this (or a better version of this) as a "dired-rainbow starter kit," for lazy people like myself who would be fine just copy-pasting something into their .emacs.

@Fuco1
Copy link
Owner

Fuco1 commented Mar 26, 2019

The last number of the triplet maps through this: https://jonasjacek.github.io/colors/

The ;1 part marks bold.

This is indeed pretty cool, maybe a simple sed/awk script could turn LS_COLORS into the lisp equivalent.

Either way your example can be included in the readme for sure. PR welcome!

EDIT: also unrelated, but Algebraic geometry is awesome! My 3rd year thesis was on the Nullstellensatz... a pretty unusual proof through some more obscure theorems. Sadly I only really got into it my last year :/ I was more into CT nonsense due to my compsci origins :D

@publicimageltd
Copy link

I just want to remark that for me, dired-rainbow also never worked. Accidentally, I found out that the cause was a wrong regexp in dired-hacks-datetime-regexp.

The original value was:

"\\sw\\sw\\sw....\\(?:[0-9][0-9]:[0-9][0-9]\\|.[0-9]\\{4\\}\\)"

I changed it to:

"\\sw\\sw\\sw.\\(?:[0-9][0-9]:[0-9][0-9]\\|[0-9]\\{4\\}\\)"

Now everything works fine. So basically, I now wrap all definitions in init.el within a let-statement:

  (let ((dired-hacks-datetime-regexp
	"\\sw\\sw\\sw.\\(?:[0-9][0-9]:[0-9][0-9]\\|[0-9]\\{4\\}\\)"))
    (dired-rainbow-define-chmod directory "#6cb2eb" "d.*")
    .... etc ....
   )

I have no clue why this change is necessary. Looking at the regexps, it's something with the spaces between the dates and the rights. I pass no unconventional switches to ls, however, so I think it might be some change of the behavior of \sw (syntax table or whatever). I leave finding the cause to the experts; just wanted to point out that this helps.

@Fuco1
Copy link
Owner

Fuco1 commented Jan 17, 2021

These outputs can also depend on the platform and versions of many other packages/commands. Maybe we can come up with a regexp that works for everything out of the box.

@publicimageltd
Copy link

I'd be happy to help if you have any idea which parameters or programs could be relevant.

For a starter, maybe it would be enough to just replace the three dots ... with a simple .*?. The result is:

"\\sw\\sw\\sw.*?\\(?:[0-9][0-9]:[0-9][0-9]\\|[0-9]\\{4\\}\\)"

Works for me right now, and would also cover the case where the original regexp applied.

@Fuco1
Copy link
Owner

Fuco1 commented Jan 17, 2021

Yes I think that would be reasonable. I'll try it also and we'll see.

@jpdur7729
Copy link

dired-rainbow does not work for me... Within dired the faces used are still the dired-faces when any (C-u C-x =). I tried the trick suggested above but did not work either for me. I am on w10 with Emacs 27.1.

Any Idea of how to sort out the issue.... I have attached below a quick snapshot of what I can see.

image

@legends2k
Copy link

legends2k commented Nov 1, 2022

@Fuco1 I'm on Emacs 28.2 (Windows 11), I'm not able to get it to work either. Here's my configuration:

(use-package dired-rainbow
  :ensure t
  :after dired
  :config
    (dired-rainbow-define markdown "#ffed4a" ("org" "etx" "info" "markdown" "md" "mkd" "nfo" "pod" "rst" "tex" "adoc"
                                              "textfile" "txt"))
    (dired-rainbow-define compiled "#4dc0b5" ("asm" "cl" "m" "mm" "lisp" "el" "c" "h" "c++" "h++" "hpp" "hxx" "m" "cc"
                                              "cs" "cp" "cpp" "go" "f" "rs" "hi" "hs" "pyc" ".java"))
)

I only see directories with a different colour and nothing more. Any way I can debug this? Help on dired-rainbow-ext-to-face variable shows

(
(("org" "etx" "info" "markdown" "md" "mkd" "nfo" "pod" "rst" "tex" "adoc" "textfile" "txt")
  dired-rainbow-markdown-face "\\.\\(?:adoc\\|etx\\|info\\|m\\(?:arkdown\\|k?d\\)\\|nfo\\|org\\|pod\\|rst\\|t\\(?:ex\\(?:tfile\\)?\\|xt\\)\\)")
(("asm" "cl" "m" "mm" "lisp" "el" "c" "h" "c++" "h++" "hpp" "hxx" "m" "cc" "cs" "cp" "cpp" "go" "f" "rs" "hi" "hs" "pyc" ".java")
  dired-rainbow-compiled-face "\\.\\(?:\\.java\\|asm\\|c\\(?:\\+\\+\\|pp\\|[clps]\\)\\|el\\|go\\|h\\(?:\\+\\+\\|pp\\|xx\\|[is]\\)\\|lisp\\|mm\\|pyc\\|rs\\|[cfhm]\\)")
)

@legends2k
Copy link

legends2k commented Nov 1, 2022

Got it working!

(setq dired-hacks-datetime-regexp "\\(?:[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]\\|[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)")

works as my dired buffers show date and time as DD-MM hh:mm or YYYY-MM-DD.

@Fuco1
Copy link
Owner

Fuco1 commented Mar 16, 2023

@purcell has a diredfl package https://github.com/purcell/diredfl which also adds a lot of dired fontifications. For those who have issues with the dates you can also steal the regexp from there 😁

@purcell
Copy link

purcell commented Mar 17, 2023

Yeah, extracted from dired+ and independently updated a few times since.

@groskwik
Copy link

groskwik commented Dec 5, 2023

Got it working!

(setq dired-hacks-datetime-regexp "\\(?:[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]\\|[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)")

works as my dired buffers show date and time as DD-MM hh:mm or YYYY-MM-DD.

Thanks so much !!! my config was only working on my mcbook but failed on linux and PC at work. This simple line fixed the issue.

@emilsenan
Copy link

@Fuco1 Hi, is dired-rainbow still supposed to work with latest emacs? Faces based on file extension are actually not added, checked with (C-u C-x =).

@Fuco1 Fuco1 added the bug label Mar 18, 2024
@sven765
Copy link

sven765 commented Mar 18, 2024

The datetime regexp tip helped me too! Thanks!

My dired shows datetime as "8. Mär 20:06" or "27. Feb 2023" for examples, so this regexp helped me:

(setq dired-hacks-datetime-regexp "\\(?:[0-9]\\| \\)[0-9]. \\w\\w\\w \\(?:[0-9][0-9]:[0-9][0-9]\\|[0-9][0-9][0-9][0-9] \\)")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

10 participants