Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: repl-electric/sonic-pi.el
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 621ec0084af7f4cd4cb721ba9fb8e0284571053c
Choose a base ref
..
head repository: repl-electric/sonic-pi.el
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f737bcd671457c3967907692da494f2e23b3a029
Choose a head ref
Showing with 16 additions and 15 deletions.
  1. +16 −15 sonic-pi-osc.el
31 changes: 16 additions & 15 deletions sonic-pi-osc.el
Original file line number Diff line number Diff line change
@@ -91,36 +91,37 @@
(hlt-highlight-regexp-region nil nil ".+" 'eval-sonic-pi-flash nil)
(run-at-time flash-time nil 'hlt-unhighlight-region))

(defun sonic-pi--send (region)
"Helper function to send and highlighting region."
(cl-destructuring-bind (start end) region
(sonic-pi-osc-send-text start end)
(hlt-highlight-regexp-region start end ".+" 'eval-sonic-pi-flash nil))
(run-at-time flash-time nil 'hlt-unhighlight-region nil nil nil))

(defun sonic-pi-send-live-loop ()
"send a live-loop to sonic via osc"
(interactive)
(save-excursion
(let ((s (re-search-backward "^\\(live_loop\\|with_fx\\)")))
(ruby-end-of-block)
(end-of-line)
(sonic-pi-osc-send-text s (point))
(hlt-highlight-regexp-region s (point) ".+" 'eval-sonic-pi-flash nil))
(run-at-time flash-time nil 'hlt-unhighlight-region nil nil nil)))
(sonic-pi--send (sonic-pi--live-loop-region)))

(defun sonic-pi-send-dwim ()
"Send in a do wait I mean style.
If region is active, send it.
Then if there is an enclosing `live_loop' or `with_fx' sent it.
Otherwise send current line."
(interactive)
(cl-destructuring-bind (start end) (sonic-pi--dwim-region)
(message "Sending:\n%s" (buffer-substring start end))
(sonic-pi-osc-send-text start end)
(hlt-highlight-regexp-region start end ".+" 'eval-sonic-pi-flash nil))
(run-at-time flash-time nil 'hlt-unhighlight-region nil nil nil))
(sonic-pi--send (sonic-pi--dwim-region)))

(defun sonic-pi--dwim-region ()
"Find region for dwim command."
(if (region-active-p)
(list (region-beginning) (region-end))
(if-let (start (save-excursion (re-search-backward "^\\(live_loop\\|with_fx\\)" nil t)))
(list start (save-excursion (ruby-end-of-block) (line-end-position)))
(list (line-beginning-position) (line-end-position)))))
(or (sonic-pi--live-loop-region)
(list (line-beginning-position) (line-end-position)))))

(defun sonic-pi--live-loop-region ()
"Find region with `live_loop' or `with_fx'."
(when-let (start (save-excursion (re-search-backward "^\\(live_loop\\|with_fx\\)" nil t)))
(list start (save-excursion (ruby-end-of-block) (line-end-position)))))

(defun sonic-pi-osc-make-client (host port)
(make-network-process