emacs - add counsel packet
[dotfiles.git] / emacs.d / config.org
index 9406601..0bd61bd 100644 (file)
@@ -406,13 +406,37 @@ Install powerline mode [[https://github.com/milkypostman/powerline][powerline]]
 #+END_SRC
 
 Revised powerline-center-theme
-
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (defun sd/powerline-simpler-vc (s)
     (if s
         (replace-regexp-in-string "Git[:-]" "" s)
       s))
 
+  (defface sd/powerline-active1 '((t (:background "yellow" :foreground "black" :inherit mode-line)))
+    "My Powerline face 1 based on powerline-active1."
+    :group 'powerline)
+
+  (defface sd/buffer-modified-active1 '((t (:background "red" :foreground "black" :inherit mode-line)))
+    "My Powerline face 1 based on powerline-active1."
+    :group 'powerline)
+
+  (defface sd/buffer-view-active1 '((t (:background "green" :foreground "black" :inherit mode-line)))
+    "My Powerline face 1 based on powerline-active1."
+    :group 'powerline)
+
+  (defface sd/mode-line-buffer-id
+    '((t (:background "yellow" :foreground "black" :inherit mode-line-buffer-id)))
+    "My powerline mode-line face, based on mode-line-buffer-id"
+    :group 'powerline)
+
+  ;; Don't show buffer modified for scratch and eshell mode
+  (defun sd/buffer-show-modified ()
+    "Dot not show modified indicator for buffers"
+    (interactive)
+    (unless (or (string-match "*scratch*" (buffer-name))
+                (equal major-mode 'eshell-mode))
+      t))
+
   (defun sd/powerline-center-theme_revised ()
     "Setup a mode-line with major and minor modes centered."
     (interactive)
@@ -420,8 +444,13 @@ Revised powerline-center-theme
                   '("%e"
                     (:eval
                      (let* ((active (powerline-selected-window-active))
-                            (mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive))
+                            (mode-line-buffer-id (if active 'sd/mode-line-buffer-id 'mode-line-buffer-id-inactive))
                             (mode-line (if active 'mode-line 'mode-line-inactive))
+                            (my-face1 (if active 'sd/powerline-active1 'powerline-inactive1))
+                            (my-face-buffer-modified (if (and (sd/buffer-show-modified) (buffer-modified-p)) 
+                                                         'sd/buffer-modified-active1
+                                                       (if buffer-read-only 'sd/buffer-view-active1
+                                                         my-face1)))
                             (face1 (if active 'powerline-active1 'powerline-inactive1))
                             (face2 (if active 'powerline-active2 'powerline-inactive2))
                             (separator-left (intern (format "powerline-%s-%s"
@@ -430,23 +459,24 @@ Revised powerline-center-theme
                             (separator-right (intern (format "powerline-%s-%s"
                                                              (powerline-current-separator)
                                                              (cdr powerline-default-separator-dir))))
-                            (lhs (list (powerline-raw "%*" mode-line 'l)
+                            (lhs (list (powerline-raw "%* " my-face-buffer-modified 'l)
                                        ;; (powerline-buffer-size mode-line 'l)
                                        (powerline-buffer-id mode-line-buffer-id 'l)
-                                       (powerline-raw " ")
-                                       (funcall separator-left mode-line face1)
+                                       (powerline-raw " " my-face1)
+                                       (funcall separator-left my-face1 face1)
                                        (powerline-narrow face1 'l)
                                        ;; (powerline-vc face1)
-                                       (sd/powerline-simpler-vc (powerline-vc face1))
-                                       ))
+                                       (sd/powerline-simpler-vc (powerline-vc face1))))
                             (rhs (list (powerline-raw global-mode-string face1 'r)
                                        (powerline-raw "%4l" face1 'r)
-                                       (powerline-raw ":" face1)
+                                       (powerline-raw ":" face1)     
                                        (powerline-raw "%3c" face1 'r)
-                                       (funcall separator-right face1 mode-line)
-                                       (powerline-raw " ")
-                                       (powerline-raw "%6p" mode-line 'r)
-                                       (powerline-hud face2 face1)))
+                                       (funcall separator-right face1 my-face1)
+                                       ;; (powerline-raw " " my-face1)
+                                       (powerline-raw (format-time-string " %I:%M %p ") my-face1 'r)
+                                       ;; (powerline-raw "%6p" my-face1 'r)
+                                       ;; (powerline-hud my-face1 face1 )
+                                       ))
                             (center (list (powerline-raw " " face1)
                                           (funcall separator-left face1 face2)
                                           (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode)
@@ -467,21 +497,19 @@ Revised powerline-center-theme
 #+END_SRC
 
 Fix the issue in mode line when showing triangle 
-
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (setq ns-use-srgb-colorspace nil)
 #+END_SRC
 
 set height in mode line
-
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-
-  (custom-set-variables
-   '(powerline-height 14)
-   '(powerline-text-scale-factor 0.8))
-  ;; 100/140
+  (set-variable 'powerline-height 14)
+  (set-variable 'powerline-text-scale-factor (/ (float 100) 140))
+  ;; (custom-set-variables
+  ;;  '(powerline-height 14)
+  ;;  '(powerline-text-scale-factor (/ (float 100) 140)))
+  ;; 100/140;0.8
   (set-face-attribute 'mode-line nil :height 100)
-
 #+END_SRC
 
 * IDO & SMEX
@@ -600,10 +628,10 @@ Stolen from [[https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-spell
   ;;   ;; Turn off RUN-TOGETHER option when spell check text-mode
   ;;   (setq-local ispell-extra-args (flyspell-detect-ispell-args)))
   ;; (add-hook 'text-mode-hook 'text-mode-hook-setup)
-  (add-hook 'text-mode-hook 'flyspell-mode)
+  ;; (add-hook 'text-mode-hook 'flyspell-mode)
 
   ;; enable flyspell check on comments and strings in progmamming modes
-  (add-hook 'prog-mode-hook 'flyspell-prog-mode)
+  ;; (add-hook 'prog-mode-hook 'flyspell-prog-mode)
 
   ;; I don't use the default mappings
   (with-eval-after-load 'flyspell
@@ -866,14 +894,18 @@ Occur search key bindings
   (ivy-mode 1)
   (setq ivy-use-virtual-buffers t)
   (global-set-key (kbd "s-/") 'swiper)
+
+  (use-package counsel
+    :ensure t
+    :defer t)
   ;;* 
   ;; (global-set-key "\C-s" 'swiper)
   ;; (global-set-key (kbd "C-c C-r") 'ivy-resume)
   ;; (global-set-key (kbd "<f6>") 'ivy-resume)
-  ;; ;; (global-set-key (kbd "M-x") 'counsel-M-x)
+  (global-set-key (kbd "M-x") 'counsel-M-x)
   ;; ;; (global-set-key (kbd "C-x C-f") 'counsel-find-file)
-  ;; (global-set-key (kbd "<f1> f") 'counsel-describe-function)
-  ;; (global-set-key (kbd "<f1> v") 'counsel-describe-variable)
+  (global-set-key (kbd "C-h f") 'counsel-describe-function)
+  (global-set-key (kbd "C-h v") 'counsel-describe-variable)
   ;; (global-set-key (kbd "<f1> l") 'counsel-load-library)
   ;; (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
   ;; (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
@@ -884,6 +916,10 @@ Occur search key bindings
   ;; (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
   ;; ;; (define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
 
+  (set-face-attribute
+   'ivy-current-match nil
+   :background "Orange"
+   :foreground "black")
 #+END_SRC
 
 *** =M-s= prefix
@@ -971,7 +1007,8 @@ Always indents header, and hide header leading starts so that no need type =#+ST
      (sh . t)
      (sqlite . t)
      (js . t)
-     (gnuplot . t)))
+     (gnuplot . t)
+     (ditaa . t)))
 
   ;; use current window for org source buffer editting
   (setq org-src-window-setup 'current-window )
@@ -1735,6 +1772,23 @@ Play Go in Emacs, gnugo xpm refert [[https://github.com/okanotor/dotemacs/blob/f
 
 #+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
+  (dir-locals-set-class-variables
+   'emacs
+   '((nil . ((buffer-read-only . t)
+             (show-trailing-whitespace . nil)
+             (tab-width . 8)
+             (eval . (whitespace-mode -1))))))
+
+  ;; (dir-locals-set-directory-class (expand-file-name "/usr/local/share/emacs") 'emacs)
+  (dir-locals-set-directory-class "/usr/local/Cellar/emacs" 'emacs)
+  ;; (dir-locals-set-directory-class "~/.emacs.d/elpa" 'emacs)
+  (dir-locals-set-directory-class "~/dotfiles/emacs.d/elpa" 'emacs)
+  (dir-locals-set-directory-class "~/dotfiles/emacs.d/el-get" 'emacs)
+#+END_SRC
+
 ** Info plus
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (el-get-bundle info+
@@ -1768,11 +1822,6 @@ Play Go in Emacs, gnugo xpm refert [[https://github.com/okanotor/dotemacs/blob/f
 
 ** TODO Man mode
 Color for Man-mode
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  ;; (add-hook 'Man-mode-hook (lambda ()
-  ;;                         (interactive)
-  ;;                         (setenv "GROFF_NO_SRG")))
-#+END_SRC
 
 ** TODO swiper to occur
 
@@ -1911,6 +1960,20 @@ Refer [[https://www.emacswiki.org/emacs/AutoInsertMode][AutoInsertMode]] Wiki
          )))
 #+END_SRC
 
+*** Perl Keywords
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (font-lock-add-keywords 'cperl-mode
+                          '(("\\(say\\)" . cperl-nonoverridable-face)
+                            ("\\([0-9.]\\)*" . font-lock-constant-face)
+                            ("\".*\\(\\\n\\).*\"" . font-lock-constant-face)
+                            ("\n" . font-lock-constant-face)
+                            ("\\(^#!.*\\)$" .  cperl-nonoverridable-face)))
+
+    ;; (font-lock-add-keywords 'Man-mode
+    ;;                         '(("\\(NAME\\)" . font-lock-function-name-face)))
+
+#+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
@@ -2278,6 +2341,16 @@ Use =gnuplot= on =Org-mode= file, see [[http://orgmode.org/worg/org-contrib/babe
 - passion
 - vision
 - mission
+* Ediff
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (with-eval-after-load 'ediff
+    (setq ediff-split-window-function 'split-window-horizontally)
+    (setq ediff-window-setup-function 'ediff-setup-windows-plain)
+    (add-hook 'ediff-startup-hook 'ediff-toggle-wide-display)
+    (add-hook 'ediff-cleanup-hook 'ediff-toggle-wide-display)
+    (add-hook 'ediff-suspend-hook 'ediff-toggle-wide-display))
+#+END_SRC
+
 * TODO Convert ASCII to key
 ** map =function-key-map= [[http://academic.evergreen.edu/projects/biophysics/technotes/program/ascii_ctrl.htm][ascii_ctrl]]
 new file =C-x C-f C-f=
@@ -2286,9 +2359,27 @@ new file =C-x C-f C-f=
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (font-lock-add-keywords 'perl-mode '(("\\(|\\w+?\\(,\\w+?\\)?|\\)" 1 'py-builtins-face)))
-
-  (font-lock-add-keywords
-   'cperl-mode
-  '(("\\(say\\)" . font-lock-constant-face)))
 #+END_SRC
 
+* TODO set fly-spell binding
+
+* TODO imenu bindings
+
+* DONE modified indicator
+:LOGBOOK:
+- State "DONE"       from "TODO"       [2016-07-18 Mon 23:35]
+:END:
+* DONE highlight selected ido candicate
+:LOGBOOK:
+- State "DONE"       from "TODO"       [2016-07-19 Tue 01:49]
+:END:
+* DONE show time in right of mode-line
+:LOGBOOK:
+- State "DONE"       from "TODO"       [2016-07-19 Tue 01:11]
+:END:
+* DONE ediff mode
+:LOGBOOK:
+- State "DONE"       from "TODO"       [2016-07-19 Tue 01:11]
+:END:
+* TODO jump last change point
+* TODO emms mode-line