Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csound-score-align-block #26

Open
ghost opened this issue May 29, 2023 · 6 comments
Open

csound-score-align-block #26

ghost opened this issue May 29, 2023 · 6 comments

Comments

@ghost
Copy link

ghost commented May 29, 2023

hi! i am having problems with it when using characters like ^ or >
e.g.

i1 0 2.5
i1 + .
i1 ^ .

will output;

i1 0 2.5
i1 + .
i1 .

Emacs 27.1
csound-mode 0.2.9

@hlolli
Copy link
Owner

hlolli commented May 29, 2023

Weird, I can say off the bat that this isn't happening for me. But is it happening as you are typing or when you are saving?

@hlolli
Copy link
Owner

hlolli commented May 29, 2023

ahh you are calling the function align-block, gotcha! Let me try agian!

@hlolli
Copy link
Owner

hlolli commented May 29, 2023

yes I can reproduce, thanks, I'll fix it now

@luqtas
Copy link

luqtas commented Nov 26, 2023

so, i'm using this till the fix (sorry i don't understand much about Emacs to fix myself your code);

(defun aling (BEG END)
   (interactive "r")
   (align-regexp BEG END "\\(\\s-*\\)\\s-+" 1 1 t))
(defun csound-score-aling ()
   (interactive)
   (just-one-space) ; (tab-to-tab-stop)
   (point-to-register 0)
   (mark-paragraph)
   (call-interactively 'aling)
   (jump-to-register 0))

(define-key csound-mode-map (kbd "SPC") 'csound-score-aling)
(define-key csound-mode-map (kbd "S-SPC") 'just-one-space)

beware that it aligns everything at cursor's paragraph... ((undo)) can do its job in case you screw! and Shift + SPC for the normal behaviour

@luqtas
Copy link

luqtas commented Nov 26, 2023

by the way, can the score-align tool quantify the + or ^ sings?
e.g.

i1 0 3
i. + .

after the score-align

i1 0 3
i. 3 .

@sohet
Copy link
Contributor

sohet commented Aug 19, 2024

A bit more sophisticated version of Iuqtas's aling. Original csound-score--align-cols in csound-score.el can be replaced with it.

(defun csound-score--align-cols (start end)
  (save-excursion
    (save-restriction
      (narrow-to-region (point-min) end)
      (while (progn (goto-char start)
                    (re-search-forward "^\\s-*\\([^;\n]*?[^;\n\0]\\)\\(\\s-+\\|$\\)" nil t))
        (replace-match "\\1\0"))
      (align-regexp start (point-max) "\\(\\)\0" 1 1 t)
      (while (re-search-forward "\0\\| +\0$" nil t)
        (replace-match ""))
      (align-regexp start (point-max) "^[^;]*\\( +\\);" 1 1 t))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants