emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ mode and c-beginning-of-current-token


From: martin rudalics
Subject: Re: C++ mode and c-beginning-of-current-token
Date: Thu, 17 May 2007 23:40:52 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

I do have my own problems with UPDATE_SYNTAX_TABLE_BACKWARD.  To
reproduce with Emacs -Q define foo as

(defun foo ()
  (interactive)
  (put-text-property (1- (point)) (point) 'syntax-table '(2))
  (setq parse-sexp-lookup-properties t))

open a text-mode buffer, insert a couple of non-word chars in the
buffer, leave point after them, and type M-x foo followed by M-b.  On my
system it goes back by _two_ characters instead of one.  I'm yet too
silly to understand what's going on.

The attached patch seems to fix both the syntax and word backward scanning
problems.  Could someone please try?
*** syntax.c    Wed Jan 17 09:31:10 2007
--- syntax.c    Thu May 17 23:30:50 2007
***************
*** 1276,1294 ****
           position of it.  */
        while (1)
        {
-         int temp_byte;
- 
          if (from == beg)
            break;
!         temp_byte = dec_bytepos (from_byte);
          UPDATE_SYNTAX_TABLE_BACKWARD (from);
!         ch0 = FETCH_CHAR (temp_byte);
          code = SYNTAX (ch0);
          if (!(words_include_escapes
                && (code == Sescape || code == Scharquote)))
            if (code != Sword || WORD_BOUNDARY_P (ch0, ch1))
!             break;
!         DEC_BOTH (from, from_byte);
          ch1 = ch0;
        }
        count++;
--- 1276,1294 ----
           position of it.  */
        while (1)
        {
          if (from == beg)
            break;
!         DEC_BOTH (from, from_byte);
          UPDATE_SYNTAX_TABLE_BACKWARD (from);
!         ch0 = FETCH_CHAR (from_byte);
          code = SYNTAX (ch0);
          if (!(words_include_escapes
                && (code == Sescape || code == Scharquote)))
            if (code != Sword || WORD_BOUNDARY_P (ch0, ch1))
!             {
!               INC_BOTH (from, from_byte);
!               break;
!             }
          ch1 = ch0;
        }
        count++;
***************
*** 1669,1678 ****
                      p = GPT_ADDR;
                      stop = endp;
                    }
-                 if (! fastmap[(int) SYNTAX (p[-1])])
-                   break;
                  p--, pos--;
!                 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1);
                }
          }
        }
--- 1669,1681 ----
                      p = GPT_ADDR;
                      stop = endp;
                    }
                  p--, pos--;
!                 UPDATE_SYNTAX_TABLE_BACKWARD (pos);
!                 if (! fastmap[(int) SYNTAX (*p)])
!                   {
!                     p++, pos++;
!                     break;
!                   }
                }
          }
        }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]