unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* dired-hide-details-mode, how to customize?
@ 2015-06-24 19:53 jenia.ivlev
  2015-06-24 20:55 ` Michael Heerdegen
  0 siblings, 1 reply; 5+ messages in thread
From: jenia.ivlev @ 2015-06-24 19:53 UTC (permalink / raw)
  To: emacs-devel

Hello.

I want to customize the dired-hide-details-mode.

Or, more precisely, to customize the columns that appear when this mode
is disabled. For example, to add a column that shows the `wc -l` for
each file and so on.

Maybe someone knows where is the definition of what will appear, in
the columns in dired, when you do `M-x dired-hide-details-mode`? 

For now, I discovered that when I call `M-: (remove-from-invisibility-spec
'dired-hide-details-detail)`, the columns in dired mode appear.

But I can't find the definition of `dired-hide-details-detail`.
Can someone tell me, where can I find it?


Thanks very much in advance for your kind help.
Jenia




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: dired-hide-details-mode, how to customize?
  2015-06-24 19:53 dired-hide-details-mode, how to customize? jenia.ivlev
@ 2015-06-24 20:55 ` Michael Heerdegen
  2015-06-24 22:22   ` jenia.ivlev
  2015-06-24 23:00   ` jenia.ivlev
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Heerdegen @ 2015-06-24 20:55 UTC (permalink / raw)
  To: emacs-devel

Hi jenia.ivlev

> I want to customize the dired-hide-details-mode.
>
> Or, more precisely, to customize the columns that appear when this mode
> is disabled. For example, to add a column that shows the `wc -l` for
> each file and so on.
>
> Maybe someone knows where is the definition of what will appear, in
> the columns in dired, when you do `M-x dired-hide-details-mode`?

dired is more or less just an ls output with some font locking and text
properties added.  What you call columns does not exist as such in the
code.  See `dired-insert-directory' and `dired-insert-set-properties'
how that works internally.

You are a bit luckier if you use ls-lisp.el, this makes things a bit
more configurable because it implements `insert-directory' in Elisp.

But you won't get lucky with what you want to do.  If you change the
contents of the dired buffer, this will probably break the rest of the
mode.  Parts of the code assume that the contents look like normal ls
output.  You would have to reduplicate large amounts of dired's defuns
to change that..

> But I can't find the definition of `dired-hide-details-detail`.
> Can someone tell me, where can I find it?

That's just a symbol (without any kind of definition) used as a flag.


HTH,

Michael.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: dired-hide-details-mode, how to customize?
  2015-06-24 20:55 ` Michael Heerdegen
@ 2015-06-24 22:22   ` jenia.ivlev
  2015-06-24 23:00   ` jenia.ivlev
  1 sibling, 0 replies; 5+ messages in thread
From: jenia.ivlev @ 2015-06-24 22:22 UTC (permalink / raw)
  To: emacs-devel

Thanks very much!!





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: dired-hide-details-mode, how to customize?
  2015-06-24 20:55 ` Michael Heerdegen
  2015-06-24 22:22   ` jenia.ivlev
@ 2015-06-24 23:00   ` jenia.ivlev
  2015-06-24 23:55     ` Michael Heerdegen
  1 sibling, 1 reply; 5+ messages in thread
From: jenia.ivlev @ 2015-06-24 23:00 UTC (permalink / raw)
  To: emacs-devel

Thanks again for your reply. 

I placed `(required 'ls-lisp)` in my config
file, and added `(setq ls-lisp-use-insert-directory-program nil)` too.

I can see that function being is executed `ls-lisp-insert-directory`, 
instead of the `ls` GNU program, by setting a break on it and opening a
dired buffer.

But, in so far as my original goal - to write the # of lines in each
file when dired-hide-details-mode is disabled - how do you suggest I go
about doing that?

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?

Thanks
Jenia





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: dired-hide-details-mode, how to customize?
  2015-06-24 23:00   ` jenia.ivlev
@ 2015-06-24 23:55     ` Michael Heerdegen
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Heerdegen @ 2015-06-24 23:55 UTC (permalink / raw)
  To: emacs-devel

jenia.ivlev@gmail.com (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.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-24 23:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-24 19:53 dired-hide-details-mode, how to customize? jenia.ivlev
2015-06-24 20:55 ` Michael Heerdegen
2015-06-24 22:22   ` jenia.ivlev
2015-06-24 23:00   ` jenia.ivlev
2015-06-24 23:55     ` Michael Heerdegen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).