1 ;;; -*- Mode: Emacs-Lisp -*-
4 ;;; ILISP low level interface functions Lisp <-> Emacs.
6 ;;; This file is part of ILISP.
7 ;;; Please refer to the file COPYING for copyrights and licensing
9 ;;; Please refer to the file ACKNOWLEGDEMENTS for an (incomplete) list
10 ;;; of present and past contributors.
12 ;;; $Id: ilisp-low.el,v 1.3 2001-07-02 09:40:47 youngs Exp $
14 ;;;%Lisp mode extensions
16 (defun lisp-previous-sexp (&optional prefix)
17 "Return the previous sexp. If PREFIX is T, then prefix like ' or #'
22 (if (and (memq major-mode ilisp-modes)
24 (process-mark (get-buffer-process (current-buffer)))))
27 (or (eobp) (memq (char-after (point)) '(? ?\) ?\n ?\t))))
29 (skip-chars-backward " \t\n")
30 (let ((point (point)))
32 (skip-chars-backward "^ \t\n(\",")
33 (if (not prefix) (skip-chars-forward "#'"))
34 (buffer-substring (point) point))))
38 (defun lisp-def-name (&optional namep)
39 "Return the name of a definition assuming that you are at the start
40 of the sexp. If the form starts with DEF, the form start and the next
41 symbol will be returned. Optional NAMEP will return only the name without the defining symbol."
42 (let ((case-fold-search t))
44 ;; (( \( (def*) (( \( (setf)) | \(?)) | \(?) (symbol)
45 ;; 12 3 3 45 6 65 42 1 7 7
46 ;;0011\(22 def* 22 32 43\(54 setf54 43 \(?32 11 00 60 60
47 "\\(\\((\\(def[^ \t\n]*\\)[ \t\n]+\\(\\((\\(setf\\)[ \t\n]+\\)\\|(*\\)\\)\\|(?\\)\\([^ \t\n)]*\\)")
48 (let ((symbol (buffer-substring (match-beginning 7) (match-end 7))))
50 (concat (if (not namep)
52 (buffer-substring (match-beginning 3) (match-end 3))
55 (buffer-substring (match-beginning 6) (match-end 6))
58 (concat (if (not namep)
60 (buffer-substring (match-beginning 3)
68 (defun lisp-minus-prefix ()
69 "Set current-prefix-arg to its absolute value if numeric and return
70 T if it is a negative."
71 (if current-prefix-arg
72 (if (symbolp current-prefix-arg)
73 (progn (setq current-prefix-arg nil) t)
74 (if (< (setq current-prefix-arg
75 (prefix-numeric-value current-prefix-arg))
78 (setq current-prefix-arg (- current-prefix-arg)) t)))))
83 (defun lisp-defun-region-and-name ()
84 "Return the region of the current defun and the name starting it."
86 (let ((end (lisp-defun-end))
87 (begin (lisp-defun-begin)))
88 (list begin end (lisp-def-name)))))
91 (defun lisp-region-name (start end)
92 "Return a name for the region from START to END."
95 (if (re-search-forward "^[ \t]*[^;\n]" end t)
99 (re-search-backward "^[ \t]*[^;\n]" start 'move)
101 (skip-chars-backward " \t")
102 (setq end (min (point) end))
105 (if (= (char-after (point)) ?\()
107 (buffer-substring (point)
108 (progn (forward-sexp) (point))))))
110 (if (= (char-after (1- (point))) ?\))
113 (if (= (point) start)
115 (concat "from " from " to " (lisp-def-name))))
116 (concat "from " from " to "
117 (buffer-substring (save-excursion