[slime-cvs] CVS slime/contrib

CVS User nsiivola nsiivola at common-lisp.net
Sun May 15 17:05:22 UTC 2011


Update of /project/slime/cvsroot/slime/contrib
In directory common-lisp.net:/tmp/cvs-serv1127/contrib

Modified Files:
	ChangeLog slime-indentation.el 
Added Files:
	slime-cl-indent.el 
Log Message:
slime-indentation: switch to current GNU Emacs cl-indent.el

  The old version inlined in slime-indentation.el was from 1995.
  This should make it easier to merge our changes back into Emacs.

  To that end, don't inline the file, but keep it as slime-cl-indent.el
  instead.


--- /project/slime/cvsroot/slime/contrib/ChangeLog	2011/03/14 07:18:35	1.434
+++ /project/slime/cvsroot/slime/contrib/ChangeLog	2011/05/15 17:05:21	1.435
@@ -1,3 +1,13 @@
+2011-05-10  Nikodemus Siivola  <nikodemus at random-state.net>
+
+	* slime-cl-indent.el: New file. Copy of cl-indent.el from current
+	GNU Emacs HEAD. Replaces the ancient copy previously kept as part
+	of slime-indentation.el.
+	* slime-indentation.el (slime-handle-indentation-update): Deleted.
+	Since we now directly replace the previous version of
+	cl-indent.el, the normal version defined in slime.el works fine.
+	ALSO DELETED: the inline copy of 1995 vintage cl-indent.el.
+
 2011-03-14  Stas Boukarev  <stassats at gmail.com>
 
 	* swank-sprof.lisp (swank-sprof-get-call-graph): Don't call
--- /project/slime/cvsroot/slime/contrib/slime-indentation.el	2010/05/28 19:13:17	1.6
+++ /project/slime/cvsroot/slime/contrib/slime-indentation.el	2011/05/15 17:05:22	1.7
@@ -1,1167 +1,8 @@
 
 (define-slime-contrib slime-indentation
-  "cl-indent.el as a slime-contrib module"
-  (:swank-dependencies swank-indentation)
-  (:on-load (run-hooks 'cl-indent:load-hook)))
+  "Patched version of cl-indent.el as a slime-contrib module"
+  (:swank-dependencies swank-indentation))
 
-
-;; redefine this for cl-indent:method
-(defun slime-handle-indentation-update (alist)
-  "Update Lisp indent information for slime-indentation.el.
-
-ALIST is a list of (SYMBOL-NAME . INDENT-SPEC) of proposed indentation
-settings for `common-lisp-indent-function'. The appropriate property
-is setup, unless the user already set one explicitly."
-  (dolist (info alist)
-    (let ((symbol (intern (car info)))
-          (indent (cdr info)))
-      (define-cl-indent (cons symbol
-                              (etypecase indent
-                                (number (list indent))
-                                (cons (labels ((walk (indent)
-                                                 (etypecase indent
-                                                   ((or number null) indent)
-                                                   (cons (cons (walk (car indent))
-                                                               (walk (cdr indent))))
-                                                   (string (intern (downcase indent))))))
-                                        (list (walk indent))))
-                                (string (intern (downcase indent))))))
-      (run-hook-with-args 'slime-indentation-update-hooks symbol indent))))
-
-;; $ITI: cl-indent.el,v 1.6 1995/09/10 14:13:34 schrod Exp $
-;; ----------------------------------------------------------------------
-;; Copyright (C) 1987, 1993 Free Software Foundation, Inc.
-;; Written by Richard Mlynarik July 1987
-;; Merged with cl-indent-patches.el by Marco Baringer (2007-11-14)
-;; Documented and intensively modified by Joachim Schrod
-;; <jschrod at acm.org>, history at end.
-;; Send bug reports, gripes, patches to me.
-
-;;
-;; cl-indent.el  ---  highly configurable indentation for Lisp modes
-;;
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs 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.
-
-;; GNU Emacs 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 GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-
-;; ----------------------------------------------------------------------
-
-;; USAGE:
-
-;; This file delivers highly configurable indentation of Lisp code.
-;; Eval (cl-indent) to use this indentation for a specific file,
-;; (setq lisp-indent-function 'cl-indent:function) to use it for all
-;; Lisp files.
-
-;; The indentation for a specific form may be defined by
-;; (define-cl-indent SPEC &optional MODE-METHODS). Indentation specs
-;; for Common Lisp constructs are given already. Check the on-line
-;; documentation of this function for more information.
-
-;; Actually, the whole (`real') documentation of this source is stored
-;; as the documentation strings of respective functions. Start with
-;; #'define-cl-indent, you'll find references to all other relevant
-;; functions.
-
-;; It's also possible to specify specific indentations for a mode
-;; (e.g., some special Lisp-mode) and even specific ones for a file.
-;; File specific indentations are taken from the alist bound to
-;; cl-indent:local-methods, you can set it in your `Local Variables'
-;; section. Mode-specific methods are stored in hash tables, the mode
-;; setup must bind cl-indent:mode-methods to the name of that hash
-;; table.
-
-;; You may want to override my global indentation specs. If you load
-;; this file immediately, just issue some #'define-cl-indent calls. If
-;; you use autoload, add an appropriate hook function to
-;; 'cl-indent:load-hook.
-
-;; I'm interested in feedback on this module. Do you use it, was it
-;; useful to you? (Further development depends on the amount of people
-;; who send feedback. :-)
-;; Send email to <jschrod at acm.org>.
-
-
-
-;; ------------------------------------------------------------
-
-;;>> TODO
-
-;; Urgently need better user documentation, it's hard to get a grasp
-;; for the overall strategy how this package may be customized. One
-;; has to look at too many function documentation strings.
-
-;; Have to check if the usage of hash tables makes this package XEmacs
-;; specific. If FSF Emacs doesn't have them, they might be emulated by
-;; alists or obarrays. (I don't have FSF Emacs available, may somebody
-;; please check this, maybe even send patches?)
-
-;; Realize `parent method tables', to be able to inherit an indentation
-;; method table. `(make-method-table &optional size parent)' ?! That's
-;; needed before the CL specific indentation is moved to an own table,
-;; as some modes (e.g., stil-mode) may inherit their indentation from
-;; CL definitions.
-
-;; Common Lisp specific indentation methods should be moved to a
-;; method table, it's not good to have them globally for all kinds of
-;; Lisp modes. How about a table for Elisp indentations as well?
-
-;; special handling of keywords in forms, e.g.,
-;;
-;; :foo
-;;   bar
-;; :baz
-;;   zap
-;;
-;; &key (like &body)??
-
-;; &rest 1 in lambda-lists doesn't work, really want
-;;
-;;     (foo bar
-;;      baz)
-;;
-;; not
-;;
-;;     (foo bar
-;;          baz)
-;;
-;; Need something better than &rest for such cases. Perhaps a function
-;; that just returns normal-point? Might work...
-
-
-;;; ------------------------------------------------------------
-;;;
-;;; USER TOP-LEVEL FUNCTION
-;;;
-
-;;;###autoload
-(defun cl-indent ()
-  "Switch on Common Lisp indentation for the current buffer.
-May also be used as hook function, e.g., in lisp-mode-hook.
-If you want to do use this indentation for all Lisp buffers, incl.
-Emacs Lisp code, simply eval
-	(setq lisp-indent-function 'cl-indent:function)
-You might want to do this in some setup file, e.g., in ~/.emacs ."
-  (interactive)
-  (make-local-variable 'lisp-indent-function)
-  (setq lisp-indent-function 'cl-indent:function))
-
-
-
-;;; ------------------------------------------------------------
-;;;
-;;; Configuration:
-;;;
-
-(defvar cl-indent::maximum-backtracking 3
-  "Maximum depth to backtrack out from a sublist for structured indentation.
-If this variable is 0, no backtracking will occur and forms such as flet
-may not be correctly indented.")
-
-(defvar cl-indent:tag-indentation 1
-  "*Indentation of tags relative to containing list.
-This variable is used by the function cl-indent:tagbody.")
-
-(defvar cl-indent:tag-body-indentation 3
-  "*Indentation of non-tagged lines relative to containing list.
-This variable is used by the function cl-indent:tagbody to indent normal
-lines (lines without tags).
-The indentation is relative to the indentation of the parenthesis enclosing
-he special form.  If the value is t, the body of tags will be indented
-as a block at the same indentation as the first s-expression following
-the tag.  In this case, any forms before the first tag are indented
-by lisp-body-indent.")
-
-
-
-;;; ============================================================
-;;;
-;;; compute the indentation of the current line
-;;;
-
-
-;;;###autoload
-(defun common-lisp-indent-function (indent-point state)
-  "Old name of #'cl-indent:function."
-  (cl-indent:function indent-point state))
-
-(make-obsolete #'common-lisp-indent-function #'cl-indent:function)
-
-
-;;;###autoload
-(defun cl-indent:function (indent-point state)
-  "Compute the indentation of the current line of Common Lisp code.
-INDENT-POINT is the current point. STATE is the result of a
-#'parse-partial-sexp from the start of the current function to the
-start of the line this function was called.
-
-The indentation is determined by the expressions point is in.
-
-When this function is called, the column of point may be used as the
-normal indentation. Therefore we call this position _normal
-point_. Actually, if the first element of the current expression is a
-list, it's at the start of this element. Otherwise it's at the start
-of first expression on the same line as the last complete expression.
-
-Within a quoted list or a non-form list, all subsequent lines are
-indented to the column directly after the opening parenthesis. Quoted
-lists are those that are prefixed with ?\`, ?\', or ?\#. Note that the
-quote must be immediately in front of the opening parenthesis. I.e.,
-if you want to use automatic code indentation in a macro expansion
-formulated with a backquoted list, add a blank between the backquote
-and the expansion form.
-
-Within a list form, the indentation is determined by the indentation
-method associated to the form symbol. (See #'cl-indent::method.)
-
-** If the indentation method is nil, the form is assumed to be a
-function call, arguments are aligned beneath each other if the first
-argument was written behind the function symbol, otherwise they're
-aligned below the function symbol.
-
-** If the indentation method is a symbol, a function must be bound to
-that symbol that will compute the current indentation. Such a function
-is named an _indentation function_ and is called with 5 arguments:
-
- (1) PATH is a list of numbers, the path from the top-level form to
-     the current structural element (the first element is number 0).
-     E.g., `foo' has a path of (0 3 1) in `((a b c (d foo) f) g)'.
- (2) STATE is passed.
- (3) INDENT-POINT is passed.
- (4) SEXP-COLUMN is the column where the innermost form starts.
- (5) NORMAL-INDENT is the column of normal point.
-
-** If the indentation method is a list, this list specifies the form
-structure and the indentation of each substructure. The possible list
-structure and elements are described in #'cl-indent::form-method.
-
-** If the indentation method is the number $n$, the first $n$
-arguments are _distinguished arguments_; they are indented by 4
-spaces. Further arguments are indented by lisp-body-indent. That's
-roughly equivalent to '(4 4 ... &body)' with $n$ 4s.
-
-** Furthermore values as described for #'lisp-indent-function may be
-used for upward compatibility."
-  (let ((normal-indent (current-column)))
-    ;; Walk up list levels until we see something
-    ;;  which does special things with subforms.
-    (let ((depth 0)
-          ;; Path describes the position of point in terms of
-          ;;  list-structure with respect to contining lists.
-          ;; `foo' has a path of (0 4 1) in `((a b c (d foo) f) g)'
-          (path ())
-          ;; set non-nil when somebody works out the indentation to use
-          calculated
-          (last-point indent-point)
-          ;; the position of the open-paren of the innermost containing list
-          (containing-form-start (elt state 1))
-          ;; the column of the above
-          sexp-column)
-      ;; Move to start of innermost containing list
-      (goto-char containing-form-start)
-      (setq sexp-column (current-column))
-      ;; Look over successively less-deep containing forms
-      (while (and (not calculated)
-                  (< depth cl-indent::maximum-backtracking))
-        (let ((containing-sexp (point)))
-          (forward-char 1)
-          (parse-partial-sexp (point) indent-point 1 t)
-          ;; Move to the car of the relevant containing form
-          (let (tem function method)
-            (if (not (looking-at "\\sw\\|\\s_"))
-                ;; This form doesn't seem to start with a symbol
-                (setq function nil method nil)
-              (setq tem (point))
-              (forward-sexp 1)
-              (setq function (downcase (buffer-substring tem (point))))
-              (goto-char tem)
-              (setq tem (intern-soft function)
-                    method (get tem 'cl-indent:method))
-              (cond ((and (null method)
-                          (string-match ":[^:]+" function))
-                     ;; The pleblisp package feature
-                     (setq function (substring function
-                                               (1+ (match-beginning 0)))
-                           method (get (intern-soft function)
-                                       'cl-indent:method)))
-                    ((and (null method))
-                     ;; backwards compatibility
-                     (setq method (get tem 'lisp-indent-function)))))
-            (let ((n 0))
-              ;; How far into the containing form is the current form?
-              (if (< (point) indent-point)
-                  (while (condition-case ()
-                             (progn
-                               (forward-sexp 1)
-                               (if (>= (point) indent-point)
-                                   nil
-                                 (parse-partial-sexp (point)
-                                                     indent-point 1 t)
-                                 (setq n (1+ n))
-                                 t))
-                           (error nil))))
-              (setq path (cons n path)))
-
-            ;; backwards compatibility.
-            (cond ((null function))
-                  ((null method)
-                   (if (null (cdr path))
-                       ;; (package prefix was stripped off above)
-                       (setq method (cond ((string-match "\\`def"
-                                                         function)
-                                           '(4 (&whole 4 &rest 1) &body))
-                                          ((string-match "\\`\\(with\\|do\\)-"
-                                                         function)
-                                           '(4 &body))))))
-                  ;; backwards compatibility.  Bletch.
-                  ((eq method 'defun)
-                   (setq method '(4 (&whole 4 &rest 1) &body))))
-
-            (cond ((and (eql (char-after (1- containing-sexp)) ?\') ; patched to only do this for ' and not `.  
-                        (not (eql (char-after (- containing-sexp 2)) ?\#)))
-                   ;; No indentation for "'(...)" elements
-                   (setq calculated (1+ sexp-column)))
-                  ((eql (char-after (1- containing-sexp)) ?\#)
-                   ;; "#(...)"
-                   (setq calculated (1+ sexp-column)))
-                  ((null method))
-                  ((integerp method)
-                   ;; convenient top-level hack.
-                   ;;  (also compatible with lisp-indent-function)
-                   ;; The number specifies how many `distinguished'
-                   ;;  forms there are before the body starts
-                   ;; Equivalent to (4 4 ... &body)
-                   (setq calculated (cond ((cdr path)
-                                           normal-indent)
-                                          ((<= (car path) method)
-                                           ;; `distinguished' form
-                                           (list (+ sexp-column 4)
-                                                 containing-form-start))
-                                          ((= (car path) (1+ method))
-                                           ;; first body form.
-                                           (+ sexp-column lisp-body-indent))
-                                          (t
-                                           ;; other body form
-                                           normal-indent))))
-                  ((symbolp method)
-                   (setq calculated (funcall method
-                                             path state indent-point
-                                             sexp-column normal-indent)))
-                  (t
-                   (setq calculated (cl-indent::form-method
-                                      method path state indent-point
-                                      sexp-column normal-indent)))))
-
-          (goto-char containing-sexp)
-          (setq last-point containing-sexp)
-          (if (not calculated)
-              (condition-case ()
-                   (progn (backward-up-list 1)
-                          (setq depth (1+ depth)))
-                (error (setq depth cl-indent::maximum-backtracking))))))
-      calculated)))
-
-(defun cl-indent::normal (state)
-  "Compute normal indentation according to STATE and current position."
-  ;; Actually, the current column (i.e., the normal point) _is_ a good
-  ;; approximation for the normal indentation. But lists with a list
-  ;; as the first element make problems if an &rest or an &body method
-  ;; is in effect.
-  ;;
-  ;; There we can distinguish two cases:
-  ;;
-  ;;  1. ((foo) (bar)
-  ;;		(baz))
-  ;;  2. ((foo)
-  ;;        (bar)
-  ;;        (baz))
-  ;;
-  ;; Both are used in do result-forms, or in cond-forms. If
-  ;; #'cl-indent:function is called in the baz line, the normal point
-  ;; will be at (foo), i.e., (baz) would be aligned below (foo). (Of

[773 lines skipped]

--- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/05/15 17:05:22	NONE
+++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el	2011/05/15 17:05:22	1.1

[1466 lines skipped]




More information about the slime-cvs mailing list