emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dired-hide-details-mode, how to customize?


From: Michael Heerdegen
Subject: Re: dired-hide-details-mode, how to customize?
Date: Thu, 25 Jun 2015 01:55:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

address@hidden (jenia.ivlev) writes:

> Should I change the function ls-lisp-insert-directory to run `wc -l`
> on each file and print the output on each row? Is that sort of the
> idea?

I guess this thread should better be continued in gnu.emacs.help...

As I said before, dired will probably get confused if you change the
buffer contents.  So, I take it back, using ls-lisp is not really
helpful here.

I would use an after advice on `dired-insert-set-properties' that uses
the display text property to display the wc where you want, like
this for the start:

--8<---------------cut here---------------start------------->8---
(defun my-dired-insert-add-wc (beg end)
  (save-excursion
    (goto-char beg)
    (while (< (point) end)
      (condition-case nil
          (when (dired-move-to-filename)
             (<call wc for this file and add text properties here>))
        (error nil))
      (forward-line 1))))

(advice-add 'dired-insert-set-properties
            :after #'my-dired-insert-add-wc)
--8<---------------cut here---------------end--------------->8---

I use something similar to show directory contents in a tooltip in dired
buffers.

The text properties could be attached to a space character somewhere.
You could use the invisible text property like dired-hide-details-mode
to make the wc invisible if you want to hide it.

This advice will probably make dired start quite slowly for larger
directories, so you should handle that case somehow.  Opening all files
in a directory to count their line numbers is rather time consuming,
dunno if it's really a good idea.


Regards,

Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]