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: Sat, 19 May 2007 19:48:43 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

> As for scan_words, I don't know of such a bug.  Also looking at the code,
> I don't see it (not that it proves anything, of course).  Could you tell me
> where's the problem in scan_words?

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.  It
goes back by _two_ characters instead of one.  The attached patch was
supposed to fix this and the other problem.
*** 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]