From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: michael@cadilhac.name (=?iso-8859-1?Q?Micha=EBl?= Cadilhac) Newsgroups: gmane.emacs.devel Subject: Indentation in the METAPOST mode. Date: Thu, 09 Aug 2007 03:00:39 +0200 Organization: Epita/LRDE Message-ID: <87y7gl7c94.fsf@lrde.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0841310635==" X-Trace: sea.gmane.org 1186621312 2817 80.91.229.12 (9 Aug 2007 01:01:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 9 Aug 2007 01:01:52 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 09 03:01:49 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IIwPN-0006DC-1N for ged-emacs-devel@m.gmane.org; Thu, 09 Aug 2007 03:01:49 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IIwPM-0006jT-LQ for ged-emacs-devel@m.gmane.org; Wed, 08 Aug 2007 21:01:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IIwPJ-0006he-2Z for emacs-devel@gnu.org; Wed, 08 Aug 2007 21:01:45 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IIwPI-0006hK-Jx for emacs-devel@gnu.org; Wed, 08 Aug 2007 21:01:44 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IIwPI-0006hH-Dw for emacs-devel@gnu.org; Wed, 08 Aug 2007 21:01:44 -0400 Original-Received: from smtp3-g19.free.fr ([212.27.42.29]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IIwPH-0004Az-IE for emacs-devel@gnu.org; Wed, 08 Aug 2007 21:01:43 -0400 Original-Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id 624CC73A9 for ; Thu, 9 Aug 2007 03:01:41 +0200 (CEST) Original-Received: from localhost (ivr94-6-82-230-255-91.fbx.proxad.net [82.230.255.91]) by smtp3-g19.free.fr (Postfix) with ESMTP id 0A9FD5D59 for ; Thu, 9 Aug 2007 03:01:40 +0200 (CEST) X-Website: http://michael.cadilhac.name Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEU/JREXDATg1LV8UCao i1fQpmoP3Nd6AAACa0lEQVQ4jWWUQW7jMAxFqZEPICJzAjXeM6W8dyNqX9ji/a8yn04xnWIEJLD9 LJH85DcJFyJV3erqPty8ExHfBikXSdn0WVezC0hOAQiA2nCsAHOqEnPe4k+puU8zw/t+xquqjRKA 4lHsmQBT8C5pDtBwfwH8VdcHI5+FHtjRxrQRwZsf3hNjZRKAPEzHEdH9mFNSYb5dQK3r8KM6ftNy KikAirDZFWdVkDqbxjGFbAcwbQCxxc8mPRHUGOcCIMgMACV23RfJTch3gC6ofT3qCdG0NyUUPfYF yQrKCIAnuYsgX2qPzW2i9sNrfSOSPPZQiygtCNlCjlpXJV38lIKshF/AZzsAMoArdCKNHfXukPuJ ImbLh+9J2gXwap0QpZ7NjZ7ekdkFcDiqPiLGcHmuvaG/AHgy62s52Lae1ABoA7D6d2kDoAvgbnyD ZutEd6lTHOXfYPHVJDH1K8a1+oyrjoZpAGn1x5pfwPr2E9yjxSpk50/gEyKgD/+BD/KzN3tQ13b8 Cx5loF0AgnZf5IUny9hRHQOYBllHDM+6s3oviZBu77mFjDm621Np3hkjR90wE1BkTYvhdDgDgCmR xWChFfcYAOqMm5NZkVWMur8AL5+oeMQOob2FmY76FiM+PrDDZypwGdqokSlAaQOmGH6mW8KpsOwl 0YOLedjSITr6scNRF8D4PesH33QmLrx8AzjpV/3kkg025w2gfAFYKCLluJAc4Ap+h18oo4S8wzaY klDsBUTiY8EZFkg5Iass75FubC9wd8qa0u9+gRxAsAKEaRAo6iB+vwCMGmdBjvgidQGA1ntMX4CS ZYGV/wADyL80LIX/UAAAAABJRU5ErkJggg== User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux) X-Detected-Kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:76227 Archived-At: --===============0841310635== Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi guys, long time no see=A0! Indentation in the METAPOST mode has, IMO, two major flaws=A0: 1. A bug. If the buffer starts with beginfig, the contents of the figure is not properly indented (it stays on the first column). 2. When wrapping an expression on several lines, the indentation is the same for each line, this is bad style=A0: I'd prefer beginfig(1) draw (0,0)--(1,2)--(10,3)-- (0,1)--(10,3); draw (2,2); endfig I propose the following patch which considers that keywords like beginfig does not need ending semicolon (it's /quite/ the case). Tell me if it's worth installing it. --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: inline; filename=meta-mode.patch Content-Transfer-Encoding: quoted-printable Index: lisp/progmodes/meta-mode.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/progmodes/meta-mode.el,v retrieving revision 1.19 diff -c -r1.19 meta-mode.el *** lisp/progmodes/meta-mode.el 26 Jul 2007 05:27:28 -0000 1.19 =2D-- lisp/progmodes/meta-mode.el 9 Aug 2007 00:51:47 -0000 *************** *** 620,625 **** =2D-- 620,628 ---- ((and meta-ignore-comment-regexp (looking-at meta-ignore-comment-regexp)) (current-indentation)) + ;; Beginning of buffer. + ((eq (point-at-bol) (point-min)) + 0) ;; Backindent at end of environments. ((looking-at (concat "\\<" meta-end-environment-regexp "\\>")) *************** *** 631,661 **** (t (meta-indent-calculate-last))))) =20=20 (defun meta-indent-calculate-last () ! "Return the indentation of previous line of Metafont or MetaPost source= ." (save-restriction (widen) (skip-chars-backward "\n\t ") ! (move-to-column (current-indentation)) ! ;; Ignore comments. ! (while (and (looking-at comment-start) (not (bobp))) ! (skip-chars-backward "\n\t ") ! (if (not (bobp)) ! (move-to-column (current-indentation)))) ! (cond ! ((bobp) 0) ! (t (+ (current-indentation) ! (meta-indent-level-count) ! (cond ! ;; Compensate for backindent at end of environments. ! ((looking-at ! (concat "\\<"meta-end-environment-regexp "\\>")) ! meta-indent-level) ! ;; Compensate for backindent within environments. ! ((looking-at ! (concat "\\<" meta-within-environment-regexp "\\>")) ! meta-indent-level) ! (t 0))))) ! )) =20=20 (defun meta-indent-level-count () "Count indentation change for begin-end commands in the current line." =2D-- 634,700 ---- (t (meta-indent-calculate-last))))) =20=20 (defun meta-indent-calculate-last () ! "Return the indentation of previous line of Metafont or MetaPost source. ! If the current line is a continuation, i.e. the previous line doesn't end ! up with a semicolon, add some more indentation." (save-restriction (widen) + (meta-indent-previous-line) + (+ (current-indentation) + (meta-indent-level-count) + (let ((unfinished (meta-indent-unfinished-line-p))) + (cond ((eq unfinished t) meta-indent-level) + ((and (not unfinished) + (save-excursion + (meta-indent-previous-line) + (meta-indent-unfinished-line-p))) + ;; Compensate a previous continuation indentation. + (- meta-indent-level)) + (t 0))) + (cond + ;; Compensate for backindent at end of environments. + ((looking-at + (concat "\\<" meta-end-environment-regexp "\\>")) + meta-indent-level) + ;; Compensate for backindent within environments. + ((looking-at + (concat "\\<" meta-within-environment-regexp "\\>")) + meta-indent-level) + (t 0))))) +=20 + (defun meta-indent-previous-line () + "Go to the previous line of code, skipping comments." + (skip-chars-backward "\n\t ") + (move-to-column (current-indentation)) + ;; Ignore comments. + (while (and (looking-at comment-start) (not (bobp))) (skip-chars-backward "\n\t ") ! (if (not (bobp)) ! (move-to-column (current-indentation))))) !=20 ! (defun meta-indent-unfinished-line-p () ! "Tell if the current line of code ends with an unfinished expression. ! Return t if the line is the first line of the unfinished expression. ! Return 'continued if the line is a continuation. ! Return nil if the line is a finished one." ! (save-excursion ! (end-of-line) ! (if (search-backward ";" (point-at-bol) t) ! (forward-char) ! (beginning-of-line)) ! ;; See if the last statement of the line is environment-related, ! ;; or exists at all. ! (if (looking-at (concat "[ \t]*\\($\\|" (regexp-quote comment-start) ! "\\|\\<" meta-end-environment-regexp "\\>" ! "\\|\\<" meta-begin-environment-regexp "\\>" ! "\\|\\<" meta-within-environment-regexp "\\>\\)")) ! nil ! (if (or (bobp) (/=3D (point-at-bol) (point))) ! t ! ;; Otherwise, if there was no semicolon on the line, see if ! ;; the previous line was a continuation. ! (meta-indent-previous-line) ! (if (meta-indent-unfinished-line-p) 'continued t))))) =20=20 (defun meta-indent-level-count () "Count indentation change for begin-end commands in the current line." Index: lisp/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/ChangeLog,v retrieving revision 1.11534 diff -C 0 -r1.11534 ChangeLog *** lisp/ChangeLog 8 Aug 2007 16:38:31 -0000 1.11534 =2D-- lisp/ChangeLog 9 Aug 2007 00:52:04 -0000 *************** *** 0 **** =2D-- 1,12 ---- + 2007-08-09 Micha=EBl Cadilhac +=20 + * progmodes/meta-mode.el (meta-indent-calculate): Force + indentation at bop to 0. + (meta-indent-previous-line): New. Go to the previous line of code + by skipping comments backward. + (meta-indent-unfinished-line-p): New. Tell if the current line is + unfinished, i.e. contains an expression that will be ended in a + future line. + (meta-indent-calculate-last): Use it to add some more indentation + when continuing a line. +=20 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable =2D-=20 | Micha=EBl `Micha' Cadilhac | Le copillage-collage = | | http://michael.cadilhac.name | tue le programmeur. = | | JID/MSN: | -- Dictons LRDE = | `---- michael.cadilhac@gmail.com | - = --' --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.2 (GNU/Linux) iD8DBQFGumc6UJhDmOfFA3URAguhAKDbMw+jcEU42tr1xTrV2uf/q+EouACgzWum FVJuM8iySFoBs/N3Lno/h4U= =h0sN -----END PGP SIGNATURE----- --==-=-=-- --===============0841310635== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============0841310635==--