* `common-lisp-indent-function', `flet' and "def*"
@ 2002-05-24 13:02 Dave Pearson
2002-05-25 21:19 ` Richard Stallman
0 siblings, 1 reply; 3+ messages in thread
From: Dave Pearson @ 2002-05-24 13:02 UTC (permalink / raw)
In GNU Emacs 21.2.1 (i586-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2002-03-20 on hagbard
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: nil
locale-coding-system: nil
default-enable-multibyte-characters: nil
Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:
`common-lisp-indent-function' gets the indentation of the first line of a
function wrong when defining a function via `flet' and where the name of
that function begins with "def".
To test this start a new "emacs -q", then, in the *scratch* buffer,
evaluate:
,----
| (setq lisp-indent-function 'common-lisp-indent-function)
`----
now enter and indent this code:
,----
| (flet ((is-defun-p ()
| nil)))
`----
followed by:
,----
| (flet ((defunp ()
| nil))
`----
note how the indent of the second form differs from the indent of the first
form.
--
Dave Pearson
http://www.davep.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: `common-lisp-indent-function', `flet' and "def*"
2002-05-24 13:02 `common-lisp-indent-function', `flet' and "def*" Dave Pearson
@ 2002-05-25 21:19 ` Richard Stallman
2002-05-27 10:27 ` Dave Pearson
0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2002-05-25 21:19 UTC (permalink / raw)
Cc: bug-gnu-emacs
Does this give good results? It seems correct with my
limited testing.
*** cl-indent.el.~1.36.~ Sat Mar 16 01:45:49 2002
--- cl-indent.el Sat May 25 10:57:06 2002
***************
*** 153,159 ****
(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
--- 153,160 ----
(path ())
;; set non-nil when somebody works out the indentation to use
calculated
! 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
***************
*** 169,175 ****
(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)
--- 170,176 ----
(forward-char 1)
(parse-partial-sexp (point) indent-point 1 t)
;; Move to the car of the relevant containing form
! (let (tem function method tentative-defun)
(if (not (looking-at "\\sw\\|\\s_"))
;; This form doesn't seem to start with a symbol
(setq function nil method nil)
***************
*** 209,221 ****
(cond ((null function))
((null method)
(when (null (cdr path))
! ;; (package prefix was stripped off above)
! (setq method (cond ((string-match "\\`def"
! function)
! lisp-indent-defun-method)
! ((string-match "\\`\\(with\\|do\\)-"
! function)
! '(&lambda &body))))))
;; backwards compatibility. Bletch.
((eq method 'defun)
(setq method lisp-indent-defun-method)))
--- 210,222 ----
(cond ((null function))
((null method)
(when (null (cdr path))
! ;; (package prefix was stripped off above)
! (cond ((string-match "\\`def"
! function)
! (setq tentative-defun t))
! ((string-match "\\`\\(with\\|do\\)-"
! function)
! (setq method '(&lambda &body))))))
;; backwards compatibility. Bletch.
((eq method 'defun)
(setq method lisp-indent-defun-method)))
***************
*** 234,240 ****
((eq (char-after (1- containing-sexp)) ?\#)
;; "#(...)"
(setq calculated (1+ sexp-column)))
! ((null method))
((integerp method)
;; convenient top-level hack.
;; (also compatible with lisp-indent-function)
--- 235,260 ----
((eq (char-after (1- containing-sexp)) ?\#)
;; "#(...)"
(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)))
((integerp method)
;; convenient top-level hack.
;; (also compatible with lisp-indent-function)
***************
*** 253,277 ****
(t
;; other body form
normal-indent))))
! ((symbolp method)
! (let ((lisp-indent-error-function function))
! (setq calculated (funcall method
! path state indent-point
! sexp-column normal-indent))))
! (t
! (let ((lisp-indent-error-function function))
! (setq calculated (lisp-indent-259
! 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))))))
! calculated)))
(defun lisp-indent-report-bad-format (m)
(error "%s has a badly-formed %s property: %s"
--- 273,302 ----
(t
;; other body form
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))))))
! (or calculated tentative-calculated))))
!
+ (defun common-lisp-indent-call-method (function method path state indent-point
+ sexp-column normal-indent)
+ (let ((lisp-indent-error-function function))
+ (if (symbolp method)
+ (funcall method
+ path state indent-point
+ sexp-column normal-indent)
+ (lisp-indent-259 method path state indent-point
+ sexp-column normal-indent))))
(defun lisp-indent-report-bad-format (m)
(error "%s has a badly-formed %s property: %s"
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-05-27 10:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-24 13:02 `common-lisp-indent-function', `flet' and "def*" Dave Pearson
2002-05-25 21:19 ` Richard Stallman
2002-05-27 10:27 ` Dave Pearson
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.