;;supress the redefined warning at startup
(setq ad-redefinition-action 'accept)
+
+ (setq scroll-step 1)
+ (setq scroll-margin 5)
+
+ (when (display-graphic-p)
+ (fringe-mode '(0 . 0)))
#+END_SRC
*** Custom file
#+END_SRC
+search text theme
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (set-face-attribute 'lazy-highlight nil :background "yellow" :foreground "black" :weight 'bold)
+#+END_SRC
+
** Rainbow-delimiter
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(irony-mode . "")
(page-break-lines-mode . "")
(yas-minor-mode . "y")
+ ;; default jj
+ (evil-escape-mode . "")
;; Major modes
(lisp-interaction-mode . "λ")
(hi-lock-mode . "")
))
(center (list (powerline-raw " " face1)
(funcall separator-left face1 face2)
+ (powerline-raw (when (and (boundp 'evil-mode) evil-mode) evil-mode-line-tag) face2)
(when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode)
(powerline-raw erc-modified-channels-object face2 'l))
(powerline-major-mode face2 'l)
:config
(ido-mode 1)
(ido-everywhere 1)
- (add-to-list 'completion-ignored-extensions ".pyc"))
+ (add-to-list 'completion-ignored-extensions ".pyc")
+
+
+ (define-key ido-buffer-completion-map (kbd "C-w") #'ido-delete-backward-word-updir)
+ (define-key ido-file-completion-map (kbd "C-w") #'ido-delete-backward-word-updir)
+ (define-key ido-file-dir-completion-map (kbd "C-w") #'ido-delete-backward-updir)
+ ;; (define-key ido-file-dir-completion-map (kbd "C-i") #'ido-copy-current-word)
+
+ ;; (dolist (map (list
+ ;; ido-buffer-completion-map
+ ;; ido-file-completion-map
+ ;; ido-file-dir-completion-map
+ ;; ido-common-completion-map))
+ ;; (define-key map (kbd "C-w") #'ido-delete-backward-word-updir)
+ ;; ;; (define-key map (kbd "C-i") #'ido-copy-current-file-name)
+ ;; )
+ )
(icomplete-mode t)
#+END_SRC
(define-key map "n" nil)
(define-key map "p" nil)
(define-key map "v" 'recenter-top-bottom)
- (define-key map "i" 'magit-section-toggle)))
+ (define-key map "i" 'magit-section-toggle))
+ (define-key magit-mode-map "q" (lambda () (interactive)
+ (magit-mode-bury-buffer t))))
#+END_SRC
* Eshell
;; (add-hook 'eshell-mode-hook (lambda ()
;; (local-set-key (kbd "C-l") 'sd/eshell-clear-buffer)))
(add-hook 'eshell-mode-hook (apply-partially #'local-set-key (kbd "C-l") 'sd/eshell-clear-buffer))
+ ;; (add-hook 'eshell-mode-map (lambda () (interactive)
+ ;; (define-key eshell-mode-map (kbd "<tab>") 'completion-at-point)))
#+END_SRC
** Toggle Eshell
;; should map both (kbd "TAB") and [tab],https://github.com/company-mode/company-mode/issues/75
(define-key company-active-map (kbd "TAB") #'company-complete-selection)
(define-key company-active-map [tab] #'company-complete-selection)
+ (define-key company-active-map (kbd "C-w") nil)
+ (define-key company-active-map (kbd "C-h") nil)
(global-company-mode)
;; magig-commit is text-modeh
(setq company-global-modes '(not org-mode magit-status-mode text-mode eshell-mode gfm-mode markdown-mode)))
(use-package lispy
:ensure t
:init
+ (setq lispy-delete-backward-recenter 0)
(with-eval-after-load "lispy"
(define-key lispy-mode-map (kbd "M-o") nil)
(define-key lispy-mode-map (kbd "g") 'special-lispy-goto-local)
#+END_SRC
-*** Run Perl
-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)
-#+END_SRC
-
** C & C++
C/C++ ide tools
1. completion (file name, function name, variable name)
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(defun my-cpp-hook ()
(let* ((current-file-name)
- (a-dot-out-file))
+ (out-file-name))
(when buffer-file-name
(setq current-file-name (shell-quote-argument buffer-file-name))
- (setq a-dot-out-file (concat (file-name-directory buffer-file-name) "a.out")))
+ (setq out-file-name (shell-quote-argument (concat (file-name-sans-extension buffer-file-name) ".out"))))
(setq-local compilation-read-command t)
(set (make-local-variable 'compile-command)
(concat "g++ -Wall "
current-file-name
+ " -o "
+ out-file-name
" && "
- a-dot-out-file))
+ out-file-name
+ ))
(local-set-key (kbd "s-r") 'compile)))
(add-hook 'c-mode-hook 'my-cpp-hook)
;; set racket path
(setenv "PATH" (concat (getenv "PATH")
- ":" "/Applications/Racket v6.6/bin"))
+ ":" "/Applications/Racket v6.10.1/bin"))
(setenv "MANPATH" (concat (getenv "MANPATH")
- ":" "/Applications/Racket v6.6/man"))
- (setq exec-path (append exec-path '("/Applications/Racket v6.6/bin")))
+ ":" "/Applications/Racket v6.10.1/man"))
+ (setq exec-path (append exec-path '("/Applications/Racket v6.10.1/bin")))
(add-to-list 'auto-mode-alist '("\\.rkt\\'" . racket-mode))
#+END_SRC
(setq compilation-environment (cons "LC_ALL=C" compilation-environment))
(setq compilation-auto-jump-to-first-error t)
(setq compilation-auto-jump-to-next t)
- (setq compilation-scroll-output 'first-error))
+ (setq compilation-scroll-output 'first-error)
+ ;; this will save all the modified buffers before compile
+ (setq compilation-ask-about-save nil))
;; super-r to compile
(with-eval-after-load "compile"
(define-key compilation-mode-map (kbd "C-o") nil)
(define-key compilation-mode-map (kbd "n") 'compilation-next-error)
(define-key compilation-mode-map (kbd "p") 'compilation-previous-error)
+ (define-key compilation-mode-map (kbd "q") (lambda () (interactive) (quit-window t)))
(define-key compilation-mode-map (kbd "r") #'recompile))
+
+ ;; (loop for (mode . program) in '(
+ ;; (lua-mode-hook . "lua")
+ ;; (perl-mode-hook . "perl")
+ ;; (python-mode-hook . "python")
+ ;; (shell-mode-hook . "sh"))
+ ;; do (add-hook mode `(lambda ()
+ ;; (unless (or (file-exists-p "makefile")
+ ;; (file-exists-p "Makefile"))
+ ;; (set (make-local-variable 'compile-command)
+ ;; (concat ,program
+ ;; " "
+ ;; (if buffer-file-name
+ ;; (shell-quote-argument buffer-file-name))))))))
+
+ ;; here note dynamic binding the value of vv, otherwise it will resport error when run the hook.
+ ;; https://emacs.stackexchange.com/questions/10394/scope-in-lambda
+ (dolist (vv '(
+ (cperl-mode-hook . "perl")
+ (lua-mode-hook . "lua")
+ (python-mode-hook . "python")
+ (shell-mode-hook . "sh")))
+ (add-hook (car vv) `(lambda ()
+ (unless (or (file-exists-p "makefile")
+ (file-exists-p "Makefile"))
+ (set (make-local-variable 'compile-command)
+ (concat (cdr ',vv)
+ " "
+ (if buffer-file-name
+ (shell-quote-argument buffer-file-name))))))))
+
(global-set-key (kbd "s-r") 'compile)
#+END_SRC
* Key Bindings
Here are some global key bindings for basic editting
+** Global key bingding
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (global-set-key (kbd "C-h") 'delete-backward-char)
+ (global-set-key (kbd "s-m") 'man)
+#+END_SRC
+
+Refer [[https://github.com/fnwiya/dotfiles/blob/c9ca79f1b22c919d9f4c3a0f944ba8281255a594/setup/.emacs.d/loader-init/_90-kill-region-or-backward-kill-word.el][kill-region-or-backward-kill-word]]
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (require 'utilities)
+ (global-set-key (kbd "C-w") 'sd/kill-region-or-backward-kill-word)
+#+END_SRC
+
+
** Esc in minibuffer
Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g=
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(dired-jump)))
#+END_SRC
+Kill the help window and buffer when quit.
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (with-eval-after-load "help-mode"
+ (define-key help-mode-map (kbd "q") (lambda ()
+ (interactive)
+ (quit-window t))))
+
+ (with-eval-after-load 'man
+ (set-face-attribute 'Man-overstrike nil :inherit 'bold :foreground "orange red")
+ (set-face-attribute 'Man-underline nil :inherit 'underline :foreground "forest green")
+ (define-key Man-mode-map (kbd "q") (lambda ()
+ (interactive)
+ (Man-kill))))
+
+
+ ;; (advice-add 'man :after (lambda (man-args) (other-window 1)))
+ (advice-add 'man :after (apply-partially 'other-window 1))
+
+
+ (require 'shell-command-output-mode)
+
+ (defun my/shell-command-after (command &optional output-buffer error-buffer)
+ (let* ((buffer (get-buffer "*Shell Command Output*"))
+ (window (get-buffer-window buffer)))
+ (if buffer (with-current-buffer buffer
+ (shell-command-output-mode)))
+ (if window
+ (select-window window))))
+
+ (advice-add 'shell-command :after 'my/shell-command-after)
+#+END_SRC
+
** Motion
- =C-M-=
[[https://www.masteringemacs.org/article/effective-editing-movement][effective-editing-movement]]
#+END_SRC
*** TODO make expand-region hydra work with lispy selected
-** =C-w= delete backward word
-Refer [[https://github.com/fnwiya/dotfiles/blob/c9ca79f1b22c919d9f4c3a0f944ba8281255a594/setup/.emacs.d/loader-init/_90-kill-region-or-backward-kill-word.el][kill-region-or-backward-kill-word]]
-
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- (require 'utilities)
- (global-set-key (kbd "C-w") 'sd/kill-region-or-backward-kill-word)
-#+END_SRC
* Developing
** perspeen
#+END_SRC
* Evil Mode
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- ;; (org-babel-load-file "~/.emacs.d/emacs-evil.org")
-
+ (org-babel-load-file "~/.emacs.d/emacs-evil.org")
#+END_SRC
blog with modify list
draw one line top of the windows
+* test
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ ;; test local mode line
+ ;; (add-to-list 'load-path "~/.emacs.d/elisp")
+ ;; (require 'my-mode-line)
+#+END_SRC