Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
f97b734f
Commit
f97b734f
authored
Jan 20, 2019
by
Alan Mackenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix electric-pair-tests by disabling bug#33794's fix with a variable"
This reverts commit
be505726
.
parent
6038fdb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
62 deletions
+40
-62
lisp/progmodes/cc-cmds.el
lisp/progmodes/cc-cmds.el
+40
-56
test/lisp/electric-tests.el
test/lisp/electric-tests.el
+0
-6
No files found.
lisp/progmodes/cc-cmds.el
View file @
f97b734f
...
...
@@ -485,20 +485,6 @@ function to control that."
(
c-hungry-delete-forward
)
(
c-hungry-delete-backwards
)))
(
defvar
c--disable-fix-of-bug-33794
nil
"If non-nil disable alans controversional fix of 33794.
This fix breaks most features of `electric-pair-mode' by
incompletely reimplementing in in this mode."
)
(
defmacro
c--with-post-self-insert-hook-maybe
(
&rest
body
)
`
(
let
((
post-self-insert-hook
(
if
c--disable-fix-of-bug-33794
post-self-insert-hook
;; Acording to AM: Disable random functionality to get
;; defined functionality from `self-insert-command'
nil
)))
,@
body
))
(
defun
c-electric-pound
(
arg
)
"Insert a \"#\".
If `c-electric-flag' is set, handle it specially according to the variable
...
...
@@ -518,7 +504,7 @@ inside a literal or a macro, nothing special happens."
(
eq
(
char-before
)
?\\
))))
(
c-in-literal
)))
;; do nothing special
(
c--with-
post-self-insert-hook
-maybe
(
let
(
post-self-insert-hook
)
; Disable random functionality.
(
self-insert-command
(
prefix-numeric-value
arg
)))
;; place the pound character at the left edge
(
let
((
pos
(
-
(
point-max
)
(
point
)))
...
...
@@ -871,38 +857,36 @@ settings of `c-cleanup-list' are done."
;; Insert the brace. Note that expand-abbrev might reindent
;; the line here if there's a preceding "else" or something.
(
c--with-post-self-insert-hook-maybe
(
self-insert-command
(
prefix-numeric-value
arg
)))
(
let
(
post-self-insert-hook
)
; the only way to get defined functionality
; from `self-insert-command'.
(
self-insert-command
(
prefix-numeric-value
arg
)))
;; Emulate `electric-pair-mode'.
(
unless
c--disable-fix-of-bug-33794
(
when
(
and
(
boundp
'electric-pair-mode
)
electric-pair-mode
)
(
let
((
size
(
buffer-size
))
(
c-in-electric-pair-functionality
t
)
post-self-insert-hook
)
(
electric-pair-post-self-insert-function
)
(
setq
got-pair-}
(
and
at-eol
(
eq
(
c-last-command-char
)
?{
)
(
eq
(
char-after
)
?}
))
electric-pair-deletion
(
<
(
buffer-size
)
size
))))
;; Perform any required CC Mode electric actions.
(
cond
((
or
literal
arg
(
not
c-electric-flag
)
active-region
))
((
not
at-eol
)
(
c-indent-line
))
(
electric-pair-deletion
(
c-indent-line
)
(
c-do-brace-electrics
'ignore
nil
))
(
t
(
c-do-brace-electrics
nil
nil
)
(
when
got-pair-}
(
save-excursion
(
forward-char
)
(
c-do-brace-electrics
'assume
'ignore
))
(
c-indent-line
)))))
(
when
(
and
(
boundp
'electric-pair-mode
)
electric-pair-mode
)
(
let
((
size
(
buffer-size
))
(
c-in-electric-pair-functionality
t
)
post-self-insert-hook
)
(
electric-pair-post-self-insert-function
)
(
setq
got-pair-}
(
and
at-eol
(
eq
(
c-last-command-char
)
?{
)
(
eq
(
char-after
)
?}
))
electric-pair-deletion
(
<
(
buffer-size
)
size
))))
;; Perform any required CC Mode electric actions.
(
cond
((
or
literal
arg
(
not
c-electric-flag
)
active-region
))
((
not
at-eol
)
(
c-indent-line
))
(
electric-pair-deletion
(
c-indent-line
)
(
c-do-brace-electrics
'ignore
nil
))
(
t
(
c-do-brace-electrics
nil
nil
)
(
when
got-pair-}
(
save-excursion
(
forward-char
)
(
c-do-brace-electrics
'assume
'ignore
))
(
c-indent-line
))))
;; blink the paren
(
and
(
eq
(
c-last-command-char
)
?\}
)
...
...
@@ -960,7 +944,7 @@ is inhibited."
c-electric-flag
(
eq
(
c-last-command-char
)
?/
)
(
eq
(
char-before
)
(
if
literal
?*
?/
))))
(
c--with-
post-self-insert-hook
-maybe
(
let
(
post-self-insert-hook
)
; Disable random functionality.
(
self-insert-command
(
prefix-numeric-value
arg
)))
(
if
indentp
(
indent-according-to-mode
))))
...
...
@@ -974,7 +958,7 @@ supplied, point is inside a literal, or `c-syntactic-indentation' is nil,
this indentation is inhibited."
(
interactive
"*P"
)
(
c--with-
post-self-insert-hook
-maybe
(
let
(
post-self-insert-hook
)
; Disable random functionality.
(
self-insert-command
(
prefix-numeric-value
arg
)))
;; if we are in a literal, or if arg is given do not reindent the
;; current line, unless this star introduces a comment-only line.
...
...
@@ -1022,7 +1006,7 @@ settings of `c-cleanup-list'."
(
setq
lim
(
c-most-enclosing-brace
(
c-parse-state
))
literal
(
c-in-literal
lim
)))
(
c--with-
post-self-insert-hook
-maybe
(
let
(
post-self-insert-hook
)
; Disable random functionality.
(
self-insert-command
(
prefix-numeric-value
arg
)))
(
if
(
and
c-electric-flag
(
not
literal
)
(
not
arg
))
...
...
@@ -1092,7 +1076,7 @@ reindented unless `c-syntactic-indentation' is nil.
newlines
is-scope-op
;; shut this up
(
c-echo-syntactic-information-p
nil
))
(
c--with-
post-self-insert-hook
-maybe
(
let
(
post-self-insert-hook
)
; Disable random functionality.
(
self-insert-command
(
prefix-numeric-value
arg
)))
;; Any electric action?
(
if
(
and
c-electric-flag
(
not
literal
)
(
not
arg
))
...
...
@@ -1186,7 +1170,7 @@ numeric argument is supplied, or the point is inside a literal."
(
let
((
c-echo-syntactic-information-p
nil
)
final-pos
found-delim
case-fold-search
)
(
c--with-
post-self-insert-hook
-maybe
(
let
(
post-self-insert-hook
)
; Disable random functionality.
(
self-insert-command
(
prefix-numeric-value
arg
)))
(
setq
final-pos
(
point
))
...
...
@@ -1252,7 +1236,8 @@ newline cleanups are done if appropriate; see the variable `c-cleanup-list'."
;; shut this up
(
c-echo-syntactic-information-p
nil
)
case-fold-search
)
(
c--with-post-self-insert-hook-maybe
(
let
(
post-self-insert-hook
)
; The only way to get defined functionality
; from `self-insert-command'.
(
self-insert-command
(
prefix-numeric-value
arg
)))
(
if
(
and
(
not
arg
)
(
not
literal
))
...
...
@@ -1303,11 +1288,10 @@ newline cleanups are done if appropriate; see the variable `c-cleanup-list'."
(
insert-and-inherit
"} catch ("
)))
;; Apply `electric-pair-mode' stuff.
(
unless
c--disable-fix-of-bug-33794
(
when
(
and
(
boundp
'electric-pair-mode
)
electric-pair-mode
)
(
let
(
post-self-insert-hook
)
(
electric-pair-post-self-insert-function
))))
(
when
(
and
(
boundp
'electric-pair-mode
)
electric-pair-mode
)
(
let
(
post-self-insert-hook
)
(
electric-pair-post-self-insert-function
)))
;; Check for clean-ups at function calls. These two DON'T need
;; `c-electric-flag' or `c-syntactic-indentation' set.
...
...
test/lisp/electric-tests.el
View file @
f97b734f
...
...
@@ -47,14 +47,10 @@
(
declare
(
indent
defun
)
(
debug
t
))
`
(
call-with-saved-electric-modes
#'
(
lambda
()
,@
body
)))
;; Defined in lisp/progmodes/cc-cmds.el
(
defvar
c--disable-fix-of-bug-33794
t
)
(
defun
electric-pair-test-for
(
fixture
where
char
expected-string
expected-point
mode
bindings
fixture-fn
)
(
with-temp-buffer
(
funcall
mode
)
(
setq-local
c--disable-fix-of-bug-33794
t
)
(
insert
fixture
)
(
save-electric-modes
(
let
((
last-command-event
char
)
...
...
@@ -825,7 +821,6 @@ baz\"\""
(
electric-layout-local-mode
1
)
(
electric-pair-local-mode
1
)
(
electric-indent-local-mode
1
)
(
setq-local
c--disable-fix-of-bug-33794
t
)
(
setq-local
electric-layout-rules
'
((
?\{
.
(
after-stay
after
))))
(
insert
"int main () "
)
...
...
@@ -839,7 +834,6 @@ baz\"\""
(
electric-layout-local-mode
1
)
(
electric-pair-local-mode
1
)
(
electric-indent-local-mode
1
)
(
setq-local
c--disable-fix-of-bug-33794
t
)
(
setq-local
electric-layout-rules
'
((
?\{
.
(
before
after-stay
after
))))
(
insert
"int main () "
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment