0

Does Emacs have 'macro variables'?

Midnight Commander allows the use of macro substitution expressions like %f %D %t which can be use when running commands. eg %f is the name of the current file in a directory, %t refers to currently tagged files.

I'm sure Emacs has such a feature, but haven't figure it out yet...

Suppose I mark a number files and want to perform some command on all them, how would I go about doing that?

1
  • Please split your question in two. The question of the last paragraph seems separate from what comes before it.
    – Drew
    Commented Nov 12, 2023 at 20:10

1 Answer 1

0

You should split your question in two. If you do, I'll move this answer to your post for your second question, "Suppose I mark a number files and want to perform some command on all them, how would I go about doing that?"

If you use Dired+ (dired+.el) then you have these commands:

  • diredp-do-aggregate-apply-to-marked

    Aggregate results of applying a function to the marked files and dirs. This command prompts you for the aggregate function, AGGREGATE-FUN. Then it calls diredp-do-apply-to-marked, which prompts you for a function to apply to the name of each marked file or dir.

  • diredp-do-aggregate-eval-in-marked

    Aggregate results of evaluating a sexp in the marked files and dirs. This command prompts you for the aggregate function, AGGREGATE-FUN. Then it calls diredp-do-eval-in-marked, which prompts you for a Lisp sexp to evaluate in each marked file or dir.

  • diredp-do-apply/eval-marked

    Apply a function to the marked files, or evaluate a sexp in them. Return a list of the results. You are prompted for the function or sexp.

  • diredp-do-apply/eval-marked-recursive

    Apply a function to marked files, or evaluate a sexp in them. Like diredp-do-apply/eval-marked but act recursively on subdirs, and do no result-logging, error-logging or echoing. The files acted on are those that are marked in the current Dired buffer, or all files in the directory if none are marked. Marked subdirectories are handled recursively in the same way.

  • diredp-do-apply-to-marked

    Apply FUNCTION to the absolute name of each marked file. Return a list of the results. You are prompted for FUNCTION.

  • diredp-do-apply-to-marked-recursive

    Apply FUNCTION to names of marked files, including in marked subdirs. The absolute file name is passed to FUNCTION. Like diredp-do-apply-to-marked but act recursively on subdirs, and do no result-logging, error-logging, or echoing. The files included are those that are marked in the current Dired buffer, or all files in the directory if none are marked. Marked subdirectories are handled recursively in the same way.

  • diredp-do-eval-in-marked

    Evaluate an Emacs-Lisp SEXP in each marked file. Visit each marked file at its beginning, then evaluate SEXP. Return a list of the results. You are prompted for the SEXP.

  • diredp-do-eval-in-marked-recursive

    Evaluate SEXP in each of the marked files, including in marked subdirs. Like diredp-do-eval-in-marked but act recursively on subdirs, and do no result-logging, error-logging, or echoing. The files included are those that are marked in the current Dired buffer, or all files in the directory if none are marked. Marked subdirectories are handled recursively in the same way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.