Xah Lee, 2007-03, ..., 2009-04, 2009-08-27
This is the home page of xlsl-mode, a emacs mode for editing Linden Scripting Language. (If you don't know what's LSL or emacs, see LSL Tutorial or Emacs Tutorial. )
Download location: http://code.google.com/p/lsl-mode/downloads/list
You can also download ErgoEmacs at http://ErgoEmacs.org/. ErgoEmacs includes xlsl-mode, all setup and ready to use.
To install, open the file, then type “Alt+x eval-buffer”. You are done. Open any LSL source code, then type “Alt+x xlsl-mode”, you'll see the source code syntax colored.
To have emacs automatically load the file when it restarts, and automatically use the mode when opening files ending in “.lsl”, follow these steps:
Rename the file to “xlsl-mode.el”. Now, put the following lines in your emacs init file “.emacs”:
(add-to-list 'load-path "/path/to/parent/dir/") ;; make sure dir is the file's parent (autoload 'xlsl-mode "xlsl-mode" "Load xlsl-mode for editing Linden Scripting Lang." t) (add-to-list 'auto-mode-alist '("\\.lsl\\'" . xlsl-mode))
Then, restart emacs.
xlsl-mode, showing its menu. Screenshot on Mac
Opening any file ending in “.lsl” will syntax color the file.
To lookup documentation of the word under cursor, type “Ctrl+c Ctrl+r” (xlsl-lookup-lsl-ref). It'll switch you to the web browser of the function's documentation page at “lslwiki.net”.
Type “Ctrl+c Ctrl+f” (xlsl-lookup-lsl-ref2) to lookup a second reference site. By default the second site is “wiki.secondlife.com”.
Type “Alt+;” (comment-dwim) to comment or uncomment current line or text selection in a smart way.
Typing “Esc Tab” will try to complete the word to the left of cursor to one of LSL's keyword. The keyword also includes all constants (such as “ALL_SIDES”).
xlsl-mode showing command completion.
Tip: If you are looking for a function that has a name “key” in it, but you don't remember how it starts, you can type “Esc Tab” on a blank line, then it will list all lsl keywords. Then, you can switch cursor to the completion panel and do standard search. This works for any function or event handler or predefined CONSTANTS.
If your cursor is at the end of the word “llSensorRepeat”, press “Tab”, then it becomes:
llSensorRepeat(string name, key id, integer type, float range, float arc, float rate)
This works on any event handler or function name. For this feature to work, you need to intsall the package yasnippet. Then, download this template set for LSL: http://code.google.com/p/lsl-mode/downloads/list.
Once downloaded, unpack it, then move it into your yasnippet's template dir. For example, on my machine i place it in this dir: “~/Documents/emacs/yasnippet/yasnippet-0.5.9/snippets/text-mode/”. Then, pull the menu “YASnippet‣Reload all snippets” (or type “Alt+x yas/reload-all”). Then, template completion will be ready to use while you are in xlsl-mode.
The template set support all 34 events and 358 functions. If you find one missing, please post a issue at: http://code.google.com/p/lsl-mode/issues/list.
To check lsl syntax, type “Ctrl+c Ctrl+l”. This will call the emacs command xlsl-syntax-check, which in turn calls lslint.
For this feature to be available, you need to install lslint first, then set its path to the variable “xlsl-lslint-path”. For example:
(setq xlsl-lslint-path "~/bin/lslint")
“lslint” is a command line tool by “W-Hat Corporation” that checks the syntax of your lsl source code. You can download it at http://w-hat.com/lslint/ (2008-10).
For some tips on installing lslint on OS X, see: lslint_install.txt
You can have your vector types colored by their own value. This is useful when you work a lot with colors, such as particle shows, dance floors.
Colored vectors.
To color, select a region, then type “Alt+x xlsl-color-vectors-region” or pull the menu.
To view a colored vector that's too dark, just select the text.
You can convert RGB color values between hexidecimal format and LSL vector format. For example, if your cursor is on the word “#cc90ff”, then type “Ctrl+c Ctrl+g” or “Alt+x xlsl-convert-rgb”, then it'll become “<0.8000,0.5647,1.0000>”, and vice versa.
If you need a color palette, and their hex values, type “Alt+x list-colors-display”.
To copy the whole buffer, type “Ctrl+c Ctrl+c”.
xlsl-mode follows emacs's convention in choices of keyboard shortcuts. Many of them are not very convenient. If you prefer easier keys, or other conveniences, put the following code in your emacs init file “.emacs”.
(defun my-xlsl-mode-customizations () "Some customization for xlsl-mode." (define-key xlsl-mode-map (kbd "<C-tab>") 'xlsl-complete-symbol) (define-key xlsl-mode-map (kbd "<f8>") 'xlsl-copy-all) (define-key xlsl-mode-map (kbd "<f9>") 'xlsl-lookup-lsl-ref) ) (add-hook 'xlsl-mode-hook 'my-xlsl-mode-customizations)
You need to restart emacs.
For more detail about how to set emacs keyboard shortcuts in general, see: How To Define Your Own Emacs Keyboard Shortcuts.
If you would like emacs to display keyword completion suggestions using the color as shown in screenshot here, type “Alt+x customize-group Enter completion Enter”. Then, emacs will show a GUI for you to tweak. Edit the “Completions Common Part”. After you are done, click on “Save for Future Sessions” then “Finish”. Emacs will add elisp code to your emacs init file. The following is my personal settings.
(show-paren-mode 1) ; highlight matching pairs (setq show-paren-style 'expression) ; highlight all code inbetween (cua-mode 1) ; Ctrl + x c v keys for Cut Copy Paste (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(completions-common-part ((t (:inherit default :foreground "red")))) '(show-paren-match ((((class color) (background light)) (:background "azure2")))))
If you have any bug report or feature request, please post a issue at: http://code.google.com/p/lsl-mode/issues/list. Thanks. I'm Xah Toll in Second Life. There's a emacs group in Second Life. The group name is “emacs”. Please join us!
If you like this software, please support me by buying my products at: Xah Productions. Thank you.