all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#2205: electric-perl-terminator leaves point at beginning of line on error
@ 2009-02-05 11:11 Keith Ponting
  0 siblings, 0 replies; 3+ messages in thread
From: Keith Ponting @ 2009-02-05 11:11 UTC (permalink / raw)
  To: bug-gnu-emacs


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@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









^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#2205: My fix does not quite work
@ 2009-02-05 13:12 Keith Ponting
  2011-10-05  5:30 ` bug#2205: electric-perl-terminator leaves point at beginning of line on error Glenn Morris
  0 siblings, 1 reply; 3+ messages in thread
From: Keith Ponting @ 2009-02-05 13:12 UTC (permalink / raw)
  To: 2205

[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]

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

 


[-- Attachment #2: Type: text/html, Size: 10459 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#2205: electric-perl-terminator leaves point at beginning of line on error
  2009-02-05 13:12 bug#2205: My fix does not quite work Keith Ponting
@ 2011-10-05  5:30 ` Glenn Morris
  0 siblings, 0 replies; 3+ messages in thread
From: Glenn Morris @ 2011-10-05  5:30 UTC (permalink / raw)
  To: 2205-done

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.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-05  5:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-05 13:12 bug#2205: My fix does not quite work Keith Ponting
2011-10-05  5:30 ` bug#2205: electric-perl-terminator leaves point at beginning of line on error Glenn Morris
  -- strict thread matches above, loose matches on Subject: below --
2009-02-05 11:11 Keith Ponting

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.