home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
bbs
/
may94
/
util
/
edit
/
jade.lha
/
Jade
/
lisp
/
lisp-mode.jl
< prev
next >
Wrap
Lisp/Scheme
|
1994-04-16
|
3KB
|
104 lines
;;;; lisp-mode.jl -- Simple mode for editing Lisp files
;;; Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
;;; This file is part of Jade.
;;; Jade 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, or (at your option)
;;; any later version.
;;; Jade is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;; You should have received a copy of the GNU General Public License
;;; along with Jade; see the file COPYING. If not, write to
;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
(provide 'lisp-mode)
(defvar lisp-mode-tab 3)
(defvar lisp-mode-auto-indent nil)
(setq symbol-word-regexps ["[^][()?'\"#; ]" "[][()?'\"#; ]|$"])
(setq
lisp-mode-keymap (make-keylist)
lisp-mode-esc-keymap (make-keylist))
(bind-keys lisp-mode-keymap
"return" 'lisp-return
"shift-return" 'split-line
"ctrl-return" 'eval-insert-paragraph
"tab" 'lisp-tab
"meta-tab" 'goto-next-tab
"esc" '(setq next-keymap-path '(lisp-mode-esc-keymap esc-keymap)))
(bind-keys lisp-mode-esc-keymap
"ctrl-x" 'eval-print-paragraph)
(defun lisp-mode ()
(eval-hook 'lisp-mode-hook)
(setq
mode-name "lisp-mode"
keymap-path (cons lisp-mode-keymap keymap-path)
major-mode-kill 'lisp-mode-kill
screen-tab lisp-mode-tab))
(defun lisp-mode-kill ()
(setq
keymap-path (delq lisp-mode-keymap keymap-path)
mode-name nil))
(defun eval-paragraph ()
(goto (prev-paragraph))
(eval (read (current-buffer))))
(defun eval-insert-paragraph ()
(format (current-buffer) "\n%S\n\n" (eval-paragraph)))
(defun eval-print-paragraph ()
(prin1 (eval-paragraph) t))
(defun lisp-return ()
(split-line)
(when lisp-mode-auto-indent
(if (empty-line-p)
(goto (lisp-indent-pos-empty))
(set-indent-pos (lisp-indent-pos)))))
(defun lisp-tab ()
(if (empty-line-p)
(goto (lisp-indent-pos-empty (cursor-pos)))
(setq tmp (set-indent-pos (lisp-indent-pos (cursor-pos))))
(cond
((> tmp (cursor-pos))
(goto tmp))
((> (cursor-pos) (line-end))
(goto (line-end))))))
(defun lisp-indent-pos (&optional line-pos)
(setq line-pos (line-start line-pos))
(let
((ind-pos (lisp-indent-pos-empty line-pos)))
(unless (empty-line-p line-pos)
(when (regexp-match-line "^ *;;;" line-pos)
(set-pos-col ind-pos 1)))
ind-pos))
(defun lisp-indent-pos-empty (&optional line-pos)
(setq line-pos (line-start line-pos))
(let*
((anchor-pos (prev-line 1 (dup-pos line-pos))))
(while (regexp-match-line "^ *($|;)" anchor-pos)
(unless (prev-line 1 anchor-pos)
(return)))
(let
((ind-pos (indent-pos anchor-pos)))
(set-pos-line ind-pos (pos-line line-pos))
(next-tab (balance-brackets "(" ")" (copy-area anchor-pos (line-end anchor-pos))) ind-pos))))
;;; ::jade-code::
;;; (setq mode-name "generic")
;;; ::end::