Compare commits
No commits in common. "main" and "topic/ninja" have entirely different histories.
main
...
topic/ninj
38 changed files with 1352 additions and 1825 deletions
|
@ -1,5 +0,0 @@
|
|||
;; setting for elisp mode and elisp linter
|
||||
((emacs-lisp-mode . ((fill-column . 80)
|
||||
(indent-tabs-mode . nil)
|
||||
(elisp-lint-indent-specs . ((describe . 1)
|
||||
(it . 1))))))
|
55
.github/workflows/test.yml
vendored
55
.github/workflows/test.yml
vendored
|
@ -1,55 +0,0 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '**.org'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
emacs_version:
|
||||
- 27.2
|
||||
- 28.1
|
||||
- snapshot
|
||||
steps:
|
||||
- name: Set up Emacs
|
||||
uses: purcell/setup-emacs@master
|
||||
with:
|
||||
version: ${{matrix.emacs_version}}
|
||||
|
||||
- name: Install w3m
|
||||
run: sudo apt-get install -y w3m
|
||||
|
||||
- name: Install Eldev
|
||||
run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh
|
||||
|
||||
- name: Check out the elisp source code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# - name: Lint source code with elisp-lint
|
||||
# run: |
|
||||
# cd el
|
||||
# eldev -p -dtT -q lint elisp-lint
|
||||
|
||||
- name: Lint documentation with checkdoc
|
||||
run: |
|
||||
cd el
|
||||
eldev -p -dtT lint doc
|
||||
|
||||
- name: Test the uncompiled source
|
||||
run: |
|
||||
cd el
|
||||
eldev -p -dtT test
|
||||
|
||||
- name: Compile and run tests again
|
||||
run: |
|
||||
cd el
|
||||
eldev compile
|
||||
eldev -p -dtT test
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +0,0 @@
|
|||
.DS_Store
|
||||
*.elc
|
||||
.eldev
|
||||
/el/sclang-autoloads.el
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -1,16 +0,0 @@
|
|||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- Ability to distribute via package managers
|
||||
- Support for `completion-at-point-functions` and `company` via `company-capf`
|
||||
|
||||
### Changed
|
||||
- `M-<tab>` or `C-M-i` is no longer bound to `sclang-complete-symbol`
|
||||
to make builtin completion work as expected.
|
||||
- `sclang-mode` is now derived from `prog-mode`.
|
|
@ -1,4 +1,4 @@
|
|||
add_subdirectory(el)
|
||||
add_subdirectory(sc/scide_scel)
|
||||
add_subdirectory(sc)
|
||||
install(DIRECTORY HelpSource
|
||||
DESTINATION share/SuperCollider/Extensions/scide_scel/)
|
||||
|
|
203
README.md
203
README.md
|
@ -1,142 +1,83 @@
|
|||
# scel - sclang-mode for emacs
|
||||
Scel
|
||||
====
|
||||
|
||||
SuperCollider/Emacs interface
|
||||
|
||||
## Installation
|
||||
|
||||
There are 3 options for installation:
|
||||
Installation requirements
|
||||
-------------------------
|
||||
|
||||
1. Using SuperCollider Quarks (recommended)
|
||||
2. Using an Emacs package manager
|
||||
3. From debian package `supercollider-emacs`
|
||||
4. From source
|
||||
For the HTML help system, you will need emacs-w3m support.
|
||||
|
||||
Option #1 is the best cross-platform option, and is recommended. Whatever option
|
||||
you choose, *make sure not to mix installation methods*. In particular, do not
|
||||
install the Quark if you already have the supercollider-emacs package or if you
|
||||
compiled SuperCollider with the `-DSC_EL=ON` option. Otherwise you will get an
|
||||
error from SuperCollider about duplicated classes.
|
||||
|
||||
### Install Option 1: SuperCollider's own package manager
|
||||
Installation (default)
|
||||
----------------------
|
||||
|
||||
The repository contains two subprojects. `/el` contains the emacs-lisp
|
||||
implementation. `/sc` contains the SuperCollider code required to
|
||||
implement the Emacs interface. SuperCollider has its own package system
|
||||
called Quarks, which we can use to install both halves.
|
||||
By default emacs-lisp files are installed in
|
||||
|
||||
Evaluate this code in the SuperCollider GUI by pasting it and pressing
|
||||
shift+enter:
|
||||
`$prefix/share/emacs/site-lisp`
|
||||
|
||||
SuperCollider files are put in
|
||||
|
||||
`$prefix/share/SuperCollider/Extensions/scide_scel`
|
||||
|
||||
|
||||
The only thing you need to do is loading the sclang interface in your `~/.emacs`:
|
||||
|
||||
``` supercollider
|
||||
Quarks.install("https://github.com/supercollider/scel");
|
||||
```
|
||||
|
||||
The scel repository will be downloaded to your local file system and the path
|
||||
will be added to your currently used `sclang_conf.yaml` file. (You can find its
|
||||
location by evaluating `Platform.userConfigDir`)
|
||||
|
||||
Next, find out where scel was installed. You will use this install-path in your
|
||||
emacs config.
|
||||
|
||||
``` supercollider
|
||||
Quarks.folder.postln;
|
||||
|
||||
// -> /Users/<username>/Library/Application Support/SuperCollider/downloaded-quarks
|
||||
```
|
||||
|
||||
Now in your emacs config, add the `/el` subdirectory to your load path
|
||||
``` emacs-lisp
|
||||
;; in ~/.emacs
|
||||
|
||||
;; Paste path from above, appending "/scel/el"
|
||||
(add-to-list 'load-path "/Users/<username>/Library/Application Support/SuperCollider/downloaded-quarks/scel/el")
|
||||
(require 'sclang)
|
||||
```
|
||||
#### On macOS
|
||||
|
||||
If `sclang` executable is not on your path, you may need to add it to your
|
||||
exec-path.
|
||||
|
||||
``` emacs-lisp
|
||||
;; in ~/.emacs
|
||||
(setq exec-path (append exec-path '("/Applications/SuperCollider.app/Contents/MacOS/")))
|
||||
```
|
||||
|
||||
### Install Option 2: Emacs package manager
|
||||
|
||||
The `sclang` package can be installed from [MELPA](https://melpa.org/#/sclang) and configured with [use-package](https://github.com/jwiegley/use-package).
|
||||
|
||||
It's possible to install with
|
||||
[straight.el](https://github.com/raxod502/straight.el),
|
||||
[use-package](https://github.com/jwiegley/use-package),
|
||||
[doom](https://github.com/hlissner/doom-emacs), etc. Instructions for doing so
|
||||
are beyond the scope of this README, but note that `autoloads` are implemented
|
||||
for entry-point functions so if you like to have a speedy start-up time you can
|
||||
use the `:defer t` option.
|
||||
|
||||
### Install Option 3: Debian package
|
||||
|
||||
There is a debian package which provides emacs integration called
|
||||
`supercollider-emacs`. Option #1 will likely be more recent, but
|
||||
if you prefer you can install the package with:
|
||||
|
||||
``` shell
|
||||
sudo apt install supercollider-emacs
|
||||
```
|
||||
|
||||
### Install Option 4: Installing from source
|
||||
|
||||
If you are building SuperCollider from source, you can optionally compile and
|
||||
install this library along with it. The cmake `-DSC_EL` flag controls whether
|
||||
scel will be compiled. On Linux machines `-DSC_EL=ON` by default. See the
|
||||
supercollider README files for more info.
|
||||
|
||||
``` emacs-lisp
|
||||
;; in ~/.emacs
|
||||
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/SuperCollider/") ;; path will depend on your compilation settings
|
||||
(require 'sclang)
|
||||
```
|
||||
|
||||
## Optional Installation Requirements
|
||||
|
||||
There are two options for SuperCollider help files. They can be opened in the
|
||||
help browser that ships with SuperCollider, or if you prefer an emacs-only
|
||||
workflow they can be opened using the w3m browser. The browse-in-emacs option
|
||||
requires an additional dependency.
|
||||
|
||||
```emacs-lisp
|
||||
;; in ~/.emacs
|
||||
For the HTML help system to fully function also add
|
||||
```
|
||||
(require 'w3m)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The main function which starts interacting with the sclang interpreter is
|
||||
`sclang-start`. You can execute that anywhere with `M-x sclang-start`, or from
|
||||
within a `.scd` buffer by pressing `C-c C-o`.
|
||||
Installation (detailed)
|
||||
-----------------------
|
||||
|
||||
If you know you want to launch sclang when you start emacs you can use the `-f`
|
||||
option to execute that function right away:
|
||||
Put all `*.el` files in emacs' load-path. e.g. if you put them in
|
||||
`~/emacs/`, add the following lines to `~/.emacs` (or whatever your init
|
||||
file is called):
|
||||
|
||||
``` shell
|
||||
# in your terminal
|
||||
emacs -f sclang-start
|
||||
```
|
||||
(add-to-list 'load-path "~/emacs")
|
||||
(require 'sclang)
|
||||
```
|
||||
|
||||
## Configuration
|
||||
for the HTML help system to fully function also add
|
||||
```
|
||||
(require 'w3m)
|
||||
```
|
||||
|
||||
To fine-tune the installation from within emacs' graphical customization
|
||||
interface, type:
|
||||
now put all `*.sc` files in sclang's library path, e.g. if you put them
|
||||
in a non-standard location, such as `~/SuperCollider/Emacs`, add the
|
||||
following to `~/.config/SuperCollider/sclang_conf.yaml` (Linux) or `~/Library/Application Support/SuperCollider/sclang_conf.yaml` (macOS):
|
||||
|
||||
`M-x sclang-customize`
|
||||
```
|
||||
includePaths:
|
||||
[~/SuperCollider/Emacs]
|
||||
```
|
||||
|
||||
NOTE: If you use an sclang configuration file different from the default
|
||||
`sclang_conf.yaml`, you need to specify it in scel by customizing the
|
||||
`sclang-library-configuration-file `variable. Otherwise, even after installing
|
||||
the Quark in SuperCollider, you won't be able to run sclang code in emacs.
|
||||
(note normally this is not needed as they are put into sclang's library
|
||||
path during installation with scons).
|
||||
|
||||
|
||||
## Getting help
|
||||
Usage
|
||||
-----
|
||||
|
||||
In order to automatically start sclang when invoking emacs, use the following command line:
|
||||
|
||||
```
|
||||
$> emacs -sclang
|
||||
```
|
||||
|
||||
you're now ready to edit, inspect and execute sclang code!
|
||||
|
||||
|
||||
Getting help
|
||||
------------
|
||||
|
||||
Inside an sclang-mode buffer (e.g. by editing a .sc file), execute
|
||||
|
||||
|
@ -146,16 +87,11 @@ and a window with key bindings in sclang-mode will pop up.
|
|||
|
||||
`C-x C-h` lets you search for a help file
|
||||
|
||||
`C-M-h` opens or switches to the Help browser (if no Help file has been opened,
|
||||
the default Help file will be opened).
|
||||
`C-M-h` opens or switches to the Help browser (if no Help file has been opened, the default Help file will be opened).
|
||||
|
||||
`E` copies the buffer, puts it in text mode and sclang-minor-mode, to enable you
|
||||
to edit the code parts to try out variations of the provided code in the help
|
||||
file. With `C-M-h` you can then return to the Help browser and browse further
|
||||
from the Help file.
|
||||
`E` copies the buffer, puts it in text mode and sclang-minor-mode, to enable you to edit the code parts to try out variations of the provided code in the help file. With `C-M-h` you can then return to the Help browser and browse further from the Help file.
|
||||
|
||||
`C-c C-e` allows you to edit the source of the HTML file, for example if you
|
||||
want to improve it and commit it to the repository.
|
||||
`C-c C-e` allows you to edit the source of the HTML file, for example if you want to improve it and commit it to the repository.
|
||||
|
||||
To enable moving around in the help file with arrow keys add the following
|
||||
in your `~/.emacs`:
|
||||
|
@ -169,18 +105,25 @@ in your `~/.emacs`:
|
|||
(define-key w3m-mode-map [down] 'next-line)))
|
||||
```
|
||||
|
||||
This ensures that the arrow keys are just for moving through the document, and
|
||||
not from hyperlink to hyperlink, which is the default in w3m-mode.
|
||||
This ensures that the arrow keys are just for moving through the document, and not from hyperlink to hyperlink, which is the default in w3m-mode.
|
||||
|
||||
|
||||
## Server control
|
||||
Customization
|
||||
-------------
|
||||
|
||||
In the post buffer window, right-click on the server name; by default the two
|
||||
servers `internal` and `localhost` are available. You will get a menu with
|
||||
common server control operations.
|
||||
To fine-tune the installation from within emacs' graphical customization interface, type:
|
||||
|
||||
To select another server, step through the server list by left-clicking on the
|
||||
server name.
|
||||
`M-x sclang-customize`
|
||||
|
||||
Servers instantiated from the language will automatically be available in the
|
||||
mode line.
|
||||
In particular, you will have to customize `sclang-runtime-directory'.
|
||||
|
||||
|
||||
Server control
|
||||
--------------
|
||||
|
||||
In the post buffer window, right-click on the server name; by default the two servers `internal` and `localhost` are available. You will get a menu with common server control operations.
|
||||
|
||||
To select another server, step through the server list by left-clicking on the server name.
|
||||
|
||||
Servers instantiated from the language will automatically be available
|
||||
in the mode line.
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
;; setting for elisp mode and elisp linter
|
||||
((emacs-lisp-mode . ((fill-column . 80)
|
||||
(indent-tabs-mode . nil)
|
||||
(elisp-lint-indent-specs . ((describe . 1)
|
||||
(it . 1))))))
|
|
@ -1,32 +1,10 @@
|
|||
option(SC_EL_BYTECOMPILE "Build emacs-based IDE." ON)
|
||||
mark_as_advanced(SC_EL_BYTECOMPILE)
|
||||
|
||||
set(PKG_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/SuperCollider)
|
||||
|
||||
file(GLOB scel_sources
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.el)
|
||||
|
||||
list(REMOVE_ITEM scel_sources ".dir-locals.el")
|
||||
|
||||
# if w3m in installed locally add to the load-path
|
||||
file(GLOB local-load-path
|
||||
LIST_DIRECTORIES true
|
||||
"$ENV{HOME}/.emacs.d/site-lisp/w3m-*"
|
||||
"$ENV{HOME}/.emacs.d/elpa/w3m-*")
|
||||
|
||||
foreach (path ${local-load-path})
|
||||
if(NOT IS_DIRECTORY ${path})
|
||||
list(REMOVE_ITEM local-load-path ${path})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(APPEND local-load-path ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# convert to string of form " dir1 -L dir2 -L dir3 ..." when more than one dir
|
||||
string(JOIN " -L " load-path ${local-load-path})
|
||||
|
||||
# build the argument string
|
||||
string(CONCAT EMACS_ARGS "-batch -L " ${load-path} " -f batch-byte-compile")
|
||||
set(PKG_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/SuperCollider)
|
||||
|
||||
configure_file(sclang-vars.el.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/sclang-vars.el)
|
||||
|
@ -39,8 +17,6 @@ set(all_scel_sources ${scel_sources} sclang-vars.el)
|
|||
|
||||
install (FILES ${scel_sources} ${CMAKE_CURRENT_BINARY_DIR}/sclang-vars.el
|
||||
DESTINATION share/emacs/site-lisp/SuperCollider)
|
||||
|
||||
# the emacs command needs to be evaled due to layers of (un)escaping required to add load-path
|
||||
if (SC_EL_BYTECOMPILE)
|
||||
find_program(EMACS_EXECUTABLE emacs)
|
||||
if(NOT EMACS_EXECUTABLE)
|
||||
|
@ -49,8 +25,10 @@ if (SC_EL_BYTECOMPILE)
|
|||
|
||||
foreach (el ${all_scel_sources})
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${el}c
|
||||
VERBATIM
|
||||
COMMAND eval "${EMACS_EXECUTABLE} ${EMACS_ARGS} ${CMAKE_CURRENT_BINARY_DIR}/${el}"
|
||||
COMMAND ${EMACS_EXECUTABLE} -batch
|
||||
-L ${CMAKE_CURRENT_BINARY_DIR}
|
||||
-f batch-byte-compile
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${el}
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${el}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Creating byte-compiled Emacs lisp ${CMAKE_CURRENT_BINARY_DIR}/${el}c")
|
||||
|
|
7
el/Eldev
7
el/Eldev
|
@ -1,7 +0,0 @@
|
|||
; -*- mode: emacs-lisp; lexical-binding: t -*-
|
||||
;
|
||||
;; You can obtain eldev from https://github.com/doublep/eldev
|
||||
;; We use it for package development and running tests
|
||||
|
||||
(eldev-use-plugin 'autoloads)
|
||||
(eldev-use-package-archive 'melpa)
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-browser.el --- SuperCollider documentation browser -*- coding: utf-8; lexical-binding: t -*-
|
||||
;; copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,40 +15,31 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
;;; Commentary:
|
||||
;; Browser for SuperCollider documentation.
|
||||
(require 'sclang-util)
|
||||
(require 'view nil t)
|
||||
|
||||
;; TODO: better factoring
|
||||
;; - derive from view mode, make mode-map pluggable
|
||||
;; - define derived mode for completion, definition, help
|
||||
;; - update 'display-buffer-reuse-frames'
|
||||
;; - update ‘view-return-to-alist’
|
||||
;; derive from view mode, make mode-map pluggable
|
||||
;; define derived mode for completion, definition, help
|
||||
|
||||
(require 'sclang-util)
|
||||
(require 'view)
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defun sclang-browser-fill-keymap ()
|
||||
"Create keymap and bindings."
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(set-keymap-parent map view-mode-map)
|
||||
(defun sclang-browser-fill-keymap (map)
|
||||
(define-key map "\r" 'sclang-browser-follow-link)
|
||||
(define-key map [mouse-2] 'sclang-browser-mouse-follow-link)
|
||||
(define-key map "\t" 'sclang-browser-next-link)
|
||||
(define-key map [backtab] 'sclang-browser-previous-link)
|
||||
(define-key map [(shift tab)] 'sclang-browser-previous-link)
|
||||
(define-key map [?q] 'sclang-browser-quit)
|
||||
map))
|
||||
map)
|
||||
|
||||
(defvar sclang-browser-mode-map (sclang-browser-fill-keymap))
|
||||
(defvar sclang-browser-mode-map (sclang-browser-fill-keymap (make-sparse-keymap)))
|
||||
(defvar sclang-browser-mode-hook nil)
|
||||
(defvar sclang-browser-show-hook nil)
|
||||
(defvar sclang-browser-link-function nil)
|
||||
(defvar sclang-browser-return-method nil)
|
||||
(defvar sclang-browser-link-function nil
|
||||
"buffer local")
|
||||
(defvar sclang-browser-return-method nil
|
||||
"buffer local")
|
||||
|
||||
(defun sclang-browser-beginning-of-link ()
|
||||
"Beginning of link."
|
||||
(interactive)
|
||||
(when (get-text-property (point) 'sclang-browser-link)
|
||||
(while (and (not (bobp))
|
||||
|
@ -62,7 +49,6 @@
|
|||
(point)))
|
||||
|
||||
(defun sclang-browser-next-link (&optional n)
|
||||
"Next link (or N further)."
|
||||
(interactive)
|
||||
(let* ((n (or n 1))
|
||||
(prop 'sclang-browser-link)
|
||||
|
@ -87,12 +73,10 @@
|
|||
(setq pos (point)))))))
|
||||
|
||||
(defun sclang-browser-previous-link ()
|
||||
"Previous link."
|
||||
(interactive)
|
||||
(sclang-browser-next-link -1))
|
||||
|
||||
(defun sclang-browser-follow-link (&optional pos)
|
||||
"Follow link (optionally POS)."
|
||||
(interactive)
|
||||
(let* ((pos (or pos (point)))
|
||||
(data (get-text-property pos 'sclang-browser-link)))
|
||||
|
@ -105,7 +89,6 @@
|
|||
(error (sclang-message "Error in link function") nil)))))))
|
||||
|
||||
(defun sclang-browser-mouse-follow-link (event)
|
||||
"Link. click. EVENT."
|
||||
(interactive "e")
|
||||
(let* ((start (event-start event))
|
||||
(window (car start))
|
||||
|
@ -114,54 +97,53 @@
|
|||
(sclang-browser-follow-link pos))))
|
||||
|
||||
(defun sclang-browser-mode ()
|
||||
"Major mode for viewing hypertext and navigating references.
|
||||
Entry to this mode runs the normal hook `sclang-browser-mode-hook'
|
||||
|
||||
"Major mode for viewing hypertext and navigating references in it.
|
||||
Entry to this mode runs the normal hook `sclang-browser-mode-hook'.
|
||||
Commands:
|
||||
\\{sclang-browser-mode-map}"
|
||||
(interactive)
|
||||
(view-mode)
|
||||
(kill-all-local-variables)
|
||||
(use-local-map sclang-browser-mode-map)
|
||||
(set-keymap-parent sclang-browser-mode-map view-mode-map)
|
||||
(setq mode-name "Browser")
|
||||
(setq major-mode 'sclang-browser-mode)
|
||||
(set (make-local-variable 'sclang-browser-link-function) nil)
|
||||
(set (make-local-variable 'sclang-browser-return-method) nil)
|
||||
(set (make-local-variable 'font-lock-defaults) nil)
|
||||
(view-mode)
|
||||
(set (make-local-variable 'minor-mode-overriding-map-alist)
|
||||
(list (cons 'view-mode sclang-browser-mode-map)))
|
||||
(set (make-local-variable 'view-no-disable-on-exit) t)
|
||||
(run-hooks 'sclang-browser-mode-hook))
|
||||
|
||||
(defun sclang-browser-mode-setup ()
|
||||
"Setup sclang-browser-mode."
|
||||
(sclang-browser-mode)
|
||||
(setq buffer-read-only nil))
|
||||
|
||||
(defun sclang-browser-mode-finish ()
|
||||
"Finish sclang-browser-mode."
|
||||
(read-only-mode)
|
||||
;; ‘view-return-to-alist’ is an obsolete variable (as of 24.1)
|
||||
;;(setq view-return-to-alist
|
||||
;; (list (cons (selected-window) sclang-browser-return-method)))
|
||||
(view-mode -1)
|
||||
(toggle-read-only 1)
|
||||
(setq view-return-to-alist
|
||||
(list (cons (selected-window) sclang-browser-return-method)))
|
||||
(run-hooks 'sclang-browser-show-hook))
|
||||
|
||||
(defun sclang-browser-quit ()
|
||||
"Quit the sclang help browser."
|
||||
(interactive)
|
||||
(when (eq major-mode 'sclang-browser-mode)
|
||||
(kill-buffer (current-buffer))))
|
||||
|
||||
(defun sclang-browser-make-link (link-text &optional link-data link-function)
|
||||
"Make a link using LINK-TEXT (optional LINK-DATA and LINK-FUNCTION)."
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(propertize link-text
|
||||
'mouse-face 'highlight
|
||||
'sclang-browser-link (cons link-function link-data)))
|
||||
;;'help-echo "mouse-2: follow link"
|
||||
;;'keymap map
|
||||
'sclang-browser-link (cons link-function link-data)
|
||||
;;'sclang-browser-link-data link-data
|
||||
;;'sclang-browser-link-function link-function)))
|
||||
)))
|
||||
|
||||
(defun sclang-display-browser (buffer-name output-function)
|
||||
"Display browser using BUFFER-NAME and OUTPUT-FUNCTION.
|
||||
header: what to insert in the buffer.
|
||||
"header: what to insert in the buffer
|
||||
link-list: list of (link-text link-function link-data)
|
||||
link-function: function with args (link-text link-data)"
|
||||
(let ((temp-buffer-setup-hook '(sclang-browser-mode-setup))
|
||||
|
@ -178,25 +160,18 @@ link-function: function with args (link-text link-data)"
|
|||
;; Secondly, the buffer has not been displayed yet,
|
||||
;; so we don't know whether its frame will be selected.
|
||||
(cons (selected-window) t))
|
||||
;; display-buffer-reuse-frames is obsolete since 24.3
|
||||
;; replace with something like
|
||||
;;+ (add-to-list 'display-buffer-alist
|
||||
;;+ '("." nil (reusable-frames . t)))
|
||||
;;- (display-buffer-reuse-frames
|
||||
;;- (cons (selected-window) 'quit-window))
|
||||
(display-buffer-reuse-frames
|
||||
(cons (selected-window) 'quit-window))
|
||||
((not (one-window-p t))
|
||||
(cons (selected-window) 'quit-window))
|
||||
;; This variable is provided mainly for backward compatibility
|
||||
;; and should not be used in new code.
|
||||
;; (pop-up-windows
|
||||
;; (cons (selected-window) t))
|
||||
(pop-up-windows
|
||||
(cons (selected-window) t))
|
||||
(t
|
||||
(list (selected-window) (window-buffer)
|
||||
(window-start) (window-point)))))
|
||||
(funcall output-function)))))
|
||||
|
||||
(defmacro with-sclang-browser (buffer-name &rest body)
|
||||
"Display browser in BUFFER-NAME and run BODY."
|
||||
`(sclang-display-browser ,buffer-name (lambda () ,@body)))
|
||||
|
||||
;; =====================================================================
|
||||
|
@ -205,4 +180,4 @@ link-function: function with args (link-text link-data)"
|
|||
|
||||
(provide 'sclang-browser)
|
||||
|
||||
;;; sclang-browser.el ends here
|
||||
;; EOF
|
|
@ -1,9 +1,3 @@
|
|||
;;; sclang-dev.el --- IDE for working with SuperCollider -*- coding: utf-8;
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -20,24 +14,36 @@
|
|||
;; USA
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;; Edit SuperCollider help files.
|
||||
|
||||
(eval-when-compile
|
||||
(require 'sclang-util)
|
||||
(require 'sclang-interp)
|
||||
)
|
||||
|
||||
|
||||
;;; Code:
|
||||
|
||||
(sclang-set-command-handler
|
||||
'openDevSource
|
||||
(lambda (file)))
|
||||
(lambda (file)
|
||||
)
|
||||
)
|
||||
|
||||
(defun sclang-edit-dev-source ()
|
||||
"Edit the help file at the development location."
|
||||
; (sclang-document-name . (prSetTitle (buffer-name)))
|
||||
(interactive)
|
||||
;; (sclang-document-name . (prSetTitle (buffer-name)))
|
||||
(sclang-perform-command 'openDevSource (buffer-file-name)))
|
||||
(sclang-perform-command 'openDevSource (buffer-file-name))
|
||||
)
|
||||
|
||||
(provide 'sclang-dev)
|
||||
|
||||
;;; sclang-dev.el ends here
|
||||
;(defun sclang-open-dev-source (file)
|
||||
; "Open the help file at the development location."
|
||||
; (if (sclang-html-file-p file)
|
||||
; (html-mode)
|
||||
; ;; (find-file file)
|
||||
; )
|
||||
; (if ( sclang-sc-file-p file )
|
||||
; (sclang-mode)
|
||||
; )
|
||||
; )
|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-document.el --- IDE for working with SuperCollider -*- coding: utf-8;
|
||||
;; copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,12 +15,6 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;; ???
|
||||
|
||||
;;; Code:
|
||||
|
||||
(provide 'sclang-document)
|
||||
|
||||
;;; sclang-document.el ends here
|
||||
;; EOF
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-help.el --- IDE for working with SuperCollider -*- coding: utf-8; -*-
|
||||
;; copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,44 +15,24 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
;;; Commentary:
|
||||
;; Access SuperCollider help files.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(require 'font-lock))
|
||||
|
||||
(require 'w3m)
|
||||
;; (require 'w3m) ;; not needed during compilation
|
||||
(require 'cl-lib)
|
||||
|
||||
(require 'sclang-util)
|
||||
(require 'sclang-interp)
|
||||
(require 'sclang-language)
|
||||
(require 'sclang-mode)
|
||||
(require 'sclang-vars nil 'ignore-missing-file)
|
||||
(require 'sclang-vars)
|
||||
(require 'sclang-minor-mode)
|
||||
|
||||
(defun sclang-system-root ()
|
||||
"Find the common install location for the platform."
|
||||
(cond
|
||||
((boundp 'sclang-system-data-dir)
|
||||
sclang-system-data-dir)
|
||||
|
||||
((eql 'darwin system-type)
|
||||
(expand-file-name "~/Library/Application Support/SuperCollider"))
|
||||
|
||||
((and (eql 'gnu/linux system-type)
|
||||
(file-exists-p "/usr/local/share/SuperCollider"))
|
||||
"/usr/local/share/SuperCollider")
|
||||
|
||||
((eql 'gnu/linux system-type)
|
||||
"/usr/share/SuperCollider")))
|
||||
|
||||
(defcustom sclang-system-help-dir (expand-file-name "Help" (sclang-system-root))
|
||||
"Installation dependent help directory."
|
||||
(defcustom sclang-help-directory "~/SuperCollider/Help"
|
||||
"*Directory where the SuperCollider help files are kept. OBSOLETE."
|
||||
:group 'sclang-interface
|
||||
:type 'directory)
|
||||
:version "21.3"
|
||||
:type 'directory
|
||||
:options '(:must-match))
|
||||
|
||||
(defcustom sclang-help-path (list sclang-system-help-dir
|
||||
"~/.local/share/SuperCollider/Help")
|
||||
|
@ -65,11 +41,6 @@
|
|||
:version "21.4"
|
||||
:type '(repeat directory))
|
||||
|
||||
(defcustom sclang-system-extension-dir (expand-file-name "Extensions" (sclang-system-root))
|
||||
"Installation dependent extension directory."
|
||||
:group 'sclang-interface
|
||||
:type 'directory)
|
||||
|
||||
(defconst sclang-extension-path (list sclang-system-extension-dir
|
||||
"~/.local/share/SuperCollider/Extensions")
|
||||
"List of SuperCollider extension directories.")
|
||||
|
@ -97,15 +68,12 @@
|
|||
(defcustom sclang-help-filters
|
||||
'(("p\\.p\\([0-9]+\\)" . "#p\\1")
|
||||
("<p class=\"\\(.*\\)\">\\(.*\\)</p>" . "<div id=\"\\1\">\\2</div>"))
|
||||
"Filters to replace html tags.
|
||||
List of pairs of (regexp . filter) defining html-tags to be replaced
|
||||
using the function `sclang-help-substitute-for-filters'."
|
||||
"list of pairs of (regexp . filter) defining html-tags to be replaced by the function sclang-help-substitute-for-filters"
|
||||
:group 'sclang-interface
|
||||
:type '(repeat (cons (string :tag "match") (string :tag "replacement"))))
|
||||
|
||||
(defun sclang-help-substitute-for-filters (&rest args)
|
||||
"Substitute various tags in SCs html-docs.
|
||||
Optional argument ARGS unused?"
|
||||
"substitute various tags in SCs html-docs"
|
||||
(mapcar #'(lambda (filter)
|
||||
(let ((regexp (car filter))
|
||||
(to-string (cdr filter)))
|
||||
|
@ -117,12 +85,12 @@ Optional argument ARGS unused?"
|
|||
;; w3m's content-filtering system
|
||||
(setq w3m-use-filter t)
|
||||
|
||||
;; checks if w3m-filter is loaded. Is `eval-after-load' necessary here?
|
||||
(eval-after-load "w3m-filter"
|
||||
'(add-to-list 'w3m-filter-rules
|
||||
;; run on all files read by w3m...
|
||||
'(".*" sclang-help-substitute-for-filters)))
|
||||
|
||||
|
||||
(defvar sclang-help-topic-alist nil
|
||||
"Alist mapping help topics to file names.")
|
||||
|
||||
|
@ -149,49 +117,38 @@ Optional argument ARGS unused?"
|
|||
;; =====================================================================
|
||||
|
||||
(defun sclang-get-help-file (topic)
|
||||
"Get the help file for TOPIC."
|
||||
(let ((topic (or (cdr (assoc topic sclang-special-help-topics)) topic)))
|
||||
(cdr (assoc topic sclang-help-topic-alist))))
|
||||
|
||||
(defun sclang-get-help-topic (file)
|
||||
"Get the help topic for FILE."
|
||||
(let ((topic (car (rassoc file sclang-help-topic-alist))))
|
||||
(or (car (rassoc topic sclang-special-help-topics)) topic)))
|
||||
|
||||
(defun sclang-help-buffer-name (topic)
|
||||
"Set the help buffer name to TOPIC."
|
||||
(sclang-make-buffer-name (concat "Help:" topic)))
|
||||
|
||||
;; file predicate functions
|
||||
|
||||
(defun sclang-rtf-file-p (file)
|
||||
"Does an rtf FILE exist?"
|
||||
(let ((case-fold-search t))
|
||||
(string-match ".*\\.rtf$" file)))
|
||||
|
||||
;; ========= ADDITION for HTML help files
|
||||
(defun sclang-html-file-p (file)
|
||||
"Does an html FILE exist?"
|
||||
(let ((case-fold-search t))
|
||||
(string-match ".*\\.html?$" file)))
|
||||
|
||||
(defun sclang-sc-file-p (file)
|
||||
"Does an sc FILE exist?"
|
||||
(let ((case-fold-search t))
|
||||
(string-match ".*\\.sc$" file)))
|
||||
|
||||
(defun sclang-scd-file-p (file)
|
||||
"Does an scd FILE exist?"
|
||||
(let ((case-fold-search t))
|
||||
(string-match ".*\\.scd$" file)))
|
||||
|
||||
(defun sclang-help-file-p (file)
|
||||
"Is FILE a help file?"
|
||||
(string-match sclang-help-file-regexp file))
|
||||
|
||||
|
||||
(defun sclang-help-topic-name (file)
|
||||
"Get the help topic from FILE."
|
||||
(when (string-match sclang-help-file-regexp file)
|
||||
(if (string-match sclang-help-file-regexp file)
|
||||
(cons (file-name-nondirectory (replace-match "" nil nil file 1))
|
||||
file)))
|
||||
|
||||
|
@ -202,7 +159,7 @@ Optional argument ARGS unused?"
|
|||
(defconst sclang-rtf-face-change-token "\0")
|
||||
|
||||
(defun sclang-fill-rtf-syntax-table (table)
|
||||
"Fill RTF syntax TABLE."
|
||||
;; character quote
|
||||
(modify-syntax-entry ?\\ "/" table)
|
||||
(modify-syntax-entry ?\" "." table)
|
||||
(modify-syntax-entry ?\{ "(" table)
|
||||
|
@ -228,19 +185,16 @@ Optional argument ARGS unused?"
|
|||
(defun sclang-code-p (pos) (not (rtf-p pos))))
|
||||
|
||||
(defmacro with-sclang-rtf-state-output (state &rest body)
|
||||
"Wrap rtf STATE output around BODY."
|
||||
`(with-current-buffer (sclang-rtf-state-output ,state)
|
||||
,@body))
|
||||
|
||||
(defmacro sclang-rtf-state-add-font (state font-id font-name)
|
||||
"Add font to STATE font table using FONT-ID and FONT-NAME."
|
||||
`(push (cons ,font-id (intern ,font-name)) (sclang-rtf-state-font-table ,state)))
|
||||
|
||||
(defmacro sclang-rtf-state-apply (state)
|
||||
"Apply STATE to rtf output."
|
||||
(let ((pos (cl-gensym))
|
||||
(font (cl-gensym))
|
||||
(face (cl-gensym)))
|
||||
(let ((pos (gensym))
|
||||
(font (gensym))
|
||||
(face (gensym)))
|
||||
`(with-current-buffer (sclang-rtf-state-output ,state)
|
||||
(let ((,pos (or (sclang-rtf-state-pos ,state) (point-min)))
|
||||
(,font (cdr (assq
|
||||
|
@ -257,14 +211,12 @@ Optional argument ARGS unused?"
|
|||
(setf (sclang-rtf-state-pos ,state) (point)))))))
|
||||
|
||||
(defmacro sclang-rtf-state-set-font (state font)
|
||||
"Set FONT in STATE."
|
||||
`(progn
|
||||
(sclang-rtf-state-apply ,state)
|
||||
(setf (sclang-rtf-state-font ,state) ,font)))
|
||||
|
||||
(defmacro sclang-rtf-state-push-face (state face)
|
||||
"Push FACE to STATE."
|
||||
(let ((list (cl-gensym)))
|
||||
(let ((list (gensym)))
|
||||
`(let ((,list (sclang-rtf-state-face state)))
|
||||
(sclang-rtf-state-apply ,state)
|
||||
(unless (memq ,face ,list)
|
||||
|
@ -272,14 +224,12 @@ Optional argument ARGS unused?"
|
|||
(append ,list (list ,face)))))))
|
||||
|
||||
(defmacro sclang-rtf-state-pop-face (state face)
|
||||
"Pop FACE from STATE."
|
||||
(let ((list (cl-gensym)))
|
||||
(let ((list (gensym)))
|
||||
`(let* ((,list (sclang-rtf-state-face ,state)))
|
||||
(sclang-rtf-state-apply ,state)
|
||||
(setf (sclang-rtf-state-face ,state) (delq ,face ,list)))))
|
||||
|
||||
(defun sclang-parse-rtf (state)
|
||||
"Parse rtf STATE."
|
||||
(while (not (eobp))
|
||||
(cond ((looking-at "{")
|
||||
;; container
|
||||
|
@ -309,7 +259,6 @@ Optional argument ARGS unused?"
|
|||
(forward-char 1)))))
|
||||
|
||||
(defun sclang-parse-rtf-container (state)
|
||||
"Parse RTF container. STATE."
|
||||
(cond ((looking-at "\\\\rtf1") ; document
|
||||
(goto-char (match-end 0))
|
||||
(sclang-parse-rtf state))
|
||||
|
@ -327,10 +276,10 @@ Optional argument ARGS unused?"
|
|||
(insert-image image)
|
||||
(sclang-rtf-state-push-face state 'italic)
|
||||
(insert file)
|
||||
(sclang-rtf-state-pop-face state 'italic)))))))
|
||||
(sclang-rtf-state-pop-face state 'italic)))))
|
||||
))
|
||||
|
||||
(defun sclang-parse-rtf-control (state ctrl)
|
||||
"Parse RTF control chars. STATE CTRL."
|
||||
(let ((char (aref ctrl 0)))
|
||||
(cond ((memq char '(?{ ?} ?\\))
|
||||
(with-sclang-rtf-state-output state (insert char)))
|
||||
|
@ -350,10 +299,10 @@ Optional argument ARGS unused?"
|
|||
((string= ctrl "b0")
|
||||
(sclang-rtf-state-pop-face state 'bold))
|
||||
((string-match "^f[0-9]+$" ctrl)
|
||||
(sclang-rtf-state-set-font state ctrl)))))
|
||||
(sclang-rtf-state-set-font state ctrl))
|
||||
)))
|
||||
|
||||
(defun sclang-convert-rtf-buffer (output)
|
||||
"Convert rtf buffer. OUTPUT."
|
||||
(let ((case-fold-search nil)
|
||||
(fill-column sclang-help-fill-column))
|
||||
(save-excursion
|
||||
|
@ -369,20 +318,17 @@ Optional argument ARGS unused?"
|
|||
;; =====================================================================
|
||||
|
||||
(defun sclang-fill-help-syntax-table (table)
|
||||
"Fill help syntax TABLE."
|
||||
;; make ?- be part of symbols for selection and sclang-symbol-at-point
|
||||
(modify-syntax-entry ?- "_" table))
|
||||
|
||||
(defun sclang-fill-help-mode-map (map)
|
||||
"Fill sclang help mode keymap MAP."
|
||||
(define-key map "\C-c}" 'bury-buffer)
|
||||
(define-key map "\C-c\C-v" 'sclang-edit-help-file))
|
||||
|
||||
(defmacro sclang-help-mode-limit-point-to-code (&rest body)
|
||||
"Limit point to code BODY."
|
||||
(let ((min (cl-gensym))
|
||||
(max (cl-gensym))
|
||||
(res (cl-gensym)))
|
||||
(let ((min (gensym))
|
||||
(max (gensym))
|
||||
(res (gensym)))
|
||||
`(if (and (sclang-code-p (point))
|
||||
(not (or (bobp) (eobp)))
|
||||
(sclang-code-p (1- (point)))
|
||||
|
@ -395,17 +341,14 @@ Optional argument ARGS unused?"
|
|||
(t ,res)))))))
|
||||
|
||||
(defun sclang-help-mode-beginning-of-defun (&optional arg)
|
||||
"Move to beginning of function (or back ARG)."
|
||||
(interactive "p")
|
||||
(sclang-help-mode-limit-point-to-code (sclang-beginning-of-defun arg)))
|
||||
|
||||
(defun sclang-help-mode-end-of-defun (&optional arg)
|
||||
"Move to end of function (or forward ARG)."
|
||||
(interactive "p")
|
||||
(sclang-help-mode-limit-point-to-code (sclang-end-of-defun arg)))
|
||||
|
||||
(defun sclang-help-mode-fontify-region (start end loudly)
|
||||
"Fontify region from START to END and LOUDLY."
|
||||
(cl-flet ((fontify-code
|
||||
(start end loudly)
|
||||
(funcall 'font-lock-default-fontify-region start end loudly))
|
||||
|
@ -433,7 +376,6 @@ Optional argument ARGS unused?"
|
|||
|
||||
|
||||
(defun sclang-help-mode-indent-line ()
|
||||
"Indent sclang code in documentation."
|
||||
(if (sclang-code-p (point))
|
||||
(sclang-indent-line)
|
||||
(insert "\t")))
|
||||
|
@ -454,7 +396,7 @@ Optional argument ARGS unused?"
|
|||
(unwind-protect
|
||||
(progn
|
||||
(sclang-convert-rtf-buffer tmp-buffer)
|
||||
(read-only-mode)
|
||||
(toggle-read-only 0)
|
||||
(erase-buffer)
|
||||
(insert-buffer-substring tmp-buffer))
|
||||
(and (buffer-modified-p) (not modified-p) (set-buffer-modified-p nil))
|
||||
|
@ -464,7 +406,8 @@ Optional argument ARGS unused?"
|
|||
(append font-lock-defaults
|
||||
'((font-lock-fontify-region-function . sclang-help-mode-fontify-region))))
|
||||
(set (make-local-variable 'beginning-of-defun-function) 'sclang-help-mode-beginning-of-defun)
|
||||
(set (make-local-variable 'indent-line-function) 'sclang-help-mode-indent-line)))
|
||||
(set (make-local-variable 'indent-line-function) 'sclang-help-mode-indent-line)
|
||||
))
|
||||
|
||||
;; =====================================================================
|
||||
;; help file access
|
||||
|
@ -474,8 +417,7 @@ Optional argument ARGS unused?"
|
|||
"Answer t if PATH should be skipped during help file indexing."
|
||||
(let ((directory (file-name-nondirectory path)))
|
||||
(cl-some (lambda (regexp) (string-match regexp directory))
|
||||
;; skip "." ".." "CVS" ".svn" and "_darcs" directories
|
||||
'("\\.\\'" "\\.\\.\\'" "^CVS\\'" "^\\.svn$" "^_darcs\\'"))))
|
||||
'("^\.$" "^\.\.$" "^CVS$" "^\.svn$" "^_darcs$"))))
|
||||
|
||||
(defun sclang-filter-help-directories (list)
|
||||
"Remove paths to be skipped from LIST of directories."
|
||||
|
@ -485,7 +427,7 @@ Optional argument ARGS unused?"
|
|||
list))
|
||||
|
||||
(defun sclang-directory-files-save (directory &optional full match nosort)
|
||||
"List files in DIRECTORY (optionally FULL MATCH NOSORT) or nil."
|
||||
"Return a list of names of files in DIRECTORY, or nil on error."
|
||||
(condition-case nil
|
||||
(directory-files directory full match nosort)
|
||||
(error nil)))
|
||||
|
@ -544,17 +486,20 @@ Optional argument ARGS unused?"
|
|||
"Edit the help file associated with the current buffer.
|
||||
Switches w3m to edit mode (actually HTML mode)."
|
||||
(interactive)
|
||||
(w3m-edit-current-url))
|
||||
(w3m-edit-current-url)
|
||||
)
|
||||
|
||||
(defun sclang-edit-help-code ()
|
||||
"Edit the help file to make code variations.
|
||||
Switches to text mode with `sclang-minor-mode'."
|
||||
Switches to text mode with sclang-minor-mode."
|
||||
(interactive)
|
||||
(w3m-copy-buffer)
|
||||
;; (text-mode)
|
||||
(sclang-mode)
|
||||
(read-only-mode)
|
||||
(rename-buffer "*SC_Help:CodeEdit*"))
|
||||
(toggle-read-only)
|
||||
(rename-buffer "*SC_Help:CodeEdit*")
|
||||
)
|
||||
|
||||
|
||||
(defun sclang-edit-help-file ()
|
||||
"Edit the help file associated with the current buffer.
|
||||
|
@ -588,7 +533,7 @@ Either visit file internally (.sc) or start external editor (.rtf)."
|
|||
sclang-help-topic-alist))))))
|
||||
|
||||
(defun sclang-goto-help-browser ()
|
||||
"Switch to the *w3m* buffer to browse help files."
|
||||
"Switch to the *w3m* buffer to browse help files"
|
||||
(interactive)
|
||||
(let* ((buffer-name "*w3m*")
|
||||
(buffer (get-buffer buffer-name)))
|
||||
|
@ -600,15 +545,24 @@ Either visit file internally (.sc) or start external editor (.rtf)."
|
|||
(if buffer2
|
||||
(switch-to-buffer buffer2)
|
||||
;; else
|
||||
(sclang-find-help "Help"))))
|
||||
(sclang-find-help "Help")
|
||||
)
|
||||
)
|
||||
)
|
||||
(if buffer
|
||||
(with-current-buffer buffer
|
||||
(rename-buffer "*SC_Help:w3m*")
|
||||
(sclang-help-minor-mode)
|
||||
;;(setq buffer-read-only false)
|
||||
(sclang-help-minor-mode)))))
|
||||
)
|
||||
)
|
||||
; (if buffer
|
||||
;
|
||||
; )
|
||||
)
|
||||
)
|
||||
|
||||
(defun sclang-find-help (topic)
|
||||
"Find help for TOPIC."
|
||||
(interactive
|
||||
(list
|
||||
(let ((topic (or (and mark-active (buffer-substring-no-properties (region-beginning) (region-end)))
|
||||
|
@ -636,15 +590,17 @@ Either visit file internally (.sc) or start external editor (.rtf)."
|
|||
(set-buffer-modified-p nil)))
|
||||
(switch-to-buffer buffer))
|
||||
(if (sclang-html-file-p file)
|
||||
(sclang-goto-help-browser)))
|
||||
(sclang-goto-help-browser))
|
||||
)
|
||||
(sclang-message "Help file not found") nil)
|
||||
(sclang-message "No help for \"%s\"" topic) nil)))
|
||||
|
||||
|
||||
(defun sclang-open-help-gui ()
|
||||
"Open SCDoc Help Browser."
|
||||
"Open SCDoc Help Browser"
|
||||
(interactive)
|
||||
(sclang-eval-string (sclang-format "Help.gui")))
|
||||
(sclang-eval-string (sclang-format "Help.gui"))
|
||||
)
|
||||
|
||||
(defvar sclang-scdoc-topics (make-hash-table :size 16385)
|
||||
"List of all scdoc topics.")
|
||||
|
@ -654,23 +610,24 @@ Either visit file internally (.sc) or start external editor (.rtf)."
|
|||
(lambda (list-of-symbols)
|
||||
(mapcar (lambda (arg)
|
||||
(puthash arg nil sclang-scdoc-topics))
|
||||
list-of-symbols)))
|
||||
list-of-symbols)
|
||||
))
|
||||
|
||||
(defun sclang-find-help-in-gui (topic)
|
||||
"Search for TOPIC in Help Browser."
|
||||
"Search for topic in SCDoc Help Browser"
|
||||
(interactive
|
||||
(list
|
||||
(let ((topic (sclang-symbol-at-point)))
|
||||
(completing-read
|
||||
(format "Help topic%s: " (if topic
|
||||
(completing-read (format "Help topic%s: " (if topic
|
||||
(format " (default %s)" topic)
|
||||
""))
|
||||
sclang-scdoc-topics nil nil nil 'sclang-help-topic-history topic))))
|
||||
sclang-scdoc-topics nil nil nil 'sclang-help-topic-history topic)))
|
||||
)
|
||||
(if topic
|
||||
(sclang-eval-string
|
||||
(sclang-format "HelpBrowser.openHelpFor(%o)" topic))
|
||||
(sclang-eval-string
|
||||
(sclang-format "Help.gui"))))
|
||||
(sclang-eval-string (sclang-format "HelpBrowser.openHelpFor(%o)" topic))
|
||||
(sclang-eval-string (sclang-format "Help.gui"))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; =====================================================================
|
||||
|
@ -688,18 +645,16 @@ Either visit file internally (.sc) or start external editor (.rtf)."
|
|||
(lambda ()
|
||||
(clrhash sclang-scdoc-topics)))
|
||||
|
||||
(add-to-list 'auto-mode-alist '("\\.rtf\\'" . sclang-help-mode))
|
||||
|
||||
(add-to-list 'auto-mode-alist '("\\.rtf$" . sclang-help-mode))
|
||||
;; ========= ADDITION for HTML help files?? ============
|
||||
;; (add-to-list 'auto-mode-alist '("\\.html$" . sclang-help-mode))
|
||||
;; (setq mm-text-html-renderer 'w3m)
|
||||
;; (setq mm-inline-text-html-with-images t)
|
||||
;; (setq mm-inline-text-html-with-w3m-keymap nil)
|
||||
;; =====================================================
|
||||
|
||||
(sclang-fill-help-syntax-table sclang-help-mode-syntax-table)
|
||||
(sclang-fill-help-mode-map sclang-help-mode-map)
|
||||
|
||||
(provide 'sclang-help)
|
||||
|
||||
;;; sclang-help.el ends here
|
||||
;; EOF
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-interp.el --- IDE for working with SuperCollider -*- coding: utf-8;
|
||||
;; copyright 2003-2005 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,12 +15,9 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;; SuperCollider interpreter interface
|
||||
|
||||
(eval-when-compile
|
||||
(require 'sclang-util)
|
||||
(require 'compile)
|
||||
(require 'compile))
|
||||
|
||||
;; =====================================================================
|
||||
;; post buffer access
|
||||
|
@ -32,8 +25,6 @@
|
|||
|
||||
;; FIXME: everything will fail when renaming the post buffer!
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defconst sclang-post-buffer (sclang-make-buffer-name "PostBuffer")
|
||||
"Name of the SuperCollider process output buffer.")
|
||||
|
||||
|
@ -44,7 +35,7 @@
|
|||
"Character for highlighting errors (utf-8).")
|
||||
|
||||
(defconst sclang-parse-error-regexp
|
||||
"^\\(WARNING\\|ERROR\\): .*\n[\t ]*in file '\\([^']+\\)'\n[\t ]*line \\([0-9]+\\) char \\([0-9]+\\)"
|
||||
"^\\(WARNING\\|ERROR\\): .*\n[\t ]*in file '\\([^']\+\\)'\n[\t ]*line \\([0-9]\+\\) char \\([0-9]\+\\)"
|
||||
"Regular expression matching parse errors during library compilation.")
|
||||
|
||||
(defcustom sclang-max-post-buffer-size 0
|
||||
|
@ -62,11 +53,9 @@ Default behavior is to only scroll when point is not at end of buffer."
|
|||
:type 'boolean)
|
||||
|
||||
(defun sclang-get-post-buffer ()
|
||||
"Get or create the sclang post buffer."
|
||||
(get-buffer-create sclang-post-buffer))
|
||||
|
||||
(defmacro with-sclang-post-buffer (&rest body)
|
||||
"BODY in the sclang post buffer."
|
||||
`(with-current-buffer (sclang-get-post-buffer)
|
||||
,@body))
|
||||
|
||||
|
@ -127,14 +116,13 @@ If EOB-P is non-nil, positions cursor at end of buffer."
|
|||
(lambda (&rest args)))
|
||||
;; setup compilation mode
|
||||
(compilation-minor-mode)
|
||||
;; see elisp docs for `make-variable-buffer-local' and `make-local-variable' use cases
|
||||
(set (make-local-variable 'compilation-error-screen-columns) nil)
|
||||
(set (make-local-variable 'compilation-error-regexp-alist)
|
||||
(set (make-variable-buffer-local 'compilation-error-screen-columns) nil)
|
||||
(set (make-variable-buffer-local 'compilation-error-regexp-alist)
|
||||
(cons (list sclang-parse-error-regexp 2 3 4) compilation-error-regexp-alist))
|
||||
(set (make-local-variable 'compilation-parse-errors-function)
|
||||
(set (make-variable-buffer-local 'compilation-parse-errors-function)
|
||||
(lambda (limit-search find-at-least)
|
||||
(compilation-parse-errors limit-search find-at-least)))
|
||||
(set (make-local-variable 'compilation-parse-errors-filename-function)
|
||||
(set (make-variable-buffer-local 'compilation-parse-errors-filename-function)
|
||||
(lambda (file-name)
|
||||
file-name)))
|
||||
(sclang-clear-post-buffer)
|
||||
|
@ -202,7 +190,6 @@ If EOB-P is non-nil, positions cursor at end of buffer."
|
|||
;; =====================================================================
|
||||
|
||||
(defun sclang-get-process ()
|
||||
"Return the current sclang process."
|
||||
(get-process sclang-process))
|
||||
|
||||
;; =====================================================================
|
||||
|
@ -231,19 +218,16 @@ If EOB-P is non-nil, positions cursor at end of buffer."
|
|||
;; initialization
|
||||
|
||||
(defun sclang-library-initialized-p ()
|
||||
"Is sclang library initialized?"
|
||||
(and (sclang-get-process)
|
||||
sclang-library-initialized-p))
|
||||
|
||||
(defun sclang-on-library-startup ()
|
||||
"Initialize sclang library."
|
||||
(sclang-message "Initializing library...")
|
||||
(setq sclang-library-initialized-p t)
|
||||
(run-hooks 'sclang-library-startup-hook)
|
||||
(sclang-message "Initializing library...done"))
|
||||
|
||||
(defun sclang-on-library-shutdown ()
|
||||
"Library shutdown."
|
||||
(when sclang-library-initialized-p
|
||||
(run-hooks 'sclang-library-shutdown-hook)
|
||||
(setq sclang-library-initialized-p nil)
|
||||
|
@ -254,7 +238,6 @@ If EOB-P is non-nil, positions cursor at end of buffer."
|
|||
;; =====================================================================
|
||||
|
||||
(defun sclang-process-sentinel (proc msg)
|
||||
"Process sentinel PROC MSG."
|
||||
(with-sclang-post-buffer
|
||||
(goto-char (point-max))
|
||||
(insert
|
||||
|
@ -266,7 +249,6 @@ If EOB-P is non-nil, positions cursor at end of buffer."
|
|||
(sclang-stop-command-process)))
|
||||
|
||||
(defun sclang-process-filter (process string)
|
||||
"Process filter PROCESS STRING."
|
||||
(let ((buffer (process-buffer process)))
|
||||
(with-current-buffer buffer
|
||||
(when (and (> sclang-max-post-buffer-size 0)
|
||||
|
@ -294,16 +276,13 @@ If EOB-P is non-nil, positions cursor at end of buffer."
|
|||
;; =====================================================================
|
||||
|
||||
(defun sclang-memory-option-p (string)
|
||||
"Is STRING an sclang memory option?"
|
||||
(let ((case-fold-search nil))
|
||||
(string-match "^[1-9][0-9]*[km]?$" string)))
|
||||
|
||||
(defun sclang-port-option-p (number)
|
||||
"Is NUMBER a valid sclang port?"
|
||||
(and (integerp number) (>= number 0) (<= number #XFFFF)))
|
||||
|
||||
(defun sclang-make-options ()
|
||||
"Make options."
|
||||
(let ((default-directory ""))
|
||||
(nconc
|
||||
(when (and sclang-runtime-directory
|
||||
|
@ -324,7 +303,6 @@ If EOB-P is non-nil, positions cursor at end of buffer."
|
|||
(list "-s"))
|
||||
(list "-iscel"))))
|
||||
|
||||
;;;###autoload (autoload 'sclang-start "sclang" "Start SuperCollider process." t)
|
||||
(defun sclang-start ()
|
||||
"Start SuperCollider process."
|
||||
(interactive)
|
||||
|
@ -368,7 +346,8 @@ If EOB-P is non-nil, positions cursor at end of buffer."
|
|||
"Recompile class library."
|
||||
(interactive)
|
||||
(when (sclang-get-process)
|
||||
(process-send-string sclang-process "\x18")))
|
||||
(process-send-string sclang-process "\x18")
|
||||
))
|
||||
|
||||
;; =====================================================================
|
||||
;; command process
|
||||
|
@ -392,26 +371,23 @@ Change this if \"cat\" has a non-standard name or location."
|
|||
"Subprocess for receiving command results from sclang.")
|
||||
|
||||
(defconst sclang-cmd-helper-proc "SCLang Command Helper"
|
||||
"Dummy subprocess that will keep the command fifo open for writing.
|
||||
This is needed so reading does not automatically fail when sclang
|
||||
closes its own writing end of the fifo.")
|
||||
"Dummy subprocess that will keep the command fifo open for writing
|
||||
so reading does not fail automatically when sclang closes its own
|
||||
writing end of the fifo")
|
||||
|
||||
(defvar sclang-command-fifo nil
|
||||
"FIFO for communicating with the subprocess.")
|
||||
|
||||
(defun sclang-delete-command-fifo ()
|
||||
"Delete the command fifo."
|
||||
(and sclang-command-fifo
|
||||
(file-exists-p sclang-command-fifo)
|
||||
(delete-file sclang-command-fifo)))
|
||||
|
||||
(defun sclang-release-command-fifo ()
|
||||
"Release the command fifo."
|
||||
(sclang-delete-command-fifo)
|
||||
(setq sclang-command-fifo nil))
|
||||
|
||||
(defun sclang-create-command-fifo ()
|
||||
"Create the command fifo."
|
||||
(setq sclang-command-fifo (make-temp-name
|
||||
(expand-file-name
|
||||
"sclang-command-fifo." temporary-file-directory)))
|
||||
|
@ -424,7 +400,6 @@ closes its own writing end of the fifo.")
|
|||
(setq sclang-command-fifo nil))))
|
||||
|
||||
(defun sclang-start-command-process ()
|
||||
"Start the command process."
|
||||
(sclang-create-command-fifo)
|
||||
(when sclang-command-fifo
|
||||
;; start the dummy process to keep the fifo open
|
||||
|
@ -448,7 +423,6 @@ closes its own writing end of the fifo.")
|
|||
(message "SCLang: Couldn't start command process"))))
|
||||
|
||||
(defun sclang-stop-command-process ()
|
||||
"Stop the command process."
|
||||
(when (get-process sclang-cmd-helper-proc)
|
||||
(kill-process sclang-cmd-helper-proc)
|
||||
(delete-process sclang-cmd-helper-proc))
|
||||
|
@ -460,7 +434,6 @@ closes its own writing end of the fifo.")
|
|||
"Unprocessed command process output.")
|
||||
|
||||
(defun sclang-command-process-filter (proc string)
|
||||
"Command process filter PROC STRING."
|
||||
(when sclang-command-process-previous
|
||||
(setq string (concat sclang-command-process-previous string)))
|
||||
(let (end)
|
||||
|
@ -479,31 +452,27 @@ closes its own writing end of the fifo.")
|
|||
;; symbol property: sclang-command-handler
|
||||
|
||||
(defun sclang-set-command-handler (symbol function)
|
||||
"Set command handler SYMBOL to FUNCTION."
|
||||
(put symbol 'sclang-command-handler function))
|
||||
|
||||
(defun sclang-perform-command (symbol &rest args)
|
||||
"Eval command SYMBOL with ARGS."
|
||||
(sclang-eval-string (sclang-format
|
||||
"Emacs.lispPerformCommand(%o, %o, true)"
|
||||
symbol args)))
|
||||
|
||||
(defun sclang-perform-command-no-result (symbol &rest args)
|
||||
"Eval command SYMBOL with ARGS. No result."
|
||||
(sclang-eval-string (sclang-format
|
||||
"Emacs.lispPerformCommand(%o, %o, false)"
|
||||
symbol args)))
|
||||
|
||||
(defun sclang-default-command-handler (fun arg)
|
||||
"Default command handler for FUN with ARG.
|
||||
"Default command handler.
|
||||
Displays short message on error."
|
||||
(condition-case err
|
||||
(condition-case nil
|
||||
(funcall fun arg)
|
||||
(error (sclang-message
|
||||
(format "Error in command handler: %s" err)) nil)))
|
||||
(error (sclang-message "Error in command handler") nil)))
|
||||
|
||||
(defun sclang-debug-command-handler (fun arg)
|
||||
"Debugging command handler for FUN with ARG.
|
||||
"Debugging command handler.
|
||||
Enters debugger on error."
|
||||
(let ((debug-on-error t)
|
||||
(debug-on-signal t))
|
||||
|
@ -513,21 +482,20 @@ Enters debugger on error."
|
|||
"Function called when handling command result.")
|
||||
|
||||
(defun sclang-toggle-debug-command-handler (&optional arg)
|
||||
"Toggle debugging of command handler (or set with ARG).
|
||||
Activate debugging iff ARG is positive."
|
||||
"Toggle debugging of command handler.
|
||||
With arg, activate debugging iff arg is positive."
|
||||
(interactive "P")
|
||||
(setq sclang-command-handler
|
||||
(if (or (and arg (> arg 0))
|
||||
(eq sclang-command-handler 'sclang-debug-command-handler))
|
||||
'sclang-default-command-handler
|
||||
'sclang-debug-command-handler))
|
||||
'sclang-default-command-handler))
|
||||
(sclang-message "Command handler debugging %s."
|
||||
(if (eq sclang-command-handler 'sclang-debug-command-handler)
|
||||
"enabled"
|
||||
"disabled")))
|
||||
|
||||
(defun sclang-handle-command-result (list)
|
||||
"Handle command result LIST."
|
||||
(condition-case nil
|
||||
(let ((fun (get (nth 0 list) 'sclang-command-handler))
|
||||
(arg (nth 1 list))
|
||||
|
@ -552,26 +520,25 @@ Activate debugging iff ARG is positive."
|
|||
:type 'boolean)
|
||||
|
||||
(defun sclang-send-string (token string &optional force)
|
||||
"Send TOKEN STRING to sclang (optionally FORCE)."
|
||||
(let ((proc (sclang-get-process)))
|
||||
(when (and proc (or (sclang-library-initialized-p) force))
|
||||
(process-send-string proc (concat string token))
|
||||
string)))
|
||||
|
||||
(defun sclang-eval-string (string &optional print-p)
|
||||
"Evaluate STRING with sclang and print the result if PRINT-P is non-nil.
|
||||
Return STRING if successful, otherwise nil."
|
||||
"Send STRING to the sclang process for evaluation and print the result
|
||||
if PRINT-P is non-nil. Return STRING if successful, otherwise nil."
|
||||
(sclang-send-string
|
||||
(if print-p sclang-token-interpret-print-cmd-line sclang-token-interpret-cmd-line)
|
||||
string))
|
||||
|
||||
(defun sclang-eval-expression (string &optional silent-p)
|
||||
"Evaluate STRING as SuperCollider code (suppress output if SILENT-P is non-nil)."
|
||||
"Execute STRING as SuperCollider code."
|
||||
(interactive "sEval: \nP")
|
||||
(sclang-eval-string string (not silent-p)))
|
||||
|
||||
(defun sclang-eval-line (&optional silent-p)
|
||||
"Evaluate current line with sclang (suppress output if SILENT-P is non-nil)."
|
||||
"Execute the current line as SuperCollider code."
|
||||
(interactive "P")
|
||||
(let ((string (sclang-line-at-point)))
|
||||
(when string
|
||||
|
@ -582,39 +549,32 @@ Return STRING if successful, otherwise nil."
|
|||
string))
|
||||
|
||||
(defun sclang-eval-region (&optional silent-p)
|
||||
"Evaluate current region with sclang (suppress output if SILENT-P is non-nil)."
|
||||
"Execute the region as SuperCollider code."
|
||||
(interactive "P")
|
||||
(sclang-eval-string
|
||||
(buffer-substring-no-properties (region-beginning) (region-end))
|
||||
(not silent-p)))
|
||||
|
||||
(defun sclang-eval-region-or-line (&optional silent-p)
|
||||
"Evaluate current line or region (suppress output if SILENT-P is non-nil)."
|
||||
(interactive "P")
|
||||
(if (and transient-mark-mode mark-active)
|
||||
(sclang-eval-region silent-p)
|
||||
(sclang-eval-line silent-p)))
|
||||
|
||||
(defun sclang-eval-defun (&optional silent-p)
|
||||
"Evaluate current function definition (suppress output if SILENT-P is non-nil)."
|
||||
(interactive "P")
|
||||
(let ((string (sclang-defun-at-point)))
|
||||
(when (and string (string-match "^(" string))
|
||||
(sclang-eval-string string (not silent-p))
|
||||
string)))
|
||||
|
||||
(defun sclang-eval-dwim ()
|
||||
"Evaluate line, region, function or buffer."
|
||||
(interactive "P")
|
||||
(or (sclang-eval-defun)
|
||||
(sclang-eval-region-or-line)))
|
||||
|
||||
(defun sclang-eval-document (&optional silent-p)
|
||||
"Evaluate current buffer with sclang (suppress output if SILENT-P is non-nil)."
|
||||
"Execute the whole document as SuperCollider code."
|
||||
(interactive "P")
|
||||
(save-excursion
|
||||
(mark-whole-buffer)
|
||||
(sclang-eval-string
|
||||
(buffer-substring-no-properties (point-min) (point-max))
|
||||
(buffer-substring-no-properties (region-beginning) (region-end))
|
||||
(not silent-p))))
|
||||
|
||||
(defvar sclang-eval-results nil
|
||||
|
@ -625,7 +585,7 @@ Return STRING if successful, otherwise nil."
|
|||
(lambda (arg) (push arg sclang-eval-results)))
|
||||
|
||||
(defun sclang-eval-sync (string)
|
||||
"Eval STRING in sclang and return result as a Lisp value."
|
||||
"Eval STRING in sclang and return result as a lisp value."
|
||||
(let ((proc (get-process sclang-command-process)))
|
||||
(if (and (processp proc) (eq (process-status proc) 'run))
|
||||
(let ((time (current-time)) (tick 10000) elt)
|
||||
|
@ -693,18 +653,15 @@ Return STRING if successful, otherwise nil."
|
|||
(defconst sclang-workspace-buffer (sclang-make-buffer-name "Workspace"))
|
||||
|
||||
(defun sclang-fill-workspace-mode-map (map)
|
||||
"Fill the workspace keymap MAP."
|
||||
(define-key map "\C-c}" 'bury-buffer))
|
||||
|
||||
(defun sclang-switch-to-workspace ()
|
||||
"Switch to SuperCollider workspace buffer."
|
||||
(interactive)
|
||||
(let ((buffer (get-buffer sclang-workspace-buffer)))
|
||||
(unless buffer
|
||||
(setq buffer (get-buffer-create sclang-workspace-buffer))
|
||||
(with-current-buffer buffer
|
||||
(sclang-mode)
|
||||
;; why a buffer local keymap?
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(set-keymap-parent map sclang-mode-map)
|
||||
(sclang-fill-workspace-mode-map map)
|
||||
|
@ -733,12 +690,10 @@ Return STRING if successful, otherwise nil."
|
|||
;; =====================================================================
|
||||
|
||||
(defun sclang-main-run ()
|
||||
"Run sclang process."
|
||||
(interactive)
|
||||
(sclang-eval-string "thisProcess.run"))
|
||||
|
||||
(defun sclang-main-stop ()
|
||||
"Stop sclang process."
|
||||
(interactive)
|
||||
(sclang-eval-string "thisProcess.stop"))
|
||||
|
||||
|
@ -784,7 +739,6 @@ Return STRING if successful, otherwise nil."
|
|||
(sclang-mode)
|
||||
(switch-to-buffer (current-buffer))))))))
|
||||
|
||||
|
||||
(provide 'sclang-interp)
|
||||
|
||||
;;; sclang-interp.el ends here
|
||||
;; EOF
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-keys.el --- IDE for working with SuperCollider -*- coding: utf-8;
|
||||
;; copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,15 +15,6 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;; Read & send keys between Emacs and SuperCollider
|
||||
|
||||
;;; Code:
|
||||
(eval-and-compile (require 'sclang-util)
|
||||
(require 'sclang-interp))
|
||||
|
||||
|
||||
;; (defvar sclang-key-table (make-char-table 'foo))
|
||||
|
||||
;; (defun sclang-define-key (char beg end)
|
||||
|
@ -38,9 +25,10 @@
|
|||
;; (defun sclang-execute-key (char)
|
||||
;; (sclang-eval-string (sclang-format "Emacs.executeKey(%o)" char)))
|
||||
|
||||
(eval-and-compile (require 'sclang-util)
|
||||
(require 'sclang-interp))
|
||||
|
||||
(defun sclang-read-keys ()
|
||||
"Read and send keys between Emacs and SuperCollider."
|
||||
(interactive)
|
||||
(let (char)
|
||||
(clear-this-command-keys)
|
||||
|
@ -51,7 +39,5 @@
|
|||
(message "%s (%d)" (char-to-string char) char)
|
||||
(sclang-eval-string (format "Emacs.keys.at(%d).value(%d)" char char))))))
|
||||
|
||||
;; EOF
|
||||
|
||||
(provide 'sclang-keys)
|
||||
|
||||
;;; sclang-keys.el ends here
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-language.el --- IDE for working with SuperCollider -*- coding: utf-8;
|
||||
;; copyright 2003-2005 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,20 +15,14 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;; Utilities for SuperCollider syntax
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'sclang-browser)
|
||||
(require 'sclang-interp)
|
||||
(require 'sclang-util)
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; regexp utilities
|
||||
;; ===================================================================
|
||||
|
||||
;;; Code:
|
||||
;; =====================================================================
|
||||
|
||||
(defun sclang-regexp-group (regexp &optional addressable)
|
||||
"Enclose REGEXP in grouping parentheses.
|
||||
|
@ -47,9 +37,9 @@ separately after matching."
|
|||
The expressions are joined as alternatives with the \\| operator."
|
||||
(mapconcat 'sclang-regexp-group regexps "\\|"))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; some useful regular expressions
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defconst sclang-symbol-regexp
|
||||
"\\(?:\\sw\\|\\s_\\)*"
|
||||
|
@ -129,9 +119,9 @@ enclosed by parenthesis (`sclang-block-regexp').")
|
|||
|
||||
A specification is of the form <class-name>-<method-name>.")
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; regexp building
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defun sclang-make-class-definition-regexp (name)
|
||||
"Return a regular expression matching the class definition NAME."
|
||||
|
@ -148,9 +138,9 @@ A specification is of the form <class-name>-<method-name>.")
|
|||
"Return a regular expression matching the method definition NAME."
|
||||
(concat "\\(" (regexp-quote name) "\\)\\s *{"))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; string matching
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defun sclang-string-match (regexp string)
|
||||
"Match REGEXP with STRING while preserving case."
|
||||
|
@ -158,57 +148,48 @@ A specification is of the form <class-name>-<method-name>.")
|
|||
(string-match regexp string)))
|
||||
|
||||
(defun sclang-symbol-match (symbol-regexp string)
|
||||
"Match SYMBOL-REGEXP in STRING."
|
||||
(sclang-string-match (concat "^" symbol-regexp "$") string))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; symbol name predicates
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defun sclang-class-name-p (string)
|
||||
"Is STRING an sclang class name?"
|
||||
(sclang-symbol-match sclang-class-name-regexp string))
|
||||
|
||||
(defun sclang-meta-class-name-p (string)
|
||||
"Is STRING an sclang meta class name?"
|
||||
(and (sclang-class-name-p string)
|
||||
(sclang-string-match "^Meta_" string)))
|
||||
|
||||
(defun sclang-method-name-p (string)
|
||||
"Is STRING an sclang method name?"
|
||||
(sclang-symbol-match sclang-method-name-regexp string))
|
||||
|
||||
(defun sclang-symbol-name-p (string)
|
||||
"Is STRING an sclang symbol name?"
|
||||
(sclang-symbol-match sclang-symbol-name-regexp string))
|
||||
|
||||
(defun sclang-method-name-setter-p (method-name)
|
||||
"Is METHOD-NAME an sclang method name setter?"
|
||||
(string-match "_$" method-name))
|
||||
|
||||
(defun sclang-method-name-getter-p (method-name)
|
||||
"Is METHOD-NAME an sclang method name getter?"
|
||||
(not (sclang-method-name-setter-p method-name)))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; symbol name manipulation
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defun sclang-method-name-setter (method-name)
|
||||
"Return a method name setter for METHOD-NAME."
|
||||
(if (sclang-method-name-setter-p method-name)
|
||||
method-name
|
||||
(concat method-name "_")))
|
||||
|
||||
(defun sclang-method-name-getter (method-name)
|
||||
"Return a method name getter for METHOD-NAME."
|
||||
(if (sclang-method-name-setter-p method-name)
|
||||
(substring method-name 0 (1- (length method-name)))
|
||||
method-name))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; symbol table access
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defcustom sclang-use-symbol-table t
|
||||
"*Retrieve symbol table upon library initialization.
|
||||
|
@ -257,21 +238,17 @@ low-resource systems."
|
|||
(sclang-update-font-lock)))
|
||||
|
||||
(defun sclang-get-symbol-completion-table ()
|
||||
"Get symbol completion table."
|
||||
(mapcar (lambda (s) (cons s nil)) sclang-symbol-table))
|
||||
|
||||
(defun sclang-make-symbol-completion-predicate (predicate)
|
||||
"Make symbol completion PREDICATE."
|
||||
(and predicate (lambda (assoc) (funcall predicate (car assoc)))))
|
||||
|
||||
(defun sclang-get-symbol (string)
|
||||
"Get symbol named STRING."
|
||||
(if (and sclang-use-symbol-table sclang-symbol-table)
|
||||
(car (member string sclang-symbol-table))
|
||||
string))
|
||||
|
||||
(defun sclang-read-symbol (prompt &optional default predicate require-match inherit-input-method)
|
||||
"Read symbol PROMPT (options DEFAULT PREDICATE REQUIRE-MATCH and INHERIT-INPUT-METHOD)."
|
||||
(if sclang-use-symbol-table
|
||||
(cl-flet ((make-minibuffer-local-map
|
||||
(parent-keymap)
|
||||
|
@ -294,12 +271,14 @@ low-resource systems."
|
|||
(read-string (sclang-make-prompt-string prompt default) nil
|
||||
'sclang-symbol-history default inherit-input-method)))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; buffer movement
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defun sclang-point-in-comment-p ()
|
||||
"Return non-nil if point is inside a comment."
|
||||
"Return non-nil if point is inside a comment.
|
||||
|
||||
Use font-lock information if font-lock-mode is enabled."
|
||||
(if (and (boundp 'font-lock-mode) (eval 'font-lock-mode))
|
||||
;; use available information in font-lock-mode
|
||||
(eq (get-text-property (point) 'face) 'font-lock-comment-face)
|
||||
|
@ -310,7 +289,6 @@ low-resource systems."
|
|||
(not (null (nth 4 (parse-partial-sexp (point) beg))))))))
|
||||
|
||||
(defun sclang-beginning-of-defun (&optional arg)
|
||||
"Move to beginning of function (optionally ARG)."
|
||||
(interactive "p")
|
||||
(let ((case-fold-search nil)
|
||||
(arg (or arg (prefix-numeric-value current-prefix-arg)))
|
||||
|
@ -346,7 +324,6 @@ Return value is nil or (beg end) of defun."
|
|||
(list beg end)))))
|
||||
|
||||
(defun sclang-end-of-defun (&optional arg)
|
||||
"Move to end of function (optionally ARG)."
|
||||
(interactive "p")
|
||||
(let ((case-fold-search nil)
|
||||
(arg (or arg (prefix-numeric-value current-prefix-arg)))
|
||||
|
@ -374,9 +351,9 @@ Return value is nil or (beg end) of defun."
|
|||
(when success
|
||||
(forward-line 1) t)))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; buffer object access
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defun sclang-symbol-at-point (&optional symbol-name-regexp)
|
||||
"Return the symbol at point, or nil if not a valid symbol.
|
||||
|
@ -417,9 +394,9 @@ A defun may either be a class definition or a code block, see
|
|||
(cl-multiple-value-bind (beg end) (sclang-point-in-defun-p)
|
||||
(and beg end (buffer-substring-no-properties beg end))))))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; symbol completion
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defun sclang-complete-symbol (&optional predicate)
|
||||
"Perform completion on symbol preceding point.
|
||||
|
@ -476,27 +453,9 @@ are considered."
|
|||
(insert " \n"))))
|
||||
(sclang-message "Making completion list...%s" "done")))))
|
||||
|
||||
(defun sclang-completion-at-point ()
|
||||
"Function used for `completion-at-point-functions' in `sclang-mode'."
|
||||
(let* ((end (point))
|
||||
(beg (save-excursion
|
||||
(backward-sexp 1)
|
||||
(skip-syntax-forward "'")
|
||||
(point)))
|
||||
(pattern (buffer-substring-no-properties beg end))
|
||||
(case-fold-search nil)
|
||||
(predicate (if (sclang-class-name-p pattern)
|
||||
#'sclang-class-name-p
|
||||
#'sclang-method-name-p)))
|
||||
(list beg
|
||||
end
|
||||
(all-completions pattern sclang-symbol-table predicate)
|
||||
:exclusive 'no
|
||||
:company-docsig #'identity)))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; introspection
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defcustom sclang-definition-marker-ring-length 32
|
||||
"*Length of marker ring `sclang-definition-marker-ring'."
|
||||
|
@ -515,7 +474,6 @@ are considered."
|
|||
(make-ring sclang-definition-marker-ring-length))))
|
||||
|
||||
(defun sclang-open-definition (name file pos &optional pos-func)
|
||||
"Open definition NAME in FILE at POS (optionally POS-FUNC)."
|
||||
(let ((buffer (find-file file)))
|
||||
(when (bufferp buffer)
|
||||
(with-current-buffer buffer
|
||||
|
@ -536,7 +494,6 @@ are considered."
|
|||
(set-marker marker nil nil))))
|
||||
|
||||
(defun sclang-browse-definitions (name definitions buffer-name header &optional pos-func)
|
||||
"Browse definitions. NAME DEFINITIONS BUFFER-NAME HEADER (optionally POS-FUNC)."
|
||||
(if (cdr definitions)
|
||||
(let ((same-window-buffer-names (list buffer-name)))
|
||||
(with-sclang-browser
|
||||
|
@ -655,7 +612,7 @@ are considered."
|
|||
(sclang-message "No references to '%s'" name)))))
|
||||
|
||||
(defun sclang-show-method-args ()
|
||||
"Show method args."
|
||||
"whooha. in full effect."
|
||||
(interactive)
|
||||
(let ((regexp (concat
|
||||
sclang-class-name-regexp
|
||||
|
@ -708,9 +665,9 @@ are considered."
|
|||
class 'sclang-class-name-p t))))
|
||||
(sclang-eval-string (format "%s.dumpInterface" class)))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; cscope interface
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defcustom sclang-source-directory nil
|
||||
"Toplevel SuperCollider source directory.
|
||||
|
@ -723,7 +680,7 @@ database."
|
|||
:options '(must-match))
|
||||
|
||||
(defun sclang-find-primitive (name)
|
||||
"Find primitive NAME in a cscope database.
|
||||
"Find primitive name a cscope database.
|
||||
|
||||
The database is searched in `sclang-source-directory', or the
|
||||
current-directory, iff `sclang-source-directoy' is nil."
|
||||
|
@ -733,26 +690,23 @@ current-directory, iff `sclang-source-directoy' is nil."
|
|||
nil nil default))))
|
||||
(if (require 'xcscope nil t)
|
||||
(let ((cscope-initial-directory sclang-source-directory))
|
||||
;; only fboundp when xcscope is loaded
|
||||
(cscope-find-this-text-string
|
||||
(if (string-match "^_" name) name (concat "_" name))))
|
||||
(sclang-message "cscope not available")))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; sc-code formatting
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(defun sclang-list-to-string (list)
|
||||
"Convert sclang LIST to string."
|
||||
(mapconcat 'sclang-object-to-string list ", "))
|
||||
|
||||
(defconst sclang-false 'false)
|
||||
(defconst false 'false)
|
||||
|
||||
(defun sclang-object-to-string (obj)
|
||||
"Convert sclang object OBJ to string."
|
||||
(cond ((null obj)
|
||||
"nil")
|
||||
((eq sclang-false obj)
|
||||
((eq false obj)
|
||||
"false")
|
||||
((eq t obj)
|
||||
"true")
|
||||
|
@ -763,7 +717,7 @@ current-directory, iff `sclang-source-directoy' is nil."
|
|||
(t (format "%S" obj))))
|
||||
|
||||
(defun sclang-format (string &rest args)
|
||||
"Format STRING using ARGS.
|
||||
"format chars:
|
||||
%s - print string
|
||||
%o - print object
|
||||
%l - print argument list"
|
||||
|
@ -826,8 +780,7 @@ want smart pattern guessing, use `sclang-format' directly to format your Pseq."
|
|||
(cl-decf i))))
|
||||
(cl-decf rep)))
|
||||
(accept-process-output nil 0 100)
|
||||
;; invent better progress info
|
||||
(message "Processed...%S" ret)
|
||||
(message "Processed...%S" ret) ;; invent better progress info
|
||||
(setq r (append r (list ret))
|
||||
items (nthcdr skip items))))
|
||||
r))
|
||||
|
@ -845,10 +798,10 @@ want smart pattern guessing, use `sclang-format' directly to format your Pseq."
|
|||
(mapconcat #'elem-to-string compressed ", ")
|
||||
" ], 1)")))))
|
||||
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
;; module setup
|
||||
;; ===================================================================
|
||||
;; =====================================================================
|
||||
|
||||
(provide 'sclang-language)
|
||||
|
||||
;;; sclang-language.el ends here
|
||||
;; EOF
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-menu.el --- IDE for working with SuperCollider -*- coding: utf-8;
|
||||
;; copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,16 +15,9 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
;;; Commentary:
|
||||
;; Menus
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; (sclang-set-command-handler
|
||||
;; '_updateMenu
|
||||
;; (lambda (arg)
|
||||
;; (message "menu: %s" arg)))
|
||||
|
||||
(provide 'sclang-menu)
|
||||
|
||||
;;; sclang-menu.el ends here
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
;;; sclang-minor-mode.el --- IDE for working with SuperCollider -*- coding: utf-8;
|
||||
;;
|
||||
;; Copyright (c) 2007, Marije Baalman - nescivi <nescivi@gmail.com>
|
||||
|
||||
;;; License:
|
||||
|
||||
;;; sclang-minor-mode for use in help files
|
||||
;;; SuperCollider
|
||||
;;; (c) 2007, Marije Baalman - nescivi <nescivi@gmail.com>
|
||||
;;;
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
|
@ -18,14 +16,11 @@
|
|||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; sclang-minor-mode for use in help files
|
||||
|
||||
;;; Code:
|
||||
(eval-when-compile
|
||||
(require 'sclang-util)
|
||||
(require 'sclang-mode)
|
||||
)
|
||||
|
||||
|
||||
(easy-mmode-define-minor-mode sclang-minor-mode
|
||||
"Toggle sclang-minor-mode.
|
||||
|
@ -33,55 +28,53 @@ With no argument, this command toggles the mode.
|
|||
Non-null prefix argument turns on the mode.
|
||||
Null prefix argument turns off the mode.
|
||||
|
||||
When sclang-minor-mode is enabled, you can use the key sequences
|
||||
\\<sclang-minor-mode-map>\\[sclang-eval-region-or-line] or \\<sclang-minor-mode-map>\\[sclang-eval-region] to eval sclang code."
|
||||
When sclang-minor-mode is enabled, you can execute
|
||||
sclang code with the normal command C-c C-c and C-c C-d."
|
||||
;; The initial value.
|
||||
:init-value nil
|
||||
nil
|
||||
;; The indicator for the mode line.
|
||||
:lighter " sclang"
|
||||
" sclang"
|
||||
;; The minor mode bindings.
|
||||
:keymap '(("\C-c\C-c" . sclang-eval-region-or-line)
|
||||
'(("\C-c\C-c" . sclang-eval-region-or-line)
|
||||
("\C-c\C-d" . sclang-eval-region)
|
||||
("\C-\M-x" . sclang-eval-defun)
|
||||
("\C-c\C-h" . sclang-find-help)
|
||||
("\C-\M-h" . sclang-goto-help-browser)
|
||||
("\C-c\C-s" . sclang-main-stop)
|
||||
("\C-c\C-k" . sclang-edit-dev-source)))
|
||||
("\C-c\C-k" . sclang-edit-dev-source)
|
||||
))
|
||||
|
||||
(provide 'sclang-minor-mode)
|
||||
|
||||
|
||||
(easy-mmode-define-minor-mode sclang-help-minor-mode
|
||||
"Toggle sclang-minor-mode.
|
||||
With no argument, this command toggles the mode.
|
||||
Non-null prefix argument turns on the mode.
|
||||
Null prefix argument turns off the mode.
|
||||
|
||||
When sclang-help-minor-mode is enabled, you can use the key sequences
|
||||
\\<sclang-minor-mode-map>\\[sclang-eval-region-or-line] or \\<sclang-minor-mode-map>\\[sclang-eval-region] to eval sclang code."
|
||||
When sclang-help-minor-mode is enabled, you can execute
|
||||
sclang code with the normal command C-c C-c and C-c C-d."
|
||||
;; The initial value.
|
||||
:init-value nil
|
||||
nil
|
||||
;; The indicator for the mode line.
|
||||
:lighter " sclang-help"
|
||||
" sclang-help"
|
||||
;; The minor mode bindings.
|
||||
:keymap '(("\C-c\C-c" . sclang-eval-region-or-line)
|
||||
'(("\C-c\C-c" . sclang-eval-region-or-line)
|
||||
("\C-c\C-d" . sclang-eval-region)
|
||||
("\C-\M-x" . sclang-eval-defun)
|
||||
("\C-c\C-h" . sclang-find-help)
|
||||
("\C-c\C-s" . sclang-main-stop)
|
||||
("\C-c\C-v" . sclang-edit-html-help-file)
|
||||
("E" . sclang-edit-help-code)
|
||||
("\C-c\C-k" . sclang-edit-dev-source)))
|
||||
("\C-c\C-k" . sclang-edit-dev-source)
|
||||
))
|
||||
|
||||
(provide 'sclang-help-minor-mode)
|
||||
|
||||
;; mode hooks
|
||||
(defun sclang-minor-hooks ()
|
||||
"Sclang minor mode hooks."
|
||||
(sclang-init-document)
|
||||
(sclang-make-document))
|
||||
|
||||
(add-hook 'sclang-help-minor-mode-hook 'sclang-minor-hooks)
|
||||
(add-hook 'sclang-minor-mode-hook 'sclang-minor-hooks)
|
||||
|
||||
;;; sclang-minor-mode.el ends here
|
||||
(defun sclang-minor-hooks ()
|
||||
(sclang-init-document)
|
||||
(sclang-make-document)
|
||||
)
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-mode.el --- IDE for working with SuperCollider -*- coding: utf-8;
|
||||
;; copyright 2003-2005 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,25 +15,18 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;; sclang mode
|
||||
|
||||
;;; Code:
|
||||
(require 'cl-lib)
|
||||
|
||||
;; Keep byte-compiler happy by declaring external functions and variables.
|
||||
(declare-function company-mode "ext:company")
|
||||
(defvar company-backends)
|
||||
|
||||
(eval-when-compile
|
||||
(require 'font-lock)
|
||||
(require 'sclang-util)
|
||||
(require 'sclang-util))
|
||||
|
||||
(require 'sclang-interp)
|
||||
(require 'sclang-language)
|
||||
(require 'sclang-dev)
|
||||
|
||||
(defun sclang-fill-syntax-table (table)
|
||||
"Fill the sclang syntax TABLE."
|
||||
;; string
|
||||
(modify-syntax-entry ?\" "\"" table)
|
||||
(modify-syntax-entry ?\' "\"" table) ; no string syntax class for single quotes
|
||||
;; expression prefix
|
||||
|
@ -81,10 +70,10 @@
|
|||
table)
|
||||
|
||||
(defun sclang-mode-make-menu (title)
|
||||
"Make mode menu with TITLE."
|
||||
(easy-menu-create-menu
|
||||
title
|
||||
'(["Start Interpreter" sclang-start :included (not (sclang-library-initialized-p))]
|
||||
'(
|
||||
["Start Interpreter" sclang-start :included (not (sclang-library-initialized-p))]
|
||||
["Restart Interpreter" sclang-start :included (sclang-library-initialized-p)]
|
||||
["Recompile Class Library" sclang-recompile :included (sclang-library-initialized-p)]
|
||||
["Stop Interpreter" sclang-stop :included (sclang-get-process)]
|
||||
|
@ -116,12 +105,10 @@
|
|||
"-"
|
||||
["Run Main" sclang-main-run]
|
||||
["Stop Main" sclang-main-stop]
|
||||
["Show Server Panels" sclang-show-server-panel])))
|
||||
["Show Server Panels" sclang-show-server-panel]
|
||||
)))
|
||||
|
||||
(defun sclang-fill-mode-map (map)
|
||||
"Fill keymap MAP for sclang mode."
|
||||
;; NOTE: keybindings should follow the conventions in https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html
|
||||
|
||||
;; process control
|
||||
(define-key map "\C-c\C-l" 'sclang-recompile)
|
||||
(define-key map "\C-c\C-o" 'sclang-start)
|
||||
|
@ -138,6 +125,7 @@
|
|||
(define-key map "\C-c\C-f" 'sclang-eval-document)
|
||||
;; language information
|
||||
(define-key map "\C-c\C-n" 'sclang-complete-symbol)
|
||||
(define-key map "\M-\t" 'sclang-complete-symbol)
|
||||
(define-key map "\C-c:" 'sclang-find-definitions)
|
||||
(define-key map "\C-c;" 'sclang-find-references)
|
||||
(define-key map "\C-c}" 'sclang-pop-definition-mark)
|
||||
|
@ -145,10 +133,10 @@
|
|||
(define-key map "\C-c{" 'sclang-dump-full-interface)
|
||||
(define-key map "\C-c[" 'sclang-dump-interface)
|
||||
;; documentation access
|
||||
(define-key map "\C-c\C-?f" 'sclang-find-help)
|
||||
(define-key map "\C-c\C-?g" 'sclang-goto-help-browser)
|
||||
(define-key map "" 'sclang-open-help-gui)
|
||||
(define-key map "" 'sclang-find-help-in-gui)
|
||||
(define-key map "\C-c\C-h" 'sclang-find-help)
|
||||
(define-key map "\C-\M-h" 'sclang-goto-help-browser)
|
||||
(define-key map "\C-c\C-y" 'sclang-open-help-gui)
|
||||
(define-key map "\C-ch" 'sclang-find-help-in-gui)
|
||||
;; language control
|
||||
(define-key map "\C-c\C-r" 'sclang-main-run)
|
||||
(define-key map "\C-c\C-s" 'sclang-main-stop)
|
||||
|
@ -171,7 +159,8 @@
|
|||
;; =====================================================================
|
||||
|
||||
(defconst sclang-font-lock-keyword-list
|
||||
'("arg"
|
||||
'(
|
||||
"arg"
|
||||
"classvar"
|
||||
"const"
|
||||
"super"
|
||||
|
@ -181,18 +170,22 @@
|
|||
"thisMethod"
|
||||
"thisProcess"
|
||||
"thisThread"
|
||||
"var")
|
||||
"var"
|
||||
)
|
||||
"*List of keywords to highlight in SCLang mode.")
|
||||
|
||||
(defconst sclang-font-lock-builtin-list
|
||||
'("false"
|
||||
'(
|
||||
"false"
|
||||
"inf"
|
||||
"nil"
|
||||
"true")
|
||||
"true"
|
||||
)
|
||||
"*List of builtins to highlight in SCLang mode.")
|
||||
|
||||
(defconst sclang-font-lock-method-list
|
||||
'("ar"
|
||||
'(
|
||||
"ar"
|
||||
"for"
|
||||
"forBy"
|
||||
"if"
|
||||
|
@ -200,16 +193,19 @@
|
|||
"kr"
|
||||
"tr"
|
||||
"loop"
|
||||
"while")
|
||||
"while"
|
||||
)
|
||||
"*List of methods to highlight in SCLang mode.")
|
||||
|
||||
(defconst sclang-font-lock-error-list
|
||||
'("die"
|
||||
'(
|
||||
"die"
|
||||
"error"
|
||||
"exit"
|
||||
"halt"
|
||||
"verboseHalt"
|
||||
"warn")
|
||||
"warn"
|
||||
)
|
||||
"*List of methods signalling errors or warnings.")
|
||||
|
||||
(defvar sclang-font-lock-class-keywords nil)
|
||||
|
@ -229,13 +225,14 @@
|
|||
(defconst sclang-font-lock-defaults '((sclang-font-lock-keywords
|
||||
sclang-font-lock-keywords-1
|
||||
sclang-font-lock-keywords-2
|
||||
sclang-font-lock-keywords-3)
|
||||
sclang-font-lock-keywords-3
|
||||
)
|
||||
nil nil
|
||||
nil
|
||||
beginning-of-defun))
|
||||
beginning-of-defun
|
||||
))
|
||||
|
||||
(defun sclang-font-lock-syntactic-face (state)
|
||||
"Return font lock face for STATE."
|
||||
(cond ((eq (nth 3 state) ?')
|
||||
;; symbol
|
||||
'font-lock-constant-face)
|
||||
|
@ -247,7 +244,6 @@
|
|||
'font-lock-comment-face)))
|
||||
|
||||
(defun sclang-font-lock-class-keyword-matcher (limit)
|
||||
"Font lock class keywords up to LIMIT."
|
||||
(let ((regexp (concat "\\<" sclang-class-name-regexp "\\>"))
|
||||
(case-fold-search nil)
|
||||
(continue t)
|
||||
|
@ -264,7 +260,6 @@
|
|||
res))
|
||||
|
||||
(defun sclang-set-font-lock-keywords ()
|
||||
"Set font lock keywords."
|
||||
(setq
|
||||
;; level 1
|
||||
sclang-font-lock-keywords-1
|
||||
|
@ -280,7 +275,8 @@
|
|||
;; constants
|
||||
(cons "\\s/\\s\\?." 'font-lock-constant-face) ; characters
|
||||
(cons (concat "\\\\\\(" sclang-symbol-regexp "\\)")
|
||||
'font-lock-constant-face)) ; symbols
|
||||
'font-lock-constant-face) ; symbols
|
||||
)
|
||||
;; level 2
|
||||
sclang-font-lock-keywords-2
|
||||
(append
|
||||
|
@ -299,19 +295,23 @@
|
|||
'font-lock-function-name-face)
|
||||
;; errors
|
||||
(cons (regexp-opt sclang-font-lock-error-list 'words)
|
||||
'font-lock-warning-face)))
|
||||
'font-lock-warning-face)
|
||||
))
|
||||
;; level 3
|
||||
sclang-font-lock-keywords-3
|
||||
(append
|
||||
sclang-font-lock-keywords-2
|
||||
(list
|
||||
;; classes
|
||||
(cons 'sclang-font-lock-class-keyword-matcher 'font-lock-type-face)))
|
||||
(cons 'sclang-font-lock-class-keyword-matcher 'font-lock-type-face)
|
||||
;; (cons (concat "\\<" sclang-class-name-regexp "\\>") 'font-lock-type-face)
|
||||
))
|
||||
;; default level
|
||||
sclang-font-lock-keywords sclang-font-lock-keywords-1))
|
||||
sclang-font-lock-keywords sclang-font-lock-keywords-1
|
||||
))
|
||||
|
||||
(defun sclang-update-font-lock ()
|
||||
"Update font-lock information in all `sclang-mode' buffers."
|
||||
"Update font-lock information in all sclang-mode buffers."
|
||||
;; too expensive
|
||||
;; (dolist (buffer (buffer-list))
|
||||
;; (with-current-buffer buffer
|
||||
|
@ -319,7 +319,7 @@
|
|||
;; (eq t (car font-lock-keywords))
|
||||
;; (setq font-lock-keywords (cdr font-lock-keywords)))))
|
||||
(if (eq major-mode 'sclang-mode)
|
||||
(font-lock-ensure (point-min) (point-max))))
|
||||
(font-lock-fontify-buffer)))
|
||||
|
||||
;; =====================================================================
|
||||
;; indentation
|
||||
|
@ -333,7 +333,7 @@
|
|||
(defun sclang-indent-line ()
|
||||
"Indent current line as sclang code.
|
||||
Return the amount the indentation changed by."
|
||||
(let ((indent (sclang-calculate-indent))
|
||||
(let ((indent (calculate-sclang-indent))
|
||||
beg shift-amt
|
||||
(case-fold-search nil)
|
||||
(pos (- (point-max) (point))))
|
||||
|
@ -352,8 +352,8 @@ Return the amount the indentation changed by."
|
|||
(goto-char (- (point-max) pos))))
|
||||
shift-amt))
|
||||
|
||||
(defun sclang-calculate-indent (&optional parse-start)
|
||||
"Return indentation for current line (optionally from PARSE-START).
|
||||
(defun calculate-sclang-indent (&optional parse-start)
|
||||
"Return appropriate indentation for current line as sclang code.
|
||||
Returns the column to indent to."
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
|
@ -406,7 +406,6 @@ Returns the column to indent to."
|
|||
;; =====================================================================
|
||||
|
||||
(defun sclang-electric-brace (arg)
|
||||
"Electrify brace ARG."
|
||||
(interactive "*P")
|
||||
(self-insert-command (prefix-numeric-value arg))
|
||||
(and (save-excursion
|
||||
|
@ -415,7 +414,6 @@ Returns the column to indent to."
|
|||
(indent-according-to-mode)))
|
||||
|
||||
(defun sclang-electric-slash (arg)
|
||||
"Electrify slash ARG."
|
||||
(interactive "*P")
|
||||
(let* ((char (char-before))
|
||||
(indent-p (or (eq char ?/)
|
||||
|
@ -424,7 +422,6 @@ Returns the column to indent to."
|
|||
(if indent-p (indent-according-to-mode))))
|
||||
|
||||
(defun sclang-electric-star (arg)
|
||||
"Electrify star ARG."
|
||||
(interactive "*P")
|
||||
(let ((indent-p (eq (char-before) ?/)))
|
||||
(self-insert-command (prefix-numeric-value arg))
|
||||
|
@ -453,30 +450,24 @@ Returns the column to indent to."
|
|||
(sclang-document-edited-p . (prSetEdited (buffer-modified-p)))))
|
||||
|
||||
(defmacro sclang-next-document-id ()
|
||||
"Return next document id."
|
||||
`(cl-incf sclang-document-counter))
|
||||
|
||||
(defun sclang-document-id (buffer)
|
||||
"Document id of BUFFER."
|
||||
(cdr (assq 'sclang-document-id (buffer-local-variables buffer))))
|
||||
|
||||
(defun sclang-document-p (buffer)
|
||||
"Is BUFFER an sclang document?"
|
||||
(integerp (sclang-document-id buffer)))
|
||||
|
||||
(defmacro with-sclang-document (buffer &rest body)
|
||||
"With sclang BUFFER BODY."
|
||||
`(when (sclang-document-p buffer)
|
||||
(with-current-buffer buffer
|
||||
,@body)))
|
||||
|
||||
(defun sclang-get-document (id)
|
||||
"Return buffer with document ID or nil."
|
||||
(cl-find-if (lambda (buffer) (eq id (sclang-document-id buffer)))
|
||||
sclang-document-list))
|
||||
|
||||
(defun sclang-init-document ()
|
||||
"Initialize document."
|
||||
(set (make-local-variable 'sclang-document-id) (sclang-next-document-id))
|
||||
(set (make-local-variable 'sclang-document-envir) nil)
|
||||
(dolist (assoc sclang-document-property-map)
|
||||
|
@ -484,7 +475,6 @@ Returns the column to indent to."
|
|||
(cl-pushnew (current-buffer) sclang-document-list))
|
||||
|
||||
(defun sclang-document-update-property-1 (assoc &optional force)
|
||||
"Update document property ASSOC (optionally FORCE)."
|
||||
(when (consp assoc)
|
||||
(let* ((key (car assoc))
|
||||
(prop (cdr assoc))
|
||||
|
@ -497,21 +487,17 @@ Returns the column to indent to."
|
|||
(car prop) cur-value)))))
|
||||
|
||||
(defun sclang-document-update-property (key &optional force)
|
||||
"Update document property KEY (optionally FORCE)."
|
||||
(sclang-document-update-property-1 (assq key sclang-document-property-map) force))
|
||||
|
||||
(defun sclang-document-update-properties (&optional force)
|
||||
"Update all document properties (optionally FORCE)."
|
||||
(dolist (assoc sclang-document-property-map)
|
||||
(sclang-document-update-property-1 assoc force)))
|
||||
|
||||
(defun sclang-make-document ()
|
||||
"Make a new document."
|
||||
(sclang-perform-command-no-result 'documentNew sclang-document-id)
|
||||
(sclang-document-update-properties t))
|
||||
|
||||
(defun sclang-close-document (buffer)
|
||||
"Close document in BUFFER."
|
||||
(with-sclang-document
|
||||
buffer
|
||||
(setq sclang-document-list (delq buffer sclang-document-list))
|
||||
|
@ -519,32 +505,27 @@ Returns the column to indent to."
|
|||
'documentClosed sclang-document-id)))
|
||||
|
||||
(defun sclang-set-current-document (buffer &optional force)
|
||||
"Set current document to BUFFER (optionally FORCE)."
|
||||
(when (or force (not (eq buffer sclang-current-document)))
|
||||
(setq sclang-current-document buffer)
|
||||
(sclang-perform-command-no-result 'documentSetCurrent (sclang-document-id buffer))
|
||||
t))
|
||||
|
||||
(defun sclang-document-library-startup-hook-function ()
|
||||
"Document library startup hook."
|
||||
(dolist (buffer sclang-document-list)
|
||||
(with-current-buffer buffer
|
||||
(sclang-make-document)))
|
||||
(sclang-set-current-document (current-buffer) t))
|
||||
|
||||
(defun sclang-document-kill-buffer-hook-function ()
|
||||
"Document kill buffer hook."
|
||||
(sclang-close-document (current-buffer)))
|
||||
|
||||
(defun sclang-document-post-command-hook-function ()
|
||||
"Document post command hook."
|
||||
(when (and (sclang-library-initialized-p)
|
||||
(sclang-document-p (current-buffer)))
|
||||
(sclang-document-update-properties))
|
||||
(sclang-set-current-document (current-buffer)))
|
||||
|
||||
(defun sclang-document-change-major-mode-hook-function ()
|
||||
"Document change major mode hook."
|
||||
(sclang-close-document (current-buffer)))
|
||||
|
||||
;; =====================================================================
|
||||
|
@ -620,7 +601,8 @@ Returns the column to indent to."
|
|||
(let ((doc (and (integerp id) (sclang-get-document id))))
|
||||
(when doc
|
||||
(with-current-buffer doc
|
||||
(insert str))
|
||||
(insert str)
|
||||
)
|
||||
nil)))))
|
||||
|
||||
(sclang-set-command-handler
|
||||
|
@ -635,7 +617,6 @@ Returns the column to indent to."
|
|||
;; =====================================================================
|
||||
|
||||
(defun sclang-mode-set-local-variables ()
|
||||
"Local variables."
|
||||
(set (make-local-variable 'require-final-newline) nil)
|
||||
;; indentation
|
||||
(set (make-local-variable 'indent-line-function)
|
||||
|
@ -684,29 +665,27 @@ Returns the column to indent to."
|
|||
:group 'sclang-mode
|
||||
:type 'hook)
|
||||
|
||||
;;;###autoload (autoload 'sclang-mode "sclang" "Major mode for editing SuperCollider language" t)
|
||||
(define-derived-mode sclang-mode prog-mode "SCLang"
|
||||
(defun sclang-mode ()
|
||||
"Major mode for editing SuperCollider language code.
|
||||
\\{sclang-mode-map}"
|
||||
:group 'sclang
|
||||
:syntax-table sclang-mode-syntax-table
|
||||
\\{sclang-mode-map}
|
||||
"
|
||||
(interactive)
|
||||
(kill-all-local-variables)
|
||||
(set-syntax-table sclang-mode-syntax-table)
|
||||
(use-local-map sclang-mode-map)
|
||||
(setq mode-name "SCLang")
|
||||
(setq major-mode 'sclang-mode)
|
||||
(sclang-mode-set-local-variables)
|
||||
(sclang-set-font-lock-keywords)
|
||||
(sclang-init-document)
|
||||
(sclang-make-document)
|
||||
|
||||
;; Setup completion
|
||||
(add-hook 'completion-at-point-functions
|
||||
#'sclang-completion-at-point nil 'local)
|
||||
(when (fboundp 'company-mode)
|
||||
(add-to-list 'company-backends 'company-capf)))
|
||||
(run-hooks 'sclang-mode-hook))
|
||||
|
||||
;; =====================================================================
|
||||
;; module initialization
|
||||
;; =====================================================================
|
||||
|
||||
;;;###autoload
|
||||
(add-to-list 'auto-mode-alist '("\\.scd?\\'" . sclang-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.\\(sc\\|scd\\)$" . sclang-mode))
|
||||
(add-to-list 'interpreter-mode-alist '("sclang" . sclang-mode))
|
||||
|
||||
(add-hook 'sclang-library-startup-hook 'sclang-document-library-startup-hook-function)
|
||||
|
@ -716,4 +695,4 @@ Returns the column to indent to."
|
|||
|
||||
(provide 'sclang-mode)
|
||||
|
||||
;;; sclang-mode.el ends here
|
||||
;; EOF
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-server.el --- IDE for working with SuperCollider -*- coding: utf-8;
|
||||
;; copyright 2003-2005 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,17 +15,13 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;; Interface to the sclang server
|
||||
|
||||
(require 'cl-lib)
|
||||
|
||||
(eval-when-compile
|
||||
(require 'sclang-util)
|
||||
(require 'sclang-interp)
|
||||
(require 'sclang-language)
|
||||
(require 'sclang-mode)
|
||||
|
||||
;;; Code:
|
||||
(require 'sclang-mode))
|
||||
|
||||
(defcustom sclang-server-panel "Server.default.makeWindow"
|
||||
"Expression to execute when `sclang-show-server-panel' is invoked."
|
||||
|
@ -57,12 +49,10 @@
|
|||
"Face for highlighting a server's running state in the mode-line.")
|
||||
|
||||
(defun sclang-get-server (&optional name)
|
||||
"Get sclang server (optionally by NAME)."
|
||||
(unless name (setq name sclang-current-server))
|
||||
(cdr (assq name sclang-server-alist)))
|
||||
|
||||
(defun sclang-set-server (&optional name)
|
||||
"Set current sclang server (optionally by NAME)."
|
||||
(unless name (setq name sclang-current-server))
|
||||
(setq sclang-current-server
|
||||
(car (or (assq name sclang-server-alist)
|
||||
|
@ -91,21 +81,18 @@
|
|||
(setq sclang-current-server (car (car list))))
|
||||
(sclang-update-server-info))
|
||||
|
||||
(defun sclang-mouse-next-server (_event)
|
||||
(defun sclang-mouse-next-server (event)
|
||||
"Select next server for display."
|
||||
(interactive "e")
|
||||
(sclang-next-server))
|
||||
|
||||
(defun sclang-server-running-p (&optional name)
|
||||
"Is the sclang server NAME running?"
|
||||
(plist-get (sclang-get-server name) 'running))
|
||||
|
||||
(defun sclang-server-booting-p (&optional name)
|
||||
"Is the sclang server NAME running?"
|
||||
(plist-get (sclang-get-server name) 'booting))
|
||||
|
||||
(defun sclang-create-server-menu (title)
|
||||
"Create the server menu with TITLE."
|
||||
(easy-menu-create-menu
|
||||
title
|
||||
'(
|
||||
|
@ -116,7 +103,6 @@
|
|||
["Make Default" sclang-server-make-default])))
|
||||
|
||||
(defun sclang-server-fill-mouse-map (map prefix)
|
||||
"Fill mouse MAP using PREFIX."
|
||||
(define-key map (vector prefix 'mouse-1) 'sclang-mouse-next-server)
|
||||
(define-key map (vector prefix 'down-mouse-3) (sclang-create-server-menu "Commands"))
|
||||
map)
|
||||
|
@ -125,7 +111,7 @@
|
|||
"Keymap used for controlling servers in the mode line.")
|
||||
|
||||
(defun sclang-server-fill-key-map (map)
|
||||
"Fill server keymap MAP."
|
||||
"Fill server prefix map."
|
||||
(define-key map [?b] 'sclang-server-boot)
|
||||
(define-key map [?d] 'sclang-server-display-default)
|
||||
(define-key map [?f] 'sclang-server-free-all)
|
||||
|
@ -170,7 +156,6 @@
|
|||
"Info string used in the post buffer mode line.")
|
||||
|
||||
(defun sclang-update-server-info ()
|
||||
"Update server info in the modeline."
|
||||
(interactive)
|
||||
(sclang-set-server)
|
||||
(setq sclang-server-info-string (sclang-get-server-info-string))
|
||||
|
@ -181,10 +166,8 @@
|
|||
;; =====================================================================
|
||||
|
||||
(defun sclang-perform-server-command (command &rest args)
|
||||
"Perform server COMMAND with ARGS."
|
||||
(sclang-eval-string
|
||||
(sclang-format
|
||||
"Server.named.at(%o.asSymbol).performList(\\tryPerform, %o.asSymbol.asArray ++ %o)"
|
||||
(sclang-format "Server.named.at(%o.asSymbol).performList(\\tryPerform, %o.asSymbol.asArray ++ %o)"
|
||||
sclang-current-server command args)
|
||||
nil))
|
||||
|
||||
|
@ -232,7 +215,7 @@ if (server.notNil) {
|
|||
nil))
|
||||
|
||||
(defun sclang-server-dump-osc (&optional code)
|
||||
"Set the current server's dump OSC mode (with optional CODE)."
|
||||
"Set the current server's dump OSC mode."
|
||||
(interactive "P")
|
||||
(sclang-perform-server-command "dumpOSC"
|
||||
(cond ((consp code) 0)
|
||||
|
@ -240,7 +223,7 @@ if (server.notNil) {
|
|||
(t code))))
|
||||
|
||||
(defun sclang-server-prepare-for-record (&optional path)
|
||||
"Prepare current server for recording a sound file (with optional PATH)."
|
||||
"Prepare current server for recording a sound file."
|
||||
(interactive
|
||||
(list
|
||||
(and current-prefix-arg (read-file-name "Record to file: "))))
|
||||
|
@ -261,10 +244,10 @@ if (server.notNil) {
|
|||
(interactive)
|
||||
(sclang-perform-server-command "stopRecording"))
|
||||
|
||||
(defun sclang-set-server-latency (latency)
|
||||
"Set the current server's LATENCY instance variable."
|
||||
(defun sclang-set-server-latency (lat)
|
||||
"Set the current server's `latency' instance variable."
|
||||
(interactive "nSet latency: ")
|
||||
(sclang-perform-server-command "latency_" latency))
|
||||
(sclang-perform-server-command "latency_" lat))
|
||||
|
||||
(defun sclang-show-server-latency ()
|
||||
"Show the current server's latency."
|
||||
|
@ -293,7 +276,6 @@ if (server.notNil) {
|
|||
(lambda ()
|
||||
(setq sclang-current-server-initialized nil)))
|
||||
|
||||
|
||||
(provide 'sclang-server)
|
||||
|
||||
;;; sclang-server.el ends here
|
||||
;; EOF
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
;;; sclang-util.el --- Utility helpers for sclang -*- coding: utf-8;
|
||||
;; copyright 2003-2005 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003-2005 stefan kersten <steve@k-hornz.de>
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -19,20 +15,13 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
;;; Commentary:
|
||||
;; Utility helpers for sclang
|
||||
|
||||
;;; Code:
|
||||
(defun sclang-message (string &rest args)
|
||||
"Create a message from STRING with optional ARGS."
|
||||
(message "SCLang: %s" (apply 'format string args)))
|
||||
|
||||
(defun sclang-make-buffer-name (name &optional private-p)
|
||||
"Set the buffer name to NAME (optimally PRIVATE-P)."
|
||||
(concat (and private-p " ") "*SCLang:" name "*"))
|
||||
(defun sclang-make-buffer-name (string &optional private-p)
|
||||
(concat (and private-p " ") "*SCLang:" string "*"))
|
||||
|
||||
(defun sclang-make-prompt-string (prompt default)
|
||||
"Return a prompt string using PROMPT and DEFAULT."
|
||||
(if (and default (string-match "\\(:\\)\\s *" prompt))
|
||||
(replace-match
|
||||
(format " (default %s):" default)
|
||||
|
@ -40,23 +29,22 @@
|
|||
prompt))
|
||||
|
||||
(defun sclang-string-to-int32 (str)
|
||||
"Convert first 4 bytes of STR (network byteorder) to 32 bit integer."
|
||||
(logior (ash (logand (aref str 0) #XFF) 24)
|
||||
(ash (logand (aref str 1) #XFF) 16)
|
||||
(ash (logand (aref str 2) #XFF) 8)
|
||||
"Convert first 4 bytes of str (network byteorder) to 32 bit integer."
|
||||
(logior (lsh (logand (aref str 0) #XFF) 24)
|
||||
(lsh (logand (aref str 1) #XFF) 16)
|
||||
(lsh (logand (aref str 2) #XFF) 8)
|
||||
(logand (aref str 3) #XFF)))
|
||||
|
||||
(defun sclang-int32-to-string (n)
|
||||
"Convert 32 bit integer N to 4 byte string (network byte order)."
|
||||
"Convert 32 bit integer n to 4 byte string (network byte order)."
|
||||
(let ((str (make-string 4 0)))
|
||||
(aset str 0 (logand (ash n -24) #XFF))
|
||||
(aset str 1 (logand (ash n -16) #XFF))
|
||||
(aset str 2 (logand (ash n -8) #XFF))
|
||||
(aset str 0 (logand (lsh n -24) #XFF))
|
||||
(aset str 1 (logand (lsh n -16) #XFF))
|
||||
(aset str 2 (logand (lsh n -8) #XFF))
|
||||
(aset str 3 (logand n #XFF))
|
||||
str))
|
||||
|
||||
(defun sclang-compress-newlines (&optional buffer)
|
||||
"Compress newlines (optionally in BUFFER)."
|
||||
(with-current-buffer (or buffer (current-buffer))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
|
@ -95,4 +83,4 @@
|
|||
|
||||
(provide 'sclang-util)
|
||||
|
||||
;;; sclang-util.el ends here
|
||||
;; EOF
|
|
@ -19,21 +19,16 @@
|
|||
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This file is included in the distribution in order to convey system
|
||||
;; installation variables which are known at compile time, but only when
|
||||
;; the library is installed with cmake along with SuperCollider source.
|
||||
;;
|
||||
;; When using the stand-alone package, this file can be ignored and
|
||||
;; the constants it defines will have no effect.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defconst sclang-system-data-dir "@PKG_DATA_DIR@"
|
||||
"Installation dependent data directory.
|
||||
Bound only when library is installed with SuperCollider.")
|
||||
"Installation dependent data directory.")
|
||||
|
||||
(defconst sclang-system-help-dir "@PKG_DATA_DIR@/Help"
|
||||
"Installation dependent help directory.")
|
||||
|
||||
(defconst sclang-system-extension-dir "@PKG_DATA_DIR@/Extensions"
|
||||
"Installation dependent extension directory.")
|
||||
|
||||
(provide 'sclang-vars)
|
||||
|
||||
;;; sclang-vars.el ends here
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
;;; sclang-widgets.el --- Widget definitions for SCLang -*- coding: utf-8; lexical-binding: t -*-
|
||||
;;; sclang-widgets.el --- Widget definitions for SCLang
|
||||
|
||||
;; Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Mario Lang <mlang@blind.guru>
|
||||
;; Keywords: comm
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,18 +21,15 @@
|
|||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;
|
||||
;; Widget definitions for SCLang
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'sclang-util)
|
||||
(require 'sclang-language)
|
||||
(require 'sclang-interp)
|
||||
|
||||
(require 'widget)
|
||||
(require 'wid-edit)
|
||||
(eval-when-compile (require 'sclang-util)
|
||||
(require 'sclang-language))
|
||||
(eval-and-compile (require 'sclang-interp))
|
||||
|
||||
(defvar sclang-widgets nil)
|
||||
(make-variable-buffer-local 'sclang-widgets)
|
||||
|
@ -48,13 +46,13 @@
|
|||
(widget-specify-insert
|
||||
(let ((from (point))
|
||||
button-begin button-end)
|
||||
(setq button-begin from)
|
||||
(setq button-begin (point))
|
||||
(insert (widget-get-indirect widget :button-prefix))
|
||||
|
||||
(princ (nth (widget-get widget :value) (widget-get widget :states)) (current-buffer))
|
||||
|
||||
(insert (widget-get-indirect widget :button-suffix))
|
||||
(setq button-end from)
|
||||
(setq button-end (point))
|
||||
|
||||
;; Specify button, and insert value.
|
||||
(and button-begin button-end
|
||||
|
@ -67,8 +65,7 @@
|
|||
(widget-put widget :to to)))
|
||||
(widget-clear-undo))
|
||||
|
||||
(defun sclang-widget-button-action (widget _event)
|
||||
"Set button action for WIDGET."
|
||||
(defun sclang-widget-button-action (widget event)
|
||||
(widget-value-set widget
|
||||
(if (>= (widget-get widget :value) (1- (length (widget-get widget :states))))
|
||||
0
|
||||
|
@ -106,7 +103,7 @@
|
|||
(let ((from (point))
|
||||
(inhibit-redisplay t)
|
||||
button-begin button-end)
|
||||
(setq button-begin from)
|
||||
(setq button-begin (point))
|
||||
(insert (widget-get-indirect widget :button-prefix))
|
||||
|
||||
(insert-char ?- (widget-get widget :size))
|
||||
|
@ -128,7 +125,6 @@
|
|||
(widget-clear-undo))
|
||||
|
||||
(defun sclang-widget-slider-value-set (widget value)
|
||||
"Set slider WIDGET to VALUE."
|
||||
(save-excursion
|
||||
(let ((inhibit-read-only t))
|
||||
(goto-char (widget-get widget :from))
|
||||
|
@ -149,7 +145,6 @@
|
|||
:dynargs #'sclang-widget-class-tree-dynargs)
|
||||
|
||||
(defun sclang-widget-class-tree-dynargs (widget)
|
||||
"Class tree WIDGET."
|
||||
(sclang-eval-sync (sclang-format "EmacsClassTree.dynargs(%o)"
|
||||
(widget-get widget :tag))))
|
||||
|
||||
|
@ -166,7 +161,5 @@
|
|||
(list (sclang-read-symbol "Class: " "Object" #'sclang-class-name-p)))
|
||||
(sclang-eval-string (format "EmacsClassBrowser(%s)" class-name)))
|
||||
|
||||
|
||||
(provide 'sclang-widgets)
|
||||
|
||||
;;; sclang-widgets.el ends here
|
||||
|
|
42
el/sclang.el
42
el/sclang.el
|
@ -1,15 +1,6 @@
|
|||
;;; sclang.el --- IDE for working with SuperCollider -*- coding: utf-8; lexical-binding: t -*-
|
||||
;;; sclang.el --- IDE for working with the SuperCollider language
|
||||
;; copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Copyright 2003 stefan kersten <steve@k-hornz.de>
|
||||
;;
|
||||
;; Author: stefan kersten
|
||||
;; Keywords: supercollider, multimedia, languages, tools
|
||||
;; Version: 1.1.0
|
||||
;; Package-Requires: ((emacs "27.1") (w3m "0.0"))
|
||||
;; URL: https://github.com/supercollider/scel
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of the
|
||||
|
@ -25,25 +16,7 @@
|
|||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
;; USA
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This package provides code for interfacing with sclang and scsynth.
|
||||
;; In order to be useful you need to install SuperCollider and the
|
||||
;; sc-el Quark. See the README or https://github.com/supercollider/scel
|
||||
;; for more information.
|
||||
;;
|
||||
;; Recent versions of w3m use tab-line which is only available after 27.1
|
||||
;; However sclang should work on Emacs 26.3 to 27.1 without the help browser.
|
||||
|
||||
;;; Credits:
|
||||
;;
|
||||
;; stefan kersten <steve@k-hornz.de>
|
||||
;; and everyone in...
|
||||
;; git shortlog -s | sort -r | cut -c8-
|
||||
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defgroup sclang nil
|
||||
"IDE for working with the SuperCollider language."
|
||||
:group 'languages)
|
||||
|
@ -61,19 +34,24 @@
|
|||
:group 'sclang)
|
||||
|
||||
(defgroup sclang-programs nil
|
||||
"Paths to programs used by `sclang-mode'."
|
||||
"Paths to programs used by sclang-mode."
|
||||
:group 'sclang-interface)
|
||||
|
||||
(defgroup sclang-options nil
|
||||
"Options for the SuperCollider process."
|
||||
:group 'sclang-interface)
|
||||
|
||||
;;;###autoload
|
||||
(defun sclang-customize ()
|
||||
"Customize sclang variables."
|
||||
(interactive)
|
||||
(customize-group 'sclang))
|
||||
|
||||
(eval-and-compile
|
||||
(let ((load-path
|
||||
(if (and (boundp 'byte-compile-dest-file)
|
||||
(stringp byte-compile-dest-file))
|
||||
(cons (file-name-directory byte-compile-dest-file) load-path)
|
||||
load-path)))
|
||||
(require 'sclang-util)
|
||||
(require 'sclang-browser)
|
||||
(require 'sclang-interp)
|
||||
|
@ -83,7 +61,7 @@
|
|||
(require 'sclang-minor-mode)
|
||||
(require 'sclang-help)
|
||||
(require 'sclang-server)
|
||||
(require 'sclang-widgets)
|
||||
(require 'sclang-widgets)))
|
||||
|
||||
(provide 'sclang)
|
||||
|
||||
|
|
1
el/test/fixtures/super-boring.scd
vendored
1
el/test/fixtures/super-boring.scd
vendored
|
@ -1 +0,0 @@
|
|||
{ WhiteNoise.ar(0.2!2); }.play;
|
|
@ -1,12 +0,0 @@
|
|||
;; -*- no-byte-compile: t; lexical-binding: t; -*-
|
||||
;;; test/sclang-mode-test.el
|
||||
|
||||
(ert-deftest sclang-autoloaded-functions ()
|
||||
"Some functions should be callable interactively without requiring them"
|
||||
(should (commandp 'sclang-start t))
|
||||
(should (commandp 'sclang-mode t)))
|
||||
|
||||
(ert-deftest sclang-major-mode-init-test ()
|
||||
"Loading a file with an scd extension should init sclang-mode"
|
||||
(find-file "fixtures/super-boring.scd")
|
||||
(should (eq 'sclang-mode major-mode)))
|
|
@ -1,5 +0,0 @@
|
|||
(
|
||||
name: "scel",
|
||||
summary: "SuperCollider/Emacs interface",
|
||||
version: "1.0.0",
|
||||
)
|
Loading…
Reference in a new issue