Elisp: Get Dired Marked Files

By Xah Lee. Date: . Last updated: .

To get marked files in dired, use dired-get-marked-files

Then, you can map a function to all the files.

;; apply a function to dired's marked files

(require 'dired)

(defun xah-open-dired-marked ()
  "Open marked files in dired."
  (interactive)
  (mapc 'find-file (dired-get-marked-files))
)

;; test
;; M-x dired, then mark some files, then M-x xah-open-dired-marked

;; replace find-file to your own function

Emacs Lisp Basics

  1. Elisp Basics
  2. ELisp Text-Processing Overview
  3. Elisp Examples
  4. Evaluate Elisp Code
  5. Doc Lookup
  6. Search Doc
  7. How to Edit Lisp Code

Basic Functions

  1. Cursor
  2. Text Editing
  3. String Functions
  4. Buffer
  5. Read/Write File
  6. File/Dir Path

Writing Command

  1. Writing Command Basics
  2. Mark and Region
  3. Get Buffer String
  4. Work with Lines
  5. Copy Cut Paste kill-ring
  6. Get User Input
  7. Interactive Form
  8. Get universal-argument
  9. Find Replace Text
  10. thing-at-point
  11. Get Dired Marked Files

Writing Scritpt

  1. Run Elisp Script in Shell
  2. Get Command Line Args
  3. Read File
  4. Read File Content as List
  5. Write File
  6. Print, Output
  7. Format String
  8. Walk Dir
  9. Call Shell Command
  10. Get Script Name at Run Time

Lisp Data Structure

  1. List
  2. Vector
  3. Sequence: List, Array
  4. Sequence Functions
  5. Map List/Vector
  6. Exit Loop/Function
  7. Association List
  8. Property List
  9. Symbol Property List
  10. Hash Table

Lisp Symbol

  1. Lisp Symbol
  2. Lisp Special Form
  3. What's Function
  4. Is X Defined?

Elisp Misc

  1. Print Date Time
  2. Parse Date Time
  3. ƒ opt parameters
  4. Regex in Elisp
  5. Docstring Markup
  6. Unicode Escape

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs

Emacs

Emacs Lisp

Misc