From: John Mastro <john.b.mastro@gmail.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Cc: Brendan Leber <brendan@brendanleber.com>
Subject: Re: Extend Dired to Call a Function on a File?
Date: Wed, 12 Oct 2016 14:12:33 -0700 [thread overview]
Message-ID: <CAOj2CQQ2F7cJw4j6Li9bdurrcukg=TiS29AOekTP+8f0kBgdOw@mail.gmail.com> (raw)
In-Reply-To: <CAC77Q0GrDNmV=2bc2VDd+emZy5wsf-YzzdtDx=HiFcXkmnEpWQ@mail.gmail.com>
Brendan Leber <brendan@brendanleber.com> wrote:
> Greetings!
>
> I have a function I've used to work on files that right now I call
> manually with M-x my-shiny-function RET my-shiny.file. This works
> great for the one off file. Yet I usually have to process batches of
> files in a given directory. Being able to add a key binding to dired
> would be awesome as I'm already using dired on the directory to rename
> files and such.
>
> I know enough elisp to add the key binding and write the function, I
> think. The place I'm stuck is getting the file name as the first
> argument to the function when the binding is pressed. Can anyone
> share some pointers to make this happen?
If I understand your question correctly, I think you want something like
this:
(defun my-shiny-dired-command (file)
(interactive (list (dired-filename-at-point)))
(my-shiny-function file))
Or alternatively this, which will work on the files you've marked or, if
there are none, the file at point:
(defun my-shiny-dired-command (files)
(interactive (list (dired-get-marked-files)))
(dolist (file files)
(my-shiny-function file)))
Hope that helps
John
prev parent reply other threads:[~2016-10-12 21:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-12 17:46 Extend Dired to Call a Function on a File? Brendan Leber
2016-10-12 20:12 ` Drew Adams
2016-10-12 20:36 ` Brendan Leber
2016-10-13 0:34 ` Drew Adams
2016-10-13 16:59 ` Brendan Leber
2016-10-12 20:18 ` Stephen Berman
2016-10-12 21:12 ` John Mastro [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOj2CQQ2F7cJw4j6Li9bdurrcukg=TiS29AOekTP+8f0kBgdOw@mail.gmail.com' \
--to=john.b.mastro@gmail.com \
--cc=brendan@brendanleber.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.