From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.bugs Subject: Re: `common-lisp-indent-function', `flet' and "def*" Date: Sat, 25 May 2002 15:19:55 -0600 (MDT) Sender: bug-gnu-emacs-admin@gnu.org Message-ID: <200205252119.g4PLJtT04414@aztec.santafe.edu> References: <20020524140249.A25750@hagbard.davep.org> Reply-To: rms@gnu.org NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1022361697 1738 127.0.0.1 (25 May 2002 21:21:37 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 25 May 2002 21:21:37 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17Biym-0000Rv-00 for ; Sat, 25 May 2002 23:21:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17BizO-0003m8-00; Sat, 25 May 2002 17:22:14 -0400 Original-Received: from pele.santafe.edu ([192.12.12.119]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17BixE-0003WT-00; Sat, 25 May 2002 17:20:00 -0400 Original-Received: from aztec.santafe.edu (aztec [192.12.12.49]) by pele.santafe.edu (8.11.6+Sun/8.9.3) with ESMTP id g4PLJtK14622; Sat, 25 May 2002 15:19:55 -0600 (MDT) Original-Received: (from rms@localhost) by aztec.santafe.edu (8.10.2+Sun/8.9.3) id g4PLJtT04414; Sat, 25 May 2002 15:19:55 -0600 (MDT) X-Authentication-Warning: aztec.santafe.edu: rms set sender to rms@aztec using -f Original-To: davep@davep.org In-Reply-To: <20020524140249.A25750@hagbard.davep.org> (message from Dave Pearson on Fri, 24 May 2002 14:02:49 +0100) Errors-To: bug-gnu-emacs-admin@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.bugs:1596 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:1596 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"