diff options
| author | Pierre Neidhardt <ambrevar@gmail.com> | 2018-04-09 14:14:56 +0530 | 
|---|---|---|
| committer | Pierre Neidhardt <ambrevar@gmail.com> | 2018-04-09 23:09:34 +0530 | 
| commit | 33f2d96ba142f30b3953c57b9d51fac274544623 (patch) | |
| tree | db5d9c180842747f5e2a7aa07bc60279192abd7d | |
| parent | 71b8198b29b02263acd7126179c1710351787796 (diff) | |
* lisp/emms-browser.el: Add all tracks in region are with numeric prefix arg
| -rw-r--r-- | lisp/emms-browser.el | 30 | 
1 files changed, 21 insertions, 9 deletions
diff --git a/lisp/emms-browser.el b/lisp/emms-browser.el index 2c23c62..f1c7e32 100644 --- a/lisp/emms-browser.el +++ b/lisp/emms-browser.el @@ -1248,17 +1248,29 @@ Return point. If at level one, return the current point."  ;; User-visible commands  ;; -------------------------------------------------- -(defun emms-browser-add-tracks () -  "Add all tracks at point. -Return the previous point-max before adding." -  (interactive) -  (let ((first-new-track (with-current-emms-playlist (point-max))) -        (bdata (emms-browser-bdata-at-point))) -    (emms-browser-playlist-insert-bdata -     bdata (emms-browser-bdata-level bdata)) -    (next-line) +(defun emms-browser-add-tracks (&optional start end) +  "Add all tracks at point or in region if active. +When the region is not active, a numeric prefix argument inserts that many +tracks from point. +Return the playlist buffer point-max before adding." +  (interactive "r") +  (let ((count (cond +                ((use-region-p) +                 (1+ (- (line-number-at-pos end) (line-number-at-pos start)))) +                ((numberp current-prefix-arg) +                 current-prefix-arg) +                (t 1))) +        (first-new-track (with-current-emms-playlist (point-max)))) +    (when (use-region-p) (goto-char start)) +    (dotimes (_ count first-new-track) +      (let ((bdata (emms-browser-bdata-at-point))) +        (when bdata +          (emms-browser-playlist-insert-bdata +           bdata (emms-browser-bdata-level bdata)) +          (forward-line))))      (run-hook-with-args 'emms-browser-tracks-added-hook                          first-new-track) +    (deactivate-mark)      first-new-track))  (defun emms-browser-add-tracks-and-play ()  | 
