From nsiivola at common-lisp.net Sun May 8 10:16:21 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 08 May 2011 06:16:21 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv9457 Modified Files: ChangeLog slime.el Log Message: slime-indentation: make custom indentation hints from CL side work right * Downcase symbol-names for convenience -- |&lambda| gets tedious pretty quick. * Intern strings in indentation specs on the Emacs side, so that complex indentation hints can work. --- /project/slime/cvsroot/slime/ChangeLog 2011/04/16 05:17:59 1.2187 +++ /project/slime/cvsroot/slime/ChangeLog 2011/05/08 10:16:20 1.2188 @@ -1,3 +1,14 @@ +2011-05-08 Nikodemus Siivola + + * slime.el (slime-intern-indentation-spec): New function. Converts + strings in an indentation spec to symbols. + (slime-handle-indentation-update): Intern the indentation spec using + slime-intern-indentation-spec, so that lisp side can pass complex indentation + specs. + * contrib/swank-indentation.lisp (application-indentation-hint): Downcase + symbol names -- any symbol in an indentation spec is pretty much guaranteed + to have a lowecase name on the Emacs side. + 2011-04-16 Stas Boukarev * slime.el (slime-load-failed-fasl): New variable. Accepts `ask', --- /project/slime/cvsroot/slime/slime.el 2011/04/16 05:17:59 1.1363 +++ /project/slime/cvsroot/slime/slime.el 2011/05/08 10:16:20 1.1364 @@ -6921,6 +6921,15 @@ (defvar slime-indentation-update-hooks) +(defun slime-intern-indentation-spec (spec) + (cond ((consp spec) + (cons (slime-intern-indentation-spec (car spec)) + (slime-intern-indentation-spec (cdr spec)))) + ((stringp spec) + (intern spec)) + (t + spec))) + (defun slime-handle-indentation-update (alist) "Update Lisp indent information. @@ -6929,7 +6938,7 @@ is setup, unless the user already set one explicitly." (dolist (info alist) (let ((symbol (intern (car info))) - (indent (cdr info))) + (indent (slime-intern-indentation-spec (cdr info)))) ;; Does the symbol have an indentation value that we set? (when (equal (get symbol 'common-lisp-indent-function) (get symbol 'slime-indent)) From nsiivola at common-lisp.net Sun May 8 10:16:24 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 08 May 2011 06:16:24 -0400 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory cl-net:/tmp/cvs-serv9457/contrib Modified Files: swank-indentation.lisp Log Message: slime-indentation: make custom indentation hints from CL side work right * Downcase symbol-names for convenience -- |&lambda| gets tedious pretty quick. * Intern strings in indentation specs on the Emacs side, so that complex indentation hints can work. --- /project/slime/cvsroot/slime/contrib/swank-indentation.lisp 2008/02/03 18:45:14 1.1 +++ /project/slime/cvsroot/slime/contrib/swank-indentation.lisp 2011/05/08 10:16:23 1.2 @@ -21,7 +21,7 @@ (etypecase indentation-spec (null nil) (number indentation-spec) - (symbol (symbol-name indentation-spec)) + (symbol (string-downcase indentation-spec)) (cons (cons (walk (car indentation-spec)) (walk (cdr indentation-spec))))))) (walk indentation)))) From nsiivola at common-lisp.net Mon May 9 10:48:11 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Mon, 09 May 2011 06:48:11 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv31571 Modified Files: ChangeLog swank-sbcl.lisp Log Message: sbcl: use WITH-COMPILATION-UNIT :SOURCE-NAMESTRING Allows recording the right source-file for C-c C-c, which in turn allows SBCL's redefinition muffling to work right. This in turn makes it sensible to turn *trap-load-time-warnings* on by default. --- /project/slime/cvsroot/slime/ChangeLog 2011/05/08 10:16:20 1.2188 +++ /project/slime/cvsroot/slime/ChangeLog 2011/05/09 10:48:10 1.2189 @@ -1,3 +1,13 @@ +2011-05-09 Nikodemus Siivola + + * swank-sbcl.lisp (swank-compile-string): Use :SOURCE-NAMESTRING + to provide the name of the actual source file, and + :ALLOW-OTHER-KEYS for compatibility with pre-1.0.48.1 versions. + This allows SBCL to get uninteresting redefinition muffling right. + (*trap-load-time-warnings*): Default to T to make the redefinition + notes more visible, especially now that redefinition muffling hides + the boring ones. + 2011-05-08 Nikodemus Siivola * slime.el (slime-intern-indentation-spec): New function. Converts --- /project/slime/cvsroot/slime/swank-sbcl.lisp 2010/10/19 11:59:25 1.279 +++ /project/slime/cvsroot/slime/swank-sbcl.lisp 2011/05/09 10:48:10 1.280 @@ -562,7 +562,7 @@ (funcall function))) -(defvar *trap-load-time-warnings* nil) +(defvar *trap-load-time-warnings* t) (defun compiler-policy (qualities) "Return compiler policy qualities present in the QUALITIES alist. @@ -638,7 +638,9 @@ (:source-plist (list :emacs-buffer buffer :emacs-filename filename :emacs-string string - :emacs-position position)) + :emacs-position position) + :source-namestring filename + :allow-other-keys t) (multiple-value-bind (output-file warningsp failurep) (compile-file temp-file-name) (declare (ignore warningsp)) From nsiivola at common-lisp.net Sun May 15 17:05:22 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:05:22 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: 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 + + * 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 * 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 -;; , 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 . - - - -;; ------------------------------------------------------------ - -;;>> 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] From nsiivola at common-lisp.net Sun May 15 17:07:04 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:07:04 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1189/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: better defmethod and lambda-list indentation From Didier Verna's patch sent to GNU Emacs mailing list. * cl-indent.el: Advertise the changes and remove obsolete TODO entries. * cl-indent.el (lisp-lambda-list-keyword-alignment): * cl-indent.el (lisp-lambda-list-keyword-parameter-indentation): * cl-indent.el (lisp-lambda-list-keyword-parameter-alignment): New customizable user options. * cl-indent.el (lisp-indent-defun-method): Improve docstring. * cl-indent.el (extended-loop-p): Fix comment. * cl-indent.el (lisp-indent-lambda-list-keywords-regexp): New variable. * cl-indent.el (lisp-indent-lambda-list): New function. * cl-indent.el (lisp-indent-259): Use it. * cl-indent.el (lisp-indent-defmethod): Support for more than one method qualifier and properly indent methods lambda-lists. * cl-indent.el: Provide a missing common-lisp-indent-function property for defgeneric. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:05:21 1.435 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:07:04 1.436 @@ -1,5 +1,27 @@ 2011-05-10 Nikodemus Siivola + slime-indentation: indentation improvements on defmethod and + lambda-lists for cl-indent.el by Didier Verna, from emacs-devel. + + * slime-cl-indent.el: Advertise the changes and remove obsolete TODO + entries. + * slime-cl-indent.el (lisp-lambda-list-keyword-alignment): + * slime-cl-indent.el (lisp-lambda-list-keyword-parameter-indentation): + * slime-cl-indent.el (lisp-lambda-list-keyword-parameter-alignment): New + customizable user options. + * slime-cl-indent.el (lisp-indent-defun-method): Improve docstring. + * slime-cl-indent.el (extended-loop-p): Fix comment. + * slime-cl-indent.el (lisp-indent-lambda-list-keywords-regexp): New + variable. + * slime-cl-indent.el (lisp-indent-lambda-list): New function. + * slime-cl-indent.el (lisp-indent-259): Use it. + * slime-cl-indent.el (lisp-indent-defmethod): Support for more than one + method qualifier and properly indent methods lambda-lists. + * slime-cl-indent.el: Provide a missing common-lisp-indent-function + property for defgeneric. + +2011-05-10 Nikodemus Siivola + * 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. --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:05:22 1.1 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:07:04 1.2 @@ -31,20 +31,6 @@ ;; ;; (setq lisp-indent-function 'common-lisp-indent-function) -;;>> TODO -;; :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 - ;;; Code: (defgroup lisp-indent nil @@ -101,9 +87,55 @@ :type 'integer :group 'lisp-indent) +(defcustom lisp-lambda-list-keyword-alignment nil + "Whether to vertically align lambda-list keywords together. +If nil (the default), keyworded lambda-list parts are aligned +with the initial mandatory arguments, like this: + +\(defun foo (arg1 arg2 &rest rest + &key key1 key2) + #|...|#) + +If non-nil, alignment is done with the first keyword +\(or falls back to the previous case), as in: + +\(defun foo (arg1 arg2 &rest rest + &key key1 key2) + #|...|#)" + :type 'boolean + :group 'lisp-indent) + +(defcustom lisp-lambda-list-keyword-parameter-indentation 2 + "Indentation of lambda list keyword parameters. +See `lisp-lambda-list-keyword-parameter-alignment' +for more information." + :type 'integer + :group 'lisp-indent) + +(defcustom lisp-lambda-list-keyword-parameter-alignment nil + "Whether to vertically align lambda-list keyword parameters together. +If nil (the default), the parameters are aligned +with their corresponding keyword, plus the value of +`lisp-lambda-list-keyword-parameter-indentation', like this: + +\(defun foo (arg1 arg2 &key key1 key2 + key3 key4) + #|...|#) + +If non-nil, alignment is done with the first parameter +\(or falls back to the previous case), as in: + +\(defun foo (arg1 arg2 &key key1 key2 + key3 key4) + #|...|#)" + :type 'boolean + :group 'lisp-indent) + (defvar lisp-indent-defun-method '(4 &lambda &body) - "Indentation for function with `common-lisp-indent-function' property `defun'.") + "Defun-like indentation method. +This applies when the value of the `common-lisp-indent-function' property +is set to `defun'.") (defun extended-loop-p (loop-start) @@ -217,8 +249,7 @@ (let ((depth 0) ;; Path describes the position of point in terms of ;; list-structure with respect to containing lists. - ;; `foo' has a path of (0 4 1) in `((a b c (d foo) f) g)' - ;; (Surely (0 3 1)?). + ;; `foo' has a path of (0 3 1) in `((a b c (d foo) f) g)'. (path ()) ;; set non-nil when somebody works out the indentation to use calculated @@ -381,10 +412,74 @@ ;; Love those free variable references!! lisp-indent-error-function 'common-lisp-indent-function m)) + +;; Lambda-list indentation is now done in LISP-INDENT-LAMBDA-LIST. +;; See also `lisp-lambda-list-keyword-alignment', +;; `lisp-lambda-list-keyword-parameter-alignment' and +;; `lisp-lambda-list-keyword-parameter-indentation' -- dvl + +(defvar lisp-indent-lambda-list-keywords-regexp + "&\\(\ +optional\\|rest\\|key\\|allow-other-keys\\|aux\\|whole\\|body\\|environment\ +\\)\\([ \t]\\|$\\)" + "Regular expression matching lambda-list keywords.") + +(defun lisp-indent-lambda-list + (indent-point sexp-column containing-form-start) + (let (limit) + (cond ((save-excursion + (goto-char indent-point) + (beginning-of-line) + (skip-chars-forward " \t") + (setq limit (point)) + (looking-at lisp-indent-lambda-list-keywords-regexp)) + ;; We're facing a lambda-list keyword. + (if lisp-lambda-list-keyword-alignment + ;; Align to the first keyword if any, or to the beginning of + ;; the lambda-list. + (save-excursion + (goto-char containing-form-start) + (save-match-data + (if (re-search-forward + lisp-indent-lambda-list-keywords-regexp + limit t) + (progn + (goto-char (match-beginning 0)) + (current-column)) + (1+ sexp-column)))) + ;; Align to the beginning of the lambda-list. + (1+ sexp-column))) + (t + ;; Otherwise, align to the first argument of the last lambda-list + ;; keyword, the keyword itself, or the beginning of the + ;; lambda-list. + (save-excursion + (goto-char indent-point) + (forward-line -1) + (end-of-line) + (save-match-data + (if (re-search-backward lisp-indent-lambda-list-keywords-regexp + containing-form-start t) + (let* ((keyword-posn + (progn + (goto-char (match-beginning 0)) + (current-column))) + (indented-keyword-posn + (+ keyword-posn + lisp-lambda-list-keyword-parameter-indentation))) + (goto-char (match-end 0)) + (skip-chars-forward " \t") + (if (eolp) + indented-keyword-posn + (if lisp-lambda-list-keyword-parameter-alignment + (current-column) + indented-keyword-posn))) + (1+ sexp-column)))))))) + ;; Blame the crufty control structure on dynamic scoping ;; -- not on me! -(defun lisp-indent-259 (method path state indent-point - sexp-column normal-indent) +(defun lisp-indent-259 + (method path state indent-point sexp-column normal-indent) (catch 'exit (let ((p path) (containing-form-start (elt state 1)) @@ -452,8 +547,14 @@ (cond ((null p) (list (+ sexp-column 4) containing-form-start)) ((null (cdr p)) - (+ sexp-column 1)) - (t normal-indent)))) + ;; Indentation within a lambda-list. -- dvl + (list (lisp-indent-lambda-list + indent-point + sexp-column + containing-form-start) + containing-form-start)) + (t + normal-indent)))) ((integerp tem) (throw 'exit (if (null p) ;not in subforms @@ -523,19 +624,26 @@ path state indent-point sexp-column normal-indent))) -(defun lisp-indent-defmethod (path state indent-point sexp-column - normal-indent) - "Indentation function defmethod." - (lisp-indent-259 (if (and (>= (car path) 3) - (null (cdr path)) - (save-excursion (goto-char (elt state 1)) - (forward-char 1) - (forward-sexp 3) - (backward-sexp) - (looking-at ":\\|\\sw+"))) - '(4 4 (&whole 4 &rest 4) &body) - (get 'defun 'common-lisp-indent-function)) - path state indent-point sexp-column normal-indent)) +;; LISP-INDENT-DEFMETHOD now supports the presence of more than one method +;; qualifier and indents the method's lambda list properly. -- dvl +(defun lisp-indent-defmethod + (path state indent-point sexp-column normal-indent) + (lisp-indent-259 + (let ((nqual 0)) + (if (and (>= (car path) 3) + (save-excursion + (beginning-of-defun) + (forward-char 1) + (forward-sexp 2) + (skip-chars-forward " \t\n") + (while (looking-at "\\sw\\|\\s_") + (incf nqual) + (forward-sexp) + (skip-chars-forward " \t\n")) + (> nqual 0))) + (append '(4) (make-list nqual 4) '(&lambda &body)) + (get 'defun 'common-lisp-indent-function))) + path state indent-point sexp-column normal-indent)) (defun lisp-indent-function-lambda-hack (path state indent-point @@ -577,6 +685,7 @@ (define-modify-macro (4 &lambda &body)) (defsetf (4 &lambda 4 &body)) (defun (4 &lambda &body)) + (defgeneric (4 &lambda &body)) (define-setf-method . defun) (define-setf-expander . defun) (defmacro . defun) From nsiivola at common-lisp.net Sun May 15 17:07:47 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:07:47 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1237/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: don't take `default' for a tentative defun cl-indent.el assumed that anything starting with `def' is a defining form, which is mostly a good assumption, but breaks horribly with `default', which isn't even all that rare. This patch fixes indentation of defclass :default-initargs, among other things. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:07:04 1.436 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:07:47 1.437 @@ -1,5 +1,11 @@ 2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (common-lisp-indent-function-1): Don't take + `default' for a tentative defun, unlike anything else starting + with `def'. + +2011-05-10 Nikodemus Siivola + slime-indentation: indentation improvements on defmethod and lambda-lists for cl-indent.el by Didier Verna, from emacs-devel. --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:07:04 1.2 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:07:47 1.3 @@ -313,8 +313,8 @@ ((null method) (when (null (cdr path)) ;; (package prefix was stripped off above) - (cond ((string-match "\\`def" - function) + (cond ((and (string-match "\\`def" function) + (not (string-match "\\`default" function))) (setq tentative-defun t)) ((string-match (eval-when-compile From nsiivola at common-lisp.net Sun May 15 17:09:16 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:09:16 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1291/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: fix handling of (... &rest not-a-cons) indentation specs Previously if the expression following &rest in a cl-indent indentation spec was not a cons, all but the first form of the tail got normal indentation instead of the specified one, causing eg. PROG to be indented wrong. As far as I can tell the first leg of the COND that this patch deletes was never correct. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:07:47 1.437 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:09:16 1.438 @@ -1,5 +1,11 @@ 2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (lisp-indent-259): Don't throw to exit with + normal-indent if processing a tail that isn't a cons. Doing that + breaks (... &rest foo) specs. + +2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (common-lisp-indent-function-1): Don't take `default' for a tentative defun, unlike anything else starting with `def'. --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:07:47 1.3 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:09:16 1.4 @@ -515,10 +515,7 @@ (null (cdr method))) (lisp-indent-report-bad-format method)) - (cond ((and tail (not (consp tem))) - ;; indent tail of &rest in same way as first elt of rest - (throw 'exit normal-indent)) - ((eq tem '&body) + (cond ((eq tem '&body) ;; &body means (&rest ) (throw 'exit (if (and (= n 0) ;first body form From nsiivola at common-lisp.net Sun May 15 17:10:13 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:10:13 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1348/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: fix indentation inside ,(...) and ,@(...) For some unfathomable reason indetation logic was explicitly turned off for these -- but since these sections are evaluated, they should clearly be indented as code. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:09:16 1.438 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:10:13 1.439 @@ -1,5 +1,12 @@ 2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (common-lisp-indent-function-1): Remove + bogus special casing of ,(...) and ,@(...). Even if backquote + was being indented as data, the escaped forms are evaluated, + and hence should be indented as lisp code. + +2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (lisp-indent-259): Don't throw to exit with normal-indent if processing a tail that isn't a cons. Doing that breaks (... &rest foo) specs. --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:09:16 1.4 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:10:13 1.5 @@ -333,11 +333,6 @@ (not (eq (char-after (- containing-sexp 2)) ?\#))) ;; No indentation for "'(...)" elements (setq calculated (1+ sexp-column))) - ((or (eq (char-after (1- containing-sexp)) ?\,) - (and (eq (char-after (1- containing-sexp)) ?\@) - (eq (char-after (- containing-sexp 2)) ?\,))) - ;; ",(...)" or ",@(...)" - (setq calculated normal-indent)) ((eq (char-after (1- containing-sexp)) ?\#) ;; "#(...)" (setq calculated (1+ sexp-column))) From nsiivola at common-lisp.net Sun May 15 17:11:25 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:11:25 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1411/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: make indent-sexp work properly for loop indentation Prior to this indent-sexp didn't indent loops properly, but simply aligned all lines of the loop body. common-lisp-loop-part-indentation needs to return a list of ( ) to let calculate-lisp-indent know that the following lines might have a different indentation. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:10:13 1.439 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:11:25 1.440 @@ -1,5 +1,13 @@ 2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (common-lisp-loop-part-indentation): Return + ( ) instead of for non-simple loops. + This lets calculate-lisp-indent know that the following lines of + the loop might be indented differently -- fixing indent-sexp for + loops. + +2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (common-lisp-indent-function-1): Remove bogus special casing of ,(...) and ,@(...). Even if backquote was being indented as data, the escaped forms are evaluated, --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:10:13 1.5 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:11:25 1.6 @@ -149,20 +149,20 @@ (looking-at "\\sw")) (error t))) - (defun common-lisp-loop-part-indentation (indent-point state) "Compute the indentation of loop form constituents." - (let* ((loop-indentation (save-excursion - (goto-char (elt state 1)) + (let* ((loop-start (elt state 1)) + (loop-indentation (save-excursion + (goto-char loop-start) (current-column)))) (goto-char indent-point) (beginning-of-line) - (cond ((not (extended-loop-p (elt state 1))) - (+ loop-indentation lisp-simple-loop-indentation)) - ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)") - (+ loop-indentation lisp-loop-keyword-indentation)) - (t - (+ loop-indentation lisp-loop-forms-indentation))))) + (cond ((not (extended-loop-p loop-start)) + (+ loop-indentation lisp-simple-loop-indentation)) + ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)") + (list (+ loop-indentation lisp-loop-keyword-indentation) loop-start)) + (t + (list (+ loop-indentation lisp-loop-forms-indentation) loop-start))))) ;;;###autoload From nsiivola at common-lisp.net Sun May 15 17:13:28 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:13:28 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1475/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: handle both split and unsplit loops A "split" loop is one where the body does not start on the same line as the opening parenthesis: (loop for x in ...) Replace extended-loop-p with common-lisp-loop-type, returning either 'simple, 'extended, or 'extended/split. Adjust indentation in common-lisp-loop-part-indentation based on that. Since previously loop customization variables were mostly for picking either the split or the unsplit style, remove them except for lisp-simple-loop-indentation: old settings for the others would not produce the intended results anymore. Now both (loop for x in list1 for y in ...) and (loop for x in list1 for y in ...) styles work out of the box. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:11:25 1.440 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:13:28 1.441 @@ -1,5 +1,17 @@ 2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (common-lisp-loop-type): New function, + replaces extended-loop-p. + (common-lisp-loop-part-indentation): Use common-lisp-loop-type to + decide how to indent, supporting both "split" and "unsplit" styles. + (lisp-loop-keyword-indentation, lisp-loop-forms-indentation): + Deleted: pointless now that both split and unsplit styles work + automatically. + (extended-loop-p): Deleted. + (lisp-simple-loop-indentation): Change default to 2. + +2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (common-lisp-loop-part-indentation): Return ( ) instead of for non-simple loops. This lets calculate-lisp-indent know that the following lines of --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:11:25 1.6 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:13:28 1.7 @@ -69,20 +69,7 @@ :type 'boolean :group 'lisp-indent) - -(defcustom lisp-loop-keyword-indentation 3 - "Indentation of loop keywords in extended loop forms." - :type 'integer - :group 'lisp-indent) - - -(defcustom lisp-loop-forms-indentation 5 - "Indentation of forms in extended loop forms." - :type 'integer - :group 'lisp-indent) - - -(defcustom lisp-simple-loop-indentation 3 +(defcustom lisp-simple-loop-indentation 2 "Indentation of forms in simple loop forms." :type 'integer :group 'lisp-indent) @@ -137,32 +124,43 @@ This applies when the value of the `common-lisp-indent-function' property is set to `defun'.") - -(defun extended-loop-p (loop-start) - "True if an extended loop form starts at LOOP-START." +(defun common-lisp-loop-type (loop-start) + "Returns the type of the loop form at LOOP-START. +Possible types are SIMPLE, EXTENDED, and EXTENDED/SPLIT. +EXTENDED/SPLIT refers to extended loops whose body does +not start on the same line as the opening parenthesis of +the loop." (condition-case () (save-excursion - (goto-char loop-start) - (forward-char 1) - (forward-sexp 2) - (backward-sexp 1) - (looking-at "\\sw")) - (error t))) + (goto-char loop-start) + (let ((line (line-number-at-pos))) + (forward-char 1) + (forward-sexp 2) + (backward-sexp 1) + (if (looking-at "\\sw") + (if (= line (line-number-at-pos)) + 'extended + 'extended/split) + 'simple))) + (error 'simple))) (defun common-lisp-loop-part-indentation (indent-point state) "Compute the indentation of loop form constituents." (let* ((loop-start (elt state 1)) + (type (common-lisp-loop-type loop-start)) (loop-indentation (save-excursion (goto-char loop-start) - (current-column)))) + (if (eq 'extended/split type) + (- (current-column) 4) + (current-column))))) (goto-char indent-point) (beginning-of-line) - (cond ((not (extended-loop-p loop-start)) + (cond ((eq 'simple type) (+ loop-indentation lisp-simple-loop-indentation)) ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)") - (list (+ loop-indentation lisp-loop-keyword-indentation) loop-start)) + (list (+ loop-indentation 6) loop-start)) (t - (list (+ loop-indentation lisp-loop-forms-indentation) loop-start))))) + (list (+ loop-indentation 9) loop-start))))) ;;;###autoload From nsiivola at common-lisp.net Sun May 15 17:16:24 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:16:24 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1555/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: subclause aware loop indentation Adapted from cl-indent-patches.el. Setting lisp-loop-indent-subclauses to nil causes old indentation method to be used. Default is t. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:13:28 1.441 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:16:24 1.442 @@ -1,5 +1,29 @@ 2011-05-10 Nikodemus Siivola + * slime-cl-indent.el: subclause aware loop indentation, adapted from + cl-indent-patches.el. + (lisp-indent-loop-subclauses): New customization. + (common-lisp-indent-function): Trampoline directly to + common-lisp-indent-function-1 -- loop indentation is now picked up + by the normal machinery instead of being special cased here. + (lisp-indent-loop): New function. Chooses between the old naive + indentation and new subclause-aware version based on + lisp-indent-loop-subclauses. + (common-lisp-indent-body-introducing-loop-macro-keyword): + (common-lisp-indent-prefix-loop-macro-keyword): + (common-lisp-indent-clause-joining-loop-macro-keyword): + (common-lisp-indent-indented-loop-macro-keyword): + (common-lisp-indent-indenting-loop-macro-keyword): + (common-lisp-indent-loop-macro-else-keyword): Regular expressions + for identifying loop parts. + (common-lisp-indent-parse-state-depth): + (common-lisp-indent-parse-state-start): + (common-lisp-indent-parse-state-prev): Parse state accessors. + (common-lisp-indent-loop-macro-1): Subclause aware loop indentation. + (common-lisp-indent-loop-advance-past-keyword-on-line): Utility used by the above. + +2011-05-10 Nikodemus Siivola + * slime-cl-indent.el (common-lisp-loop-type): New function, replaces extended-loop-p. (common-lisp-loop-part-indentation): Use common-lisp-loop-type to --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:13:28 1.7 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:16:24 1.8 @@ -69,6 +69,11 @@ :type 'boolean :group 'lisp-indent) +(defcustom lisp-loop-indent-subclauses t + "Whether or not to indent loop subclauses." + :type 'boolean + :group 'lisp-indent) + (defcustom lisp-simple-loop-indentation 2 "Indentation of forms in simple loop forms." :type 'integer @@ -122,7 +127,9 @@ (defvar lisp-indent-defun-method '(4 &lambda &body) "Defun-like indentation method. This applies when the value of the `common-lisp-indent-function' property -is set to `defun'.") +is set to `defun'.") + +;;;; LOOP indentation, the simple version (defun common-lisp-loop-type (loop-start) "Returns the type of the loop form at LOOP-START. @@ -162,7 +169,6 @@ (t (list (+ loop-indentation 9) loop-start))))) - ;;;###autoload (defun common-lisp-indent-function (indent-point state) "Function to indent the arguments of a Lisp function call. @@ -234,10 +240,7 @@ * arguments after the first should be lists, and there may be any number of them. The first list element has an offset of 2, all the rest have an offset of 2+1=3." - (if (save-excursion (goto-char (elt state 1)) - (looking-at "([Ll][Oo][Oo][Pp]")) - (common-lisp-loop-part-indentation indent-point state) - (common-lisp-indent-function-1 indent-point state))) + (common-lisp-indent-function-1 indent-point state)) (defun common-lisp-indent-function-1 (indent-point state) @@ -654,8 +657,204 @@ (+ sexp-column lisp-body-indent))) (error (+ sexp-column lisp-body-indent))))) +(defun lisp-indent-loop (path state indent-point sexp-column normal-indent) + (if lisp-loop-indent-subclauses + (list (common-lisp-indent-loop-macro-1 state indent-point) + (common-lisp-indent-parse-state-start state)) + (common-lisp-loop-part-indentation indent-point state))) + +;;;; LOOP indentation, the complex version -- handles subclause indentation + +;; Regexps matching various varieties of loop macro keyword ... +(defvar common-lisp-indent-body-introducing-loop-macro-keyword + "do\\|finally\\|initially" + "Regexp matching loop macro keywords which introduce body-forms.") + +;; This is so "and when" and "else when" get handled right +;; (not to mention "else do" !!!) +(defvar common-lisp-indent-prefix-loop-macro-keyword + "and\\|else" + "Regexp matching loop macro keywords which are prefixes.") + +(defvar common-lisp-indent-clause-joining-loop-macro-keyword + "and" + "Regexp matching 'and', and anything else there ever comes to be like it.") + +;; This is handled right, but it's incomplete ... +;; (It could probably get arbitrarily long if I did *every* iteration-path) +(defvar common-lisp-indent-indented-loop-macro-keyword + "into\\|by\\|upto\\|downto\\|above\\|below\\|on\\|being\\|=\\|first\\|then\\|from\\|to" + "Regexp matching keywords introducing loop subclauses. +Always indented two.") + +(defvar common-lisp-indent-indenting-loop-macro-keyword + "when\\|unless\\|if" + "Regexp matching keywords introducing conditional clauses. +Cause subsequent clauses to be indented.") + +(defvar common-lisp-indent-loop-macro-else-keyword "else") + +;;; Attempt to indent the loop macro ... + +(defun common-lisp-indent-parse-state-depth (parse-state) + (car parse-state)) + +(defun common-lisp-indent-parse-state-start (parse-state) + (car (cdr parse-state))) + +(defun common-lisp-indent-parse-state-prev (parse-state) + (car (cdr (cdr parse-state)))) + +(defun common-lisp-indent-loop-macro-1 (parse-state indent-point) + (catch 'return-indentation + (save-excursion + ;; Find first clause of loop macro, and use it to establish + ;; base column for indentation + (goto-char (common-lisp-indent-parse-state-start parse-state)) + (let ((loop-start-column (current-column))) + (common-lisp-indent-loop-advance-past-keyword-on-line) + + (when (eolp) + (forward-line 1) + (end-of-line) + ;; If indenting first line after "(loop " + ;; cop out ... + (if (<= indent-point (point)) + (throw 'return-indentation (+ 2 loop-start-column))) + (back-to-indentation)) + + (let* ((case-fold-search t) + (loop-macro-first-clause (point)) + (previous-expression-start (common-lisp-indent-parse-state-prev parse-state)) + (default-value (current-column)) + (loop-body-p nil) + (loop-body-indentation nil) + (indented-clause-indentation (+ 2 default-value))) + ;; Determine context of this loop clause, starting with the + ;; expression immediately preceding the line we're trying to indent + (goto-char previous-expression-start) + + ;; Handle a body-introducing-clause which ends a line specially. + (if (looking-at common-lisp-indent-body-introducing-loop-macro-keyword) + (let ((keyword-position (current-column))) + (setq loop-body-p t) + (setq loop-body-indentation + (if (common-lisp-indent-loop-advance-past-keyword-on-line) + (current-column) + (back-to-indentation) + (if (/= (current-column) keyword-position) + (+ 2 (current-column)) + (+ keyword-position 3))))) + + (back-to-indentation) + (if (< (point) loop-macro-first-clause) + (goto-char loop-macro-first-clause)) + ;; If there's an "and" or "else," advance over it. + ;; If it is alone on the line, the next "cond" will treat it + ;; as if there were a "when" and indent under it ... + (let ((exit nil)) + (while (and (null exit) + (looking-at common-lisp-indent-prefix-loop-macro-keyword)) + (if (null (common-lisp-indent-loop-advance-past-keyword-on-line)) + (progn (setq exit t) + (back-to-indentation))))) + + ;; Found start of loop clause preceding the one we're trying to indent. + ;; Glean context ... + (cond + ((looking-at "(") + ;; We're in the middle of a clause body ... + (setq loop-body-p t) + (setq loop-body-indentation (current-column))) + ((looking-at common-lisp-indent-body-introducing-loop-macro-keyword) + (setq loop-body-p t) + ;; Know there's something else on the line (or would + ;; have been caught above) + (common-lisp-indent-loop-advance-past-keyword-on-line) + (setq loop-body-indentation (current-column))) + (t + (setq loop-body-p nil) + (if (or (looking-at common-lisp-indent-indenting-loop-macro-keyword) + (looking-at common-lisp-indent-prefix-loop-macro-keyword)) + (setq default-value (+ 2 (current-column)))) + (setq indented-clause-indentation (+ 2 (current-column))) + ;; We still need loop-body-indentation for "syntax errors" ... + (goto-char previous-expression-start) + (setq loop-body-indentation (current-column))))) + + ;; Go to first non-blank character of the line we're trying to indent. + ;; (if none, wind up poised on the new-line ...) + (goto-char indent-point) + (back-to-indentation) + (cond + ((looking-at "(") + ;; Clause body ... + loop-body-indentation) + ((or (eolp) (looking-at ";")) + ;; Blank line. If body-p, indent as body, else indent as + ;; vanilla clause. + (if loop-body-p + loop-body-indentation + default-value)) + ((looking-at common-lisp-indent-indented-loop-macro-keyword) + indented-clause-indentation) + ((looking-at common-lisp-indent-clause-joining-loop-macro-keyword) + (let ((stolen-indent-column nil)) + (forward-line -1) + (while (and (null stolen-indent-column) + (> (point) loop-macro-first-clause)) + (back-to-indentation) + (if (and (< (current-column) loop-body-indentation) + (looking-at "\\sw")) + (progn + (if (looking-at common-lisp-indent-loop-macro-else-keyword) + (common-lisp-indent-loop-advance-past-keyword-on-line)) + (setq stolen-indent-column + (current-column))) + (forward-line -1))) + (if stolen-indent-column + stolen-indent-column + default-value))) + (t default-value))))))) + +(defun common-lisp-indent-loop-advance-past-keyword-on-line () + (forward-word 1) + (while (and (looking-at "\\s-") (not (eolp))) + (forward-char 1)) + (if (eolp) + nil + (current-column))) + +;; Test-case for subclause indentation +'(loop for i from 0 below 2 + for j from 0 below 2 + when foo + do (fubar) + (bar) + (moo) + and collect cash + into honduras + else do ;; this is the body of the first else + ;; the body is ... + (indented to the above comment) + (ZMACS gets this wrong) + and do this + and do that + and when foo + do the-other + and cry + when this-is-a-short-condition do + (body code of the when) + when here's something I used to botch do (here is a body) + (rest of body indented same) + do + (exdented loop body) + (I'm not sure I like this but it's compatible) + when funny-predicate do ;; Here's a comment + (body filled to comment)) +;;;; Indentation specs for standard symbols, and a few semistandard ones. (let ((l '((block 1) (case (4 &rest (&whole 2 &rest 1))) (ccase . case) @@ -710,7 +909,7 @@ (handler-bind . let) (restart-bind . let) (locally 1) - ;(loop lisp-indent-loop) + (loop lisp-indent-loop) (:method (&lambda &body)) ; in `defgeneric' (multiple-value-bind ((&whole 6 &rest 1) 4 &body)) (multiple-value-call (4 &body)) From nsiivola at common-lisp.net Sun May 15 17:17:23 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:17:23 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1608/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: whitespace changes Delete trailing whitespace, untabify, and fix part of the indentation. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:16:24 1.442 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:17:23 1.443 @@ -1,5 +1,9 @@ 2011-05-10 Nikodemus Siivola + * slime-cl-indent.el: whitespace cleanup. + +2011-05-10 Nikodemus Siivola + * slime-cl-indent.el: subclause aware loop indentation, adapted from cl-indent-patches.el. (lisp-indent-loop-subclauses): New customization. --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:16:24 1.8 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:17:23 1.9 @@ -107,7 +107,7 @@ (defcustom lisp-lambda-list-keyword-parameter-alignment nil "Whether to vertically align lambda-list keyword parameters together. If nil (the default), the parameters are aligned -with their corresponding keyword, plus the value of +with their corresponding keyword, plus the value of `lisp-lambda-list-keyword-parameter-indentation', like this: \(defun foo (arg1 arg2 &key key1 key2 @@ -156,8 +156,8 @@ (let* ((loop-start (elt state 1)) (type (common-lisp-loop-type loop-start)) (loop-indentation (save-excursion - (goto-char loop-start) - (if (eq 'extended/split type) + (goto-char loop-start) + (if (eq 'extended/split type) (- (current-column) 4) (current-column))))) (goto-char indent-point) @@ -254,10 +254,10 @@ (path ()) ;; set non-nil when somebody works out the indentation to use calculated - ;; If non-nil, this is an indentation to use - ;; if nothing else specifies it more firmly. - tentative-calculated - (last-point indent-point) + ;; If non-nil, this is an indentation to use + ;; if nothing else specifies it more firmly. + tentative-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 @@ -313,24 +313,24 @@ (cond ((null function)) ((null method) (when (null (cdr path)) - ;; (package prefix was stripped off above) - (cond ((and (string-match "\\`def" function) + ;; (package prefix was stripped off above) + (cond ((and (string-match "\\`def" function) (not (string-match "\\`default" function))) - (setq tentative-defun t)) - ((string-match + (setq tentative-defun t)) + ((string-match (eval-when-compile (concat "\\`\\(" (regexp-opt '("with" "without" "do")) "\\)-")) function) - (setq method '(&lambda &body)))))) + (setq method '(&lambda &body)))))) ;; backwards compatibility. Bletch. ((eq method 'defun) (setq method lisp-indent-defun-method))) (cond ((and (or (eq (char-after (1- containing-sexp)) ?\') - (and (not lisp-backquote-indentation) - (eq (char-after (1- containing-sexp)) ?\`))) + (and (not lisp-backquote-indentation) + (eq (char-after (1- containing-sexp)) ?\`))) (not (eq (char-after (- containing-sexp 2)) ?\#))) ;; No indentation for "'(...)" elements (setq calculated (1+ sexp-column))) @@ -338,25 +338,25 @@ ;; "#(...)" (setq calculated (1+ sexp-column))) ((null method) - ;; If this looks like a call to a `def...' form, - ;; think about indenting it as one, but do it - ;; tentatively for cases like - ;; (flet ((defunp () - ;; nil))) - ;; Set both normal-indent and tentative-calculated. - ;; The latter ensures this value gets used - ;; if there are no relevant containing constructs. - ;; The former ensures this value gets used - ;; if there is a relevant containing construct - ;; but we are nested within the structure levels - ;; that it specifies indentation for. - (if tentative-defun - (setq tentative-calculated - (common-lisp-indent-call-method - function lisp-indent-defun-method - path state indent-point - sexp-column normal-indent) - normal-indent tentative-calculated))) + ;; If this looks like a call to a `def...' form, + ;; think about indenting it as one, but do it + ;; tentatively for cases like + ;; (flet ((defunp () + ;; nil))) + ;; Set both normal-indent and tentative-calculated. + ;; The latter ensures this value gets used + ;; if there are no relevant containing constructs. + ;; The former ensures this value gets used + ;; if there is a relevant containing construct + ;; but we are nested within the structure levels + ;; that it specifies indentation for. + (if tentative-defun + (setq tentative-calculated + (common-lisp-indent-call-method + function lisp-indent-defun-method + path state indent-point + sexp-column normal-indent) + normal-indent tentative-calculated))) ((integerp method) ;; convenient top-level hack. ;; (also compatible with lisp-indent-function) @@ -375,30 +375,30 @@ (t ;; other body form normal-indent)))) - (t - (setq calculated - (common-lisp-indent-call-method - function method path state indent-point - sexp-column normal-indent))))) + (t + (setq calculated + (common-lisp-indent-call-method + function method path state indent-point + sexp-column normal-indent))))) (goto-char containing-sexp) (setq last-point containing-sexp) (unless calculated - (condition-case () - (progn (backward-up-list 1) - (setq depth (1+ depth))) - (error (setq depth lisp-indent-maximum-backtracking)))))) + (condition-case () + (progn (backward-up-list 1) + (setq depth (1+ depth))) + (error (setq depth lisp-indent-maximum-backtracking)))))) (or calculated tentative-calculated)))) (defun common-lisp-indent-call-method (function method path state indent-point - sexp-column normal-indent) + sexp-column normal-indent) (let ((lisp-indent-error-function function)) (if (symbolp method) - (funcall method - path state indent-point - sexp-column normal-indent) + (funcall method + path state indent-point + sexp-column normal-indent) (lisp-indent-259 method path state indent-point - sexp-column normal-indent)))) + sexp-column normal-indent)))) ;; Dynamically bound in common-lisp-indent-call-method. (defvar lisp-indent-error-function) @@ -412,7 +412,7 @@ ;; Lambda-list indentation is now done in LISP-INDENT-LAMBDA-LIST. ;; See also `lisp-lambda-list-keyword-alignment', ;; `lisp-lambda-list-keyword-parameter-alignment' and -;; `lisp-lambda-list-keyword-parameter-indentation' -- dvl +;; `lisp-lambda-list-keyword-parameter-indentation' -- dvl (defvar lisp-indent-lambda-list-keywords-regexp "&\\(\ @@ -424,57 +424,57 @@ (indent-point sexp-column containing-form-start) (let (limit) (cond ((save-excursion - (goto-char indent-point) - (beginning-of-line) - (skip-chars-forward " \t") - (setq limit (point)) - (looking-at lisp-indent-lambda-list-keywords-regexp)) - ;; We're facing a lambda-list keyword. - (if lisp-lambda-list-keyword-alignment - ;; Align to the first keyword if any, or to the beginning of - ;; the lambda-list. - (save-excursion - (goto-char containing-form-start) - (save-match-data - (if (re-search-forward - lisp-indent-lambda-list-keywords-regexp - limit t) - (progn - (goto-char (match-beginning 0)) - (current-column)) - (1+ sexp-column)))) - ;; Align to the beginning of the lambda-list. - (1+ sexp-column))) - (t - ;; Otherwise, align to the first argument of the last lambda-list - ;; keyword, the keyword itself, or the beginning of the - ;; lambda-list. - (save-excursion - (goto-char indent-point) - (forward-line -1) - (end-of-line) - (save-match-data - (if (re-search-backward lisp-indent-lambda-list-keywords-regexp - containing-form-start t) - (let* ((keyword-posn - (progn - (goto-char (match-beginning 0)) - (current-column))) - (indented-keyword-posn - (+ keyword-posn - lisp-lambda-list-keyword-parameter-indentation))) - (goto-char (match-end 0)) - (skip-chars-forward " \t") - (if (eolp) - indented-keyword-posn - (if lisp-lambda-list-keyword-parameter-alignment - (current-column) - indented-keyword-posn))) - (1+ sexp-column)))))))) + (goto-char indent-point) + (beginning-of-line) + (skip-chars-forward " \t") + (setq limit (point)) + (looking-at lisp-indent-lambda-list-keywords-regexp)) + ;; We're facing a lambda-list keyword. + (if lisp-lambda-list-keyword-alignment + ;; Align to the first keyword if any, or to the beginning of + ;; the lambda-list. + (save-excursion + (goto-char containing-form-start) + (save-match-data + (if (re-search-forward + lisp-indent-lambda-list-keywords-regexp + limit t) + (progn + (goto-char (match-beginning 0)) + (current-column)) + (1+ sexp-column)))) + ;; Align to the beginning of the lambda-list. + (1+ sexp-column))) + (t + ;; Otherwise, align to the first argument of the last lambda-list + ;; keyword, the keyword itself, or the beginning of the + ;; lambda-list. + (save-excursion + (goto-char indent-point) + (forward-line -1) + (end-of-line) + (save-match-data + (if (re-search-backward lisp-indent-lambda-list-keywords-regexp + containing-form-start t) + (let* ((keyword-posn + (progn + (goto-char (match-beginning 0)) + (current-column))) + (indented-keyword-posn + (+ keyword-posn + lisp-lambda-list-keyword-parameter-indentation))) + (goto-char (match-end 0)) + (skip-chars-forward " \t") + (if (eolp) + indented-keyword-posn + (if lisp-lambda-list-keyword-parameter-alignment + (current-column) + indented-keyword-posn))) + (1+ sexp-column)))))))) ;; Blame the crufty control structure on dynamic scoping ;; -- not on me! -(defun lisp-indent-259 +(defun lisp-indent-259 (method path state indent-point sexp-column normal-indent) (catch 'exit (let ((p path) @@ -532,22 +532,22 @@ ;; Too few elements in pattern. (throw 'exit normal-indent))) ((eq tem 'nil) - (throw 'exit (if (consp normal-indent) - normal-indent - (list normal-indent containing-form-start)))) - ((eq tem '&lambda) - (throw 'exit - (cond ((null p) - (list (+ sexp-column 4) containing-form-start)) - ((null (cdr p)) - ;; Indentation within a lambda-list. -- dvl - (list (lisp-indent-lambda-list - indent-point - sexp-column - containing-form-start) - containing-form-start)) - (t - normal-indent)))) + (throw 'exit (if (consp normal-indent) + normal-indent + (list normal-indent containing-form-start)))) + ((eq tem '&lambda) + (throw 'exit + (cond ((null p) + (list (+ sexp-column 4) containing-form-start)) + ((null (cdr p)) + ;; Indentation within a lambda-list. -- dvl + (list (lisp-indent-lambda-list + indent-point + sexp-column + containing-form-start) + containing-form-start)) + (t + normal-indent)))) ((integerp tem) (throw 'exit (if (null p) ;not in subforms @@ -561,9 +561,9 @@ ;; must be a destructing frob (if (not (null p)) ;; descend - (setq method (cddr tem) + (setq method (cddr tem) n nil) - (setq tem (cadr tem)) + (setq tem (cadr tem)) (throw 'exit (cond (tail normal-indent) @@ -624,18 +624,18 @@ (lisp-indent-259 (let ((nqual 0)) (if (and (>= (car path) 3) - (save-excursion - (beginning-of-defun) - (forward-char 1) - (forward-sexp 2) - (skip-chars-forward " \t\n") - (while (looking-at "\\sw\\|\\s_") - (incf nqual) - (forward-sexp) - (skip-chars-forward " \t\n")) - (> nqual 0))) + (save-excursion + (beginning-of-defun) + (forward-char 1) + (forward-sexp 2) + (skip-chars-forward " \t\n") + (while (looking-at "\\sw\\|\\s_") + (incf nqual) + (forward-sexp) + (skip-chars-forward " \t\n")) + (> nqual 0))) (append '(4) (make-list nqual 4) '(&lambda &body)) - (get 'defun 'common-lisp-indent-function))) + (get 'defun 'common-lisp-indent-function))) path state indent-point sexp-column normal-indent)) @@ -712,9 +712,9 @@ ;; base column for indentation (goto-char (common-lisp-indent-parse-state-start parse-state)) (let ((loop-start-column (current-column))) - (common-lisp-indent-loop-advance-past-keyword-on-line) + (common-lisp-indent-loop-advance-past-keyword-on-line) - (when (eolp) + (when (eolp) (forward-line 1) (end-of-line) ;; If indenting first line after "(loop " @@ -723,45 +723,45 @@ (throw 'return-indentation (+ 2 loop-start-column))) (back-to-indentation)) - (let* ((case-fold-search t) - (loop-macro-first-clause (point)) - (previous-expression-start (common-lisp-indent-parse-state-prev parse-state)) - (default-value (current-column)) - (loop-body-p nil) - (loop-body-indentation nil) - (indented-clause-indentation (+ 2 default-value))) - ;; Determine context of this loop clause, starting with the - ;; expression immediately preceding the line we're trying to indent - (goto-char previous-expression-start) - - ;; Handle a body-introducing-clause which ends a line specially. - (if (looking-at common-lisp-indent-body-introducing-loop-macro-keyword) - (let ((keyword-position (current-column))) - (setq loop-body-p t) - (setq loop-body-indentation - (if (common-lisp-indent-loop-advance-past-keyword-on-line) - (current-column) - (back-to-indentation) - (if (/= (current-column) keyword-position) - (+ 2 (current-column)) + (let* ((case-fold-search t) + (loop-macro-first-clause (point)) + (previous-expression-start (common-lisp-indent-parse-state-prev parse-state)) + (default-value (current-column)) + (loop-body-p nil) + (loop-body-indentation nil) + (indented-clause-indentation (+ 2 default-value))) + ;; Determine context of this loop clause, starting with the [66 lines skipped] From nsiivola at common-lisp.net Sun May 15 17:18:21 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:18:21 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1668/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: indent forms following #+foo specially --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:17:23 1.443 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:18:21 1.444 @@ -1,3 +1,8 @@ +2011-05-11 Nikodemus Siivola + + * slime-cl-indent.el (common-lisp-indent-function-1): Handle + #+ and #-. Also support the SBCL idiom of #!+ #!-. + 2011-05-10 Nikodemus Siivola * slime-cl-indent.el: whitespace cleanup. --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:17:23 1.9 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:18:21 1.10 @@ -334,6 +334,16 @@ (not (eq (char-after (- containing-sexp 2)) ?\#))) ;; No indentation for "'(...)" elements (setq calculated (1+ sexp-column))) + ((save-excursion + (goto-char indent-point) + (backward-sexp) + (let ((xxx (buffer-substring-no-properties + (point) (+ (point) 3)))) + (and (eq ?\# (elt xxx 0)) + (or (member (elt xxx 1) '(?\+ ?\-)) + (and (eq ?\! (elt xxx 1)) + (member (elt xxx 2) '(?\+ ?\-))))))) + normal-indent) ((eq (char-after (1- containing-sexp)) ?\#) ;; "#(...)" (setq calculated (1+ sexp-column))) From nsiivola at common-lisp.net Sun May 15 17:18:52 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:18:52 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1717/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: sexp-based traversal for lambda-list indentation Fixes indentation of destructuring lambda-lists. Not: (defmacro with-foo ((foo &rest args) &body body) ...) but: (defmacro with-foo ((foo &rest args) &body body) ...) --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:18:21 1.444 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:18:52 1.445 @@ -1,3 +1,11 @@ +2011-05-12 Nikodemus Siivola + + * slime-cl-indent.el (lisp-indent-lambda-list): Use sexp-based + traversal instead of regular expressions to figure out how to + indent lambda-lists. Allows indenting destructuring lambda-lists correctly: + previously we could align to a keyword in a previous sublist, instead + of the sublist itself. + 2011-05-11 Nikodemus Siivola * slime-cl-indent.el (common-lisp-indent-function-1): Handle --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:18:21 1.10 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:18:52 1.11 @@ -445,13 +445,19 @@ ;; the lambda-list. (save-excursion (goto-char containing-form-start) - (save-match-data - (if (re-search-forward - lisp-indent-lambda-list-keywords-regexp - limit t) - (progn - (goto-char (match-beginning 0)) - (current-column)) + (down-list) + (let ((key-indent nil) + (next t)) + (while (and next (< (point) indent-point)) + (if (looking-at lisp-indent-lambda-list-keywords-regexp) + (setq key-indent (current-column) + next nil) + (setq next (ignore-errors (forward-sexp) t)) + (if next + (ignore-errors + (forward-sexp) + (backward-sexp))))) + (or key-indent (1+ sexp-column)))) ;; Align to the beginning of the lambda-list. (1+ sexp-column))) @@ -461,26 +467,26 @@ ;; lambda-list. (save-excursion (goto-char indent-point) - (forward-line -1) - (end-of-line) - (save-match-data - (if (re-search-backward lisp-indent-lambda-list-keywords-regexp - containing-form-start t) - (let* ((keyword-posn - (progn - (goto-char (match-beginning 0)) - (current-column))) - (indented-keyword-posn - (+ keyword-posn - lisp-lambda-list-keyword-parameter-indentation))) - (goto-char (match-end 0)) - (skip-chars-forward " \t") - (if (eolp) - indented-keyword-posn - (if lisp-lambda-list-keyword-parameter-alignment - (current-column) - indented-keyword-posn))) - (1+ sexp-column)))))))) + (let ((indent nil) + (next t)) + (while (and next (> (point) containing-form-start)) + (setq next (ignore-errors (backward-sexp) t)) + (let* ((col (current-column)) + (pos + (save-excursion + (ignore-errors (forward-sexp)) + (skip-chars-forward " \t") + (if (eolp) + (+ col lisp-lambda-list-keyword-parameter-indentation) + col)))) + (if (looking-at lisp-indent-lambda-list-keywords-regexp) + (setq indent (if lisp-lambda-list-keyword-parameter-alignment + (or indent pos) + (+ col + lisp-lambda-list-keyword-parameter-indentation)) + next nil) + (setq indent col)))) + (or indent (1+ sexp-column)))))))) ;; Blame the crufty control structure on dynamic scoping ;; -- not on me! From nsiivola at common-lisp.net Sun May 15 17:19:46 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:19:46 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1797/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: identify &more in lambda-lists --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:18:52 1.445 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:19:46 1.446 @@ -5,6 +5,7 @@ indent lambda-lists. Allows indenting destructuring lambda-lists correctly: previously we could align to a keyword in a previous sublist, instead of the sublist itself. + (lisp-indent-lambda-list-keywords-regexp): Add support for non-standard &more. 2011-05-11 Nikodemus Siivola --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:18:52 1.11 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:19:46 1.12 @@ -426,7 +426,7 @@ (defvar lisp-indent-lambda-list-keywords-regexp "&\\(\ -optional\\|rest\\|key\\|allow-other-keys\\|aux\\|whole\\|body\\|environment\ +optional\\|rest\\|key\\|allow-other-keys\\|aux\\|whole\\|body\\|environment\\|more\ \\)\\([ \t]\\|$\\)" "Regular expression matching lambda-list keywords.") From nsiivola at common-lisp.net Sun May 15 17:20:33 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:20:33 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1856/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: rudimentary tests Too damn easy to break things otherwise. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:19:46 1.446 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:20:33 1.447 @@ -6,6 +6,7 @@ previously we could align to a keyword in a previous sublist, instead of the sublist itself. (lisp-indent-lambda-list-keywords-regexp): Add support for non-standard &more. + (test-lisp-indent, run-lisp-indent-tests): Rudimentary tests. 2011-05-11 Nikodemus Siivola --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:19:46 1.12 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:20:33 1.13 @@ -960,6 +960,112 @@ (get (cdr el) 'common-lisp-indent-function) (car (cdr el)))))) +(defun test-lisp-indent (tests) + (let ((ok 0)) + (dolist (test tests) + (with-temp-buffer + (lisp-mode) + (when (consp test) + (dolist (bind (first test)) + (make-variable-buffer-local (first bind)) + (set (first bind) (second bind))) + (setf test (second test))) + (insert test) + (goto-char 0) + (skip-chars-forward " \t\n") + ;; Mess up the indentation so we know reindentation works + (let ((mess nil)) + (save-excursion + (while (not (eobp)) + (forward-line 1) + (ignore-errors (delete-char 1) (setf mess t)))) + (if (not mess) + (error "Couldn't mess up indentation?"))) + (indent-sexp) + (if (equal (buffer-string) test) + (incf ok) + (error "Bad indentation.\nWanted: %s\nGot: %s" + test + (buffer-string))))) + ok)) + +;; (run-lisp-indent-tests) + +(defun run-lisp-indent-tests () + (test-lisp-indent + '(" + (defun foo () + t)" + (((lisp-lambda-list-keyword-parameter-alignment nil) + (lisp-lambda-list-keyword-alignment nil)) + " + (defun foo (foo &optional opt1 + opt2 + &rest rest) + (list foo opt1 opt2 + rest))") + (((lisp-lambda-list-keyword-parameter-alignment t) + (lisp-lambda-list-keyword-alignment nil)) + " + (defun foo (foo &optional opt1 + opt2 + &rest rest) + (list foo opt1 opt2 + rest))") + (((lisp-lambda-list-keyword-parameter-alignment nil) + (lisp-lambda-list-keyword-alignment t)) + " + (defun foo (foo &optional opt1 + opt2 + &rest rest) + (list foo opt1 opt2 + rest))") + (((lisp-lambda-list-keyword-parameter-alignment y) + (lisp-lambda-list-keyword-alignment t)) + " + (defun foo (foo &optional opt1 + opt2 + &rest rest) + (list foo opt1 opt2 + rest))") + " + (let ((x y) + (foo #-foo (no-foo) + #+foo (yes-foo)) + (bar #-bar + (no-bar) + #+bar + (yes-bar))) + (list foo bar + x))" + " + (loop for i from 0 below 2 + for j from 0 below 2 + when foo + do (fubar) + (bar) + (moo) + and collect cash + into honduras + else do ;; this is the body of the first else + ;; the body is ... + (indented to the above comment) + (ZMACS gets this wrong) + and do this + and do that + and when foo + do the-other + and cry + when this-is-a-short-condition do + (body code of the when) + when here's something I used to botch do (here is a body) + (rest of body indented same) + do + (exdented loop body) + (I'm not sure I like this but it's compatible) + when funny-predicate do ;; Here's a comment + (body filled to comment))"))) + ;(defun foo (x) ; (tagbody From nsiivola at common-lisp.net Sun May 15 17:21:11 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:21:11 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1904/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: fix indentation of sublists in destructuring lambda-lists Simply apply the existing logic even if the path is not empty: (defmacro foo ((&optional o1 o2 &rest rest) &body body) ...) instead of: (defmacro foo ((&optional o1 o2 &rest rest) &body body) ...) --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:20:33 1.447 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:21:11 1.448 @@ -7,6 +7,9 @@ of the sublist itself. (lisp-indent-lambda-list-keywords-regexp): Add support for non-standard &more. (test-lisp-indent, run-lisp-indent-tests): Rudimentary tests. + (lisp-indent-259): Use lambda-list-indentation even if the CDR of the path + isn't null: this allows correct indentation of destructuring sublists. + (run-lisp-indent-tests): More test-cases. 2011-05-11 Nikodemus Siivola --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:20:33 1.13 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:21:11 1.14 @@ -555,15 +555,13 @@ (throw 'exit (cond ((null p) (list (+ sexp-column 4) containing-form-start)) - ((null (cdr p)) + (t ;; Indentation within a lambda-list. -- dvl (list (lisp-indent-lambda-list indent-point sexp-column containing-form-start) - containing-form-start)) - (t - normal-indent)))) + containing-form-start))))) ((integerp tem) (throw 'exit (if (null p) ;not in subforms @@ -1020,7 +1018,7 @@ &rest rest) (list foo opt1 opt2 rest))") - (((lisp-lambda-list-keyword-parameter-alignment y) + (((lisp-lambda-list-keyword-parameter-alignment t) (lisp-lambda-list-keyword-alignment t)) " (defun foo (foo &optional opt1 @@ -1028,6 +1026,38 @@ &rest rest) (list foo opt1 opt2 rest))") + (((lisp-lambda-list-keyword-parameter-alignment nil) + (lisp-lambda-list-keyword-alignment nil)) + " + (defmacro foo ((foo &optional opt1 + opt2 + &rest rest)) + (list foo opt1 opt2 + rest))") + (((lisp-lambda-list-keyword-parameter-alignment t) + (lisp-lambda-list-keyword-alignment nil)) + " + (defmacro foo ((foo &optional opt1 + opt2 + &rest rest)) + (list foo opt1 opt2 + rest))") + (((lisp-lambda-list-keyword-parameter-alignment nil) + (lisp-lambda-list-keyword-alignment t)) + " + (defmacro foo ((foo &optional opt1 + opt2 + &rest rest)) + (list foo opt1 opt2 + rest))") + (((lisp-lambda-list-keyword-parameter-alignment t) + (lisp-lambda-list-keyword-alignment t)) + " + (defmacro foo ((foo &optional opt1 + opt2 + &rest rest)) + (list foo opt1 opt2 + rest))") " (let ((x y) (foo #-foo (no-foo) @@ -1064,37 +1094,37 @@ (exdented loop body) (I'm not sure I like this but it's compatible) when funny-predicate do ;; Here's a comment - (body filled to comment))"))) + (body filled to comment))" + " + (defun foo (x) + (tagbody + foo + (bar) + baz + (when (losing) + (with-big-loser + (yow) + ((lambda () + foo) + big))) + (flet ((foo (bar baz zap) + (zip)) + (zot () + quux)) + (do () + ((lose) + (foo 1)) + (quux) + foo + (lose)) + (cond ((x) + (win 1 2 + (foo))) + (t + (lose + 3))))))"))) -;(defun foo (x) -; (tagbody -; foo -; (bar) -; baz -; (when (losing) -; (with-big-loser -; (yow) -; ((lambda () -; foo) -; big))) -; (flet ((foo (bar baz zap) -; (zip)) -; (zot () -; quux)) -; (do () -; ((lose) -; (foo 1)) -; (quux) -; foo -; (lose)) -; (cond ((x) -; (win 1 2 -; (foo))) -; (t -; (lose -; 3)))))) - ;(put 'while 'common-lisp-indent-function 1) ;(put 'defwrapper'common-lisp-indent-function ...) From nsiivola at common-lisp.net Sun May 15 17:22:36 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:22:36 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv1964/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: support for IF* From Gabor Melis' post to slime-devel 2011-01-24. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:21:11 1.448 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:22:36 1.449 @@ -1,3 +1,13 @@ +2011-05-14 Nikodemus Siivola + + * slime-cl-indent.el (common-lisp-indent-if*-keyword): + (common-lisp-indent-if*, common-lisp-indent-if*-1): + (common-lisp-indent-if*-advance-past-keyword-on-line): IF* + indentation code from Gabor Melis. It should be noted that this + should not be considered an endorsement on IF* by the commiter, + but rather an act of compassion to all who labor under its shadow. + (run-lisp-indent-tests): Test-case for IF* indentation. + 2011-05-12 Nikodemus Siivola * slime-cl-indent.el (lisp-indent-lambda-list): Use sexp-based --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:21:11 1.14 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:22:36 1.15 @@ -839,33 +839,85 @@ nil (current-column))) -;; Test-case for subclause indentation -'(loop for i from 0 below 2 - for j from 0 below 2 - when foo - do (fubar) - (bar) - (moo) - and collect cash - into honduras - else do ;; this is the body of the first else - ;; the body is ... - (indented to the above comment) - (ZMACS gets this wrong) - and do this - and do that - and when foo - do the-other - and cry - when this-is-a-short-condition do - (body code of the when) - when here's something I used to botch do (here is a body) - (rest of body indented same) - do - (exdented loop body) - (I'm not sure I like this but it's compatible) - when funny-predicate do ;; Here's a comment - (body filled to comment)) +;;;; IF* is not standard, but a plague upon the land +;;;; ...let's at least try to indent it. + +(defvar common-lisp-indent-if*-keyword + "threnret\\|elseif\\|then\\|else" + "Regexp matching if* keywords") + +(defun common-lisp-indent-if* + (path parse-state indent-point sexp-column normal-indent) + (list (common-lisp-indent-if*-1 parse-state indent-point) + (common-lisp-indent-parse-state-start parse-state))) + +(defun common-lisp-indent-if*-1 (parse-state indent-point) + (catch 'return-indentation + (save-excursion + ;; Find first clause of if* macro, and use it to establish + ;; base column for indentation + (goto-char (common-lisp-indent-parse-state-start parse-state)) + (let ((if*-start-column (current-column))) + (common-lisp-indent-if*-advance-past-keyword-on-line) + (let* ((case-fold-search t) + (if*-first-clause (point)) + (previous-expression-start + (common-lisp-indent-parse-state-prev parse-state)) + (default-value (current-column)) + (if*-body-p nil) + (if*-body-indentation nil)) + ;; Determine context of this if* clause, starting with the + ;; expression immediately preceding the line we're trying to indent + (goto-char previous-expression-start) + ;; Handle a body-introducing-clause which ends a line specially. + (back-to-indentation) + (if (< (point) if*-first-clause) + (goto-char if*-first-clause)) + ;; Found start of if* clause preceding the one we're trying to indent. + ;; Glean context ... + (cond + ((looking-at common-lisp-indent-if*-keyword) + (setq if*-body-p t) + ;; Know there's something else on the line (or would + ;; have been caught above) + (common-lisp-indent-if*-advance-past-keyword-on-line) + (setq if*-body-indentation (current-column))) + ((looking-at "#'\\|'\\|(") + ;; We're in the middle of a clause body ... + (setq if*-body-p t) + (setq if*-body-indentation (current-column))) + (t + (setq if*-body-p nil) + ;; We still need if*-body-indentation for "syntax errors" ... + (goto-char previous-expression-start) + (setq if*-body-indentation (current-column)))) + + ;; Go to first non-blank character of the line we're trying to indent. + ;; (if none, wind up poised on the new-line ...) + (goto-char indent-point) + (back-to-indentation) + (cond + ((or (eolp) (looking-at ";")) + ;; Blank line. If body-p, indent as body, else indent as + ;; vanilla clause. + (if if*-body-p + if*-body-indentation + default-value)) + ((not (looking-at common-lisp-indent-if*-keyword)) + ;; Clause body ... + if*-body-indentation) + (t + (- (+ 7 if*-start-column) + (- (match-end 0) (match-beginning 0)))))))))) + +(defun common-lisp-indent-if*-advance-past-keyword-on-line () + (forward-word 1) + (block move-forward + (while (and (looking-at "\\s-") (not (eolp))) + (forward-char 1))) + (if (eolp) + nil + (current-column))) ;;;; Indentation specs for standard symbols, and a few semistandard ones. @@ -916,6 +968,7 @@ (if (nil nil &body)) ;; single-else style (then and else equally indented) (if (&rest nil)) + (if* common-lisp-indent-if*) (lambda (&lambda &rest lisp-indent-function-lambda-hack)) (let ((&whole 4 &rest (&whole 1 1 2)) &body)) (let* . let) @@ -1122,7 +1175,15 @@ (foo))) (t (lose - 3))))))"))) + 3))))))" + " + (if* (eq t nil) + then () + () + elseif (dsf) + thenret x + else (balbkj) + (sdf))"))) From nsiivola at common-lisp.net Sun May 15 17:25:15 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:25:15 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv2041/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: Use back-to-indentation instead of reinventing it. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:22:36 1.449 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:25:15 1.450 @@ -1,3 +1,8 @@ +2011-05-15 Didier Verna + + * slime-cl-indent.el (lisp-indent-tagbody): + (lisp-indent-lambda-list): Use back-to-indentation. + 2011-05-14 Nikodemus Siivola * slime-cl-indent.el (common-lisp-indent-if*-keyword): --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:22:36 1.15 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:25:15 1.16 @@ -435,8 +435,7 @@ (let (limit) (cond ((save-excursion (goto-char indent-point) - (beginning-of-line) - (skip-chars-forward " \t") + (back-to-indentation) (setq limit (point)) (looking-at lisp-indent-lambda-list-keywords-regexp)) ;; We're facing a lambda-list keyword. @@ -596,8 +595,7 @@ normal-indent (save-excursion (goto-char indent-point) - (beginning-of-line) - (skip-chars-forward " \t") + (back-to-indentation) (list (cond ((looking-at "\\sw\\|\\s_") ;; a tagbody tag (+ sexp-column lisp-tag-indentation)) From nsiivola at common-lisp.net Sun May 15 17:26:01 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 10:26:01 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv2089/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: Make sure indent-tabs-mode is nil in tests. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:25:15 1.450 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:26:01 1.451 @@ -1,5 +1,11 @@ 2011-05-15 Didier Verna + * slime-cl-indent.el (test-lisp-indent): Make sure + indent-tabs-mode is nil in the test buffer. Otherwise, spaces may + be converted into tabs which would make the tests fail. + +2011-05-15 Didier Verna + * slime-cl-indent.el (lisp-indent-tagbody): (lisp-indent-lambda-list): Use back-to-indentation. --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:25:15 1.16 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:26:01 1.17 @@ -1014,6 +1014,7 @@ (dolist (test tests) (with-temp-buffer (lisp-mode) + (setq indent-tabs-mode nil) (when (consp test) (dolist (bind (first test)) (make-variable-buffer-local (first bind)) From nsiivola at common-lisp.net Sun May 15 18:07:56 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 11:07:56 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv3428/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: better #+foo support (list bar #+foo (foo) #-foo (no-foo)) instead of (list bar #+foo (foo) #-foo (no-foo)) . --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 17:26:01 1.451 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 18:07:56 1.452 @@ -1,3 +1,8 @@ +2011-05-15 Nikodemus Siivola + + * slime-cl-indent.el (common-lisp-indent-function-1): Better #+ + support. + 2011-05-15 Didier Verna * slime-cl-indent.el (test-lisp-indent): Make sure --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 17:26:01 1.17 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 18:07:56 1.18 @@ -337,13 +337,12 @@ ((save-excursion (goto-char indent-point) (backward-sexp) - (let ((xxx (buffer-substring-no-properties - (point) (+ (point) 3)))) - (and (eq ?\# (elt xxx 0)) - (or (member (elt xxx 1) '(?\+ ?\-)) - (and (eq ?\! (elt xxx 1)) - (member (elt xxx 2) '(?\+ ?\-))))))) - normal-indent) + (let ((re "#!?\\(+\\|-\\)")) + (if (or (looking-at re) + (ignore-errors + (backward-sexp) + (looking-at re))) + (setq calculated (current-column)))))) ((eq (char-after (1- containing-sexp)) ?\#) ;; "#(...)" (setq calculated (1+ sexp-column))) @@ -1182,7 +1181,10 @@ elseif (dsf) thenret x else (balbkj) - (sdf))"))) + (sdf))" + " + (list foo #+foo (foo) + #-foo (no-foo))"))) From nsiivola at common-lisp.net Sun May 15 19:36:57 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Sun, 15 May 2011 12:36:57 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv5828/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: nicer newline-and-indent interaction with loop indentation (For non-subclause aware loop indentation.) --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 18:07:56 1.452 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 19:36:56 1.453 @@ -2,6 +2,8 @@ * slime-cl-indent.el (common-lisp-indent-function-1): Better #+ support. + (common-lisp-loop-part-indentation): Make newline-and-indent work better + with non-subclause-aware loop indentation. 2011-05-15 Didier Verna --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 18:07:56 1.18 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 19:36:56 1.19 @@ -164,7 +164,7 @@ (beginning-of-line) (cond ((eq 'simple type) (+ loop-indentation lisp-simple-loop-indentation)) - ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)") + ((looking-at "^\\s-*\\(:?\\sw+\\|;\\|)\\|\n\\)") (list (+ loop-indentation 6) loop-start)) (t (list (+ loop-indentation 9) loop-start))))) @@ -1028,7 +1028,7 @@ (while (not (eobp)) (forward-line 1) (ignore-errors (delete-char 1) (setf mess t)))) - (if (not mess) + (if (or (not mess) (equal (buffer-string) test)) (error "Couldn't mess up indentation?"))) (indent-sexp) (if (equal (buffer-string) test) @@ -1184,7 +1184,17 @@ (sdf))" " (list foo #+foo (foo) - #-foo (no-foo))"))) + #-foo (no-foo))" + (((lisp-loop-indent-subclauses t)) + " + (loop for x in foo1 + for y in quux1 + )") + (((lisp-loop-indent-subclauses nil)) + " + (loop for x in foo + for y in quux + )")))) From nsiivola at common-lisp.net Mon May 16 07:59:18 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Mon, 16 May 2011 00:59:18 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv23877/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: one more loop indentation option Catering for: (loop for x in xs do (foo x) finally (bar x) (quux x)) --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/15 19:36:56 1.453 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/16 07:59:18 1.454 @@ -1,3 +1,11 @@ +2011-05-16 Nikodemus Siivola + + * slime-cl-indent.el (lisp-loop-indent-forms-like-keywords) + (common-lisp-loop-part-indentation, run-lisp-indent-tests): Cater + to loop indentation style that prefers to align forms with keywords. + Activated by setting lisp-loop-indent-forms-like-keywords to t, + and lisp-loop-indent-subclauses to nil. + 2011-05-15 Nikodemus Siivola * slime-cl-indent.el (common-lisp-indent-function-1): Better #+ --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/15 19:36:56 1.19 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/16 07:59:18 1.20 @@ -79,6 +79,13 @@ :type 'integer :group 'lisp-indent) +(defcustom lisp-loop-indent-forms-like-keywords nil + "Whether or not to indent loop subforms just like +loop keywords. Only matters when `lisp-loop-indent-subclauses' +is nil." + :type 'integer + :group 'lisp-indent) + (defcustom lisp-lambda-list-keyword-alignment nil "Whether to vertically align lambda-list keywords together. If nil (the default), keyworded lambda-list parts are aligned @@ -159,13 +166,27 @@ (goto-char loop-start) (if (eq 'extended/split type) (- (current-column) 4) - (current-column))))) + (current-column)))) + (indent loop-indentation)) (goto-char indent-point) (beginning-of-line) (cond ((eq 'simple type) (+ loop-indentation lisp-simple-loop-indentation)) - ((looking-at "^\\s-*\\(:?\\sw+\\|;\\|)\\|\n\\)") + ;; Previous line starts a body, and has a form on it + ((and (save-excursion + (previous-line) + (back-to-indentation) + (looking-at common-lisp-indent-body-introducing-loop-macro-keyword)) + (save-excursion + (when (and (ignore-errors (backward-sexp) t) + (not (looking-at common-lisp-indent-body-introducing-loop-macro-keyword))) + (setf indent (current-column))))) + (list indent loop-start)) + ;; Keyword-style + ((or lisp-loop-indent-forms-like-keywords + (looking-at "^\\s-*\\(:?\\sw+\\|;\\|)\\|\n\\)")) (list (+ loop-indentation 6) loop-start)) + ;; Form-style (t (list (+ loop-indentation 9) loop-start))))) @@ -961,8 +982,6 @@ (generic-labels . flet) (handler-case (4 &rest (&whole 2 &lambda &body))) (restart-case . handler-case) - ;; `else-body' style - (if (nil nil &body)) ;; single-else style (then and else equally indented) (if (&rest nil)) (if* common-lisp-indent-if*) @@ -1015,6 +1034,8 @@ (lisp-mode) (setq indent-tabs-mode nil) (when (consp test) + (when (cddr test) + (error "Malformed test: %s" test)) (dolist (bind (first test)) (make-variable-buffer-local (first bind)) (set (first bind) (second bind))) @@ -1119,7 +1140,8 @@ (yes-bar))) (list foo bar x))" - " + (((lisp-loop-indent-subclauses t)) + " (loop for i from 0 below 2 for j from 0 below 2 when foo @@ -1145,7 +1167,7 @@ (exdented loop body) (I'm not sure I like this but it's compatible) when funny-predicate do ;; Here's a comment - (body filled to comment))" + (body filled to comment))") " (defun foo (x) (tagbody @@ -1194,7 +1216,27 @@ " (loop for x in foo for y in quux - )")))) + )") + (((lisp-loop-indent-subclauses nil) + (lisp-loop-indent-forms-like-keywords t)) + " + (loop for x in foo + for y in quux + finally (foo) + (fo) + do + (print x) + (print y))") + (((lisp-loop-indent-subclauses nil) + (lisp-loop-indent-forms-like-keywords nil)) + " + (loop for x in foo + for y in quux + finally (foo) + (fo) + do + (print x) + (print y))")))) From nsiivola at common-lisp.net Mon May 16 08:23:45 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Mon, 16 May 2011 01:23:45 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv24759/contrib Modified Files: slime-cl-indent.el Log Message: slime-indentation: better multiform loop bodies better When subclause indentation is disabled: (loop repeat n do (foo) finally (fini1) (fini2) (fini3)) fixes the previous commit that didn't get this right if there were more than 2 subforms. Duh. --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/16 07:59:18 1.20 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/16 08:23:45 1.21 @@ -167,24 +167,24 @@ (if (eq 'extended/split type) (- (current-column) 4) (current-column)))) - (indent loop-indentation)) + (indent nil) + (re "\\(:?\\sw+\\|;\\|)\\|\n\\)")) (goto-char indent-point) - (beginning-of-line) + (back-to-indentation) (cond ((eq 'simple type) (+ loop-indentation lisp-simple-loop-indentation)) - ;; Previous line starts a body, and has a form on it - ((and (save-excursion - (previous-line) - (back-to-indentation) - (looking-at common-lisp-indent-body-introducing-loop-macro-keyword)) + ;; We are already in a body, with forms in it. + ((and (not (looking-at re)) (save-excursion - (when (and (ignore-errors (backward-sexp) t) - (not (looking-at common-lisp-indent-body-introducing-loop-macro-keyword))) - (setf indent (current-column))))) + (while (and (ignore-errors (backward-sexp) t) + (not (looking-at re))) + (setq indent (current-column))) + (when (and indent + (looking-at common-lisp-indent-body-introducing-loop-macro-keyword)) + t))) (list indent loop-start)) ;; Keyword-style - ((or lisp-loop-indent-forms-like-keywords - (looking-at "^\\s-*\\(:?\\sw+\\|;\\|)\\|\n\\)")) + ((or lisp-loop-indent-forms-like-keywords (looking-at re)) (list (+ loop-indentation 6) loop-start)) ;; Form-style (t @@ -1224,9 +1224,11 @@ for y in quux finally (foo) (fo) + (zoo) do (print x) - (print y))") + (print y) + (print 'ok!))") (((lisp-loop-indent-subclauses nil) (lisp-loop-indent-forms-like-keywords nil)) " @@ -1234,9 +1236,22 @@ for y in quux finally (foo) (fo) + (zoo) do (print x) - (print y))")))) + (print y) + (print 'ok!))") + (((lisp-loop-indent-subclauses t) + (lisp-loop-indent-forms-like-keywords nil)) + " + (loop for x in foo + for y in quux + finally (foo) + (fo) + do + (print x) + (print y) + (print 'ok!))")))) From nsiivola at common-lisp.net Tue May 17 19:54:38 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Tue, 17 May 2011 12:54:38 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv12277/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: fix indentation of function calls inside loop forms ...and add a test-case. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/16 07:59:18 1.454 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/17 19:54:38 1.455 @@ -1,3 +1,8 @@ +2011-05-17 Nikodemus Siivola + + * slime-cl-indent.el (run-lisp-indent-tests, lisp-indent-loop): Fix + indentation of function calls, etc, inside loop forms. + 2011-05-16 Nikodemus Siivola * slime-cl-indent.el (lisp-loop-indent-forms-like-keywords) --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/16 08:23:45 1.21 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/17 19:54:38 1.22 @@ -690,10 +690,13 @@ (error (+ sexp-column lisp-body-indent))))) (defun lisp-indent-loop (path state indent-point sexp-column normal-indent) - (if lisp-loop-indent-subclauses - (list (common-lisp-indent-loop-macro-1 state indent-point) - (common-lisp-indent-parse-state-start state)) - (common-lisp-loop-part-indentation indent-point state))) + (cond ((not (null (cdr path))) + normal-indent) + (lisp-loop-indent-subclauses + (list (common-lisp-indent-loop-macro-1 state indent-point) + (common-lisp-indent-parse-state-start state))) + (t + (common-lisp-loop-part-indentation indent-point state)))) ;;;; LOOP indentation, the complex version -- handles subclause indentation @@ -1229,8 +1232,8 @@ (print x) (print y) (print 'ok!))") - (((lisp-loop-indent-subclauses nil) - (lisp-loop-indent-forms-like-keywords nil)) + (((lisp-loop-indent-subclauses nil) + (lisp-loop-indent-forms-like-keywords nil)) " (loop for x in foo for y in quux @@ -1251,7 +1254,22 @@ do (print x) (print y) - (print 'ok!))")))) + (print 'ok!))") + (((lisp-loop-indent-subclauses nil) + (lisp-loop-indent-forms-like-keywords nil)) + " + (loop for f in files + collect (open f + :direction :output) + do (foo) (bar) + (quux))") + (((lisp-loop-indent-subclauses t)) + " + (loop for f in files + collect (open f + :direction :output) + do (foo) (bar) + (quux))")))) From nsiivola at common-lisp.net Wed May 18 19:26:41 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Wed, 18 May 2011 12:26:41 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv723/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indention: add support for short form DEFSETF --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/17 19:54:38 1.455 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/18 19:26:40 1.456 @@ -1,3 +1,8 @@ +2011-05-18 Nikodemus Siivola + + * slime-cl-indent.el (lisp-indent-defsetf, run-lisp-indent-tests): + Better DEFSETF indentation: support both long and short forms. + 2011-05-17 Nikodemus Siivola * slime-cl-indent.el (run-lisp-indent-tests, lisp-indent-loop): Fix --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/17 19:54:38 1.22 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/18 19:26:40 1.23 @@ -648,6 +648,35 @@ (&whole nil &rest 1)) path state indent-point sexp-column normal-indent))) +(defun lisp-indent-defsetf + (path state indent-point sexp-column normal-indent) + (list + (cond + ;; Inside the lambda-list in a long-form defsetf. + ((and (eql 2 (car path)) (cdr path)) + (lisp-indent-lambda-list indent-point sexp-column (elt state 1))) + ;; Long form: has a lambda-list. + ((or (cdr path) + (save-excursion + (goto-char (elt state 1)) + (ignore-errors + (down-list) + (forward-sexp 3) + (backward-sexp) + (looking-at "nil\\|(")))) + (+ sexp-column + (case (car path) + ((1 3) 4) + (2 4) + (t 2)))) + ;; Short form. + (t + (+ sexp-column + (case (car path) + (1 4) + (2 4) + (t 2))))) + (elt state 1))) ;; LISP-INDENT-DEFMETHOD now supports the presence of more than one method ;; qualifier and indents the method's lambda list properly. -- dvl @@ -959,7 +988,7 @@ (defconst . defcustom) (define-condition . defclass) (define-modify-macro (4 &lambda &body)) - (defsetf (4 &lambda 4 &body)) + (defsetf lisp-indent-defsetf) (defun (4 &lambda &body)) (defgeneric (4 &lambda &body)) (define-setf-method . defun) @@ -1269,7 +1298,20 @@ collect (open f :direction :output) do (foo) (bar) - (quux))")))) + (quux))") + " + (defsetf foo bar + \"the doc string\")" + " + (defsetf foo + bar + \"the doc string\")" + (((lisp-lambda-list-keyword-parameter-alignment t)) + " + (defsetf foo (x y &optional a + z) + (a b c) + stuff)")))) From nsiivola at common-lisp.net Wed May 18 21:48:04 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Wed, 18 May 2011 14:48:04 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv6428/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: aligning keywords in calls Provides (make-instance 'foo :bar t :quux t :zot t) and (vecto:with-canvas (:height 42 :width 100) (save-png foo)) Controlled via lisp-align-keywords-in-calls. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/18 19:26:40 1.456 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/18 21:48:04 1.457 @@ -1,3 +1,9 @@ +2011-05-19 Nikodemus Siivola + + * slime-cl-indent.el (common-lisp-indent-function-1) + (lisp-align-keywords-in-calls): Support for aligning keyword + arguments in calls. + 2011-05-18 Nikodemus Siivola * slime-cl-indent.el (lisp-indent-defsetf, run-lisp-indent-tests): --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/18 19:26:40 1.23 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/18 21:48:04 1.24 @@ -86,6 +86,22 @@ :type 'integer :group 'lisp-indent) +(defcustom lisp-align-keywords-in-calls t + "Whether to align keyword arguments vertically or not. +If t (the default), keywords in contexts where no other +indentation rule takes precedence are aligned like this: + +\(make-instance 'foo :bar t + :quux 42) + +If nil, they are indented like any other function +call arguments: + +\(make-instance 'foo :bar t + :quux 42)" + :type 'boolean + :group 'lisp-indent) + (defcustom lisp-lambda-list-keyword-alignment nil "Whether to vertically align lambda-list keywords together. If nil (the default), keyworded lambda-list parts are aligned @@ -386,7 +402,19 @@ function lisp-indent-defun-method path state indent-point sexp-column normal-indent) - normal-indent tentative-calculated))) + normal-indent tentative-calculated) + (when lisp-align-keywords-in-calls + ;; No method so far. If we're looking at a keyword, + ;; align with the first keyword in this expression. + ;; This gives a reasonable indentation to most things + ;; with keyword arguments. + (save-excursion + (goto-char indent-point) + (back-to-indentation) + (when (looking-at ":") + (while (ignore-errors (backward-sexp 2) t) + (when (looking-at ":") + (setq calculated (current-column))))))))) ((integerp method) ;; convenient top-level hack. ;; (also compatible with lisp-indent-function) @@ -1311,7 +1339,15 @@ (defsetf foo (x y &optional a z) (a b c) - stuff)")))) + stuff)") + (((lisp-align-keywords-in-calls t)) + " + (make-instance 'foo :bar t quux t + :zot t)") + (((lisp-align-keywords-in-calls nil)) + " + (make-instance 'foo :bar t quux t + :zot t)")))) From nsiivola at common-lisp.net Thu May 19 18:25:41 2011 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Thu, 19 May 2011 11:25:41 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv21544/contrib Modified Files: ChangeLog slime-cl-indent.el Log Message: slime-indentation: support for turning off lambda-list indentation By request. (setq lisp-lambda-list-indentation nil) and lambda-lists will be more boring than ever before. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/18 21:48:04 1.457 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/19 18:25:40 1.458 @@ -3,6 +3,9 @@ * slime-cl-indent.el (common-lisp-indent-function-1) (lisp-align-keywords-in-calls): Support for aligning keyword arguments in calls. + (lisp-lambda-list-indentation, lisp-indent-lambda-list) + (run-lisp-indent-tests): Support for turning off the + fancy lambda-list indentation. 2011-05-18 Nikodemus Siivola --- /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/18 21:48:04 1.24 +++ /project/slime/cvsroot/slime/contrib/slime-cl-indent.el 2011/05/19 18:25:40 1.25 @@ -102,6 +102,22 @@ :type 'boolean :group 'lisp-indent) +(defcustom lisp-lambda-list-indentation t + "Whether to indent lambda-lists specially. Defaults to t. Setting this to +nil makes `lisp-lambda-list-keyword-alignment', +`lisp-lambda-list-keyword-parameter-alignment', and +`lisp-lambda-list-keyword-parameter-indentation' meaningless, causing +lambda-lists to be indented as if they were data: + +\(defun example (a b &optional o1 o2 + o3 o4 + &rest r + &key k1 k2 + k3 k4) + #|...|#)" + :type 'boolean + :group 'lisp-indent) + (defcustom lisp-lambda-list-keyword-alignment nil "Whether to vertically align lambda-list keywords together. If nil (the default), keyworded lambda-list parts are aligned @@ -480,60 +496,62 @@ (defun lisp-indent-lambda-list (indent-point sexp-column containing-form-start) - (let (limit) - (cond ((save-excursion - (goto-char indent-point) - (back-to-indentation) - (setq limit (point)) - (looking-at lisp-indent-lambda-list-keywords-regexp)) - ;; We're facing a lambda-list keyword. - (if lisp-lambda-list-keyword-alignment - ;; Align to the first keyword if any, or to the beginning of - ;; the lambda-list. - (save-excursion - (goto-char containing-form-start) - (down-list) - (let ((key-indent nil) - (next t)) - (while (and next (< (point) indent-point)) - (if (looking-at lisp-indent-lambda-list-keywords-regexp) - (setq key-indent (current-column) - next nil) - (setq next (ignore-errors (forward-sexp) t)) - (if next - (ignore-errors - (forward-sexp) - (backward-sexp))))) - (or key-indent - (1+ sexp-column)))) + (if (not lisp-lambda-list-indentation) + (1+ sexp-column) + (let (limit) + (cond ((save-excursion + (goto-char indent-point) + (back-to-indentation) + (setq limit (point)) + (looking-at lisp-indent-lambda-list-keywords-regexp)) + ;; We're facing a lambda-list keyword. + (if lisp-lambda-list-keyword-alignment + ;; Align to the first keyword if any, or to the beginning of + ;; the lambda-list. + (save-excursion + (goto-char containing-form-start) + (down-list) + (let ((key-indent nil) + (next t)) + (while (and next (< (point) indent-point)) + (if (looking-at lisp-indent-lambda-list-keywords-regexp) + (setq key-indent (current-column) + next nil) + (setq next (ignore-errors (forward-sexp) t)) + (if next + (ignore-errors + (forward-sexp) + (backward-sexp))))) + (or key-indent + (1+ sexp-column)))) ;; Align to the beginning of the lambda-list. (1+ sexp-column))) - (t - ;; Otherwise, align to the first argument of the last lambda-list - ;; keyword, the keyword itself, or the beginning of the - ;; lambda-list. - (save-excursion - (goto-char indent-point) - (let ((indent nil) - (next t)) - (while (and next (> (point) containing-form-start)) - (setq next (ignore-errors (backward-sexp) t)) - (let* ((col (current-column)) - (pos - (save-excursion - (ignore-errors (forward-sexp)) - (skip-chars-forward " \t") - (if (eolp) - (+ col lisp-lambda-list-keyword-parameter-indentation) - col)))) - (if (looking-at lisp-indent-lambda-list-keywords-regexp) - (setq indent (if lisp-lambda-list-keyword-parameter-alignment - (or indent pos) - (+ col - lisp-lambda-list-keyword-parameter-indentation)) - next nil) - (setq indent col)))) - (or indent (1+ sexp-column)))))))) + (t + ;; Otherwise, align to the first argument of the last lambda-list + ;; keyword, the keyword itself, or the beginning of the + ;; lambda-list. + (save-excursion + (goto-char indent-point) + (let ((indent nil) + (next t)) + (while (and next (> (point) containing-form-start)) + (setq next (ignore-errors (backward-sexp) t)) + (let* ((col (current-column)) + (pos + (save-excursion + (ignore-errors (forward-sexp)) + (skip-chars-forward " \t") + (if (eolp) + (+ col lisp-lambda-list-keyword-parameter-indentation) + col)))) + (if (looking-at lisp-indent-lambda-list-keywords-regexp) + (setq indent (if lisp-lambda-list-keyword-parameter-alignment + (or indent pos) + (+ col + lisp-lambda-list-keyword-parameter-indentation)) + next nil) + (setq indent col)))) + (or indent (1+ sexp-column))))))))) ;; Blame the crufty control structure on dynamic scoping ;; -- not on me! @@ -1347,7 +1365,15 @@ (((lisp-align-keywords-in-calls nil)) " (make-instance 'foo :bar t quux t - :zot t)")))) + :zot t)") + (((lisp-lambda-list-indentation nil)) + " + (defun example (a b &optional o1 o2 + o3 o4 + &rest r + &key k1 k2 + k3 k4) + 'hello)")))) From heller at common-lisp.net Sat May 21 17:01:44 2011 From: heller at common-lisp.net (CVS User heller) Date: Sat, 21 May 2011 10:01:44 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv22158/contrib Modified Files: ChangeLog swank-indentation.lisp Log Message: * swank-indentation.lisp: Provide :swank-indentation. Reported by Robert Brown --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/19 18:25:40 1.458 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/21 17:01:44 1.459 @@ -1,3 +1,8 @@ +2011-05-21 Helmut Eller + + * swank-indentation.lisp: Provide :swank-indentation. + Reported by Robert Brown + 2011-05-19 Nikodemus Siivola * slime-cl-indent.el (common-lisp-indent-function-1) --- /project/slime/cvsroot/slime/contrib/swank-indentation.lisp 2011/05/08 10:16:23 1.2 +++ /project/slime/cvsroot/slime/contrib/swank-indentation.lisp 2011/05/21 17:01:44 1.3 @@ -44,3 +44,5 @@ (list (macro-indentation arglist))))) (t nil))) + +(provide :swank-indentation) From heller at common-lisp.net Sat May 21 17:01:48 2011 From: heller at common-lisp.net (CVS User heller) Date: Sat, 21 May 2011 10:01:48 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv22183/contrib Modified Files: ChangeLog slime-snapshot.el Log Message: * slime-snapshot.el: License is GPL. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/21 17:01:44 1.459 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/21 17:01:48 1.460 @@ -1,5 +1,9 @@ 2011-05-21 Helmut Eller + * slime-snapshot.el: License is GPL. + +2011-05-21 Helmut Eller + * swank-indentation.lisp: Provide :swank-indentation. Reported by Robert Brown --- /project/slime/cvsroot/slime/contrib/slime-snapshot.el 2010/08/21 06:39:59 1.6 +++ /project/slime/cvsroot/slime/contrib/slime-snapshot.el 2011/05/21 17:01:48 1.7 @@ -2,7 +2,7 @@ (define-slime-contrib slime-snapshot "Save&restore memory images without disconnecting" (:authors "Helmut Eller ") - (:license "Unknown") + (:license "GPL v3") (:swank-dependencies swank-snapshot)) (defun slime-snapshot (filename &optional background) From heller at common-lisp.net Sat May 21 18:11:40 2011 From: heller at common-lisp.net (CVS User heller) Date: Sat, 21 May 2011 11:11:40 -0700 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory common-lisp.net:/tmp/cvs-serv25842 Modified Files: ChangeLog slime.el Log Message: Minor tweaks to avoid some compiler warnings. * slime.el (slime-modeline-string, slime-buffer-connection): Declare variables. (slime-flatten-tree): Helper function. (destructure-case): Use it, and make '_ ignorable if it occurs in some pattern. (slime-connect): Avoid obsolete functions: string-to-int -> string-to-number interactive-p -> called-interactively-p (slime-complete-maybe-restore-window-configuration) last-command-char -> last-command-event completion-base-size -> completion-base-position (slime-xref-mode-map): Use call-interactively when calling the remapped next-line/previous-line commands. --- /project/slime/cvsroot/slime/ChangeLog 2011/05/09 10:48:10 1.2189 +++ /project/slime/cvsroot/slime/ChangeLog 2011/05/21 18:11:39 1.2190 @@ -1,3 +1,21 @@ +2011-05-21 Helmut Eller + + Minor tweaks to avoid some compiler warnings. + + * slime.el (slime-modeline-string, slime-buffer-connection): + Declare variables. + (slime-flatten-tree): Helper function. + (destructure-case): Use it, and make '_ ignorable if + it occurs in some pattern. + (slime-connect): Avoid obsolete functions: + string-to-int -> string-to-number + interactive-p -> called-interactively-p + (slime-complete-maybe-restore-window-configuration) + last-command-char -> last-command-event + completion-base-size -> completion-base-position + (slime-xref-mode-map): Use call-interactively + when calling the remapped next-line/previous-line commands. + 2011-05-09 Nikodemus Siivola * swank-sbcl.lisp (swank-compile-string): Use :SOURCE-NAMESTRING --- /project/slime/cvsroot/slime/slime.el 2011/05/08 10:16:20 1.1364 +++ /project/slime/cvsroot/slime/slime.el 2011/05/21 18:11:39 1.1365 @@ -384,6 +384,9 @@ This is a hack so that we can reinitilize the real slime-mode-map more easily. See `slime-init-keymaps'.") +(defvar slime-modeline-string) +(defvar slime-buffer-connection) + (define-minor-mode slime-mode "\\\ SLIME: The Superior Lisp Interaction Mode for Emacs (minor-mode). @@ -684,6 +687,12 @@ (put 'when-let 'lisp-indent-function 1) +(eval-and-compile + (defun slime-flatten-tree (tree) + (cond ((atom tree) (list tree)) + (t (append (slime-flatten-tree (car tree)) + (slime-flatten-tree (cdr tree))))))) + (defmacro destructure-case (value &rest patterns) "Dispatch VALUE to one of PATTERNS. A cross between `case' and `destructuring-bind'. @@ -704,6 +713,8 @@ `(t ,@(cdr clause)) (destructuring-bind ((op &rest rands) &rest body) clause `(,op (destructuring-bind ,rands ,operands + ,@(if (memq '_ (slime-flatten-tree rands)) + '((ignore _))) . ,body))))) patterns) ,@(if (eq (caar (last patterns)) t) @@ -1182,10 +1193,12 @@ (interactive (list (read-from-minibuffer "Host: " (first slime-connect-host-history) nil nil '(slime-connect-host-history . 1)) - (string-to-int (read-from-minibuffer - "Port: " (first slime-connect-port-history) - nil nil '(slime-connect-port-history . 1))))) - (when (and (interactive-p) slime-net-processes + (string-to-number + (read-from-minibuffer + "Port: " (first slime-connect-port-history) + nil nil '(slime-connect-port-history . 1))))) + (when (and (called-interactively-p 'interactive) + slime-net-processes (y-or-n-p "Close old connections first? ")) (slime-disconnect-all)) (message "Connecting to Swank on port %S.." port) @@ -3643,7 +3656,7 @@ (remove-hook 'pre-command-hook 'slime-complete-maybe-restore-window-configuration) (condition-case err - (cond ((find last-command-char "()\"'`,# \r\n:") + (cond ((find last-command-event "()\"'`,# \r\n:") (slime-complete-restore-window-configuration)) ((not (slime-completion-window-active-p)) (slime-complete-forget-window-configuration)) @@ -3666,7 +3679,7 @@ (display-completion-list completions) (let ((offset (- (point) 1 (length base)))) (with-current-buffer standard-output - (setq completion-base-size offset) + (setq completion-base-position offset) (set-syntax-table lisp-mode-syntax-table)))) (when savedp (setq slime-completions-window @@ -4606,8 +4619,8 @@ ((kbd "RET") 'slime-goto-xref) ((kbd "SPC") 'slime-goto-xref) ("v" 'slime-show-xref) - ("n" (lambda () (interactive) (next-line))) - ("p" (lambda () (interactive) (previous-line))) + ("n" (lambda () (interactive) (call-interactively #'next-line))) + ("p" (lambda () (interactive) (call-interactively #'previous-line))) ("\C-c\C-c" 'slime-recompile-xref) ("\C-c\C-k" 'slime-recompile-all-xrefs) ("\M-," 'slime-xref-retract) From heller at common-lisp.net Sun May 22 07:18:52 2011 From: heller at common-lisp.net (CVS User heller) Date: Sun, 22 May 2011 00:18:52 -0700 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory common-lisp.net:/tmp/cvs-serv19330 Modified Files: ChangeLog slime.el Log Message: Turn on lexical-binding for slime.el. This mostly involves prefixing unused variables with underscores to shut up the compiler, but also some less harmless changes. * slime.el (slime-dispatching-connection, slime-current-thread): Add defvars. (slime-connect): called-interactively-p wants 1 arg in Emacs 24 but none in Emacs 22. So we can't use it; instead add an extra optional arg and set that to non-nil in the interactive spec. (slime-read-from-minibuffer): Actually use the history arg. (slime-inspector-quit): Drop the unused kill-buffer arg from the lambda-list. (slime-run-tests): Can't specbind slime-repl-history-file without variable declation. I don't want to declare it here so I just eliminated it and let somebody else fix slime-repl.el. --- /project/slime/cvsroot/slime/ChangeLog 2011/05/21 18:11:39 1.2190 +++ /project/slime/cvsroot/slime/ChangeLog 2011/05/22 07:18:52 1.2191 @@ -1,3 +1,22 @@ +2011-05-22 Helmut Eller + + Turn on lexical-binding for slime.el. + This mostly involves prefixing unused variables + with underscores to shut up the compiler, but + also some less harmless changes. + + * slime.el (slime-dispatching-connection, slime-current-thread): + Add defvars. + (slime-connect): called-interactively-p wants 1 arg in Emacs 24 + but none in Emacs 22. So we can't use it; instead add an extra + optional arg and set that to non-nil in the interactive spec. + (slime-read-from-minibuffer): Actually use the history arg. + (slime-inspector-quit): Drop the unused kill-buffer arg from the + lambda-list. + (slime-run-tests): Can't specbind slime-repl-history-file without + variable declation. I don't want to declare it here so I just + eliminated it and let somebody else fix slime-repl.el. + 2011-05-21 Helmut Eller Minor tweaks to avoid some compiler warnings. --- /project/slime/cvsroot/slime/slime.el 2011/05/21 18:11:39 1.1365 +++ /project/slime/cvsroot/slime/slime.el 2011/05/22 07:18:52 1.1366 @@ -386,6 +386,8 @@ (defvar slime-modeline-string) (defvar slime-buffer-connection) +(defvar slime-dispatching-connection) +(defvar slime-current-thread) (define-minor-mode slime-mode "\\\ @@ -1188,7 +1190,7 @@ (defun slime-start* (options) (apply #'slime-start options)) -(defun slime-connect (host port &optional coding-system) +(defun slime-connect (host port &optional coding-system interactive-p) "Connect to a running Swank server. Return the connection." (interactive (list (read-from-minibuffer "Host: " (first slime-connect-host-history) @@ -1196,8 +1198,9 @@ (string-to-number (read-from-minibuffer "Port: " (first slime-connect-port-history) - nil nil '(slime-connect-port-history . 1))))) - (when (and (called-interactively-p 'interactive) + nil nil '(slime-connect-port-history . 1))) + nil t)) + (when (and interactive-p slime-net-processes (y-or-n-p "Close old connections first? ")) (slime-disconnect-all)) @@ -1499,7 +1502,7 @@ "Find the magic secret from the user's home directory. Return nil if the file doesn't exist or is empty; otherwise the first line of the file." - (condition-case err + (condition-case _err (with-temp-buffer (insert-file-contents "~/.slime-secret") (goto-char (point-min)) @@ -1928,8 +1931,7 @@ (let ((slime-dispatching-connection connection) (slime-current-thread t)) (destructuring-bind (&key pid style lisp-implementation machine - features package version modules - &allow-other-keys) info + features version modules &allow-other-keys) info (slime-check-version version connection) (setf (slime-pid) pid (slime-communication-style) style @@ -1941,7 +1943,7 @@ (slime-lisp-implementation-name) name (slime-lisp-implementation-program) program (slime-connection-name) (slime-generate-connection-name name))) - (destructuring-bind (&key instance type version) machine + (destructuring-bind (&key instance ((:type _)) ((:version _))) machine (setf (slime-machine-instance) instance))) (let ((args (when-let (p (slime-inferior-process)) (slime-inferior-lisp-args p)))) @@ -2183,7 +2185,7 @@ (error "Reply to canceled synchronous eval request tag=%S sexp=%S" tag sexp)) (throw tag (list #'identity value))) - ((:abort condition) + ((:abort _condition) (throw tag (list #'error "Synchronous Lisp Evaluation aborted")))) (let ((debug-on-quit t) (inhibit-quit nil) @@ -2502,14 +2504,14 @@ (assert (slime-inferior-process) () "No inferior lisp process") (slime-quit-lisp-internal (slime-connection) 'slime-restart-sentinel t)) -(defun slime-restart-sentinel (process message) +(defun slime-restart-sentinel (process _message) "Restart the inferior lisp process. Also rearrange windows." (assert (process-status process) 'closed) (let* ((proc (slime-inferior-process process)) (args (slime-inferior-lisp-args proc)) (buffer (buffer-name (process-buffer proc))) - (buffer-window (get-buffer-window buffer)) + ;;(buffer-window (get-buffer-window buffer)) (new-proc (slime-start-lisp (plist-get args :program) (plist-get args :program-args) (plist-get args :env) @@ -3051,7 +3053,7 @@ (let ((location (slime-note.location note))) (when location (destructure-case location - ((:error _) _ nil) ; do nothing + ((:error _) nil) ; do nothing ((:location file pos _hints) (cond ((eq (car file) ':source-form) nil) ((eq (slime-note.severity note) :read-error) @@ -3402,7 +3404,7 @@ | (:source-path ) | (:method . )" (destructure-case location - ((:location buffer position hints) + ((:location buffer _position _hints) (slime-goto-location-buffer buffer) (let ((pos (slime-location-offset location))) (cond ((and (<= (point-min) pos) (<= pos (point-max)))) @@ -3502,7 +3504,7 @@ (goto-char here) (message "No previous note.")))) -(defun slime-goto-first-note (&rest ignore) +(defun slime-goto-first-note (&rest _) "Go to the first note in the buffer." (let ((point (point))) (goto-char (point-min)) @@ -3793,7 +3795,7 @@ reading input. The result is a string (\"\" if no input was given)." (let ((minibuffer-setup-hook (slime-minibuffer-setup-hook))) (read-from-minibuffer prompt initial-value slime-minibuffer-map - nil 'slime-minibuffer-history))) + nil (or history 'slime-minibuffer-history)))) (defun slime-bogus-completion-alist (list) "Make an alist out of list. @@ -3920,7 +3922,7 @@ (format "%S" buffer) ; "#" (format "%s (previously existing buffer)" bufname)))) ((:source-form _) "(S-Exp)") - ((:zip zip entry) entry))) + ((:zip _zip entry) entry))) (t "(No location)"))) @@ -4638,7 +4640,7 @@ ;;;;; XREF results buffer and window management -(defmacro* slime-with-xref-buffer ((xref-type symbol &optional package) +(defmacro* slime-with-xref-buffer ((_xref-type _symbol &optional package) &body body) "Execute BODY in a xref buffer, then show that buffer." `(let ((xref-buffer-name% (slime-buffer-name :xref))) @@ -4690,8 +4692,8 @@ "The most recent XREF results buffer. This is used by `slime-goto-next-xref'") -(defun slime-show-xref-buffer (xrefs type symbol package) - (slime-with-xref-buffer (type symbol package) +(defun slime-show-xref-buffer (xrefs _type _symbol package) + (slime-with-xref-buffer (_type _symbol package) (slime-insert-xrefs xrefs) (setq slime-next-location-function 'slime-goto-next-xref) (setq slime-previous-location-function 'slime-goto-previous-xref) @@ -4752,6 +4754,7 @@ (interactive (list (slime-read-symbol-name "List callees: "))) (slime-xref :callees symbol-name)) +;; FIXME: whats the call (slime-postprocess-xrefs result) good for? (defun slime-xref (type symbol &optional continuation) "Make an XREF request to Lisp." (slime-eval-async @@ -5144,7 +5147,7 @@ (unless (memq (process-status process) '(exit signal)) (kill-process process)))))) -(defun slime-quit-sentinel (process message) +(defun slime-quit-sentinel (process _message) (assert (process-status process) 'closed) (let* ((inferior (slime-inferior-process process)) (inferior-buffer (if inferior (process-buffer inferior)))) @@ -5418,7 +5421,7 @@ ((:ok result) (apply #'sldb-setup thread level result)))) -(defun sldb-exit (thread level &optional stepping) +(defun sldb-exit (thread _level &optional stepping) "Exit from the debug level LEVEL." (when-let (sldb (sldb-find-buffer thread)) (with-current-buffer sldb @@ -5546,7 +5549,7 @@ (slime-add-face face string))) (insert "\n")))) -(defun sldb-fetch-more-frames (&rest ignore) +(defun sldb-fetch-more-frames (&rest _) "Fetch more backtrace frames. Called on the `point-entered' text-property hook." (let ((inhibit-point-motion-hooks t) @@ -5719,7 +5722,7 @@ (defun sldb-default-action/mouse (event) "Invoke the action pointed at by the mouse." (interactive "e") - (destructuring-bind (mouse-1 (w pos &rest _)) event + (destructuring-bind (_mouse-1 (_w pos &rest _)) event (save-excursion (goto-char pos) (let ((fn (get-text-property (point) 'sldb-default-action))) @@ -5853,8 +5856,8 @@ (funcall sldb-insert-frame-variable-value-function value frame i) (insert "\n"))))) -(defun sldb-insert-frame-variable-value (value frame index) - (insert (in-sldb-face local-value value))) +(defun sldb-insert-frame-variable-value (value _frame _index) + (insert (in-sldb-face local-value value))) (defun sldb-hide-frame-details () ;; delete locals and catch tags, but keep the function name and args. @@ -6607,7 +6610,7 @@ (t (message "No next object") (ding))))) -(defun slime-inspector-quit (&optional kill-buffer) +(defun slime-inspector-quit () "Quit the inspector and kill the buffer." (interactive) (slime-eval-async `(swank:quit-inspector)) @@ -6764,7 +6767,7 @@ (t '(nil nil)))))) (defun slime-inspector-join-chunks (chunk1 chunk2) - (destructuring-bind (i1 l1 s1 e1) chunk1 + (destructuring-bind (i1 _l1 s1 e1) chunk1 (destructuring-bind (i2 l2 s2 e2) chunk2 (cond ((= e1 s2) (list (append i1 i2) l2 s1 e2)) @@ -6859,7 +6862,7 @@ (ignore-errors (kill-buffer "*Select Help*")) (with-current-buffer (get-buffer-create "*Select Help*") (insert "Select Methods:\n\n") - (loop for (key line function) in slime-selector-methods + (loop for (key line _function) in slime-selector-methods do (insert (format "%c:\t%s\n" key line))) (goto-char (point-min)) (help-mode) @@ -6990,7 +6993,7 @@ authors license) -(defmacro define-slime-contrib (name docstring &rest clauses) +(defmacro define-slime-contrib (name _docstring &rest clauses) (destructuring-bind (&key slime-dependencies swank-dependencies on-load @@ -7024,7 +7027,7 @@ (put 'slime-indulge-pretty-colors 'define-slime-contrib t) (defun slime-all-contribs () - (loop for (name val) on (symbol-plist 'slime-contribs) by #'cddr + (loop for (_name val) on (symbol-plist 'slime-contribs) by #'cddr when (slime-contrib-p val) collect val)) @@ -7207,11 +7210,13 @@ (defun slime-cheat-sheet () (interactive) - (switch-to-buffer-other-frame (get-buffer-create (slime-buffer-name :cheat-sheet))) + (switch-to-buffer-other-frame + (get-buffer-create (slime-buffer-name :cheat-sheet))) (setq buffer-read-only nil) (delete-region (point-min) (point-max)) (goto-char (point-min)) - (insert "SLIME: The Superior Lisp Interaction Mode for Emacs (minor-mode).\n\n") + (insert + "SLIME: The Superior Lisp Interaction Mode for Emacs (minor-mode).\n\n") (dolist (mode slime-cheat-sheet-table) (let ((title (getf mode :title)) (mode-map (getf mode :map)) @@ -7238,19 +7243,17 @@ (integerp (aref binding 0))) (push binding key-bindings))) (push (mapconcat 'key-description key-bindings " or ") keys))) - (loop - with key-length = (apply 'max (mapcar 'length keys)) - with desc-length = (apply 'max (mapcar 'length descriptions)) - for key in (nreverse keys) - for desc in (nreverse descriptions) - do (insert desc) - do (insert (make-string (- desc-length (length desc)) ? )) - do (insert " => ") - do (insert (if (string= "" key) - "" - key)) - do (insert "\n") - finally do (insert "\n"))))) + (loop with desc-length = (apply 'max (mapcar 'length descriptions)) + for key in (nreverse keys) + for desc in (nreverse descriptions) + do (insert desc) + do (insert (make-string (- desc-length (length desc)) ? )) + do (insert " => ") + do (insert (if (string= "" key) + "" + key)) + do (insert "\n") + finally do (insert "\n"))))) (setq buffer-read-only t) (goto-char (point-min))) @@ -7303,9 +7306,7 @@ (assert (slime-at-top-level-p) () "Pending RPCs or open debuggers.") (slime-create-test-results-buffer) (unwind-protect - (let ((slime-repl-history-file - (expand-file-name "slime-repl-history" (slime-temp-directory))) - (slime-tests (if slime-randomize-test-order + (let ((slime-tests (if slime-randomize-test-order (slime-shuffle-list slime-tests) slime-tests))) (slime-execute-tests)) @@ -7353,7 +7354,6 @@ (save-window-excursion (let ((slime-total-tests 0) (slime-skipped-tests 0) - (slime-expected-passes 0) (slime-unexpected-failures 0) (slime-expected-failures 0) (slime-lisp-under-test (slime-lisp-implementation-name))) @@ -7409,10 +7409,8 @@ (slime) ;; Block until we are up and running. (let* ((timeout 30) - (cell (cons nil nil)) - (timer (run-with-timer timeout nil (lambda (cell) - (setcar cell t)) - cell))) + (cell (cons nil nil))) + (run-with-timer timeout nil (lambda (cell) (setcar cell t)) cell) (while (not (slime-connected-p)) (sit-for 1) (when (car cell) @@ -7557,7 +7555,7 @@ ;; Clear out old tests. (setq slime-tests nil) -(defun slime-check-top-level (&optional test-name) +(defun slime-check-top-level () ;(&optional _test-name) (slime-accept-process-output nil 0.001) (slime-check "At the top level (no debugging or pending RPCs)" (slime-at-top-level-p))) @@ -8998,9 +8996,9 @@ (interactive) (let ((saved-point (point)) (state (parse-partial-sexp (point-min) (point-max) -1))) - (destructuring-bind (depth innermost-start last-terminated-start + (destructuring-bind (depth innermost-start _last-terminated-start in-string in-comment after-quote - minimum-depth comment-style + _minimum-depth comment-style comment-or-string-start &rest _) state (cond ((and (zerop depth) (not in-string) @@ -9044,15 +9042,15 @@ (or (eq coding-system 'binary) (error "No such coding system: %S" coding-system))) -(slime-defun-if-undefined process-coding-system (process) +(slime-defun-if-undefined process-coding-system (_process) '(binary . binary)) (slime-defun-if-undefined set-process-coding-system - (process &optional decoding encoding)) + (_process &optional _decoding _encoding)) ;; For Emacs 21 (slime-defun-if-undefined display-warning - (type message &optional level buffer-name) + (type message &optional level _buffer-name) (with-output-to-temp-buffer "*Warnings*" (princ (format "Warning (%s %s): %s" type level message)))) @@ -9158,6 +9156,7 @@ (run-hooks 'slime-load-hook) ;; Local Variables: +;; lexical-binding: t ;; outline-regexp: ";;;;+" ;; indent-tabs-mode: nil ;; coding: latin-1-unix From heller at common-lisp.net Mon May 23 11:41:27 2011 From: heller at common-lisp.net (CVS User heller) Date: Mon, 23 May 2011 04:41:27 -0700 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory common-lisp.net:/tmp/cvs-serv19997 Modified Files: ChangeLog slime.el Log Message: * slime.el (slime-apropos-label-properties): Deleted. Just auto-load apropos-mode. (slime-print-apropos): Use the variable apropos-label-face which seems to exist in all relevant Emacsen. --- /project/slime/cvsroot/slime/ChangeLog 2011/05/22 07:18:52 1.2191 +++ /project/slime/cvsroot/slime/ChangeLog 2011/05/23 11:41:27 1.2192 @@ -1,3 +1,10 @@ +2011-05-23 Helmut Eller + + * slime.el (slime-apropos-label-properties): Deleted. Just + auto-load apropos-mode. + (slime-print-apropos): Use the variable apropos-label-face + which seems to exist in all relevant Emacsen. + 2011-05-22 Helmut Eller Turn on lexical-binding for slime.el. --- /project/slime/cvsroot/slime/slime.el 2011/05/22 07:18:52 1.1366 +++ /project/slime/cvsroot/slime/slime.el 2011/05/23 11:41:27 1.1367 @@ -4518,6 +4518,7 @@ current-prefix-arg)) (slime-apropos "" (not internal) package)) +(autoload 'apropos-mode "apropos") (defun slime-show-apropos (plists string package summary) (if (null plists) (message "No apropos matches for %S" string) @@ -4532,55 +4533,42 @@ (set-syntax-table lisp-mode-syntax-table) (goto-char (point-min))))) -(defvar slime-apropos-label-properties - (progn - (require 'apropos) - (cond ((and (boundp 'apropos-label-properties) - (symbol-value 'apropos-label-properties))) - ((boundp 'apropos-label-face) - (etypecase (symbol-value 'apropos-label-face) - (symbol `(face ,(or (symbol-value 'apropos-label-face) - 'italic) - mouse-face highlight)) - (list (symbol-value 'apropos-label-face))))))) - (defun slime-print-apropos (plists) (dolist (plist plists) (let ((designator (plist-get plist :designator))) (assert designator) (slime-insert-propertized `(face ,apropos-symbol-face) designator)) (terpri) - (let ((apropos-label-properties slime-apropos-label-properties)) - (loop for (prop namespace) - in '((:variable "Variable") - (:function "Function") - (:generic-function "Generic Function") - (:macro "Macro") - (:special-operator "Special Operator") - (:setf "Setf") - (:type "Type") - (:class "Class") - (:alien-type "Alien type") - (:alien-struct "Alien struct") - (:alien-union "Alien type") - (:alien-enum "Alien enum")) - ;; Properties not listed here will not show up in the buffer - do - (let ((value (plist-get plist prop)) - (start (point))) - (when value - (princ " ") - (slime-insert-propertized apropos-label-properties namespace) - (princ ": ") - (princ (etypecase value - (string value) - ((member :not-documented) "(not documented)"))) - (add-text-properties - start (point) - (list 'type prop 'action 'slime-call-describer - 'button t 'apropos-label namespace - 'item (plist-get plist :designator))) - (terpri))))))) + (loop for (prop namespace) + in '((:variable "Variable") + (:function "Function") + (:generic-function "Generic Function") + (:macro "Macro") + (:special-operator "Special Operator") + (:setf "Setf") + (:type "Type") + (:class "Class") + (:alien-type "Alien type") + (:alien-struct "Alien struct") + (:alien-union "Alien type") + (:alien-enum "Alien enum")) + ;; Properties not listed here will not show up in the buffer + do + (let ((value (plist-get plist prop)) + (start (point))) + (when value + (princ " ") + (slime-insert-propertized `(face ,apropos-label-face) namespace) + (princ ": ") + (princ (etypecase value + (string value) + ((member :not-documented) "(not documented)"))) + (add-text-properties + start (point) + (list 'type prop 'action 'slime-call-describer + 'button t 'apropos-label namespace + 'item (plist-get plist :designator))) + (terpri)))))) (defun slime-call-describer (arg) (let* ((pos (if (markerp arg) arg (point))) From sboukarev at common-lisp.net Mon May 23 22:51:46 2011 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Mon, 23 May 2011 15:51:46 -0700 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory common-lisp.net:/tmp/cvs-serv19109 Modified Files: ChangeLog slime.el swank.lisp Log Message: * slime.el (sdlb-print-condition): New (or old new) function. It was bound by P in sldb-mode, but for some reason it was lost. --- /project/slime/cvsroot/slime/ChangeLog 2011/05/23 11:41:27 1.2192 +++ /project/slime/cvsroot/slime/ChangeLog 2011/05/23 22:51:45 1.2193 @@ -1,3 +1,9 @@ +2011-05-23 Stas Boukarev + + * swank.lisp (sdlb-print-condition): New (or old new) + function. It was bound by P in sldb-mode, but for some reason it + was lost. + 2011-05-23 Helmut Eller * slime.el (slime-apropos-label-properties): Deleted. Just --- /project/slime/cvsroot/slime/slime.el 2011/05/23 11:41:27 1.1367 +++ /project/slime/cvsroot/slime/slime.el 2011/05/23 22:51:45 1.1368 @@ -5905,6 +5905,10 @@ (slime-eval-async '(swank:inspect-current-condition) 'slime-open-inspector)) +(defun sldb-print-condition () + (interactive) + (slime-eval-describe `(swank:sdlb-print-condition))) + ;;;;;; SLDB movement --- /project/slime/cvsroot/slime/swank.lisp 2011/04/14 01:21:11 1.742 +++ /project/slime/cvsroot/slime/swank.lisp 2011/05/23 22:51:46 1.743 @@ -2773,6 +2773,9 @@ (setq *break-on-signals* (not *break-on-signals*)) (format nil "*break-on-signals* = ~a" *break-on-signals*)) +(defslimefun sdlb-print-condition () + (princ-to-string *swank-debugger-condition*)) + ;;;; Compilation Commands. From heller at common-lisp.net Tue May 24 06:27:55 2011 From: heller at common-lisp.net (CVS User heller) Date: Mon, 23 May 2011 23:27:55 -0700 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory common-lisp.net:/tmp/cvs-serv12599 Modified Files: ChangeLog slime.el Log Message: * slime.el (destructure-case): Fix "`_' not left unused" warnings. Insert an (ignore) form for empty bodies; this inhibts the compiler transformation that leads to the spurios warning. This has no runtime cost in compiled code, since the compiler recognizes (ignore) and emits no code for it. (slime-flatten-tree): Deleted. No longer used. --- /project/slime/cvsroot/slime/ChangeLog 2011/05/23 22:51:45 1.2193 +++ /project/slime/cvsroot/slime/ChangeLog 2011/05/24 06:27:55 1.2194 @@ -1,3 +1,12 @@ +2011-05-24 Helmut Eller + + * slime.el (destructure-case): Fix "`_' not left unused" warnings. + Insert an (ignore) form for empty bodies; this inhibts the + compiler transformation that leads to the spurios warning. This + has no runtime cost in compiled code, since the compiler + recognizes (ignore) and emits no code for it. + (slime-flatten-tree): Deleted. No longer used. + 2011-05-23 Stas Boukarev * swank.lisp (sdlb-print-condition): New (or old new) --- /project/slime/cvsroot/slime/slime.el 2011/05/23 22:51:45 1.1368 +++ /project/slime/cvsroot/slime/slime.el 2011/05/24 06:27:55 1.1369 @@ -689,12 +689,6 @@ (put 'when-let 'lisp-indent-function 1) -(eval-and-compile - (defun slime-flatten-tree (tree) - (cond ((atom tree) (list tree)) - (t (append (slime-flatten-tree (car tree)) - (slime-flatten-tree (cdr tree))))))) - (defmacro destructure-case (value &rest patterns) "Dispatch VALUE to one of PATTERNS. A cross between `case' and `destructuring-bind'. @@ -715,9 +709,9 @@ `(t ,@(cdr clause)) (destructuring-bind ((op &rest rands) &rest body) clause `(,op (destructuring-bind ,rands ,operands - ,@(if (memq '_ (slime-flatten-tree rands)) - '((ignore _))) - . ,body))))) + . ,(or body + '((ignore)) ; suppress some warnings + )))))) patterns) ,@(if (eq (caar (last patterns)) t) '() @@ -3053,7 +3047,7 @@ (let ((location (slime-note.location note))) (when location (destructure-case location - ((:error _) nil) ; do nothing + ((:error _)) ; do nothing ((:location file pos _hints) (cond ((eq (car file) ':source-form) nil) ((eq (slime-note.severity note) :read-error) From sboukarev at common-lisp.net Thu May 26 00:27:14 2011 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Wed, 25 May 2011 17:27:14 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv12733 Modified Files: ChangeLog slime-package-fu.el Log Message: * slime-package-fu.el (slime-add-export): Add :export to the end of a defpackage form when there's no :export present. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/21 17:01:48 1.460 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/26 00:27:14 1.461 @@ -1,3 +1,8 @@ +2011-05-26 Stas Boukarev + + * slime-package-fu.el (slime-add-export): Add :export to the end + of a defpackage form when there's no :export present. + 2011-05-21 Helmut Eller * slime-snapshot.el: License is GPL. --- /project/slime/cvsroot/slime/contrib/slime-package-fu.el 2010/07/24 23:39:24 1.12 +++ /project/slime/cvsroot/slime/contrib/slime-package-fu.el 2011/05/26 00:27:14 1.13 @@ -180,17 +180,20 @@ number-of-actions))) (defun slime-add-export () - (let (point) - (save-excursion - (while (ignore-errors (slime-goto-next-export-clause) t) - (setq point (point)))) - (cond (point - (goto-char point) - (down-list) - (slime-end-of-list)) - (t - (insert "(:export ") - (save-excursion (insert ")")))))) + (let (point) + (save-excursion + (while (ignore-errors (slime-goto-next-export-clause) t) + (setq point (point)))) + (cond (point + (goto-char point) + (down-list) + (slime-end-of-list)) + (t + (slime-end-of-list) + (unless (looking-back "^\\s-*") + (newline-and-indent)) + (insert "(:export ") + (save-excursion (insert ")")))))) (defun slime-insert-export (symbol-name) ;; Assumes we're at the inside :export after the last symbol From heller at common-lisp.net Fri May 27 07:45:44 2011 From: heller at common-lisp.net (CVS User heller) Date: Fri, 27 May 2011 00:45:44 -0700 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory common-lisp.net:/tmp/cvs-serv27143 Modified Files: ChangeLog slime.el Log Message: Fix "wrong number of args" problem with slime-inspector-quit. Reported by Anton Kovalenko. * slime.el (slime-popup-buffer-quit-function) (slime-quit-threads-buffer): Drop the kill-buffer-p argument. --- /project/slime/cvsroot/slime/ChangeLog 2011/05/24 06:27:55 1.2194 +++ /project/slime/cvsroot/slime/ChangeLog 2011/05/27 07:45:44 1.2195 @@ -1,3 +1,11 @@ +2011-05-27 Helmut Eller + + Fix "wrong number of args" problem with slime-inspector-quit. + Reported by Anton Kovalenko. + + * slime.el (slime-popup-buffer-quit-function) + (slime-quit-threads-buffer): Drop the kill-buffer-p argument. + 2011-05-24 Helmut Eller * slime.el (destructure-case): Fix "`_' not left unused" warnings. --- /project/slime/cvsroot/slime/slime.el 2011/05/24 06:27:55 1.1369 +++ /project/slime/cvsroot/slime/slime.el 2011/05/27 07:45:44 1.1370 @@ -1004,10 +1004,10 @@ (defvar slime-popup-buffer-quit-function 'slime-popup-buffer-quit "The function that is used to quit a temporary popup buffer.")) -(defun slime-popup-buffer-quit-function (&optional kill-buffer-p) +(defun slime-popup-buffer-quit-function () "Wrapper to invoke the value of `slime-popup-buffer-quit-function'." (interactive) - (funcall slime-popup-buffer-quit-function kill-buffer-p)) + (funcall slime-popup-buffer-quit-function)) ;; Interface (defun slime-popup-buffer-quit (&optional kill-buffer-p) @@ -6154,7 +6154,7 @@ (defvar slime-thread-index-to-id nil) -(defun slime-quit-threads-buffer (&optional _) +(defun slime-quit-threads-buffer () (when slime-threads-buffer-timer (cancel-timer slime-threads-buffer-timer) (setq slime-threads-buffer-timer nil)) From sboukarev at common-lisp.net Tue May 31 10:19:07 2011 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Tue, 31 May 2011 03:19:07 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv26172 Modified Files: ChangeLog slime-package-fu.el Log Message: * slime-package-fu.el (slime-export-symbol-representation-auto): New variable. Default value is NIL. Determine automatically which style is used for symbols, #: or : If it's mixed or no symbols are exported so far, use `slime-export-symbol-representation-function'. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/26 00:27:14 1.461 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/31 10:19:07 1.462 @@ -1,7 +1,15 @@ +2011-05-31 Stas Boukarev + + * slime-package-fu.el (slime-export-symbol-representation-auto): + New variable. Default value is NIL. + Determine automatically which style is used for symbols, #: or : + If it's mixed or no symbols are exported so far, + use `slime-export-symbol-representation-function'. + 2011-05-26 Stas Boukarev * slime-package-fu.el (slime-add-export): Add :export to the end - of a defpackage form when there's no :export present. + of a defpackage form when there's no :export present. 2011-05-21 Helmut Eller --- /project/slime/cvsroot/slime/contrib/slime-package-fu.el 2011/05/26 00:27:14 1.13 +++ /project/slime/cvsroot/slime/contrib/slime-package-fu.el 2011/05/31 10:19:07 1.14 @@ -23,10 +23,14 @@ (defvar slime-export-symbol-representation-function #'(lambda (n) (format "#:%s" n))) +(defvar slime-export-symbol-representation-auto nil + "Determine automatically which style is used for symbols, #: or : +If it's mixed or no symbols are exported so far, +use `slime-export-symbol-representation-function'.") + (defvar slime-defpackage-regexp "^(\\(cl:\\|common-lisp:\\)?defpackage\\>[ \t']*") - (defun slime-find-package-definition-rpc (package) (slime-eval `(swank:find-definition-for-thing (swank::guess-package ,package)))) @@ -195,10 +199,39 @@ (insert "(:export ") (save-excursion (insert ")")))))) +(defun slime-export-symbols () + "Return a list of symbols inside :export clause of a defpackage." + ;; Assumes we're at the beginning of :export + (save-excursion + (loop while (ignore-errors (forward-sexp) t) + collect (slime-symbol-at-point)))) + +(defun slime-determine-symbol-style () + ;; Assumes we're inside :export + (save-excursion + (slime-beginning-of-list) + (slime-forward-sexp) + (let ((symbols (slime-export-symbols))) + (cond ((every (lambda (x) + (string-match "^:" x)) + symbols) + (lambda (n) (format ":%s" n))) + ((every (lambda (x) + (string-match "^#:" x)) + symbols) + (lambda (n) (format "#:%s" n))) + (t + slime-export-symbol-representation-function))))) + +(defun slime-format-symbol-for-defpackage (symbol-name) + (funcall (if slime-export-symbol-representation-auto + (slime-determine-symbol-style) + slime-export-symbol-representation-function) + symbol-name)) + (defun slime-insert-export (symbol-name) ;; Assumes we're at the inside :export after the last symbol - (let ((symbol-name (funcall slime-export-symbol-representation-function - symbol-name))) + (let ((symbol-name (slime-format-symbol-for-defpackage symbol-name))) (unless (looking-back "^\\s-*") (newline-and-indent)) (insert symbol-name))) From sboukarev at common-lisp.net Tue May 31 10:30:02 2011 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Tue, 31 May 2011 03:30:02 -0700 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory common-lisp.net:/tmp/cvs-serv26356 Modified Files: ChangeLog slime-package-fu.el Log Message: Change default value of slime-export-symbol-representation-auto to t. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/31 10:19:07 1.462 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2011/05/31 10:30:02 1.463 @@ -1,7 +1,7 @@ 2011-05-31 Stas Boukarev * slime-package-fu.el (slime-export-symbol-representation-auto): - New variable. Default value is NIL. + New variable. Default value is t. Determine automatically which style is used for symbols, #: or : If it's mixed or no symbols are exported so far, use `slime-export-symbol-representation-function'. --- /project/slime/cvsroot/slime/contrib/slime-package-fu.el 2011/05/31 10:19:07 1.14 +++ /project/slime/cvsroot/slime/contrib/slime-package-fu.el 2011/05/31 10:30:02 1.15 @@ -23,7 +23,7 @@ (defvar slime-export-symbol-representation-function #'(lambda (n) (format "#:%s" n))) -(defvar slime-export-symbol-representation-auto nil +(defvar slime-export-symbol-representation-auto t "Determine automatically which style is used for symbols, #: or : If it's mixed or no symbols are exported so far, use `slime-export-symbol-representation-function'.")