From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "John W. Eaton" Newsgroups: gmane.emacs.devel Subject: Re: [gail@tnp-online.de: octave-mod.el: wrong indentation for "IF", "FOR", etc.] Date: Wed, 10 Oct 2007 11:38:08 -0400 Message-ID: <18188.61920.576598.871247@segfault.lan> References: <18188.40056.604794.828796@mithrandir.hornik.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_TrFeHMT05TV2eq/pRbEInw)" X-Trace: sea.gmane.org 1192030740 14164 80.91.229.12 (10 Oct 2007 15:39:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 10 Oct 2007 15:39:00 +0000 (UTC) Cc: Kurt.Hornik@wu-wien.ac.at, GAIL , rms@gnu.org, John Eaton To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 10 17:38:57 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 1Ifddy-0006pF-0V for ged-emacs-devel@m.gmane.org; Wed, 10 Oct 2007 17:38:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ifdds-00009D-Aj for ged-emacs-devel@m.gmane.org; Wed, 10 Oct 2007 11:38:36 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ifddn-000052-Ke for emacs-devel@gnu.org; Wed, 10 Oct 2007 11:38:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ifddl-0008TN-LI for emacs-devel@gnu.org; Wed, 10 Oct 2007 11:38:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ifddl-0008TE-Ek for emacs-devel@gnu.org; Wed, 10 Oct 2007 11:38:29 -0400 Original-Received: from adsum.doit.wisc.edu ([144.92.197.210]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1Ifdde-0004LZ-NJ; Wed, 10 Oct 2007 11:38:22 -0400 Original-Received: from avs-daemon.smtpauth1.wiscmail.wisc.edu by smtpauth1.wiscmail.wisc.edu (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0JPP00F0FCRMAQ00@smtpauth1.wiscmail.wisc.edu>; Wed, 10 Oct 2007 10:38:10 -0500 (CDT) Original-Received: from segfault.lan (cpe-75-187-161-108.neo.res.rr.com [75.187.161.108]) by smtpauth1.wiscmail.wisc.edu (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0JPP00B6JCRLNB40@smtpauth1.wiscmail.wisc.edu>; Wed, 10 Oct 2007 10:38:10 -0500 (CDT) In-reply-to: <18188.40056.604794.828796@mithrandir.hornik.net> X-Mailer: VM 7.19 under Emacs 22.1.1 X-Spam-PmxInfo: Server=avs-10, Version=5.3.3.310218, Antispam-Engine: 2.5.2.313940, Antispam-Data: 2007.10.10.81318, SenderIP=75.187.161.108 X-Detected-Kernel: Solaris 10 (beta) 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:80519 Archived-At: --Boundary_(ID_TrFeHMT05TV2eq/pRbEInw) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-description: message body text On 10-Oct-2007, Kurt Hornik wrote: | >>>>> Richard Stallman writes: | | > Can you please send the apropriate fix to emacs-devel@gnu.org, | > then ack this message? | | I assume this means that in all functions using looking-at() or | re-search-forward() with possibly case sensitive regexps one needs to | let() case-fold-search to nil? Thanks. How about the attached patch then? Here's the original message: ------- Start of forwarded message ------- X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=failed version=3.1.0 Date: Mon, 08 Oct 2007 13:17:49 +0200 From: GAIL MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=ISO-8859-15; format=flowed Subject: octave-mod.el: wrong indentation for "IF", "FOR", etc. In octave-mode, depending on toggle-case-fold-search, octave-indent-line produces either this IF = 1 ; x = 2 ; or that: IF = 1 ; x = 2 ; (via the function re-search-backward). The second behavior is obviously nonsense. Similar for "FOR" etc. I verified the behavior for emacs-20.7.1/octave-2.1.34 and emacs 22.1.1/octave 2.9.14. G. ------- End of forwarded message ------- jwe --Boundary_(ID_TrFeHMT05TV2eq/pRbEInw) Content-type: text/plain; NAME=diffs Content-transfer-encoding: 7BIT Content-disposition: inline; filename=diffs lisp/ChangeLog: 2007-10-10 John W. Eaton * progmodes/octave-mod.el (octave-looking-at-kw, octave-re-search-forward-kw, octave-re-search-backward-kw): New functions. (octave-in-defun-p, calculate-octave-indent, octave-blink-matching-block-open, octave-beginning-of-defun, octave-auto-fill): Use octave-looking-at-kw instead of looking-at to search for regexps that contain case-sensitive keywords. (octave-beginning-of-defun): Use octave-re-search-backward-kw instead of re-search-backward to search for regexps that contain case-sensitive keywords. (octave-scan-blocks): Likewise, for octave-re-search-forward-kw. Index: lisp/progmodes/octave-mod.el =================================================================== RCS file: /sources/emacs/emacs/lisp/progmodes/octave-mod.el,v retrieving revision 1.39 diff -u -u -r1.39 octave-mod.el --- lisp/progmodes/octave-mod.el 6 Oct 2007 01:48:02 -0000 1.39 +++ lisp/progmodes/octave-mod.el 10 Oct 2007 15:34:27 -0000 @@ -581,13 +581,25 @@ (error nil)) (< pos (point))))) +(defun octave-looking-at-kw (regexp) + (let ((case-fold-search nil)) + (looking-at regexp))) + +(defun octave-re-search-forward-kw (regexp) + (let ((case-fold-search nil)) + (re-search-forward regexp nil 'move inc))) + +(defun octave-re-search-backward-kw (regexp) + (let ((case-fold-search nil)) + (re-search-backward regexp nil 'move inc))) + (defun octave-in-defun-p () "Return t if point is inside an Octave function declaration. The function is taken to start at the `f' of `function' and to end after the end keyword." (let ((pos (point))) (save-excursion - (or (and (looking-at "\\") + (or (and (octave-looking-at-kw "\\") (octave-not-in-string-or-comment-p)) (and (octave-beginning-of-defun) (condition-case nil @@ -658,14 +670,14 @@ (while (< (point) eol) (if (octave-not-in-string-or-comment-p) (cond - ((looking-at "\\") + ((octave-looking-at-kw "\\") (setq icol (+ icol (* 2 octave-block-offset)))) - ((looking-at octave-block-begin-regexp) + ((octave-looking-at-kw octave-block-begin-regexp) (setq icol (+ icol octave-block-offset))) - ((looking-at octave-block-else-regexp) + ((octave-looking-at-kw octave-block-else-regexp) (if (= bot (point)) (setq icol (+ icol octave-block-offset)))) - ((looking-at octave-block-end-regexp) + ((octave-looking-at-kw octave-block-end-regexp) (if (not (= bot (point))) (setq icol (- icol (octave-block-end-offset))))))) @@ -675,10 +687,10 @@ (save-excursion (back-to-indentation) (cond - ((and (looking-at octave-block-else-regexp) + ((and (octave-looking-at-kw octave-block-else-regexp) (octave-not-in-string-or-comment-p)) (setq icol (- icol octave-block-offset))) - ((and (looking-at octave-block-end-regexp) + ((and (octave-looking-at-kw octave-block-end-regexp) (octave-not-in-string-or-comment-p)) (setq icol (- icol (octave-block-end-offset)))) ((or (looking-at "\\s<\\s<\\s<\\S<") @@ -854,8 +866,8 @@ (save-excursion (while (/= count 0) (catch 'foo - (while (or (re-search-forward - octave-block-begin-or-end-regexp nil 'move inc) + (while (or (octave-re-search-forward-kw + octave-block-begin-or-end-regexp) (if (/= depth 0) (error "Unbalanced block"))) (if (octave-not-in-string-or-comment-p) @@ -974,7 +986,7 @@ (looking-at "\\>") (save-excursion (skip-syntax-backward "w") - (looking-at octave-block-else-or-end-regexp))) + (octave-looking-at-kw octave-block-else-or-end-regexp))) (save-excursion (cond ((match-end 1) @@ -1021,11 +1033,11 @@ (inc (if (> arg 0) 1 -1)) (found)) (and (not (eobp)) - (not (and (> arg 0) (looking-at "\\"))) + (not (and (> arg 0) (octave-looking-at-kw "\\"))) (skip-syntax-forward "w")) (while (and (/= arg 0) (setq found - (re-search-backward "\\" nil 'move inc))) + (octave-re-search-backward-kw "\\"))) (if (octave-not-in-string-or-comment-p) (setq arg (- arg inc)))) (if found @@ -1078,7 +1090,7 @@ (save-excursion (beginning-of-line) (and auto-fill-inhibit-regexp - (looking-at auto-fill-inhibit-regexp)))) + (octave-looking-at-kw auto-fill-inhibit-regexp)))) nil ; Can't do anything (if (and (not (octave-in-comment-p)) (> (current-column) fc)) --Boundary_(ID_TrFeHMT05TV2eq/pRbEInw) 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 --Boundary_(ID_TrFeHMT05TV2eq/pRbEInw)--