;;用于windows下的nqemacs
;;自动补全的个人设置,调整后可以首先调用已写入的缩写词,缩写词配置见文末
(setq hippie-expand-try-functions-list
'(try-expand-all-abbrevs
try-expand-dabbrev-all-buffers
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
(add-hook 'java-mode-hook 'my-java-hook)
(defun my-java-hook()
;;缩进距离
(setq default-tab-width 4)
;;方便的编译配置,按f7,回车,编译源代码,按f6运行class文件
(setq compile-command (concat "javac " buffer-file-name))
(defun run-java()
(interactive)
(shell-command (concat "java " (car (reverse (split-string (car (split-string buffer-file-name "[/.]" t)) "/" t)))))
)
(local-set-key [(f6)] 'run-java)
;;hungry-delete模式打开
(c-toggle-hungry-state t)
;;缩写模式打开
(setq abbrev-mode t)
;;ctrl-c p输出System.out.println
(defun start-print-block ()
(interactive)
(insert "System.out.println();")
(backward-char 3)
)
(local-set-key (kbd "C-c p") 'start-print-block)
;;自动补全的快捷键
(local-set-key (kbd "TAB") 'hippie-expand)
;;代码折叠的键绑定
(local-set-key (kbd "C-o C-h") 'hs-hide-block)
(local-set-key (kbd "C-o C-s") 'hs-show-block)
(local-set-key (kbd "C-o C-l") 'hs-hide-level)
)
;;自动补全花括号
(defun my-java-mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(?{ /n > _ /n ?} >)))
(setq skeleton-pair t)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
)
(add-hook 'java-mode-hook 'my-java-mode-auto-pair)
;;设置java缩写词
(define-abbrev-table 'java-mode-abbrev-table '(
("imp" "implements" c-electric-continued-statement 0)
("syn" "synchronized" c-electric-continued-statement 0)
("ab" "abstract" c-electric-continued-statement 0)
("pro" "protected" c-electric-continued-statement 0)
))
;;自动补全的个人设置,调整后可以首先调用已写入的缩写词,缩写词配置见文末
(setq hippie-expand-try-functions-list
'(try-expand-all-abbrevs
try-expand-dabbrev-all-buffers
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
(add-hook 'java-mode-hook 'my-java-hook)
(defun my-java-hook()
;;缩进距离
(setq default-tab-width 4)
;;方便的编译配置,按f7,回车,编译源代码,按f6运行class文件
(setq compile-command (concat "javac " buffer-file-name))
(defun run-java()
(interactive)
(shell-command (concat "java " (car (reverse (split-string (car (split-string buffer-file-name "[/.]" t)) "/" t)))))
)
(local-set-key [(f6)] 'run-java)
;;hungry-delete模式打开
(c-toggle-hungry-state t)
;;缩写模式打开
(setq abbrev-mode t)
;;ctrl-c p输出System.out.println
(defun start-print-block ()
(interactive)
(insert "System.out.println();")
(backward-char 3)
)
(local-set-key (kbd "C-c p") 'start-print-block)
;;自动补全的快捷键
(local-set-key (kbd "TAB") 'hippie-expand)
;;代码折叠的键绑定
(local-set-key (kbd "C-o C-h") 'hs-hide-block)
(local-set-key (kbd "C-o C-s") 'hs-show-block)
(local-set-key (kbd "C-o C-l") 'hs-hide-level)
)
;;自动补全花括号
(defun my-java-mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(?{ /n > _ /n ?} >)))
(setq skeleton-pair t)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
)
(add-hook 'java-mode-hook 'my-java-mode-auto-pair)
;;设置java缩写词
(define-abbrev-table 'java-mode-abbrev-table '(
("imp" "implements" c-electric-continued-statement 0)
("syn" "synchronized" c-electric-continued-statement 0)
("ab" "abstract" c-electric-continued-statement 0)
("pro" "protected" c-electric-continued-statement 0)
))