help-gnu-emacs
[Top][All Lists]
Advanced

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

electric-layout-local-mode does not work in c-mode and java-mode


From: stardiviner
Subject: electric-layout-local-mode does not work in c-mode and java-mode
Date: Tue, 04 Feb 2020 09:39:01 +0800
User-agent: mu4e 1.3.2; emacs 27.0.50

I have following configurations:

#+begin_src emacs-lisp
(defun c-mode-electric-layout-setting ()
  "auto insert newline after specific characters."
  (setq-local electric-layout-rules '((?\; . after)))
  (add-to-list 'electric-layout-rules '( ?\{ .  after))
  (add-to-list 'electric-layout-rules '( ?\} .  before)))
(add-hook 'c-mode-hook #'electric-layout-local-mode)
(add-hook 'c-mode-hook #'c-mode-electric-layout-setting)

(defun java-mode-electric-layout-setting ()
  "auto insert newline after specific characters."
  (setq-local electric-layout-rules '((?\; . after)))
  (add-to-list 'electric-layout-rules '( ?\{ .  after))
  (add-to-list 'electric-layout-rules '( ?\} .  before)))
(add-hook 'java-mode-hook #'electric-layout-local-mode)
(add-hook 'java-mode-hook #'java-mode-electric-layout-setting)
#+end_src

Here is language code demo:

#+begin_src java
public class Hello {
    public static void main(String[] args) {
        System.log.output("hello");
    }
}
#+end_src

#+begin_src C
#include <stdio.h>

int main(int argc, char *argv[]) {
  printf("hello");
}
#+end_src

When I press ";", electric-layout-local-mode does not auto insert newline and 
jump to newline.

I use similar configuration works fine on js-mode and web-mode.

I also tested with minimal emacs configuration. Still does not work.

Does anyone knows what's wrong and how to fix it?

-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      



reply via email to

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