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: Glasses.el and C bug. Date: Fri, 17 Nov 2006 02:25:07 +0100 Organization: Epita/LRDE Message-ID: <878xiac1ak.fsf@lrde.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0263232095==" X-Trace: sea.gmane.org 1163726764 9357 80.91.229.2 (17 Nov 2006 01:26:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 17 Nov 2006 01:26:04 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 17 02:25:55 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GksUH-0007ZP-Hb for ged-emacs-devel@m.gmane.org; Fri, 17 Nov 2006 02:25:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GksUG-0006E3-EP for ged-emacs-devel@m.gmane.org; Thu, 16 Nov 2006 20:25:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GksTT-0005tD-6y for emacs-devel@gnu.org; Thu, 16 Nov 2006 20:24:59 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GksTR-0005rN-GS for emacs-devel@gnu.org; Thu, 16 Nov 2006 20:24:58 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GksTR-0005rH-6j for emacs-devel@gnu.org; Thu, 16 Nov 2006 20:24:57 -0500 Original-Received: from [62.39.139.2] (helo=kualalumpur.lrde.epita.fr) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GksTR-0008Sl-56 for emacs-devel@gnu.org; Thu, 16 Nov 2006 20:24:57 -0500 Original-Received: from mahaena.lrde.epita.fr ([192.168.101.66] helo=mahaena.lrde) by kualalumpur.lrde.epita.fr with esmtp (Exim 4.50) id 1GksTP-0005SP-PC for emacs-devel@gnu.org; Fri, 17 Nov 2006 02:24:55 +0100 Original-To: emacs-devel@gnu.org 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.110006 (No Gnus v0.6) Emacs/22.0.90 (gnu/linux) 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:62389 Archived-At: --===============0263232095== Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= When using cpp's #define-s, one has to deal with a huge difference between #define FOO(Bar) and #define FOO (Bar) the first one being a macro function, the second one a macro that expands itself to (Bar). glasses.el is guilty of adding a space between FOO and (Bar), making the function looking like a simple macro. It is even more guilty of actually changing this in the file if `glasses-convert-on-write-p' is set to t, corrupting the very meaning of the cpp ! The following patch addresses those two problems and a minor another one (glasses.el has to modify the file also if paren separating is t). --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: inline; filename=glasses.patch Content-Transfer-Encoding: quoted-printable Index: lisp/progmodes/glasses.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/glasses.el,v retrieving revision 1.18 diff -c -r1.18 glasses.el *** lisp/progmodes/glasses.el 23 Feb 2006 16:35:41 -0000 1.18 =2D-- lisp/progmodes/glasses.el 17 Nov 2006 01:15:43 -0000 *************** *** 110,115 **** =2D-- 110,122 ---- :group 'glasses :type 'boolean) =20=20 + (defcustom glasses-separate-parentheses-exceptions + '("^#[\t ]*define[\t ]*[A-Za-z0-9_-]* ?($") + "List of regexp that are exceptions for `glasses-separate-parentheses-p= '. + They are matched to the current line truncated to the point where the + parenthesis expression starts." + :group 'glasses + :type '(repeat regexp)) =20=20 (defcustom glasses-uncapitalize-p nil "If non-nil, downcase embedded capital letters in identifiers. *************** *** 153,158 **** =2D-- 160,173 ---- =20=20 ;;; Utility functions =20=20 + (defun glasses-parenthesis-exception-p (beg end) + "Tell if (BEG, END) is an exception to `glasses-separate-parentheses-p'. + See `glasses-separate-parentheses-exceptions'." + (save-match-data + (let ((str (buffer-substring beg end))) + (catch 'match + (dolist (re glasses-separate-parentheses-exceptions) + (and (string-match re str) (throw 'match t))))))) =20=20 (defun glasses-set-overlay-properties () "Set properties of glasses overlays. *************** *** 232,239 **** (when glasses-separate-parentheses-p (goto-char beg) (while (re-search-forward "[a-zA-Z]_*\\(\(\\)" end t) ! (glasses-make-overlay (match-beginning 1) (match-end 1) ! 'glasses-parenthesis))))))) =20=20 =20=20 (defun glasses-make-unreadable (beg end) =2D-- 247,255 ---- (when glasses-separate-parentheses-p (goto-char beg) (while (re-search-forward "[a-zA-Z]_*\\(\(\\)" end t) ! (unless (glasses-parenthesis-exception-p (point-at-bol) (match-end 1= )) ! (glasses-make-overlay (match-beginning 1) (match-end 1) ! 'glasses-parenthesis)))))))) =20=20 =20=20 (defun glasses-make-unreadable (beg end) *************** *** 247,276 **** "Convert current buffer to unreadable identifiers and return nil. This function modifies buffer contents, it removes all the separators, recognized according to the current value of the variable `glasses-separa= tor'." ! (when (and glasses-convert-on-write-p ! (not (string=3D glasses-separator ""))) (let ((case-fold-search nil) (separator (regexp-quote glasses-separator))) (save-excursion ! (goto-char (point-min)) ! (while (re-search-forward ! (format "[a-z]\\(%s\\)[A-Z]\\|[A-Z]\\(%s\\)[A-Z][a-z]" ! separator separator) ! nil t) ! (let ((n (if (match-string 1) 1 2))) ! (replace-match "" t nil nil n) ! (goto-char (match-end n)))) ! (unless (string=3D glasses-separator glasses-original-separator) (goto-char (point-min)) ! (while (re-search-forward (format "[a-zA-Z0-9]\\(%s+\\)[a-zA-Z0-9]" ! separator) ! nil t) ! (replace-match glasses-original-separator nil nil nil 1) ! (goto-char (match-beginning 1)))) (when glasses-separate-parentheses-p (goto-char (point-min)) (while (re-search-forward "[a-zA-Z]_*\\( \\)\(" nil t) ! (replace-match "" t nil nil 1)))))) ;; nil must be returned to allow use in write file hooks nil) =20=20 =2D-- 263,293 ---- "Convert current buffer to unreadable identifiers and return nil. This function modifies buffer contents, it removes all the separators, recognized according to the current value of the variable `glasses-separa= tor'." ! (when glasses-convert-on-write-p (let ((case-fold-search nil) (separator (regexp-quote glasses-separator))) (save-excursion ! (unless (string=3D glasses-separator "") (goto-char (point-min)) ! (while (re-search-forward ! (format "[a-z]\\(%s\\)[A-Z]\\|[A-Z]\\(%s\\)[A-Z][a-z]" ! separator separator) ! nil t) ! (let ((n (if (match-string 1) 1 2))) ! (replace-match "" t nil nil n) ! (goto-char (match-end n)))) ! (unless (string=3D glasses-separator glasses-original-separator) ! (goto-char (point-min)) ! (while (re-search-forward (format "[a-zA-Z0-9]\\(%s+\\)[a-zA-Z0-9]" ! separator) ! nil t) ! (replace-match glasses-original-separator nil nil nil 1) ! (goto-char (match-beginning 1))))) (when glasses-separate-parentheses-p (goto-char (point-min)) (while (re-search-forward "[a-zA-Z]_*\\( \\)\(" nil t) ! (unless (glasses-parenthesis-exception-p (point-at-bol) (1+ (match-e= nd 1))) ! (replace-match "" t nil nil 1))))))) ;; nil must be returned to allow use in write file hooks nil) =20=20 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.10303 diff -c -0 -r1.10303 ChangeLog *** lisp/ChangeLog 12 Nov 2006 19:58:10 -0000 1.10303 =2D-- lisp/ChangeLog 17 Nov 2006 01:15:47 -0000 *************** *** 0 **** =2D-- 1,11 ---- + 2006-11-17 Micha=EBl Cadilhac +=20 + * progmodes/glasses.el (glasses-separate-parentheses-exceptions): New. + Exceptions to the rule "add a space between an identifier and an + opening parenthesis". Defaulted to the `#define' problem of cpp. + (glasses-parenthesis-exception-p): New. Check if the region is an + exception regarding to that. + (glasses-make-readable): Use it. + (glasses-convert-to-unreadable): Ditto. Modify the file also if + `glasses-convert-on-write-p' and `glasses-separate-parentheses-p' are t. +=20 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable TIA! =2D-=20 /!\ My mail address changed, please update your files accordingly. | Micha=EBl `Micha' Cadilhac | La culture c'est comme la confitu= re, | | Epita/LRDE Promo 2007 | c'est meilleur avec du pain. = | | http://michael.cadilhac.name | -- MOI59 = | `--JID: michael.cadilhac@gmail.com--' - = --' --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFXQ92UJhDmOfFA3URAvCvAKCE7q0wNUEqT3MtkeK8I0H3r8i6pACgyV6c 3iOFWeJTaE1KYrw99eme8Wk= =HJxp -----END PGP SIGNATURE----- --==-=-=-- --===============0263232095== 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 --===============0263232095==--