File: clisp-ffi.el

package info (click to toggle)
clisp 1%3A2.44.1-4.1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 40,080 kB
  • ctags: 12,945
  • sloc: lisp: 77,546; ansic: 32,166; xml: 25,161; sh: 11,568; fortran: 7,094; cpp: 2,636; makefile: 1,234; perl: 164
file content (39 lines) | stat: -rw-r--r-- 1,642 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
;;; syntax highlighting for CLISP FFI forms
;;; Load this file from ~/.emacs or ~/.emacs.el

(font-lock-add-keywords
 'lisp-mode
 '(("(\\(def-\\(\\(call\\(\\s_\\|\\sw\\)*\\)\\|\\(c-const\\)\\|\\(c-var\\)\\|\\(c-enum\\|c-struct\\|c-type\\)\\)\\)\\>[ \t'\(]*\\(\\(\\s_\\|\\sw\\)*\\)"
    (1 font-lock-keyword-face)
    (8 (cond ((match-beginning 3) font-lock-function-name-face)
             ((match-beginning 5) font-lock-variable-name-face)
             (t font-lock-type-face)) nil t))))

;; convert between lisp-style-symbols and ICantReadThis

(defun cantread-to-lisp-1 (name)
  "Convert ICantReadThis to i-cant-read-this"
  (let ((case-fold-search nil))
    (while (string-match "\\([a-z]\\)\\([A-Z]\\)" name)
      (setq name (replace-match "\\1-\\2" t nil name))))
  (downcase name))
(defun cantread-to-lisp (&optional point)
  "Convert the symbol-at-point from ICantReadThis to i-cant-read-this"
  (interactive "d")
  (goto-char point)
  (let* ((bounds (bounds-of-thing-at-point 'symbol))
         (name (buffer-substring-no-properties (car bounds) (cdr bounds))))
    (delete-region (car bounds) (cdr bounds))
    (insert (cantread-to-lisp-1 name))))

(defun lisp-to-cantread-1 (name)
  "Convert i-cant-read-this to ICantReadThis"
  (delete ?\- (capitalize name)))
(defun lisp-to-cantread (&optional point)
  "Convert the symbol-at-point from i-cant-read-this to ICantReadThis"
  (interactive "d")
  (goto-char point)
  (let* ((bounds (bounds-of-thing-at-point 'symbol))
         (name (buffer-substring-no-properties (car bounds) (cdr bounds))))
    (delete-region (car bounds) (cdr bounds))
    (insert (lisp-to-cantread-1 name))))