From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Raul Laasner Newsgroups: gmane.emacs.bugs Subject: bug#19809: 24.4; f90-beginning-of-subprogram wrong behavior with string continuation Date: Sat, 7 Feb 2015 22:25:10 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1140e92277f9a1050e8555ac X-Trace: ger.gmane.org 1423342871 19346 80.91.229.3 (7 Feb 2015 21:01:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Feb 2015 21:01:11 +0000 (UTC) To: 19809@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 07 22:01:10 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YKCV3-0004qV-NN for geb-bug-gnu-emacs@m.gmane.org; Sat, 07 Feb 2015 22:01:09 +0100 Original-Received: from localhost ([::1]:54502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKCV2-00037T-RR for geb-bug-gnu-emacs@m.gmane.org; Sat, 07 Feb 2015 16:01:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKCUy-00036g-IS for bug-gnu-emacs@gnu.org; Sat, 07 Feb 2015 16:01:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKCUx-0000NH-BE for bug-gnu-emacs@gnu.org; Sat, 07 Feb 2015 16:01:04 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKCUx-0000ND-75 for bug-gnu-emacs@gnu.org; Sat, 07 Feb 2015 16:01:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YKCUw-00040S-Nr for bug-gnu-emacs@gnu.org; Sat, 07 Feb 2015 16:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Raul Laasner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Feb 2015 21:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19809 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.142334283515352 (code B ref -1); Sat, 07 Feb 2015 21:01:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Feb 2015 21:00:35 +0000 Original-Received: from localhost ([127.0.0.1]:36874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YKCUU-0003zX-6f for submit@debbugs.gnu.org; Sat, 07 Feb 2015 16:00:35 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44104) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YKBwP-00037F-In for submit@debbugs.gnu.org; Sat, 07 Feb 2015 15:25:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKBwJ-0006Hx-2J for submit@debbugs.gnu.org; Sat, 07 Feb 2015 15:25:16 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:47149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKBwI-0006Ht-W6 for submit@debbugs.gnu.org; Sat, 07 Feb 2015 15:25:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKBwH-0006nk-OV for bug-gnu-emacs@gnu.org; Sat, 07 Feb 2015 15:25:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKBwG-0006HX-C6 for bug-gnu-emacs@gnu.org; Sat, 07 Feb 2015 15:25:13 -0500 Original-Received: from mail-ig0-x22e.google.com ([2607:f8b0:4001:c05::22e]:40525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKBwG-0006HP-31 for bug-gnu-emacs@gnu.org; Sat, 07 Feb 2015 15:25:12 -0500 Original-Received: by mail-ig0-f174.google.com with SMTP id b16so9467413igk.1 for ; Sat, 07 Feb 2015 12:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=tqgHUrqq1RzGEiJ88lblEeQr3m1qjPFTaobY0RLdoSc=; b=gHRno4jh/H2bc9x6bjDXYIDhmPjSKc5wx91K3s40ctgaDmVcnz+e2WojSrr0WOGGRV s8dJOek0SGt+QGqbrFeWXrxP9gCKuOXDLQ+UayRvJ8q6uCShdYVtEKBgGZRyDs2UVczJ 6Qb1FnjgN4EDQCnmDmUG1XV1eoyyMW0WZqcQ2heRY8NBWYI6ia1QmHqxATewwZ8C565g IJDvponbTiMa4NfAaLvHWA68BOUKNdXRkt+SQ7P0fSgtmnqJBqZeJLbCA09LBs6JQadf PHr9jPD53wIhwSsR4Tl2+LTF3r0dKpg8JVZZfPvyWQxmpJxhvqx1l8D3fnDUQ2qTivje h+pA== X-Received: by 10.107.160.72 with SMTP id j69mr18381223ioe.0.1423340710916; Sat, 07 Feb 2015 12:25:10 -0800 (PST) Original-Received: by 10.36.7.205 with HTTP; Sat, 7 Feb 2015 12:25:10 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Mailman-Approved-At: Sat, 07 Feb 2015 16:00:32 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:99145 Archived-At: --001a1140e92277f9a1050e8555ac Content-Type: text/plain; charset=UTF-8 The functions f90-beginning-of-subprogram and f90-end-of-subprogram do not work correctly if the source file contains lines which begin with the correct keywords but in fact belong to a continued string. For instance, in the following, subroutine foo() print*, '& end subroutine foo' ! The cursor is here end subroutine foo f90-beginning-of-subprogram jumps past the line containing 'subroutine foo()'. A similar example could be written for f90-end-of-subprogram. I propose to put a small check of whether the previous line ended with an ampersand into the F90 major mode source file: --- f90.el 2015-02-07 16:50:56.210519581 +0200 +++ f90_new.el 2015-02-07 16:56:44.997174743 +0200 @@ -1619,6 +1619,14 @@ (looking-at "[ \t0-9]*\\(!\\|$\\|#\\)"))) not-last-statement)) +(defsubst f90-test-string-continuation () + "Return true if the the current is a string continuation." + (save-excursion + (beginning-of-line) + (backward-char) + (skip-chars-backward " ") + (string= (string (char-before)) "&"))) + (defun f90-beginning-of-subprogram () "Move point to the beginning of the current subprogram. Return (TYPE NAME), or nil if not found." @@ -1629,9 +1637,13 @@ (re-search-backward f90-program-block-re nil 'move)) (beginning-of-line) (skip-chars-forward " \t0-9") - (cond ((setq matching-beg (f90-looking-at-program-block-start)) + (cond ((and + (setq matching-beg (f90-looking-at-program-block-start)) + (not (f90-test-string-continuation))) (setq count (1- count))) - ((f90-looking-at-program-block-end) + ((and + (f90-looking-at-program-block-end) + (not (f90-test-string-continuation))) (setq count (1+ count))))) (beginning-of-line) (if (zerop count) @@ -1654,9 +1666,13 @@ (re-search-forward f90-program-block-re nil 'move)) (beginning-of-line) (skip-chars-forward " \t0-9") - (cond ((f90-looking-at-program-block-start) + (cond ((and + (f90-looking-at-program-block-start) + (not (f90-test-string-continuation))) (setq count (1+ count))) - ((setq matching-end (f90-looking-at-program-block-end)) + ((and + (setq matching-end (f90-looking-at-program-block-end)) + (not (f90-test-string-continuation))) (setq count (1- count)))) (end-of-line)) ;; This means f90-end-of-subprogram followed by f90-start-of-subprogram Best wishes, Raul Laasner -- Raul Laasner Institute of Physics University of Tartu Ravila 14c, 50411, Estonia e-mail: raullaasner@gmail.com cell: (+372)5182268 --001a1140e92277f9a1050e8555ac Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
The functions f90-beginning-of-subprogram and f90-end-of-s= ubprogram do not work correctly if the source file contains lines which beg= in with the correct keywords but in fact belong to a continued string. For = instance, in the following,

subroutine foo()
=C2=A0 print*, '= &
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 end subroutine foo'
= =C2=A0 ! The cursor is here
end subroutine foo

f90-beginning-of-s= ubprogram jumps past the line containing 'subroutine foo()'. A simi= lar example could be written for f90-end-of-subprogram. I propose to put a = small check of whether the previous line ended with an ampersand into the F= 90 major mode source file:

--- f90.el=C2=A0=C2=A0=C2=A0 2015-02-07 1= 6:50:56.210519581 +0200
+++ f90_new.el=C2=A0=C2=A0=C2=A0 2015-02-07 16:5= 6:44.997174743 +0200
@@ -1619,6 +1619,14 @@
=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (l= ooking-at "[ \t0-9]*\\(!\\|$\\|#\\)")))
=C2=A0=C2=A0=C2=A0=C2= =A0 not-last-statement))
=C2=A0
+(defsubst f90-test-string-continuati= on ()
+=C2=A0 "Return true if the the current is a string continuat= ion."
+=C2=A0 (save-excursion
+=C2=A0=C2=A0=C2=A0 (beginning-of-= line)
+=C2=A0=C2=A0=C2=A0 (backward-char)
+=C2=A0=C2=A0=C2=A0 (skip-c= hars-backward " ")
+=C2=A0=C2=A0=C2=A0 (string=3D (string (cha= r-before)) "&")))
+
=C2=A0(defun f90-beginning-of-subpr= ogram ()
=C2=A0=C2=A0 "Move point to the beginning of the current s= ubprogram.
=C2=A0Return (TYPE NAME), or nil if not found."
@@ -1= 629,9 +1637,13 @@
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (re-search-backward f90-program-= block-re nil 'move))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (beginning= -of-line)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (skip-chars-forward "= ; \t0-9")
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cond ((setq matching-beg= (f90-looking-at-program-block-start))
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (= cond ((and
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq matc= hing-beg (f90-looking-at-program-block-start))
+=C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 (not (f90-test-string-continuation)))
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (s= etq count (1- count)))
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 ((f90-looking-at-program-block-end)
+=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((and
+=C2=A0=C2=A0= =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (f90-looking-at-program-block-end)+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (not (f90-test-string-c= ontinuation)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (setq count (1+ count)))))
=C2=A0=C2=A0=C2=A0=C2= =A0 (beginning-of-line)
=C2=A0=C2=A0=C2=A0=C2=A0 (if (zerop count)
@@= -1654,9 +1666,13 @@
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (re-search-forward f90-progra= m-block-re nil 'move))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (beginni= ng-of-line)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (skip-chars-forward &qu= ot; \t0-9")
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cond ((f90-looking-at-= program-block-start)
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cond ((and
+=C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (f90-looking-at-program-bloc= k-start)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (not (f90-te= st-string-continuation)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq count (1+ count)))
-=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((setq matching-end = (f90-looking-at-program-block-end))
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((and
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 (setq matching-end (f90-looking-at-program-block-end))+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (not (f90-test-string-= continuation)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 (setq count (1- count))))
=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 (end-of-line))
=C2=A0=C2=A0=C2=A0=C2=A0 ;; This means f9= 0-end-of-subprogram followed by f90-start-of-subprogram


Best wis= hes,
Raul Laasner

--
Raul Laasner
Institute of Physics
University of= Tartu
Ravila 14c, 50411, Estonia
e-mail: raullaasner@gmail.com
cell: (+372)51= 82268
--001a1140e92277f9a1050e8555ac--