unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to call a function on every directory change (in dired)?
@ 2010-09-28 12:34 Marc Mientki
  2010-09-28 12:37 ` Marc Mientki
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Mientki @ 2010-09-28 12:34 UTC (permalink / raw)
  To: help-gnu-emacs

Hello!

I have some problem which I can't solve myself.

My goal is to run one specified function *each time* I enter
a directory in dired-mode. After some investigation I found
seemingly the right hook: dired-after-readin-hook. I defined the
test function foo:

(defun foo ()
   (message "--> huhu"))

and add it to the above hook:

(add-hook 'dired-after-readin-hook 'foo)

Now when I enter first time a directory everything works fine -
I see in minibuffer '--> huhu'. The problem is when I leave the
directory (I do RET on '..', or press '^' - NOT kill buffer) and
enter this directory once again foo will be not called. I think
the reason is that in case of reenter of a directory - which
has already an existing buffer - dired only switch to this buffer
so the dired-after-readin-hook is not affected. But I can't find
no bufer hook that can solve my problem. Some analysis of lisp
code in dired.el (dired-find-file) and files.el (find-file)
brought no success.

Any ideas?

regards
Marc



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

* Re: How to call a function on every directory change (in dired)?
  2010-09-28 12:34 How to call a function on every directory change (in dired)? Marc Mientki
@ 2010-09-28 12:37 ` Marc Mientki
  2010-09-28 12:55   ` Marc Mientki
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Mientki @ 2010-09-28 12:37 UTC (permalink / raw)
  To: help-gnu-emacs

Maybe is defadvice on dired-find-file a solution??

Marc



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

* Re: How to call a function on every directory change (in dired)?
  2010-09-28 12:37 ` Marc Mientki
@ 2010-09-28 12:55   ` Marc Mientki
  2010-09-28 19:04     ` Xah Lee
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Mientki @ 2010-09-28 12:55 UTC (permalink / raw)
  To: help-gnu-emacs

Am 28.09.2010 14:37, schrieb Marc Mientki:
> Maybe is defadvice on dired-find-file a solution??

Yes, I know, I talk to myself. However, this could also be interesting 
to others. So I post my solution:

The advice idea was right! It works:

(defun foo ()
   (message "--> hoho: current directory: %s" (dired-current-directory)))

(defadvice dired-find-file (after foo)
   "Call foo each time on directory entry in dired."
   (foo))

(ad-activate 'dired-find-file)


regards
Marc



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

* Re: How to call a function on every directory change (in dired)?
  2010-09-28 12:55   ` Marc Mientki
@ 2010-09-28 19:04     ` Xah Lee
  2010-09-30  9:01       ` Marc Mientki
  0 siblings, 1 reply; 6+ messages in thread
From: Xah Lee @ 2010-09-28 19:04 UTC (permalink / raw)
  To: help-gnu-emacs

On Sep 28, 5:55 am, Marc Mientki <mien...@nonet.com> wrote:
> Am 28.09.2010 14:37, schrieb Marc Mientki:
>
> > Maybe is defadvice on dired-find-file a solution??
>
> Yes, I know, I talk to myself. However, this could also be interesting
> to others. So I post my solution:
>
> The advice idea was right! It works:
>
> (defun foo ()
>    (message "--> hoho: current directory: %s" (dired-current-directory)))
>
> (defadvice dired-find-file (after foo)
>    "Call foo each time on directory entry in dired."
>    (foo))
>
> (ad-activate 'dired-find-file)
>
> regards
> Marc


Hi Marc Would you be interested To write a guest blog on my website on
this problem. Thanks.

Feel free to contact me privately.

Xah


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

* Re: How to call a function on every directory change (in dired)?
  2010-09-28 19:04     ` Xah Lee
@ 2010-09-30  9:01       ` Marc Mientki
  2010-09-30  9:15         ` Xah Lee
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Mientki @ 2010-09-30  9:01 UTC (permalink / raw)
  To: help-gnu-emacs

Am 28.09.2010 21:04, schrieb Xah Lee:
> On Sep 28, 5:55 am, Marc Mientki<mien...@nonet.com>  wrote:
>> Am 28.09.2010 14:37, schrieb Marc Mientki:
>>
>>> Maybe is defadvice on dired-find-file a solution??
>>
>> Yes, I know, I talk to myself. However, this could also be interesting
>> to others. So I post my solution:
>>
>> The advice idea was right! It works:
>>
>> (defun foo ()
>>     (message "-->  hoho: current directory: %s" (dired-current-directory)))
>>
>> (defadvice dired-find-file (after foo)
>>     "Call foo each time on directory entry in dired."
>>     (foo))
>>
>> (ad-activate 'dired-find-file)
>>
>> regards
>> Marc
>
>
> Hi Marc Would you be interested To write a guest blog on my website on
> this problem. Thanks.

Hello Xah!

Please do not be offended but my answer is no. I completly disagree with 
your Emacs and Lisp criticism and your "Emacs modernisation ideas" so I 
don't want support your Emacs blogs. I don't want to be associated  with 
your point of view of Emacs.

regards
Marc



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

* Re: How to call a function on every directory change (in dired)?
  2010-09-30  9:01       ` Marc Mientki
@ 2010-09-30  9:15         ` Xah Lee
  0 siblings, 0 replies; 6+ messages in thread
From: Xah Lee @ 2010-09-30  9:15 UTC (permalink / raw)
  To: help-gnu-emacs

On Sep 30, 2:01 am, Marc Mientki <mien...@nonet.com> wrote:
> Am 28.09.2010 21:04, schrieb Xah Lee:
>
>
>
>
>
> > On Sep 28, 5:55 am, Marc Mientki<mien...@nonet.com>  wrote:
> >> Am 28.09.2010 14:37, schrieb Marc Mientki:
>
> >>> Maybe is defadvice on dired-find-file a solution??
>
> >> Yes, I know, I talk to myself. However, this could also be interesting
> >> to others. So I post my solution:
>
> >> The advice idea was right! It works:
>
> >> (defun foo ()
> >>     (message "-->  hoho: current directory: %s" (dired-current-directory)))
>
> >> (defadvice dired-find-file (after foo)
> >>     "Call foo each time on directory entry in dired."
> >>     (foo))
>
> >> (ad-activate 'dired-find-file)
>
> >> regards
> >> Marc
>
> > Hi Marc Would you be interested To write a guest blog on my website on
> > this problem. Thanks.
>
> Hello Xah!
>
> Please do not be offended but my answer is no. I completly disagree with
> your Emacs and Lisp criticism and your "Emacs modernisation ideas" so I
> don't want support your Emacs blogs. I don't want to be associated  with
> your point of view of Emacs.

no problem. :)

didn't notice i also posted to gnu.emacs.help. :) must have made a
fool of myself. ☺

 Xah


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

end of thread, other threads:[~2010-09-30  9:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-28 12:34 How to call a function on every directory change (in dired)? Marc Mientki
2010-09-28 12:37 ` Marc Mientki
2010-09-28 12:55   ` Marc Mientki
2010-09-28 19:04     ` Xah Lee
2010-09-30  9:01       ` Marc Mientki
2010-09-30  9:15         ` Xah Lee

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).