GNU bug report logs - #3823
23.1.50; skip-chars-forward does not move after forward-comment

Previous Next

Package: emacs;

Reported by: Lennart Borgman <lennart.borgman <at> gmail.com>

Date: Sat, 11 Jul 2009 15:40:06 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

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 3823 in the body.
You can then email your comments to 3823 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#3823; Package emacs. (Sat, 11 Jul 2009 15:40:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 11 Jul 2009 15:40:07 GMT) Full text and rfc822 format available.

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

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.1.50; skip-chars-forward does not move after forward-comment
Date: Sat, 11 Jul 2009 17:34:44 +0200
Start from "emacs -Q" and in the scratch buffer enter some empty lines
at the top and some lines of code there so it looks like

   (message "i am at the top")

   ;; This buffer is for notes...
   ;; If you want to create a file...

Place point at the beginning of the line ";; If you ..." and do

   M-: (progn (forward-comment (- 100)) (message "skipped %s "
(skip-chars-forward "[:space:]")))

skip-forward will not move forward above. However if you then do

   M-: (message "skipped %s " (skip-chars-forward "[:space:]"))

it will.


In GNU Emacs 23.1.50.1 (i386-mingw-nt5.1.2600)
 of 2009-06-30
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags
-Ic:/g/include -fno-crossjumping'



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3823; Package emacs. (Sat, 11 Jul 2009 16:25:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 11 Jul 2009 16:25:05 GMT) Full text and rfc822 format available.

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

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: 3823 <at> debbugs.gnu.org
Subject: Seems to be a problem with the syntax table
Date: Sat, 11 Jul 2009 18:18:30 +0200
Using (skip-forward-chars " \t\r\n") works immediately after forward-comment.



Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#3823; Package emacs. (Fri, 05 Feb 2010 06:55:02 GMT) Full text and rfc822 format available.

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

From: Lenny Foner <foner <at> media.mit.edu>
To: 3823 <at> debbugs.gnu.org
Subject: skip-chars-forward "[:space:]" does not work if used after
	forward-comment
Date: Fri,  5 Feb 2010 01:00:29 -0500 (EST)
This bug just nailed me too.  The original report was in Emacs 23, but
I'm running 22, and it doesn't work here, either, so it's obviously
been broken a long time.  Here's a toy function I was in the middle
of writing, as part of making Meta-. more to my liking:

(defun bmd-beginning-of-function-including-comments ()
  "Positions point at the start of any comments preceding the current function.
Assumes it starts at the very beginning of a definition, as Meta-. will leave us.
This is defined as all non-code lines before the current function, until we find
either another line of code, or the beginning of the buffer.  If we wind up at
the beginning of the buffer, we stop there.  If we find another line of code,
we then skip forward over any whitespace after that code, so as to land at the
first line of comments but not on any whitespace before them.  (This means that
we will skip backwards over any number of interspersed blank lines and comments
but will not waste screen real estate on a blank line when we're done.)  Narrowing
is considered, so the beginning of the buffer really means the beginning of the
accessible portion if narrowing is in effect."
  (interactive)
  (forward-comment (- (buffer-size)))
  (unless (= (point) (point-min))
    (forward-line 1)
    ;; NOTE!  Trying to use "[:space:]" instead of the regexp below DOES NOT WORK!
    ;; It only works if some other (interactive?) commands have -intervened- after the forward-comment!
    ;; Someone else has apparently tripped over this; c.f. http://debbugs.gnu.org/db/38/3823.html
    (skip-chars-forward " \t\r\n")))

This works if I use M-: to evaluate each of the forward-comment,
forward-line, and skip-chars-forward by hand, but not in the function;
after wasting a bunch of time trying to figure out if I was nuts or
Emacs was, I found this report, whose workaround works for me.

So much for trying to be elegant and actually -use- the defined syntax
classes...  Feh.  I presume that forward-comment is leaving the syntax
tables messed up in some way that gets fixed by the command-loop, or
something weird like that.

My configuration:

In GNU Emacs 22.2.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2009-11-10 on yellow, modified by Ubuntu
configured using `configure  '--build=x86_64-linux-gnu' '--host=x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs22:/etc/emacs:/usr/local/share/emacs/22.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.2/leim' '--with-x=yes' '--with-x-toolkit=athena' '--with-toolkit-scroll-bars' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: C
  value of $LC_COLLATE: C
  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
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  shell-dirtrack-mode: t
  dynamic-completion-mode: t
  show-paren-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




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Fri, 05 Mar 2010 18:56:01 GMT) Full text and rfc822 format available.

Notification sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
bug acknowledged by developer. (Fri, 05 Mar 2010 18:56:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Subject: Re: 23.1.50; skip-chars-forward does not move after forward-comment
Date: Fri, 05 Mar 2010 13:47:49 -0500
> Start from "emacs -Q" and in the scratch buffer enter some empty lines
> at the top and some lines of code there so it looks like
>
>    (message "i am at the top")
>
>    ;; This buffer is for notes...
>    ;; If you want to create a file...
>
> Place point at the beginning of the line ";; If you ..." and do
>
>    M-: (progn (forward-comment (- 100)) (message "skipped %s "
> (skip-chars-forward "[:space:]")))
>
> skip-forward will not move forward above.

Yes, and that's what we want.

> However if you then do
>    M-: (message "skipped %s " (skip-chars-forward "[:space:]"))
> it will.

Oops, indeed, it does.  The patch below fixes it,


        Stefan


PS: The reason [:space:] doesn't skip forward is because in
emacs-lisp-mode, like in many other modes, LF has syntax "comment-end"
rather than "whitespace".  It's usually not a good idea to use the
"\\s-" regexp or the [:space:] char-class for that reason: better use
something like [ \t\n\r].


=== modified file 'src/syntax.c'
--- src/syntax.c	2010-01-13 08:35:10 +0000
+++ src/syntax.c	2010-03-05 18:39:56 +0000
@@ -1747,6 +1747,7 @@
       }
 
     immediate_quit = 1;
+    SETUP_SYNTAX_TABLE (BEGV, 0);
     if (forwardp)
       {
 	if (multibyte)




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

This bug report was last modified 15 years and 77 days ago.

Previous Next


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