aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 04:10:13 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 04:10:13 -0500
commitdc033c75a88102962414c3697654dd8c2fd85a27 (patch)
treefabe33c5059250e3104494dba8b25d1f9791fdf8 /modules
parent556f48a2a0518253015496a618eec9e7a7142dcc (diff)
downloaddotemacs-dc033c75a88102962414c3697654dd8c2fd85a27.tar.gz
dotemacs-dc033c75a88102962414c3697654dd8c2fd85a27.zip
fix(recording): create the selected recording directory, not its parent
The recording toggles took a directory from the prefix-arg prompt (or the default), then ran (file-name-directory location) before make-directory. For a path without a trailing slash that returns the parent, so make-directory created the parent and left the selected directory uncreated — ffmpeg then failed to write into it. Both toggles now route the destination through cj/recording--normalize-recording-dir, which expands and applies file-name-as-directory, then call make-directory on that normalized path. The selected directory itself is created (parents=t is a no-op when it already exists), including names with spaces. Tests cover trailing-slash normalization, idempotence, spaces, and relative-to-absolute expansion.
Diffstat (limited to 'modules')
-rw-r--r--modules/video-audio-recording.el34
1 files changed, 20 insertions, 14 deletions
diff --git a/modules/video-audio-recording.el b/modules/video-audio-recording.el
index b3c4d47b..282fdf85 100644
--- a/modules/video-audio-recording.el
+++ b/modules/video-audio-recording.el
@@ -774,6 +774,14 @@ Respects the user's explicit sink choice from quick-setup."
;;; Toggle Commands (User-Facing)
;;; ============================================================
+(defun cj/recording--normalize-recording-dir (location)
+ "Return LOCATION as an absolute directory path ending in a slash.
+The recording target is always a directory ffmpeg writes a timestamped
+file into, so normalizing here ensures the *selected* directory is the
+one created and recorded into, not its parent (which is what
+`file-name-directory' would yield for a path without a trailing slash)."
+ (file-name-as-directory (expand-file-name location)))
+
(defun cj/video-recording-toggle (arg)
"Toggle video recording: start if not recording, stop if recording.
On first use (or when devices not configured), runs quick setup (C-; r s).
@@ -782,13 +790,12 @@ Otherwise use the default location in `video-recordings-dir'."
(interactive "P")
(if cj/video-recording-ffmpeg-process
(cj/video-recording-stop)
- (let* ((location (if arg
- (read-directory-name "Enter recording location: ")
- video-recordings-dir))
- (directory (file-name-directory location)))
- (unless (file-directory-p directory)
- (make-directory directory t))
- (cj/ffmpeg-record-video location))))
+ (let ((directory (cj/recording--normalize-recording-dir
+ (if arg
+ (read-directory-name "Enter recording location: ")
+ video-recordings-dir))))
+ (make-directory directory t)
+ (cj/ffmpeg-record-video directory))))
(defun cj/audio-recording-toggle (arg)
"Toggle audio recording: start if not recording, stop if recording.
@@ -798,13 +805,12 @@ Otherwise use the default location in `audio-recordings-dir'."
(interactive "P")
(if cj/audio-recording-ffmpeg-process
(cj/audio-recording-stop)
- (let* ((location (if arg
- (read-directory-name "Enter recording location: ")
- audio-recordings-dir))
- (directory (file-name-directory location)))
- (unless (file-directory-p directory)
- (make-directory directory t))
- (cj/ffmpeg-record-audio location))))
+ (let ((directory (cj/recording--normalize-recording-dir
+ (if arg
+ (read-directory-name "Enter recording location: ")
+ audio-recordings-dir))))
+ (make-directory directory t)
+ (cj/ffmpeg-record-audio directory))))
;;; ============================================================
;;; Start Recording