unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* electric-layout-local-mode does not work in c-mode and java-mode
@ 2020-02-04  1:39 stardiviner
  2020-02-04  8:10 ` Robert Pluim
  2020-02-04 13:43 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: stardiviner @ 2020-02-04  1:39 UTC (permalink / raw)
  To: Emacs Help


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
      



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-05  7:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-04  1:39 electric-layout-local-mode does not work in c-mode and java-mode stardiviner
2020-02-04  8:10 ` Robert Pluim
2020-02-05  5:05   ` stardiviner
2020-02-04 13:43 ` Stefan Monnier
2020-02-05  7:38   ` [SOLVED] " stardiviner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).