aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2002-03-12 16:27:15 +0000
committerGerd Moellmann2002-03-12 16:27:15 +0000
commit59e0f5794231dc51c529c61ea1adf7d7f9d7d6d4 (patch)
tree7243e4e347cabbb44cd0a8a4b7a8f67f05c5f1e6
parenta13d6523e020883906e323b4509194a4651b9459 (diff)
downloademacs-59e0f5794231dc51c529c61ea1adf7d7f9d7d6d4.tar.gz
emacs-59e0f5794231dc51c529c61ea1adf7d7f9d7d6d4.zip
(lisp-loop-keyword-indentation)
(lisp-loop-forms-indentation, lisp-simple-loop-indentation): New user options. (extended-loop-p, common-lisp-loop-part-indentation): New functions. (common-lisp-indent-function-1): Renamed from common-lisp-indent-function. (common-lisp-indent-function): Handle loop forms specially. (lisp-indent-defmethod): Use car/cdr instead of first/rest.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/emacs-lisp/cl-indent.el74
2 files changed, 81 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c0a2fd5f135..a865f7c0552 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12002-03-12 Gerd Moellmann <gerd@gnu.org>
2
3 * emacs-lisp/cl-indent.el (lisp-loop-keyword-indentation)
4 (lisp-loop-forms-indentation, lisp-simple-loop-indentation): New
5 user options.
6 (extended-loop-p, common-lisp-loop-part-indentation): New
7 functions.
8 (common-lisp-indent-function-1): Renamed from
9 common-lisp-indent-function.
10 (common-lisp-indent-function): Handle loop forms specially.
11 (lisp-indent-defmethod): Use car/cdr instead of first/rest.
12
12002-03-12 Francesco Potorti` <pot@gnu.org> 132002-03-12 Francesco Potorti` <pot@gnu.org>
2 14
3 * progmodes/etags.el (tag-exact-file-name-match-p) 15 * progmodes/etags.el (tag-exact-file-name-match-p)
diff --git a/lisp/emacs-lisp/cl-indent.el b/lisp/emacs-lisp/cl-indent.el
index 294b7b7f5d2..6b40051193e 100644
--- a/lisp/emacs-lisp/cl-indent.el
+++ b/lisp/emacs-lisp/cl-indent.el
@@ -1,6 +1,6 @@
1;;; cl-indent.el --- enhanced lisp-indent mode 1;;; cl-indent.el --- enhanced lisp-indent mode
2 2
3;; Copyright (C) 1987, 2000, 2001 Free Software Foundation, Inc. 3;; Copyright (C) 1987, 2000, 2001, 2002 Free Software Foundation, Inc.
4 4
5;; Author: Richard Mlynarik <mly@eddie.mit.edu> 5;; Author: Richard Mlynarik <mly@eddie.mit.edu>
6;; Created: July 1987 6;; Created: July 1987
@@ -78,12 +78,71 @@ by `lisp-body-indent'."
78 :type 'integer 78 :type 'integer
79 :group 'lisp-indent) 79 :group 'lisp-indent)
80 80
81(defcustom lisp-backquote-indentation t
82 "*Whether or not to indent backquoted lists as code.
83If nil, indent backquoted lists as data, i.e., like quoted lists."
84 :type 'boolean
85 :group 'lisp-indent)
86
87
88(defcustom lisp-loop-keyword-indentation 3
89 "*Indentation of loop keywords in extended loop forms."
90 :type 'integer
91 :group 'lisp-indent)
92
93
94(defcustom lisp-loop-forms-indentation 5
95 "*Indentation of forms in extended loop forms."
96 :type 'integer
97 :group 'lisp-indent)
98
99
100(defcustom lisp-simple-loop-indentation 3
101 "*Indentation of forms in simple loop forms."
102 :type 'integer
103 :group 'lisp-indent)
104
81 105
82(defvar lisp-indent-error-function) 106(defvar lisp-indent-error-function)
83(defvar lisp-indent-defun-method '(4 &lambda &body)) 107(defvar lisp-indent-defun-method '(4 &lambda &body))
84 108
109
110(defun extended-loop-p (loop-start)
111 "True if an extended loop form starta at LOOP-START."
112 (condition-case ()
113 (save-excursion
114 (goto-char loop-start)
115 (forward-char 1)
116 (forward-sexp 2)
117 (backward-sexp 1)
118 (looking-at "\\sw"))
119 (error t)))
120
121
122(defun common-lisp-loop-part-indentation (indent-point state)
123 "Compute the indentation of loop form constituents."
124 (let* ((loop-indentation (save-excursion
125 (goto-char (elt state 1))
126 (current-column))))
127 (goto-char indent-point)
128 (beginning-of-line)
129 (cond ((not (extended-loop-p (elt state 1)))
130 lisp-simple-loop-indentation)
131 ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)")
132 (+ loop-indentation lisp-loop-keyword-indentation))
133 (t
134 (+ loop-indentation lisp-loop-forms-indentation)))))
135
136
85;;;###autoload 137;;;###autoload
86(defun common-lisp-indent-function (indent-point state) 138(defun common-lisp-indent-function (indent-point state)
139 (if (save-excursion (goto-char (elt state 1))
140 (looking-at "([Ll][Oo][Oo][Pp]"))
141 (common-lisp-loop-part-indentation indent-point state)
142 (common-lisp-indent-function-1 indent-point state)))
143
144
145(defun common-lisp-indent-function-1 (indent-point state)
87 (let ((normal-indent (current-column))) 146 (let ((normal-indent (current-column)))
88 ;; Walk up list levels until we see something 147 ;; Walk up list levels until we see something
89 ;; which does special things with subforms. 148 ;; which does special things with subforms.
@@ -102,6 +161,7 @@ by `lisp-body-indent'."
102 ;; Move to start of innermost containing list 161 ;; Move to start of innermost containing list
103 (goto-char containing-form-start) 162 (goto-char containing-form-start)
104 (setq sexp-column (current-column)) 163 (setq sexp-column (current-column))
164
105 ;; Look over successively less-deep containing forms 165 ;; Look over successively less-deep containing forms
106 (while (and (not calculated) 166 (while (and (not calculated)
107 (< depth lisp-indent-maximum-backtracking)) 167 (< depth lisp-indent-maximum-backtracking))
@@ -160,7 +220,9 @@ by `lisp-body-indent'."
160 ((eq method 'defun) 220 ((eq method 'defun)
161 (setq method lisp-indent-defun-method))) 221 (setq method lisp-indent-defun-method)))
162 222
163 (cond ((and (memq (char-after (1- containing-sexp)) '(?\' ?\`)) 223 (cond ((and (or (eq (char-after (1- containing-sexp)) ?\')
224 (and (not lisp-backquote-indentation)
225 (eq (char-after (1- containing-sexp)) ?\`)))
164 (not (eq (char-after (- containing-sexp 2)) ?\#))) 226 (not (eq (char-after (- containing-sexp 2)) ?\#)))
165 ;; No indentation for "'(...)" elements 227 ;; No indentation for "'(...)" elements
166 (setq calculated (1+ sexp-column))) 228 (setq calculated (1+ sexp-column)))
@@ -355,11 +417,12 @@ by `lisp-body-indent'."
355 (&whole nil &rest 1)) 417 (&whole nil &rest 1))
356 path state indent-point sexp-column normal-indent))) 418 path state indent-point sexp-column normal-indent)))
357 419
420
358(defun lisp-indent-defmethod (path state indent-point sexp-column 421(defun lisp-indent-defmethod (path state indent-point sexp-column
359 normal-indent) 422 normal-indent)
360 "Indentation function defmethod." 423 "Indentation function defmethod."
361 (lisp-indent-259 (if (and (>= (first path) 3) 424 (lisp-indent-259 (if (and (>= (car path) 3)
362 (null (rest path)) 425 (null (cdr path))
363 (save-excursion (goto-char (elt state 1)) 426 (save-excursion (goto-char (elt state 1))
364 (forward-char 1) 427 (forward-char 1)
365 (forward-sexp 3) 428 (forward-sexp 3)
@@ -388,6 +451,7 @@ by `lisp-body-indent'."
388 (+ sexp-column lisp-body-indent))) 451 (+ sexp-column lisp-body-indent)))
389 (error (+ sexp-column lisp-body-indent))))) 452 (error (+ sexp-column lisp-body-indent)))))
390 453
454
391 455
392(let ((l '((block 1) 456(let ((l '((block 1)
393 (case (4 &rest (&whole 2 &rest 1))) 457 (case (4 &rest (&whole 2 &rest 1)))
@@ -435,7 +499,7 @@ by `lisp-body-indent'."
435 (compiler-let . let) ;barf 499 (compiler-let . let) ;barf
436 (handler-bind . let) (restart-bind . let) 500 (handler-bind . let) (restart-bind . let)
437 (locally 1) 501 (locally 1)
438 ;(loop ...) 502 ;(loop lisp-indent-loop)
439 (:method (&lambda &body)) ; in `defgeneric' 503 (:method (&lambda &body)) ; in `defgeneric'
440 (multiple-value-bind ((&whole 6 &rest 1) 4 &body)) 504 (multiple-value-bind ((&whole 6 &rest 1) 4 &body))
441 (multiple-value-call (4 &body)) 505 (multiple-value-call (4 &body))