X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=emacs.d%2Fconfig.org;h=28a33c15f0e659f68746156af50f5c2d108aa143;hb=be4017091a741b544d0a7761429fdd9f6635b128;hp=f504edc1d5b6bfd8b8d1a62ef737540293c93ed9;hpb=310874d4809bb233e73edfe4907b0fd3508b445c;p=dotfiles.git diff --git a/emacs.d/config.org b/emacs.d/config.org index f504edc..28a33c1 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 @@ -598,7 +608,23 @@ set height in mode line :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 @@ -1260,6 +1286,8 @@ set default eshell history folder ;; (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 @@ -2110,6 +2138,7 @@ 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) @@ -2169,27 +2198,6 @@ Refer [[https://www.emacswiki.org/emacs/AutoInsertMode][AutoInsertMode]] Wiki #+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) @@ -2339,16 +2347,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) @@ -2406,7 +2417,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" @@ -2415,6 +2428,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 @@ -3539,3 +3583,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