X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=emacs.d%2Fconfig.org;h=38a77d1b4ff172cd1db99a647595b2e609735acd;hb=33ae631ee61dac5ec34c09ab63ea735ae68c62b8;hp=2ae4069dce8b090dcb633ce145c1e2eeb368ebe8;hpb=d2be0835c81f15ce76276c74ced7bcddf879d5cf;p=dotfiles.git diff --git a/emacs.d/config.org b/emacs.d/config.org index 2ae4069..38a77d1 100644 --- a/emacs.d/config.org +++ b/emacs.d/config.org @@ -54,6 +54,11 @@ Set system PATH and emacs exec path ;;supress the redefined warning at startup (setq ad-redefinition-action 'accept) + + (setq scroll-step 1) + (setq scroll-margin 5) + + (fringe-mode '(0 . 0)) #+END_SRC *** Custom file @@ -355,6 +360,11 @@ improve color for org-mode #+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 @@ -422,6 +432,8 @@ clean mode line, Refer to [[https://www.masteringemacs.org/article/hiding-replac (irony-mode . "") (page-break-lines-mode . "") (yas-minor-mode . "y") + ;; default jj + (evil-escape-mode . "") ;; Major modes (lisp-interaction-mode . "λ") (hi-lock-mode . "") @@ -545,6 +557,7 @@ Revised powerline-center-theme )) (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) @@ -789,9 +802,7 @@ use [[https://github.com/sabof/org-bullets][org-bullets]] package to show utf-8 (use-package org-bullets :ensure t :init - (add-hook 'org-mode-hook - (lambda () - (org-bullets-mode t)))) + (add-hook 'org-mode-hook (apply-partially #'org-bullets-mode t))) (setq org-bullets-bullet-list '("⦿" "✪" "◉" "○" "►" "◆")) @@ -1256,8 +1267,11 @@ set default eshell history folder #+BEGIN_SRC emacs-lisp :tangle yes :results silent (require 'utilities) - (add-hook 'eshell-mode-hook (lambda () - (local-set-key (kbd "C-l") 'sd/eshell-clear-buffer))) + ;; (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 "") 'completion-at-point))) #+END_SRC ** Toggle Eshell @@ -2108,15 +2122,14 @@ bindings in =lispy-mode-map= after loaded. see [[http://stackoverflow.com/questi (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) (define-key lispy-mode-map (kbd "G") 'special-lispy-goto) (define-key lispy-mode-map (kbd "M-m") 'back-to-indentation)) :config - (add-hook 'emacs-lisp-mode-hook (lambda () (lispy-mode 1)))) - - + (add-hook 'emacs-lisp-mode-hook (apply-partially #'lispy-mode 1))) #+END_SRC ** Perl @@ -2136,9 +2149,7 @@ bindings in =lispy-mode-map= after loaded. see [[http://stackoverflow.com/questi (setq cperl-tab-always-indent t) ;(setq cperl-brace-offset 0) - (add-hook 'cperl-mode-hook - '(lambda () - (cperl-set-style "C++"))) + (add-hook 'cperl-mode-hook (apply-partially #'cperl-set-style "C++")) (defalias 'perldoc 'cperl-perldoc) #+END_SRC @@ -2176,20 +2187,21 @@ 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))))) + ;; this has be implemented in below compile part + ;; (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) + ;; (add-hook 'cperl-mode-hook 'my-perl-hook) #+END_SRC ** C & C++ @@ -2341,16 +2353,19 @@ irony-company #+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) @@ -2408,7 +2423,9 @@ Set the environments vairables in compilation mode (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" @@ -2417,6 +2434,37 @@ Set the environments vairables in compilation mode (define-key compilation-mode-map (kbd "p") 'compilation-previous-error) (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 @@ -2674,8 +2722,9 @@ Then Run =M-x gnus= ;; (with-eval-after-load 'gnus-summary-mode ;; (define-key gnus-summary-mode-map (kbd "C-o") 'sd/hydra-window/body)) - (add-hook 'gnus-summary-mode-hook (lambda () - (define-key gnus-summary-mode-map (kbd "C-o") nil))) + ;; (add-hook 'gnus-summary-mode-hook (lambda () + ;; (define-key gnus-summary-mode-map (kbd "C-o") nil))) + ;(add-hook 'gnus-summary-mode-hook (apply-partially #'define-key gnus-summary-mode-map (kbd "C-o") nil)) #+END_SRC @@ -3523,8 +3572,7 @@ Refer [[https://github.com/fnwiya/dotfiles/blob/c9ca79f1b22c919d9f4c3a0f944ba828 #+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 @@ -3541,3 +3589,9 @@ Use =display-graphic-p= instead of =window-system= 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