GNU bug report logs - #8691
23.2; In fortran 90 mode, f90-indent-subprogram gets confused by bind(c) type definitions

Previous Next

Package: emacs;

Reported by: James Tappin <jtappin <at> gmail.com>

Date: Wed, 18 May 2011 16:12:01 UTC

Severity: normal

Found in version 23.2

Fixed in version 24.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8691 in the body.
You can then email your comments to 8691 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8691; Package emacs. (Wed, 18 May 2011 16:12:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to James Tappin <jtappin <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 18 May 2011 16:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: James Tappin <jtappin <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.2; In fortran 90 mode, f90-indent-subprogram gets confused by
	bind(c) type definitions
Date: Wed, 18 May 2011 09:51:58 -0600
In fortran 90 mode, the indentation function f90-indent-subprogram does
not properly recognize type definitions with the bind(c)
property. Using tab to indent line by line does work.

I suspect that the presence of a double colon is causing the function
to think that the line is a variable declaration.

--------- Example code --------------
module demo1

  use iso_c_binding
  implicit none

  type, bind(c) :: simple_struct
  integer(kind=c_int) :: tag1
  real(kind=c_double) :: tag2
end type simple_struct

contains
subroutine s1(a)
 type(simple_struct) :: a

 print *, a%tag1, a%tag2

end subroutine s1
end module demo1
---------- END Example -------------

In GNU Emacs 23.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.4)
 of 2011-04-04 on crested, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11001000
configured using `configure  '--build' 'x86_64-linux-gnu' '--build'
'x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
'--libexecdir=/usr/lib' '--localstatedir=/var/lib'
'--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.2/leim'
'--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
'build_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g'
'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: F90

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
e a l ( k i n d = c _ d o u b l e ) S-SPC : : S-SPC
t a g 2 <return> C-c C-w <return> c o n t a i n s <return>
<tab> s u b r o u t i n e SPC a 1 <backspace> <backspace>
s 1 ( a ) <return> <tab> t y p e ( s i m p l e _ s
t r i c <backspace> <backspace> u c t ) S-SPC : : S-SPC
a <return> <return> ` <backspace> <tab> p r i n t SPC
* , SPC a % t a g 1 <return> <tab> <up> <end> , SPC
a % t a g 2 <return> <return> C-c C-w C-c C-w <help-echo>
<help-echo> <down-mouse-1> <mouse-1> <help-echo> <help-echo>
<help-echo> <help-echo> <menu-bar> <F90> <Indent Subprogram>
<down-mouse-1> <mouse-1> C-x C-s C-a <up> <up> <down>
C-k C-k <down-mouse-1> <mouse-1> <return> <tab> u s
e SPC i s o _ c _ b i n d i n s <backspace> f <backspace>
g <return> <tab> i m p l i c i t SPC n o n e <return>
<help-echo> <menu-bar> <F90> <Indent Subprogram> C-x
C-s <help-echo> <help-echo> <help-echo> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo>
<f1> a i n d e <tab> <backspace> n t - s u b p r o
b <backspace> g r a m <return> <help-echo> <help-echo>
<help-echo> <down-mouse-1> <mouse-1> C-x C-w n o <backspace>
b i n d . f 9 0 <return> <down-mouse-1> <mouse-1> <backspace>
2 <down-mouse-5> <mouse-5> <down-mouse-5> <mouse-5>
<down-mouse-5> <mouse-5> <down-mouse-1> <mouse-movement>
<mouse-1> <backspace> 2 <down-mouse-4> <mouse-4> <double-down-mouse-4>
<double-mouse-4> <triple-down-mouse-4> <triple-mouse-4>
<triple-down-mouse-4> <triple-mouse-4> <down-mouse-1>
<mouse-movement> <mouse-movement> <drag-mouse-1> C-w
<help-echo> <menu-bar> <F90> <Indent Subprogram> C-x
C-s <down-mouse-5> <mouse-5> <down-mouse-4> <mouse-4>
<double-down-mouse-4> <double-mouse-4> <help-echo>
<help-echo> M-x r e p <tab> <help-echo> <down-mouse-2>
<down-mouse-6> <mouse-6> <mouse-2>

Recent messages:
Saving file /home/james/Data/Linux/emacsbg/nbind.f90...
Wrote /home/james/Data/Linux/emacsbg/nbind.f90
Auto-saving...done
down-slightly: Beginning of buffer
Mark set
Indenting module demo2...done
Saving file /home/james/Data/Linux/emacsbg/nbind.f90...
Wrote /home/james/Data/Linux/emacsbg/nbind.f90
down-slightly: Beginning of buffer
Making completion list...

Load-path shadows:
/usr/share/emacs/23.2/site-lisp/auctex/toolbar-x hides
/usr/share/emacs/site-lisp/auctex/toolbar-x
/usr/share/emacs/23.2/site-lisp/auctex/texmathp hides
/usr/share/emacs/site-lisp/auctex/texmathp
/usr/share/emacs/23.2/site-lisp/auctex/tex hides
/usr/share/emacs/site-lisp/auctex/tex
/usr/share/emacs/23.2/site-lisp/auctex/tex-style hides
/usr/share/emacs/site-lisp/auctex/tex-style
/usr/share/emacs/23.2/site-lisp/auctex/tex-mik hides
/usr/share/emacs/site-lisp/auctex/tex-mik
/usr/share/emacs/23.2/site-lisp/auctex/tex-jp hides
/usr/share/emacs/site-lisp/auctex/tex-jp
/usr/share/emacs/23.2/site-lisp/auctex/tex-info hides
/usr/share/emacs/site-lisp/auctex/tex-info
/usr/share/emacs/23.2/site-lisp/auctex/tex-fptex hides
/usr/share/emacs/site-lisp/auctex/tex-fptex
/usr/share/emacs/23.2/site-lisp/auctex/tex-font hides
/usr/share/emacs/site-lisp/auctex/tex-font
/usr/share/emacs/23.2/site-lisp/auctex/tex-fold hides
/usr/share/emacs/site-lisp/auctex/tex-fold
/usr/share/emacs/23.2/site-lisp/auctex/tex-buf hides
/usr/share/emacs/site-lisp/auctex/tex-buf
/usr/share/emacs/23.2/site-lisp/auctex/tex-bar hides
/usr/share/emacs/site-lisp/auctex/tex-bar
/usr/share/emacs/23.2/site-lisp/auctex/multi-prompt hides
/usr/share/emacs/site-lisp/auctex/multi-prompt
/usr/share/emacs/23.2/site-lisp/auctex/latex hides
/usr/share/emacs/site-lisp/auctex/latex
/usr/share/emacs/23.2/site-lisp/auctex/font-latex hides
/usr/share/emacs/site-lisp/auctex/font-latex
/usr/share/emacs/23.2/site-lisp/auctex/context hides
/usr/share/emacs/site-lisp/auctex/context
/usr/share/emacs/23.2/site-lisp/auctex/context-nl hides
/usr/share/emacs/site-lisp/auctex/context-nl
/usr/share/emacs/23.2/site-lisp/auctex/context-en hides
/usr/share/emacs/site-lisp/auctex/context-en
/usr/share/emacs/23.2/site-lisp/auctex/bib-cite hides
/usr/share/emacs/site-lisp/auctex/bib-cite
/usr/share/emacs/23.2/site-lisp/cmake-data/cmake-mode hides
/usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs/23.2/site-lisp/debian-startup hides
/usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs23/site-lisp/dictionaries-common/ispell hides
/usr/share/emacs/23.2/lisp/textmodes/ispell
/usr/share/emacs23/site-lisp/dictionaries-common/flyspell hides
/usr/share/emacs/23.2/lisp/textmodes/flyspell

Features:
(shadow sort mail-extr message sendmail regexp-opt ecomplete rfc822 mml
mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse
rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util
netrc time-date mm-util mail-prsvr gmm-utils mailheader canlock sha1
hex-util hashcash mail-utils emacsbug help-mode view apropos f90
cus-edit easymenu cus-start cus-load wid-edit preview-latex tex-site
auto-loads tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win
x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8691; Package emacs. (Wed, 18 May 2011 19:12:02 GMT) Full text and rfc822 format available.

Message #8 received at 8691 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: James Tappin <jtappin <at> gmail.com>
Cc: 8691 <at> debbugs.gnu.org
Subject: Re: bug#8691: 23.2;
	In fortran 90 mode, f90-indent-subprogram gets confused by bind(c)
	type definitions
Date: Wed, 18 May 2011 15:10:58 -0400
Hello, I think this patch fixes it. You can test it with:

(setq f90-type-def-re "...value-from-patch...")


*** lisp/progmodes/f90.el	2011-02-04 03:21:11 +0000
--- lisp/progmodes/f90.el	2011-05-18 19:09:26 +0000
***************
*** 809,816 ****
    ;; type word
    ;; type :: word
    ;; type, stuff :: word
    ;; NOT "type ("
!   "\\<\\(type\\)\\>\\(?:[^()\n]*::\\)?[ \t]*\\(\\sw+\\)"
    "Regexp matching the definition of a derived type.")
  
  (defconst f90-typeis-re
--- 809,818 ----
    ;; type word
    ;; type :: word
    ;; type, stuff :: word
+   ;; type, bind(c) :: word
    ;; NOT "type ("
!   "\\<\\(type\\)\\>\\(?:\\(?:[^()\n]*\\|\
! .*,[ \t]*bind[ \t]*([ \t]*c[ \t]*)[ \t]*\\)::\\)?[ \t]*\\(\\sw+\\)"
    "Regexp matching the definition of a derived type.")
  
  (defconst f90-typeis-re





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8691; Package emacs. (Wed, 18 May 2011 21:22:02 GMT) Full text and rfc822 format available.

Message #11 received at 8691 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: James Tappin <jtappin <at> gmail.com>
Cc: 8691 <at> debbugs.gnu.org
Subject: Re: bug#8691: 23.2; In fortran 90 mode, f90-indent-subprogram gets
	confused by bind(c) type definitions
Date: Wed, 18 May 2011 17:21:35 -0400
(Please keep 8691 <at> debbugs included)

James Tappin wrote (on Wed, 18 May 2011 at 15:05 -0600):

> Thanks for the quick response. Unfortunately it's not clear to me
> how to use the patch: I've tried pasting the command and patch into
> the *Scratch* buffer and using "Evaluate defun" without any success.
> Also as far as I can see Ubuntu only provides the compiled emacs
> lisp files (*.elc) or I'd have made a copy and applied the patch.

sudo apt-get install emacs23-el

is probably the right command to get the Lisp sources.

However, rather than patching, it's probably easier to add to your
.emacs:

(eval-after-load "f90"
  '(setq f90-type-def-re "\\<\\(type\\)\\>\\(?:\\(?:[^()\n]*\\|\
.*,[ \t]*bind[ \t]*([ \t]*c[ \t]*)[ \t]*\\)::\\)?[ \t]*\\(\\sw+\\)"))

which should have the same effect.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8691; Package emacs. (Wed, 18 May 2011 21:39:02 GMT) Full text and rfc822 format available.

Message #14 received at 8691 <at> debbugs.gnu.org (full text, mbox):

From: James Tappin <jtappin <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 8691 <at> debbugs.gnu.org
Subject: Re: bug#8691: 23.2; In fortran 90 mode, f90-indent-subprogram gets
	confused by bind(c) type definitions
Date: Wed, 18 May 2011 15:38:07 -0600
On 18 May 2011 15:21, Glenn Morris <rgm <at> gnu.org> wrote:
>
> (Please keep 8691 <at> debbugs included)
>
> However, rather than patching, it's probably easier to add to your
> .emacs:
>
> (eval-after-load "f90"
>  '(setq f90-type-def-re "\\<\\(type\\)\\>\\(?:\\(?:[^()\n]*\\|\
> .*,[ \t]*bind[ \t]*([ \t]*c[ \t]*)[ \t]*\\)::\\)?[ \t]*\\(\\sw+\\)"))
>
> which should have the same effect.
>

Thanks Glenn,
That works on the test file, and on the original "problem" file.

James




bug marked as fixed in version 24.1, send any further explanations to 8691 <at> debbugs.gnu.org and James Tappin <jtappin <at> gmail.com> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 19 May 2011 06:19:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 18 Jun 2011 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 322 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.