From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: Extend Dired to Call a Function on a File? Date: Wed, 12 Oct 2016 14:12:33 -0700 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1476306823 14113 195.159.176.226 (12 Oct 2016 21:13:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 12 Oct 2016 21:13:43 +0000 (UTC) Cc: Brendan Leber To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 12 23:13:39 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1buQq3-00019c-Nf for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Oct 2016 23:13:23 +0200 Original-Received: from localhost ([::1]:35956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buQq2-0006cj-EB for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Oct 2016 17:13:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buQpe-0006cd-5x for help-gnu-emacs@gnu.org; Wed, 12 Oct 2016 17:12:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buQpc-0007nm-57 for help-gnu-emacs@gnu.org; Wed, 12 Oct 2016 17:12:57 -0400 Original-Received: from mail-yw0-x234.google.com ([2607:f8b0:4002:c05::234]:34120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buQpc-0007nK-1J for help-gnu-emacs@gnu.org; Wed, 12 Oct 2016 17:12:56 -0400 Original-Received: by mail-yw0-x234.google.com with SMTP id w3so40859240ywg.1 for ; Wed, 12 Oct 2016 14:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VPzYvxyI9M94dz0wZEhP5w/p0YH9qyJi5NSzEA/dsvg=; b=xDHKWzAhU9g3KkNjH6+JgBlNUp/VJ/OUZREphH5pQ7ud9eleBrjokuYjznf74q75dC Wj6HcHTdhbucE6d7QQFrQYxEW76Xy7FCGTqwIofFB3m+ZU3XtkggeicUrnnJuEUOs7dG 2XoO/ckZtRrls40Dy6IYzKHqz4Q6Kx9IZiHD/1HtB18nyWub+dAq1RDwkg85omM7yqbm eR4e7gllupvzTumKvFb5vhv5vegL7l1TJy5P0OhyrEkV6VzUaqlclWLF7BdFB4qAbHL7 8PFubSTRcGuBGV+FiocoXry1Ut0q67RHtXtpqSGbkiUVC0e0Ei5l9jtolXV5g4Y5BPrc R/ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VPzYvxyI9M94dz0wZEhP5w/p0YH9qyJi5NSzEA/dsvg=; b=J8lskbC/o55whmeRpx5M0aedw9421VuhhEmLp98Ae7GWXqa/vD+1tLe6gNwqA2s2sK qgImRgK4siFctz7YjY6Lbaseg+DPHksxdiGTyyAIKgCAFOOW7spgHIKf+3pIGNFlaqbU eIxCqtJ73mfuwXhpF5BdxSiJ05QQg+/ITfkVHl/n10s414QDESbf8gl6HeolypxeC1xn N4svBBKA8culuz1yZkMrHQ4EbRWJWoCHn++5StonMOPwRXOwfCInPMHjbwcqUJdw3ENC X7rxNSXBHC9J/Q3SkYu8hGbQXlwH7OZF4K2fyd2NoJ3k3t9mXNdeg6tRv2eKrXtOWDWQ +WWg== X-Gm-Message-State: AA6/9RlfZw91p5W/nCplvjnxfuFhQiUCCmr+H6YIdRd81PcX/rZQBk+FOetFhu5q5L+ZPmF1M9aKLQXNvu00oQ== X-Received: by 10.129.49.129 with SMTP id x123mr2896617ywx.223.1476306774127; Wed, 12 Oct 2016 14:12:54 -0700 (PDT) Original-Received: by 10.37.17.202 with HTTP; Wed, 12 Oct 2016 14:12:33 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c05::234 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111517 Archived-At: Brendan Leber 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