#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(use-package powerline
:ensure t
- :config
- ;; (powerline-center-theme)
- )
-
- ;; (use-package smart-mode-line
- ;; :ensure t)
- ;; (use-package smart-mode-line-powerline-theme
- ;; :ensure t)
+ :config)
#+END_SRC
Revised powerline-center-theme
(setq helm-split-window-in-side-p t))
#+END_SRC
+* Projectile
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (use-package projectile
+ :ensure t
+ :init
+ (setq projectile-enable-caching t)
+ (setq projectile-switch-project-action 'projectile-dired)
+ (setq projectile-cache-file (concat sd-temp-directory "projectile.cache"))
+ (setq projectile-completion-system 'ivy)
+ :config
+ (add-to-list 'projectile-globally-ignored-files "GTAGS")
+ (projectile-global-mode t))
+
+ ;; https://emacs.stackexchange.com/questions/16497/how-to-exclude-files-from-projectile
+ (if (executable-find "rg")
+ (progn
+ (defconst modi/rg-arguments
+ `("--line-number" ; line numbers
+ "--smart-case"
+ "--follow" ; follow symlinks
+ "--mmap") ; apply memory map optimization when possible
+ "Default rg arguments used in the functions in `projectile' package.")
+
+ (defun modi/advice-projectile-use-rg ()
+ "Always use `rg' for getting a list of all files in the project."
+ (mapconcat 'identity
+ (append '("\\rg") ; used unaliased version of `rg': \rg
+ modi/rg-arguments
+ '("--null" ; output null separated results,
+ "--files")) ; get file names matching the regex '' (all files)
+ " "))
+
+ (advice-add 'projectile-get-ext-command :override #'modi/advice-projectile-use-rg))
+ (message "rg is not found"))
+#+END_SRC
+
* Swiper & Ivy & Counsel
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(use-package counsel
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
(global-set-key (kbd "C-c C-r") 'ivy-resume))
-
- ;; (use-package counsel-projectile
- ;; :ensure t
- ;; :defer t)
-
- (add-to-list 'load-path "~/project/counsel-projectile/")
- (require 'counsel-projectile)
- (setq counsel-projectile-use-buffer-preselect t)
- (setq projectile-completion-system 'ivy)
#+END_SRC
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(ivy-set-actions
+ t
+ '(("q" (lambda (x) (ivy-quit-and-run (message "=="))) "exit")))
+
+ (ivy-set-actions
'projectile-switch-to-buffer
'(("j" ivy--switch-buffer-other-window-action "other window" )))
+ (defun sd/projectile-find-file-other-window-action (file)
+ (message "=========")
+ (message (projectile-expand-root file))
+ (find-file-other-window (projectile-expand-root file)))
+
(ivy-set-actions
- t
- '(("q" (lambda (x) (ivy-quit-and-run (message "=="))) "exit")))
+ 'projectile-find-file
+ '(("j" sd/projectile-find-file-other-window-action "other-window")))
- (defun sd/swith-buffer-other-window ()
+ (defun sd/swith-to-buffer ()
+ "switch to buffer"
(interactive)
- (ivy-set-action (let ((last (ivy-state-caller ivy-last)))
- (cond ((eq last 'ivy-switch-buffer) 'ivy--switch-buffer-other-window-action)
- ((eq last 'counsel-recentf) 'find-file-other-window)
- ((eq last 'projectile-find-file) 'projectile-find-file-other-window)
- ((eq last 'counsel-projectile-find-file) 'counsel-projectile-find-file-action-other-window)
- ((eq last 'projectile-switch-to-buffer) 'ivy--switch-buffer-other-window-action)
- (t nil))))
- (ivy-done)
- (ivy-shrink-after-dispatching))
+ (if (projectile-project-p)
+ (projectile-switch-to-buffer)
+ (ivy-switch-buffer)))
+
+ (ivy-set-actions
+ 'sd/swith-to-buffer
+ '(("j" ivy--switch-buffer-other-window-action "other window")))
(defun sd/exit-ivy-and-swith-to-buffer ()
"exit ivy complete, and call swith to buffer"
(ivy-quit-and-run
(ivy-switch-buffer)))
+ (defun my/ivy-read-action (key)
+ (let ((actions (ivy-state-action ivy-last)))
+ (if (null (ivy--actionp actions))
+ t
+ (let* ((action-idx (cl-position-if
+ (lambda (x) (equal (car x) key))
+ (cdr actions))))
+ (cond ((member key '("\e" "\a"))
+ nil)
+ ((null action-idx)
+ (message "%s is not bound" key)
+ nil)
+ (t
+ (message "")
+ (setcar actions (1+ action-idx))
+ (ivy-set-action actions)))))))
+
(with-eval-after-load "ivy"
- ;; (define-key ivy-minibuffer-map (kbd "C-o") 'ivy-dispatching-done)
- (define-key ivy-minibuffer-map (kbd "C-k") #'sd/swith-buffer-other-window)
- ;; (define-key ivy-minibuffer-map (kbd "M-o") nil)
- (define-key ivy-minibuffer-map (kbd "C-o") #'sd/exit-ivy-and-swith-to-buffer))
+ (define-key ivy-minibuffer-map (kbd "C-o") 'ivy-dispatching-done)
+ (define-key ivy-minibuffer-map (kbd "C-k") (lambda () (interactive)
+ (my/ivy-read-action "j")
+ (ivy-done)))
+ (define-key ivy-minibuffer-map (kbd "M-o") #'sd/exit-ivy-and-swith-to-buffer))
#+END_SRC
stolen from [[https://github.com/mariolong/emacs.d/blob/f6a061594ef1b5d1f4750e9dad9dc97d6e122840/emacs-init.org][here]]
:features ob-racket)
;; Lua support
- ;(use-package ob-lua
- ; :ensure t)
+;; (use-package ob-lua
+;; :ensure t)
;; use current window for org source buffer editting
- (setq org-src-window-setup 'current-window )
+ ;; (setq org-src-window-setup 'current-window)
(define-key org-mode-map (kbd "C-'") nil)
;; C-M-i is mapped to imenu globally
(define-key org-mode-map (kbd "C-M-i") nil)
(latex . t)
(java . t)
(ruby . t)
- ; (lua . t)
+; (lua . t)
(lisp . t)
(scheme . t)
(racket . t)
("d" ace-delete-window "Delete" :exit t)
("x" sd/exchange-win-layout "eXchange" :exit t)
("u" winner-undo "window-Undo" :exit t)
- ("r" winner-redo "window-Redo" :exit t))
+ ("r" winner-redo "window-Redo" :exit t)
+ ("C-h" (lambda () (interactive) (evil-window-increase-width 3)) "<<")
+ ("C-l" (lambda () (interactive) (evil-window-decrease-width 3)) ">>")
+ ("C-k" (lambda () (interactive) (evil-window-increase-height 3)) "^")
+ ("C-j" (lambda () (interactive) (evil-window-decrease-height 3)) "v")
+ ("=" balance-windows "=" :exit t)
+ ("q" nil "quit"))
(defhydra sd/hydra-gtags (:color red :colums nil)
"ggtags - global"
(ace-link-setup-default))
#+END_SRC
-** Smart Parens
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- ;; (use-package smartparens
- ;; :ensure t
- ;; :config
- ;; (progn
- ;; (require 'smartparens-config)
- ;; (add-hook 'prog-mode-hook 'smartparens-mode)))
-#+END_SRC
-
** Ace-Windows
[[https://github.com/abo-abo/ace-window][ace-window]]
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(setq aw-keys '(?a ?s ?d ?f ?j ?k ?l)))
#+END_SRC
-** Which key
-[[https://github.com/justbur/emacs-which-key][which-key]] show the key bindings
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- ;; (use-package which-key
- ;; :ensure t
- ;; :config
- ;; (which-key-mode))
-#+END_SRC
-
** View only for some directory
When see function by =C-h f=, and visit the source code, I would like the buffer is read only. See [[http://emacs.stackexchange.com/questions/3676/how-to-enter-view-only-mode-when-browsing-emacs-source-code-from-help/3681#3681][here]]
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(sd/delete-current-window))
#+END_SRC
-** Demo It
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- (use-package org-tree-slide
- :ensure t)
-#+END_SRC
-
** Presentation
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(use-package org-tree-slide
:features help-mode+)
#+END_SRC
-** goto-last-change
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- ;; (use-package goto-last-change
- ;; :ensure t)
-#+END_SRC
-
** Ag
install =ag=, =the-silver-searcher= by homebrew on mac
#+BEGIN_SRC sh
#+END_SRC
* Project operations - =super=
-** Projectile
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- (use-package projectile
- :ensure t
- :init
- (setq projectile-enable-caching t)
- (setq projectile-switch-project-action (lambda ()
- (projectile-dired)
- (sd/project-switch-action)))
- (setq projectile-cache-file (concat sd-temp-directory "projectile.cache"))
- :config
- (add-to-list 'projectile-globally-ignored-files "GTAGS")
- (projectile-global-mode t)
- (global-set-key (kbd "C-M-p") 'projectile-switch-project))
-
- ;; change default-directory of scratch buffer to projectile-project-root
- (defun sd/project-switch-action ()
- "Change default-directory of scratch buffer to current projectile-project-root directory"
- (interactive)
- (dolist (buffer (buffer-list))
- (if (string-match (concat "scratch.*" (projectile-project-name))
- (buffer-name buffer))
- (let ((root (projectile-project-root)))
- (with-current-buffer buffer
- (cd root))))))
-
-
-
- ;; https://emacs.stackexchange.com/questions/16497/how-to-exclude-files-from-projectile
- ;; (setq projectile-enable-caching t)
- (if (executable-find "rg")
- (progn
- (defconst modi/rg-arguments
- `("--line-number" ; line numbers
- "--smart-case"
- "--follow" ; follow symlinks
- "--mmap") ; apply memory map optimization when possible
- "Default rg arguments used in the functions in `projectile' package.")
-
- (defun modi/advice-projectile-use-rg ()
- "Always use `rg' for getting a list of all files in the project."
- (mapconcat 'identity
- (append '("\\rg") ; used unaliased version of `rg': \rg
- modi/rg-arguments
- '("--null" ; output null separated results,
- "--files")) ; get file names matching the regex '' (all files)
- " "))
-
- (advice-add 'projectile-get-ext-command :override #'modi/advice-projectile-use-rg))
- (message "rg is not found"))
-#+END_SRC
** Windown & Buffer - =C-o=
Defind a =hydra= function for windows, buffer & bookmark operations. And map it to =C-o= globally.
(winner-mode 1)
(require 'utilities)
- (defhydra sd/hydra-window (:color red :columns nil)
- "C-o"
- ;; windows switch
- ("h" windmove-left nil :exit t)
- ("j" windmove-down nil :exit t)
- ("k" windmove-up nil :exit t)
- ("l" windmove-right nil :exit t)
- ("C-o" other-window nil :exit t)
- ;; window resize
- ("H" hydra-move-splitter-left nil)
- ("J" hydra-move-splitter-down nil)
- ("K" hydra-move-splitter-up nil)
- ("L" hydra-move-splitter-right nil)
- ;; windows split
- ("v" (lambda ()
- (interactive)
- (split-window-right)
- (windmove-right))
- nil :exit t)
- ("x" (lambda ()
- (interactive)
- (split-window-below)
- (windmove-down))
- nil :exit t)
- ;; buffer / windows switch
- ("o" sd/toggle-max-windows nil :exit t)
- ("C-k" sd/delete-current-window nil :exit t)
- ("C-d" (lambda ()
- (interactive)
- (kill-buffer)
- (sd/delete-current-window))
- nil :exit t)
-
- ;; ace-window
- ;; ("'" other-window "other" :exit t)
- ;; ("a" ace-window "ace")
- ("s" ace-swap-window nil)
- ("D" ace-delete-window nil :exit t)
- ;; ("i" ace-maximize-window "ace-one" :exit t)
- ;; Windows undo - redo
- ("u" (progn (winner-undo) (setq this-command 'winner-undo)) nil)
- ("r" (progn (winner-redo) (setq this-command 'winner-redo)) nil)
-
- ;; ibuffer, dired, eshell, bookmarks
- ;; ("C-i" other-window nil :exit t)
- ("C-b" ido-switch-buffer nil :exit t)
- ("C-f" projectile-find-file nil :exit t)
- ("C-r" ivy-recentf nil :exit t)
- ;; ("C-p" persp-switch nil :exit t)
- ;; ("C-t" projectile-persp-switch-project nil :exit t)
-
- ;; other special buffers
- ("d" sd/project-or-dired-jump nil :exit t)
- ("b" ibuffer nil :exit t)
- ("t" multi-term nil :exit t)
- ("e" sd/toggle-project-eshell nil :exit t)
- ("m" bookmark-jump-other-window nil :exit t)
- ("M" bookmark-set nil :exit t)
- ("g" magit-status nil :exit t)
- ;; ("p" paradox-list-packages nil :exit t)
-
- ;; quit
- ("q" nil nil)
- ("<ESC>" nil nil)
- ("C-h" windmove-left nil :exit t)
- ("C-j" windmove-down nil :exit t)
- ("C-k" windmove-up nil :exit t)
- ("C-l" windmove-right nil :exit t)
- ("C-;" nil nil :exit t)
- ("n" nil nil :exit t)
- ("[" nil nil :exit t)
- ("]" nil nil :exit t)
- ("f" nil nil))
-
- (global-unset-key (kbd "C-o"))
- (global-set-key (kbd "C-o") 'sd/hydra-window/body)
-
- (defun sd/project-or-dired-jump ()
- "If under project, jump to the root directory, otherwise
- jump to dired of current file"
- (interactive)
- (if (projectile-project-p)
- (projectile-dired)
- (dired-jump)))
+ ;; (defhydra sd/hydra-window (:color red :columns nil)
+ ;; "C-o"
+ ;; ;; windows switch
+ ;; ("h" windmove-left nil :exit t)
+ ;; ("j" windmove-down nil :exit t)
+ ;; ("k" windmove-up nil :exit t)
+ ;; ("l" windmove-right nil :exit t)
+ ;; ("C-o" other-window nil :exit t)
+ ;; ;; window resize
+ ;; ("H" hydra-move-splitter-left nil)
+ ;; ("J" hydra-move-splitter-down nil)
+ ;; ("K" hydra-move-splitter-up nil)
+ ;; ("L" hydra-move-splitter-right nil)
+ ;; ;; windows split
+ ;; ("v" (lambda ()
+ ;; (interactive)
+ ;; (split-window-right)
+ ;; (windmove-right))
+ ;; nil :exit t)
+ ;; ("x" (lambda ()
+ ;; (interactive)
+ ;; (split-window-below)
+ ;; (windmove-down))
+ ;; nil :exit t)
+ ;; ;; buffer / windows switch
+ ;; ("o" sd/toggle-max-windows nil :exit t)
+ ;; ("C-k" sd/delete-current-window nil :exit t)
+ ;; ("C-d" (lambda ()
+ ;; (interactive)
+ ;; (kill-buffer)
+ ;; (sd/delete-current-window))
+ ;; nil :exit t)
+
+ ;; ;; ace-window
+ ;; ;; ("'" other-window "other" :exit t)
+ ;; ;; ("a" ace-window "ace")
+ ;; ("s" ace-swap-window nil)
+ ;; ("D" ace-delete-window nil :exit t)
+ ;; ;; ("i" ace-maximize-window "ace-one" :exit t)
+ ;; ;; Windows undo - redo
+ ;; ("u" (progn (winner-undo) (setq this-command 'winner-undo)) nil)
+ ;; ("r" (progn (winner-redo) (setq this-command 'winner-redo)) nil)
+
+ ;; ;; ibuffer, dired, eshell, bookmarks
+ ;; ;; ("C-i" other-window nil :exit t)
+ ;; ("C-b" ido-switch-buffer nil :exit t)
+ ;; ("C-f" projectile-find-file nil :exit t)
+ ;; ("C-r" ivy-recentf nil :exit t)
+ ;; ;; ("C-p" persp-switch nil :exit t)
+ ;; ;; ("C-t" projectile-persp-switch-project nil :exit t)
+
+ ;; ;; other special buffers
+ ;; ("d" sd/project-or-dired-jump nil :exit t)
+ ;; ("b" ibuffer nil :exit t)
+ ;; ("t" multi-term nil :exit t)
+ ;; ("e" sd/toggle-project-eshell nil :exit t)
+ ;; ("m" bookmark-jump-other-window nil :exit t)
+ ;; ("M" bookmark-set nil :exit t)
+ ;; ("g" magit-status nil :exit t)
+ ;; ;; ("p" paradox-list-packages nil :exit t)
+
+ ;; ;; quit
+ ;; ("q" nil nil)
+ ;; ("<ESC>" nil nil)
+ ;; ("C-h" windmove-left nil :exit t)
+ ;; ("C-j" windmove-down nil :exit t)
+ ;; ("C-k" windmove-up nil :exit t)
+ ;; ("C-l" windmove-right nil :exit t)
+ ;; ("C-;" nil nil :exit t)
+ ;; ("n" nil nil :exit t)
+ ;; ("[" nil nil :exit t)
+ ;; ("]" nil nil :exit t)
+ ;; ("f" nil nil))
+
+ ;; (global-unset-key (kbd "C-o"))
+ ;; (global-set-key (kbd "C-o") 'sd/hydra-window/body)
+
+ ;; (defun sd/project-or-dired-jump ()
+ ;; "If under project, jump to the root directory, otherwise
+ ;; jump to dired of current file"
+ ;; (interactive)
+ ;; (if (projectile-project-p)
+ ;; (projectile-dired)
+ ;; (dired-jump)))
#+END_SRC
Kill the help window and buffer when quit.
#+END_SRC
** Motion
-- =C-M-=
-[[https://www.masteringemacs.org/article/effective-editing-movement][effective-editing-movement]]
-*** Command Arguments, numeric argumens
-=C-u 4= same as =C-4=, =M-4=
-*** Basic movement
-moving by line / word /
-=C-f=, =C-b=, =C-p=, =C-n=, =M-f=, =M-b=
-=C-a=, =C-e=
-=M-m= (move first non-whitespace on this line)
-=M-}=, =M-{=, Move forward end of paragraph
-=M-a=, =M-e=, beginning / end of sentence
-=C-M-a=, =C-M-e=, move begining of defun
-=C-x ]=, =C-x [=, forward/backward one page
-=C-v=, =M-v=, =C-M-v=, =C-M-S-v= scroll down/up
-=M-<=, =M->=, beginning/end of buffer
-=M-r=, Repositiong point
-
-*** Moving by S-expression / List
+
*** Marks
=C-<SPC>= set marks toggle the region
=C-u C-<SPC>= Jump to the mark, repeated calls go further back the mark ring
:ensure t)
#+END_SRC
-*** Bookmarks
-As I would like use bookmakr for different buffer/files. to help to swith
-different buffer/file quickly. this setting is in Windows/buffer node
-=C-x r m= set a bookmarks
-=C-x r l= list bookmarks
-=C-x r b= jump to bookmarks
-
-*** Search
-Search, replace and hightlight will in later paragraph
*** =Avy= for easy motion
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(use-package avy
#+END_SRC
** Edit
-*** basic editting
-- cut, yank, =C-w=, =C-y=
-- save, revert
-- undo, redo - undo-tree
-- select, expand-region
-- spell check, flyspell
*** Kill ring
=helm-show-kill-ring=
(global-set-key (kbd "s-m") 'man)
(global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)
;; project operation
- (global-set-key (kbd "s-p") 'projectile-switch-project)
- (global-set-key (kbd "s-p") 'projectile-switch-project)
+ (global-set-key (kbd "s-p") 'projectile-switch-open-project)
(global-set-key (kbd "s-f") 'projectile-find-file)
(global-set-key (kbd "s-=") 'text-scale-increase)
(global-set-key (kbd "s--") 'text-scale-decrease)
+ (global-unset-key (kbd "s-n"))
#+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
(org-babel-load-file "~/.emacs.d/emacs-evil.org")
#+END_SRC
-* Note
-** Check if emacs is in terminal of graphic mode
-Use =display-graphic-p= instead of =window-system=
-[[info:elisp#Window%20Systems][Window Systems]]
-** =Interactive=
-** List operation
-*** add a element to list
-- ~add-to-list~ functions, append
-- ~push~ macro
-- ~(setcdr (last aa) (list element))~
-blog with modify list
-
-draw one line top of the windows
-* test
-This is a 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