help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: filter from find-dired


From: Drew Adams
Subject: RE: filter from find-dired
Date: Mon, 14 Jan 2013 09:50:21 -0800

> get-directory-name is my function too. Glad to receive suggestions on 
> how to improve it.
> 
> (defun get-directory-name ()
>   "return the current directory"
>   (interactive)
>   (let (dirname components)
>     (if (null (buffer-file-name (current-buffer)))
>         (setq dirname (expand-file-name default-directory))
>       (setq components (butlast (split-string (get-file-name) "/")))
>       (setq dirname (mapconcat 'identity components "/")))
>     (message dirname)
>     (kill-new dirname)
>     dirname))

Not sure what you are trying to do.  You don't show `get-file-name', for one
thing, so your code cannot be evaluated by someone trying to help.

If you are trying to get the (non-)directory component of an absolute file name,
consider using `file-name-(non)directory'.

When you ask for improvement suggestions, I recommend that you start by saying
what your code is intended to do.  Sometimes a completely different
implementation might be suggested, but only if someone can tell what you are
really trying to do.

Looking at just your doc string (which might be inaccurate), it would seem that
all you need is `default-directory'.  That _is_ "the current directory".

If you need that added to the kill buffer, then (kill-new default-directory)
should be adequate.




reply via email to

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