X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=emacs.d_2%2Fconfig.org;h=ea05da6e0592c7ea542fb2ab1d3e9304893b5954;hb=254309ce28de5bea8a405f03f507b761a2bc2d72;hp=5d92caa1c66c1a84bb9c4d700990d4be6d50e2fe;hpb=0d08b0dd2aa875fc87fa94d615e6b992d56739d8;p=dotfiles.git diff --git a/emacs.d_2/config.org b/emacs.d_2/config.org index 5d92caa..ea05da6 100644 --- a/emacs.d_2/config.org +++ b/emacs.d_2/config.org @@ -4,7 +4,7 @@ * Introduction -Most config are just copied from [[https://github.com/howardabrams/dot-files][howardabrams]]'s dotfiles +Most config are just copied from [[https://github.com/howardabrams/dot-files][howardabrams]]'s and [[https://github.com/abo-abo/oremacs][abo-abo's]] dotfiles * Basic Settings @@ -47,6 +47,8 @@ Disable scroll bar, tool-bar and menu-bar (defalias 'yes-or-no-p 'y-or-n-p) (show-paren-mode 1) + (global-set-key (kbd "") 'toggle-frame-fullscreen) + #+END_SRC * Package Management Tools @@ -132,7 +134,7 @@ Setting the fonts (if window-system (when sd/fixed-font-family (set-frame-font sd/fixed-font-family) - (set-face-attribute 'default nil :font sd/fixed-font-family :height 140) + (set-face-attribute 'default nil :font sd/fixed-font-family :height 120) (set-face-font 'default sd/fixed-font-family))) #+END_SRC @@ -301,7 +303,7 @@ use [[https://github.com/sabof/org-bullets][org-bullets]] package to show utf-8 [[https://github.com/abo-abo/worf][worf]] mode is an extension of vi-like binding for org-mode. In =worf-mode=, it is mapping =[=, =]= as =worf-backward= and =worf-forward= in global, wich cause we cannot input =[= and =]=, so here I unset this mappings. And redifined this two to -=M-[= and =M-]= +=M-[= and =M-]=. see this [[https://github.com/abo-abo/worf/issues/19#issuecomment-223756599][issue]] #+BEGIN_SRC emacs-lisp :tangle yes :results silent @@ -393,6 +395,107 @@ cause we cannot input =[= and =]=, so here I unset this mappings. And redifined * Misc Settings +** [[https://github.com/abo-abo/hydra][Hydra]] + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package hydra + :ensure t) + +#+END_SRC + +*** Font Zoom + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (defhydra sd/font-zoom (global-map "") + "zoom" + ("g" text-scale-increase "in") + ("l" text-scale-decrease "out")) + +#+END_SRC + +*** Windmove Splitter + +Refer [[https://github.com/abo-abo/hydra/blob/master/hydra-examples.el][hydra-example]], to enlarge or shrink the windows splitter + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (defun hydra-move-splitter-left (arg) + "Move window splitter left." + (interactive "p") + (if (let ((windmove-wrap-around)) + (windmove-find-other-window 'right)) + (shrink-window-horizontally arg) + (enlarge-window-horizontally arg))) + + (defun hydra-move-splitter-right (arg) + "Move window splitter right." + (interactive "p") + (if (let ((windmove-wrap-around)) + (windmove-find-other-window 'right)) + (enlarge-window-horizontally arg) + (shrink-window-horizontally arg))) + + (defun hydra-move-splitter-up (arg) + "Move window splitter up." + (interactive "p") + (if (let ((windmove-wrap-around)) + (windmove-find-other-window 'up)) + (enlarge-window arg) + (shrink-window arg))) + + (defun hydra-move-splitter-down (arg) + "Move window splitter down." + (interactive "p") + (if (let ((windmove-wrap-around)) + (windmove-find-other-window 'up)) + (shrink-window arg) + (enlarge-window arg))) + +#+END_SRC + +*** hydra-window + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (winner-mode 1) + + (defhydra sd/hydra-window (:color red :columns nil) + "window" + ("h" windmove-left nil) + ("j" windmove-down nil) + ("k" windmove-up nil) + ("l" windmove-right nil) + ("H" hydra-move-splitter-left nil) + ("J" hydra-move-splitter-down nil) + ("K" hydra-move-splitter-up nil) + ("L" hydra-move-splitter-right nil) + ("v" (lambda () + (interactive) + (split-window-right) + (windmove-right)) + "vert") + ("x" (lambda () + (interactive) + (split-window-below) + (windmove-down)) + "horz") + ("o" delete-other-windows "one" :exit t) + ("a" ace-window "ace") + ("s" ace-swap-window "swap") + ("d" ace-delete-window "ace-one" :exit t) + ("i" ace-maximize-window "ace-one" :exit t) + ("b" ido-switch-buffer "buf") + ("m" headlong-bookmark-jump "bmk") + ("q" nil "cancel") + ("u" (progn (winner-undo) (setq this-command 'winner-undo)) "undo") + ("f" nil)) + + (global-set-key (kbd "M-o") 'sd/hydra-window/body) + +#+END_SRC + ** Line Number Enable linum mode on programming modes @@ -472,9 +575,46 @@ Type =o= to go to the link #+END_SRC -* Programming Languages +** Emux + +[[https://github.com/re5et/emux][emux]] is + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (el-get-bundle re5et/emux) + +#+END_SRC -** Emacs Lisp +** Smart Parens + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package smartparens + :ensure t) + +#+END_SRC + +** Ace-Windows + +[[https://github.com/abo-abo/ace-window][ace-window]] + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package ace-window + :ensure t + :defer t + ; :init + ; (global-set-key (kbd "M-o") 'ace-window) + :config + (setq aw-keys '(?a ?s ?d ?f ?j ?k ?l))) + +#+END_SRC + +* Programming + +** Languages + +*** Emacs Lisp #+BEGIN_SRC emacs-lisp :tangle yes :results silent @@ -487,29 +627,154 @@ Type =o= to go to the link #+END_SRC -** Perl +*** Perl [[https://www.emacswiki.org/emacs/CPerlMode][CPerl mode]] has more features than =PerlMode= for perl programming. Alias this to =CPerlMode= #+BEGIN_SRC emacs-lisp :tangle yes :results silent - (defalias 'perl-mode 'cperl-mode) + (defalias 'perl-mode 'cperl-mode) + + ;(setq cperl-hairy t) ;; Turns on most of the CPerlMode options + (setq cperl-auto-newline t) + (setq cperl-highlight-variables-indiscriminately t) + ;(setq cperl-indent-level 4) + ;(setq cperl-continued-statement-offset 4) + (setq cperl-close-paren-offset -4) + (setq cperl-indent-parents-as-block t) + (setq cperl-tab-always-indent t) + ;(setq cperl-brace-offset 0) - (setq cperl-hairy t) ;; Turns on most of the CPerlMode options - (setq cperl-auto-newline t) - (setq cperl-highlight-variables-indiscriminately t) + (add-hook 'cperl-mode-hook + '(lambda () + (cperl-set-style "C++"))) - ;(add-to-list 'load-path "~/.emacs.d/elisp/") ;(require 'template) ;(template-initialize) ;(require 'perlnow) #+END_SRC -* Others +- auto insert +- run script + +Change the compile-command to set the default command run when call =compile= +Mapping =s-r= (on Mac, it's =Command + R= to run the script. Here =current-prefix-arg= is set +to call =compilation= interactively. + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (defun my-perl-hook () + (progn + (setq-local compilation-read-command nil) + (set (make-local-variable 'compile-command) + (concat "/usr/bin/perl " + (if buffer-file-name + (shell-quote-argument buffer-file-name)))) + (local-set-key (kbd "s-r") + (lambda () + (interactive) + ; (setq current-prefix-arg '(4)) ; C-u + (call-interactively 'compile))))) + + (add-hook 'cperl-mode-hook 'my-perl-hook) + -** Shell pop mode +#+END_SRC + +*** C & C++ + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (setq c-default-style "stroustrup" + c-basic-offset 4) + +#+END_SRC + +** Compile + +Set the environments vairables in compilation mode + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package compile + :commands compile + :config + (setq compilation-environment (cons "LC_ALL=C" compilation-environment))) + +#+END_SRC + +** Auto-Insert + +Enable auto-insert mode + +#+BEGIN_SRC emacs-lisp :tangle yes :results silenc + + (auto-insert-mode t) + (setq auto-insert-query nil) + +#+END_SRC + +*** C++ Auto Insert + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (eval-after-load 'autoinsert + '(define-auto-insert '("\\.cpp\\'" . "C++ skeleton") + '( + "Short description:" + "/*" + "\n * " (file-name-nondirectory (buffer-file-name)) + "\n */" > \n \n + "#include " \n + "#include \"" + (file-name-sans-extension + (file-name-nondirectory (buffer-file-name))) + ".hpp\"" \n \n + "using namespace std;" \n \n + "int main ()" + "\n{" \n + > _ \n + "return 1;" + "\n}" > \n + ))) + + (eval-after-load 'autoinsert + '(define-auto-insert '("\\.c\\'" . "C skeleton") + '( + "Short description:" + "/*\n" + " * " (file-name-nondirectory (buffer-file-name)) "\n" + " */" > \n \n + "#include " \n + "#include \"" + (file-name-sans-extension + (file-name-nondirectory (buffer-file-name))) + ".h\"" \n \n + "int main ()\n" + "{" \n + > _ \n + "return 1;\n" + "}" > \n + ))) + +#+END_SRC + +*** Perl Auto Insert + +Refer [[https://www.emacswiki.org/emacs/AutoInsertMode][AutoInsertMode]] Wiki + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (eval-after-load 'autoinsert + '(define-auto-insert '("\\.pl\\'" . "Perl skeleton") + '( + "Description: " + "#!/usr/bin/perl -w" \n + \n + "use strict;" \n \n + ))) + +#+END_SRC -** Smartparens mode -***