-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,844 additions
and
1,787 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,6 @@ flycheck_*.el | |
#in development | ||
csound-interaction.el | ||
releases | ||
|
||
#clj | ||
.nrepl-port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
;; Copyright (C) 2017 Hlöðver Sigurðsson | ||
|
||
;; Author: Hlöðver Sigurðsson <[email protected]> | ||
;; Version: 0.2.0 | ||
;; Package-Requires: ((emacs "25") (shut-up "0.3.2") (multi "2.0.1")) | ||
;; Version: 0.2.1 | ||
;; Package-Requires: ((emacs "25") (shut-up "0.3.2") (multi "2.0.1") (highlight "0")) | ||
;; URL: https://github.com/hlolli/csound-mode | ||
|
||
;; This program is free software; you can redistribute it and/or modify | ||
|
@@ -28,6 +28,7 @@ | |
|
||
(require 'csound-opcodes) | ||
(require 'csound-util) | ||
(require 'cl-lib) | ||
|
||
(defun csound-eldoc-get-template (opcode-list) | ||
(let ((templ nil) | ||
|
@@ -55,13 +56,11 @@ | |
(line-beginning-position countback) | ||
(csound-util-line-boundry))))) | ||
|
||
|
||
(defun csound-eldoc-statement-list (string-statement) | ||
(split-string | ||
(csound-util-untab (csound-util-chomp string-statement)) | ||
"\\(,+\s*\\)+\\|\\(\s+,*\\)+")) | ||
|
||
|
||
(defun csound-eldoc-template-lookup (statement-list) | ||
(let ((result nil) | ||
(opdoce nil) | ||
|
@@ -80,11 +79,11 @@ | |
(save-excursion (progn (setq cand (thing-at-point 'symbol (search-backward-regexp "(" (line-beginning-position) t 1))) | ||
(when (= 1 (length cand)) | ||
(setq rate-cand cand)) | ||
(while (or (and (not cand) | ||
(while (or (and (not cand) | ||
(not (eq (point) (line-beginning-position)))) | ||
(= 1 (length cand))) | ||
(setq cand (thing-at-point 'symbol)) | ||
(backward-char)) | ||
(backward-char)) | ||
(when (gethash cand csdoc-opcode-database) | ||
(setq result (csound-eldoc-get-template | ||
(gethash cand csdoc-opcode-database)) | ||
|
@@ -148,8 +147,8 @@ | |
|
||
;;;###autoload | ||
(defun csound-eldoc-function () | ||
"Returns a doc string appropriate for the current context, or nil." | ||
(let* ((csound-statement (csound-eldoc-statement)) | ||
"Returns a doc string appropriate for the current context, or nil." | ||
(let* ((csound-statement (csound-eldoc-statement)) | ||
(statement-list (csound-eldoc-statement-list csound-statement)) | ||
(template-lookup (csound-eldoc-template-lookup statement-list))) | ||
(when template-lookup | ||
|
@@ -160,11 +159,11 @@ | |
(replace-regexp-in-string | ||
"\\[, " "[" | ||
(nth 1 template-lookup)))) | ||
(template-list (csound-eldoc-statement-list csound-template)) | ||
(template-list (csound-eldoc-statement-list csound-template)) | ||
(template-list-length (1- (length template-list))) | ||
(opcode-index (csound-eldoc-opcode-index opcode-match template-list)) | ||
(template-list (if (nth 2 template-lookup) | ||
(subseq template-list opcode-index) | ||
(cl-subseq template-list opcode-index) | ||
template-list)) | ||
(argument-index (csound-eldoc-argument-index opcode-match opcode-index point-on-opcode?)) | ||
(infinite-args? (string= "[...]" (car (last template-list)))) | ||
|
@@ -173,7 +172,7 @@ | |
(eldocstr "") | ||
(inf-arg nil)) | ||
(dolist (arg template-list) | ||
(setq | ||
(setq | ||
inf-arg (if (and infinite-args? | ||
(< template-list-length argument-index)) | ||
t nil) | ||
|
@@ -203,7 +202,7 @@ | |
(if (> 0 indx) | ||
(1- indx) | ||
(1+ indx)))) | ||
list-index (1+ list-index))) | ||
list-index (1+ list-index))) | ||
eldocstr)))) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
;; Copyright (C) 2017 Hlöðver Sigurðsson | ||
|
||
;; Author: Hlöðver Sigurðsson <[email protected]> | ||
;; Version: 0.2.0 | ||
;; Package-Requires: ((emacs "25") (shut-up "0.3.2") (multi "2.0.1")) | ||
;; Version: 0.2.1 | ||
;; Package-Requires: ((emacs "25") (shut-up "0.3.2") (multi "2.0.1") (highlight "0")) | ||
;; URL: https://github.com/hlolli/csound-mode | ||
|
||
;; This program is free software; you can redistribute it and/or modify | ||
|
@@ -31,20 +31,21 @@ | |
|
||
(defvar csound-font-lock--missing-faces '()) | ||
|
||
(defcustom csound-font-lock-rainbow-score-parameters-p t | ||
(defcustom csound-font-lock-rainbow-score-parameters-p nil | ||
"Color each parameter field for | ||
not events within CsScore/.sco" | ||
:type 'boolean | ||
:group 'csound-mode-font-lock) | ||
|
||
(defface csound-font-lock-eval-flash | ||
'((((class color)) (:background "#0AD600" :foreground "white" :bold t)) | ||
'((((class color) (background light)) (:foreground "#999601" :background "#42ff42")) | ||
(((class color) (background dark)) (:background "#637863" :foreground "#00e4f0")) | ||
(t (:inverse-video t))) | ||
"Face for highlighting during evaluation." | ||
:group 'csound-mode-font-lock) | ||
|
||
(defface csound-font-lock-eval-flash-error | ||
'((((class color)) (:foreground "#D60000" :bold t)) | ||
'((((class color)) (:foreground "#5e0d0d" :bold t)) | ||
(t (:inverse-video t))) | ||
"Face for highlighting signaled errors during evaluation." | ||
:group 'csound-mode-font-lock) | ||
|
@@ -162,14 +163,15 @@ | |
csound-font-lock-strings | ||
csound-font-lock-xml-tags)) | ||
|
||
;;;###autoload | ||
(defvar csound-font-lock-list '()) | ||
|
||
(defconst csound-font-lock-keywords | ||
(ignore-errors | ||
(eval-when-compile | ||
;; Regex for i-rates | ||
(push '("\\<i+\\w*" . csound-font-lock-i-rate) csound-font-lock-list) | ||
|
||
;; Regex for global i-rates | ||
(push '("\\<\\(gi\\)+\\w*" . csound-font-lock-global-i-rate) csound-font-lock-list) | ||
|
||
|
@@ -209,7 +211,7 @@ | |
;; Regex for csound macros types | ||
(push '("\\#\\w*\\|\\$\\w*" . csound-font-lock-macros) csound-font-lock-list) | ||
|
||
;; Regex for csound string types (use syntactic fontification?) | ||
;; Regex for csound string types (use syntactic fontification?) | ||
;; (push '("\\s\"\\(.*?\\)[^\\]\\s\"" . csound-font-lock-strings) csound-font-lock-list) | ||
|
||
;; Regex for core csound xml tags | ||
|
@@ -268,16 +270,11 @@ | |
"-face"))) | ||
|
||
(defun csound-font-lock--fontify-score (beg end) | ||
(let ((backward-search-limit (if (string-match-p ".sco$" (buffer-name (current-buffer))) | ||
0 | ||
(save-excursion | ||
(end-of-buffer) | ||
(or (search-backward "<CsScore" nil t 1) 0)))) | ||
;; (score-end-line-num (or (search-forward "</CsScore" nil t 1) (line-number-at-pos (point-max)))) | ||
(beg-line-num (line-number-at-pos beg)) | ||
(end-line-num (1+ (line-number-at-pos end)))) | ||
(let ((beg-line-num (line-number-at-pos beg)) | ||
(end-line-num (min (line-number-at-pos (max-char)) | ||
(+ 2 (line-number-at-pos end))))) | ||
(save-excursion | ||
(goto-line beg-line-num) | ||
(beginning-of-line) | ||
(while (< (line-number-at-pos) end-line-num) | ||
(let* ((beg-word nil) | ||
(end-word nil) | ||
|
@@ -306,61 +303,60 @@ | |
(setq depth (1+ depth))) | ||
;; If passed i marker | ||
(progn | ||
;; (message "line: %d" (line-number-at-pos)) | ||
(setq beg-word (min (1- (or (save-excursion (search-forward-regexp "[-?0-9a-zA-Z\\[\\.\\+\\<\\>\"]" (line-end-position) t 1)) | ||
(setq beg-word (min (1- (or (save-excursion (search-forward-regexp "[-?0-9a-zA-Z\\[\\.\\+\\<\\>\"]" (line-end-position) t 1)) | ||
(line-end-position)))) | ||
end-word (save-excursion | ||
(goto-char beg-word) | ||
(let ((e (search-forward-regexp "\\s-\\|$" (line-end-position)))) | ||
(if (< e end-line) | ||
e end-line)))) | ||
;; (message "beg: %d end: %d" beg-word end-word) | ||
(goto-char end-word) | ||
;; (add-text-properties beg-word end-word `(face ,(funcall #'csound-font-lock-param-delimiters-default-pick-face depth))) | ||
(font-lock-prepend-text-property beg-word end-word 'face (funcall #'csound-font-lock-param-delimiters-default-pick-face depth)) | ||
(setq depth (1+ depth))))))) | ||
(next-line))))) | ||
(forward-line))))) | ||
|
||
(defun csound-font-lock-fontify-region (beg end &optional loud) | ||
(shut-up | ||
(save-excursion | ||
(let ((within-score-p (or (save-excursion (search-backward "<CsScore" nil t 1)) | ||
(string-match-p ".sco$" (buffer-name (current-buffer))))) | ||
(score-boundry (if (string-match-p ".sco$" (buffer-name (current-buffer))) | ||
0 | ||
(or (save-excursion (beginning-of-buffer) | ||
(search-forward-regexp "<CsScore" end t 1)) | ||
0))) | ||
(orchestra-boundry (if (or (string-match-p ".orc$" (buffer-name (current-buffer))) | ||
(string-match-p ".udo$" (buffer-name (current-buffer)))) | ||
(buffer-size) | ||
(or (save-excursion (beginning-of-buffer) | ||
(search-forward-regexp "</CsInstruments>" end t 1)) | ||
(buffer-size))))) | ||
(if (and within-score-p csound-font-lock-rainbow-score-parameters-p) | ||
(csound-font-lock--fontify-score (max score-boundry beg) end) | ||
;; All normal font-lock calls | ||
(let ((end-line (line-number-at-pos (min end orchestra-boundry)))) | ||
(goto-char beg) | ||
(beginning-of-line) | ||
(while (< (line-number-at-pos) (1+ end-line)) | ||
(save-excursion | ||
(font-lock-default-fontify-region (line-beginning-position) (line-end-position) nil)) | ||
(next-line)))))))) | ||
(save-excursion | ||
(let ((within-score-p (or (save-excursion (search-backward "<CsScore" nil t 1)) | ||
(string-match-p ".sco$" (buffer-name (current-buffer))))) | ||
(score-boundry (if (string-match-p ".sco$" (buffer-name (current-buffer))) | ||
(max-char) | ||
(or (save-excursion (goto-char (point-min)) | ||
(search-forward-regexp "<CsScore" nil t 1)) | ||
nil))) | ||
(orchestra-boundry (if (or (string-match-p ".orc$" (buffer-name (current-buffer))) | ||
(string-match-p ".udo$" (buffer-name (current-buffer)))) | ||
(buffer-size) | ||
(or (save-excursion (goto-char (point-min)) | ||
(search-forward-regexp "</CsInstruments>" end t 1)) | ||
(buffer-size))))) | ||
(if (and within-score-p score-boundry csound-font-lock-rainbow-score-parameters-p) | ||
(csound-font-lock--fontify-score (max score-boundry beg) (min end (max-char))) | ||
;; All normal font-lock calls, but let's keep rainbow delimited fonts untouched | ||
(let ((end-line (1- (line-number-at-pos (min end (point-max))))) | ||
(end-line (if (and score-boundry csound-font-lock-rainbow-score-parameters-p) | ||
(line-number-at-pos score-boundry) | ||
end-line))) | ||
(goto-char beg) | ||
(beginning-of-line) | ||
(while (< (line-number-at-pos) (1+ end-line)) | ||
(save-excursion | ||
(font-lock-default-fontify-region (line-beginning-position) (line-end-position) nil)) | ||
(forward-line))))))) | ||
|
||
(defun csound-font-lock--flush-buffer () | ||
(save-excursion | ||
(end-of-buffer) | ||
(goto-char (point-max)) | ||
(let ((line-count (line-number-at-pos))) | ||
(beginning-of-buffer) | ||
(goto-char (point-min)) | ||
(while (< (line-number-at-pos) line-count) | ||
(save-excursion (font-lock-default-fontify-region (line-beginning-position) (line-end-position) nil)) | ||
(next-line))))) | ||
(forward-line))))) | ||
|
||
(defun csound-font-lock--flush-score () | ||
(when csound-font-lock-rainbow-score-parameters-p | ||
(save-excursion | ||
(beginning-of-buffer) | ||
(goto-char (point-min)) | ||
(let ((score-beg (if (string-match-p ".sco$" (buffer-name (current-buffer))) | ||
0 | ||
(save-excursion (search-forward "<CsScore" nil t 1)))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
;; Copyright (C) 2017 Hlöðver Sigurðsson | ||
|
||
;; Author: Hlöðver Sigurðsson <[email protected]> | ||
;; Version: 0.2.0 | ||
;; Package-Requires: ((emacs "25") (shut-up "0.3.2") (multi "2.0.1")) | ||
;; Version: 0.2.1 | ||
;; Package-Requires: ((emacs "25") (shut-up "0.3.2") (multi "2.0.1") (highlight "0")) | ||
;; URL: https://github.com/hlolli/csound-mode | ||
|
||
;; This program is free software; you can redistribute it and/or modify | ||
|
@@ -247,7 +247,7 @@ | |
(defun csound-indentation--for-each-line (start end fn) | ||
(while (< (point) end) | ||
(funcall fn) | ||
(next-line))) | ||
(forward-line))) | ||
|
||
(defun csound-indentation-line () | ||
"Indent current line." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
;; Copyright (C) 2017 Hlöðver Sigurðsson | ||
|
||
;; Author: Hlöðver Sigurðsson <[email protected]> | ||
;; Version: 0.2.0 | ||
;; Package-Requires: ((emacs "25") (shut-up "0.3.2") (multi "2.0.1")) | ||
;; Version: 0.2.1 | ||
;; Package-Requires: ((emacs "25") (shut-up "0.3.2") (multi "2.0.1") (highlight "0")) | ||
;; URL: https://github.com/hlolli/csound-mode | ||
|
||
;; This program is free software; you can redistribute it and/or modify | ||
|
@@ -29,7 +29,7 @@ | |
|
||
|
||
(require 'font-lock) | ||
(require 'cl) | ||
(require 'cl-lib) | ||
(require 'csound-eldoc) | ||
(require 'csound-font-lock) | ||
(require 'csound-repl) | ||
|
@@ -106,9 +106,9 @@ | |
(if (and csound-repl-start-server-p | ||
(not (executable-find "csound"))) | ||
(error "Csound is not installed on your computer") | ||
(csound-repl--buffer-create)) | ||
(csound-repl--buffer-create))) | ||
|
||
(defvar csound-mode-map nil)) | ||
(defvar csound-mode-map nil) | ||
|
||
(setq csound-mode-map | ||
(let ((map (make-sparse-keymap))) | ||
|
Oops, something went wrong.