Skip to content

Commit

Permalink
bugfix release 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hlolli committed Oct 5, 2019
1 parent f4bc923 commit 389be23
Show file tree
Hide file tree
Showing 12 changed files with 1,844 additions and 1,787 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ flycheck_*.el
#in development
csound-interaction.el
releases

#clj
.nrepl-port
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [0.2.1]
### Minor Changes
- bytecode compilation errors fixed
- non-rainbow score syntax highlight improved
- minidocs and syopsis updated
- requiring highligh for missing hlt-highlight symbols
- new flash colors

## [0.2.0]
### Major Changes
- Csound API Removed in favour of UDP (requires Csound 6.10+)
Expand All @@ -10,7 +18,7 @@
- Repl: +/. in p2 score snippets supported
- Repl: + in p3 score snippet supported
- Score: `csound-score--align-cols` improved to decrease col width as well
- Indentation: `csound-indentation-aggressive-score` customizeable variable added
- Indentation: `csound-indentation-aggressive-score` customizeable variable added
- Font-lock: Bug causing slower font-locking fixed
- Keybinding `C-c C-c` added for region evaluation
- Repl: Newline in the prompt supported via <Ctrl-Return>
Expand Down
23 changes: 11 additions & 12 deletions csound-eldoc.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,6 +28,7 @@

(require 'csound-opcodes)
(require 'csound-util)
(require 'cl-lib)

(defun csound-eldoc-get-template (opcode-list)
(let ((templ nil)
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand All @@ -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))))
Expand All @@ -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)
Expand Down Expand Up @@ -203,7 +202,7 @@
(if (> 0 indx)
(1- indx)
(1+ indx))))
list-index (1+ list-index)))
list-index (1+ list-index)))
eldocstr))))


Expand Down
96 changes: 46 additions & 50 deletions csound-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))))
Expand Down
6 changes: 3 additions & 3 deletions csound-indentation.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down
10 changes: 5 additions & 5 deletions csound-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,7 +29,7 @@


(require 'font-lock)
(require 'cl)
(require 'cl-lib)
(require 'csound-eldoc)
(require 'csound-font-lock)
(require 'csound-repl)
Expand Down Expand Up @@ -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)))
Expand Down
Loading

0 comments on commit 389be23

Please sign in to comment.