From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Execute lisp function on marked files
Date: Thu, 11 Nov 2004 11:38:42 -0700 [thread overview]
Message-ID: <2vhpttF2lvli5U1@uni-berlin.de> (raw)
In-Reply-To: <1c6c2df9.0411110449.510132ee@posting.google.com>
Barney Dalton wrote:
> This seems to do the trick, but I can't believe it doesn't already
> exist. Comments on how to improve it would be welcomed.
>
> (defun dired-lisp-function (the-function)
> ;; Return nil for success, offending file name else.
> (let ((file (dired-get-filename)) failure)
> (condition-case err
> (funcall the-function file)
> (error (setq failure err)))
> (if (not failure)
> nil
> (dired-log "%s error for %s:\n%s\n" (symbol-name 'the-function)
> file failure)
> (dired-make-relative file))))
>
>
> (defun dired-do-lisp-function (the-function &optional arg)
> "Call THE-FUNCTION on each marked (or next ARG)
> files. THE-FUNCTION should take one argument (the filename)"
> (interactive "aFunction to apply to marked files : \nP")
> (dired-map-over-marks-check
> (function (lambda () (dired-lisp-function the-function)))
> arg
> (symbol-value 'the-function) t))
I think I would call them dired-funcall and dired-do-funcall, just name
the argument FUNCTION, make the doc string adhere to convention, and
simplify
the call to dired-map-over-marks-check:
(defun dired-funcall (function)
;; Return nil for success, offending file name else.
(let ((file (dired-get-filename)) failure)
(condition-case err
(funcall function file)
(error (setq failure err)))
(if (not failure)
nil
(dired-log "%s error for %s:\n%s\n" function file failure)
(dired-make-relative file))))
(defun dired-do-funcall (function &optional arg)
"Call FUNCTION on each marked (or next ARG) files.
FUNCTION should take one argument (the filename)."
(interactive "aFunction to call on each marked file: \nP")
(dired-map-over-marks-check (function dired-funcall) arg function t))
You might also consider restricting it to commands, which are a much
smaller set of functions that the user is more likely to be familiar
with:
(interactive "CCommand ...")
--
Kevin Rodgers
prev parent reply other threads:[~2004-11-11 18:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-10 15:35 Execute lisp function on marked files Barney Dalton
2004-11-10 19:02 ` Kevin Rodgers
2004-11-11 12:49 ` Barney Dalton
2004-11-11 18:38 ` Kevin Rodgers [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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2vhpttF2lvli5U1@uni-berlin.de \
--to=ihs_4664@yahoo.com \
/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.
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).