[CM] emacs/snd-scheme: open soundfile from dired

Orm Finnendahl orm.finnendahl at selma.hfmdk-frankfurt.de
Sun Mar 19 12:30:35 PDT 2017


Hi,

 today I implemented an emacs function to open a soundfile from a
dired buffer in an inferior snd instance. If anyone is interested,
here's the code (you need to have dired and inf-snd already set up in
emacs).

Put this into "inf-snd.el":

(defun snd-scheme-open-file (filename)
  "Open file in a running inferior Snd-Scheme process. Start the process if necessary."
  (interactive)
  (if (comint-check-proc inf-snd-scheme-buffer)
      (inf-snd-send-string (format "(open-sound \"%s\")" filename))
    (let ((cmdlist (inf-snd-args-to-list cmd)))
      (setq inf-snd-scheme-program-name "/usr/bin/snd")
      (set-buffer (apply 'make-comint inf-snd-scheme-buffer-name inf-snd-scheme-program-name nil (list filename)))
      (inf-snd-scheme-mode)
      (snd-send-invisible "#f"))))

Put this into your ".emacs.d/init.el":

(defun dired-open-snd-file ()
  "Open the file where point is or the marked files in Dired with inf-snd program."
  (interactive)
  (let* ((file-list
          (dired-get-marked-files)))
    (mapc
     (lambda (file-path)
       (snd-scheme-open-file file-path))
     file-list)))

(define-key dired-mode-map (kbd "C-<return>") 'dired-open-snd-file)

USAGE: Open a directory in emacs' dired-mode. position the cursor on a
soundfile or mark some soundfiles and press C-<return> to open them.


More information about the Cmdist mailing list