emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master e60fc32 3/5: Merge from origin/emacs-26


From: Glenn Morris
Subject: [Emacs-diffs] master e60fc32 3/5: Merge from origin/emacs-26
Date: Mon, 10 Dec 2018 12:43:15 -0500 (EST)

branch: master
commit e60fc320e3cf72327544d17db2542f56ab042e5a
Merge: 6383844 5a7451c
Author: Glenn Morris <address@hidden>
Commit: Glenn Morris <address@hidden>

    Merge from origin/emacs-26
    
    5a7451c CC Mode: stop wrongly recognizing "func(a * 9)" as "pointer t...
    b0ed9d1 * lisp/emacs-lisp/cursor-sensor.el: Add motivation
---
 lisp/emacs-lisp/cursor-sensor.el | 21 +++++++++++++++++++++
 lisp/progmodes/cc-engine.el      |  8 ++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/cursor-sensor.el b/lisp/emacs-lisp/cursor-sensor.el
index 21c48f8..6c33d04 100644
--- a/lisp/emacs-lisp/cursor-sensor.el
+++ b/lisp/emacs-lisp/cursor-sensor.el
@@ -38,6 +38,27 @@
 ;; called just before redisplay happens, according to the movement of
 ;; the cursor since the last redisplay.
 
+;;;; Motivation
+
+;; The old properties were very problematic in practice because they
+;; operate at a much lower level and hence affect all motion
+;; *functions* like goto-char, forward-char, ... hence breaking
+;; invariants like:
+;;
+;;    (forward-char N) == (progn (forward-char N1) (forward-char (- N N1)))
+;;    (point) == (progn (forward-char N) (forward-char -N) (point))
+;;    (+ N (point)) == (progn (forward-char N) (point))
+;;
+;; The problems would usually show up due to interaction between
+;; unrelated code working in the same buffer, where one code used those
+;; properties and the other (unknowingly) assumed those aren't used.
+;; In practice a *lot* of code assumes there's no such funny business.
+;;
+;; Worse: all(?) packages using those properties don't actually want those
+;; properties to affect motion at such a low-level, they only want to
+;; affect the overall effect of commands, but not the effect of every
+;; single point-motion that a given command happened to use internally.
+
 ;;; Code:
 
 ;;;###autoload
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 376d0bb..d71a829 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -8550,6 +8550,8 @@ comment at the start of cc-engine.el for more info."
          got-parens
          ;; True if there is an identifier in the declarator.
          got-identifier
+         ;; True if we find a number where an identifier was expected.
+         got-number
          ;; True if there's a non-close-paren match of
          ;; `c-type-decl-suffix-key'.
          got-suffix
@@ -8627,7 +8629,9 @@ comment at the start of cc-engine.el for more info."
          (and (looking-at c-identifier-start)
               (setq pos (point))
               (setq got-identifier (c-forward-name))
-              (setq name-start pos)))
+              (setq name-start pos))
+         (when (looking-at "[0-9]")
+           (setq got-number t))) ; We've probably got an arithmetic expression.
 
       ;; Skip over type decl suffix operators and trailing noise macros.
       (while
@@ -9101,7 +9105,7 @@ comment at the start of cc-engine.el for more info."
 
           ;; CASE 18
           (when (and (not (memq context '(nil top)))
-                     (or got-prefix
+                     (or (and got-prefix (not got-number))
                          (and (eq context 'decl)
                               (not c-recognize-paren-inits)
                               (or got-parens got-suffix))))



reply via email to

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