GNU bug report logs - #2205
electric-perl-terminator leaves point at beginning of line on error

Previous Next

Package: emacs;

Reported by: "Keith Ponting" <k.ponting <at> aurix.com>

Date: Thu, 5 Feb 2009 12:10:04 UTC

Severity: normal

Fixed in version 24.0.91

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 2205 in the body.
You can then email your comments to 2205 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 bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2205; Package emacs. (Thu, 05 Feb 2009 12:10:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Keith Ponting" <k.ponting <at> aurix.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 05 Feb 2009 12:10:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Keith Ponting" <k.ponting <at> aurix.com>
To: <bug-gnu-emacs <at> gnu.org>
Subject: electric-perl-terminator leaves point at beginning of line on error
Date: Thu, 5 Feb 2009 06:11:20 -0500
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs <at> gnu.org mailing
list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

In perl mode, entering the line-end { at the point shown in the
following closure:
{
    sub tran {
	# start of transition
	my($e,%attrs) = @_;
	my $line="";
	if ( "TURN" eq $attrs{level} ){
        # typing the { at the end of the following line gives scan error
        # and leaves point at the beginning of line, which is a pain!
        # fixed by changing progn to save-excursion in
electric-perl-terminator
    if ( exists($attrs{
	} else if ($wantlevel eq $attrs{level}){

	}
    }
}
causes the electric-perl-terminator function to stop with an error:
  forward-sexp: Scan error: "Unbalanced parentheses", 16, 410
but it leaves me at the _beginning_ of the line. This means
that I cannot easily type in the line I want, which is:
      if ( exists($attrs{tag}) ){
instead when I type that sequence of characters without pausing I end up
with:
tag}) ){    if ( exists($attrs{

This also happens under emacs 21.3.1 on Linux and on a (modified)
22.3.1 on Windows. 

It does not appear to happen in a number of simpler variants I tried
of the above source, so I do not quite understand what is going on.

A fix appears to be to replace the "progn" in
electric-perl-terminator with "save-excursion", so that when
perl-indent-line reports an error, the point remains where I want it.


If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/share/emacs/22.3/etc/DEBUG for instructions.


In GNU Emacs 22.3.1 (x86_64-suse-linux-gnu)
 of 2008-12-03 on build23
configured using `configure  '--with-gcc' '--with-pop'
'--without-hesiod' '--with-kerberos' '--with-kerberos5' '--with-leim'
'--with-xim' '--with-system-malloc' '--prefix=/usr'
'--infodir=/usr/share/info' '--mandir=/usr/share/man'
'--localstatedir=/var' '--sharedstatedir=/var/lib'
'--libexecdir=/usr/lib' '--with-x=no' '--with-sound=no'
'--build=x86_64-suse-linux-gnu' 'build_alias=x86_64-suse-linux-gnu'
'CC=gcc' 'CFLAGS=-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2
-fstack-protector -funwind-tables -fasynchronous-unwind-tables -g
-D_GNU_SOURCE -std=gnu89 -pipe -fno-strict-aliasing -Wno-pointer-sign
-Wno-unused-variable -Wno-unused-label -Wno-unprototyped-calls
-DSYSTEM_PURESIZE_EXTRA=25000 	 -DSITELOAD_PURESIZE_EXTRA=10000 '
'LDFLAGS=''

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_GB.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Perl

Minor modes in effect:
  mouse-wheel-mode: t
  show-paren-mode: t
  encoded-kbd-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
ESC x r e p o r t - e m a c s - b u g RET

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
test.pl has auto save data; consider M-x recover-this-file
Loading perl-mode...done
Loading vc-cvs...done
Loading mwheel...done
Loading emacsbug...
Loading regexp-opt...done
Loading emacsbug...done

Keith Ponting
Aurix Ltd, Malvern WR14 3SZ  UK







Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2205; Package emacs. (Thu, 05 Feb 2009 13:20:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Keith Ponting" <k.ponting <at> aurix.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 05 Feb 2009 13:20:04 GMT) Full text and rfc822 format available.

Message #10 received at 2205 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Keith Ponting" <k.ponting <at> aurix.com>
To: <2205 <at> debbugs.gnu.org>
Subject: My fix does not quite work
Date: Thu, 5 Feb 2009 08:12:29 -0500
[Message part 1 (text/plain, inline)]
A small postscript - the save-excursion  fix I suggested does not quite
work as it leaves point _before_ the inserted terminator not after it.

The following rearrangement works around that:

 

(defun perl-electric-terminator (arg)

  "Insert character and adjust indentation.

If at end-of-line, and not in a comment or a quote, correct the's
indentation."

  (interactive "P")

  (let ((insertpos (point)))

    (and (not arg)                                                ;
decide whether to indent

                 (eolp)

                 (save-excursion

                   (beginning-of-line)

                   (and (not                                          ;
eliminate comments quickly

                                 (and comment-start-skip

                                      (re-search-forward
comment-start-skip insertpos t)) )

                                (or (/= last-command-char ?:)

                                    ;; Colon is special only after a
label ....

                                    (looking-at
"\\s-*\\(\\w\\|\\s_\\)+$"))

                                (let ((pps (parse-partial-sexp

 
(perl-beginning-of-function) insertpos)))

                                  (not (or (nth 3 pps) (nth 4 pps) (nth
5 pps))))))

                 (progn                                 ; must insert,
indent, delete

                   (insert-char last-command-char 1)

                   (save-excursion (perl-indent-line))

                   (delete-char -1))))

  (self-insert-command (prefix-numeric-value arg)))

 

 

 

Keith Ponting

Aurix Ltd, Malvern WR14 3SZ  UK

 

[Message part 2 (text/html, inline)]

Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Wed, 05 Oct 2011 05:31:01 GMT) Full text and rfc822 format available.

Notification sent to "Keith Ponting" <k.ponting <at> aurix.com>:
bug acknowledged by developer. (Wed, 05 Oct 2011 05:31:02 GMT) Full text and rfc822 format available.

Message #15 received at 2205-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 2205-done <at> debbugs.gnu.org
Subject: Re: bug#2205: electric-perl-terminator leaves point at beginning of
	line on error
Date: Wed, 05 Oct 2011 01:30:31 -0400
Version: 24.0.91

I am sorry for the long delay. Hopefully this is now fixed, by stopping
perl-calculate-indent from throwing the error that was upsetting
perl-electric-terminator.




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

This bug report was last modified 13 years and 291 days ago.

Previous Next


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