Clean up Emacs configuration
- remove unused stuff - add cheat sheet - minimal setup before adding CEDET
This commit is contained in:
parent
fb23669709
commit
7f4c76c321
8 changed files with 153 additions and 499 deletions
|
|
@ -5,4 +5,4 @@ It is mostly based on tuhdo's emacs ide demo: https://github.com/tuhdo/emacs-c-i
|
||||||
|
|
||||||
This configuration requires the installation of :
|
This configuration requires the installation of :
|
||||||
- the GNU global package (for gtags)
|
- the GNU global package (for gtags)
|
||||||
- surfraw (for helm-surfraw)
|
|
||||||
|
|
|
||||||
3
cheat-sheet.txt
Normal file
3
cheat-sheet.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
C-M-Space : smartparens wrapping
|
||||||
|
C-c C-c : calculator (see init.el)
|
||||||
|
C-h k <key-sequence>: lookup key sequence
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
(require 'cc-mode)
|
|
||||||
(require 'semantic)
|
|
||||||
|
|
||||||
(global-semanticdb-minor-mode 1)
|
|
||||||
(global-semantic-idle-scheduler-mode 1)
|
|
||||||
(global-semantic-stickyfunc-mode 1)
|
|
||||||
|
|
||||||
(semantic-mode 1)
|
|
||||||
|
|
||||||
;; (defun alexott/cedet-hook ()
|
|
||||||
;; (local-set-key "\C-c\C-j" 'semantic-ia-fast-jump)
|
|
||||||
;; (local-set-key "\C-c\C-s" 'semantic-ia-show-summary))
|
|
||||||
|
|
||||||
;; (add-hook 'c-mode-common-hook 'alexott/cedet-hook)
|
|
||||||
;; (add-hook 'c-mode-hook 'alexott/cedet-hook)
|
|
||||||
;; (add-hook 'c++-mode-hook 'alexott/cedet-hook)
|
|
||||||
|
|
||||||
;; Enable EDE only in C/C++
|
|
||||||
(require 'ede)
|
|
||||||
(global-ede-mode)
|
|
||||||
|
|
||||||
(provide 'setup-cedet)
|
|
||||||
305
custom/setup-editing.el
Executable file → Normal file
305
custom/setup-editing.el
Executable file → Normal file
|
|
@ -1,34 +1,18 @@
|
||||||
;; GROUP: Editing -> Editing Basics
|
|
||||||
|
|
||||||
(setq global-mark-ring-max 5000 ; increase mark ring to contains 5000 entries
|
(setq global-mark-ring-max 5000 ; increase mark ring to contains 5000 entries
|
||||||
mark-ring-max 5000 ; increase kill ring to contains 5000 entries
|
mark-ring-max 5000 ; increase kill ring to contains 5000 entries
|
||||||
mode-require-final-newline t ; add a newline to end of file
|
mode-require-final-newline t ; add a newline to end of file
|
||||||
)
|
)
|
||||||
|
|
||||||
;; set appearance of a tab that is represented by 2 spaces
|
|
||||||
(setq-default tab-width 2)
|
|
||||||
|
|
||||||
;; automatically indent when press RET
|
|
||||||
(global-set-key (kbd "RET") 'newline-and-indent)
|
|
||||||
|
|
||||||
;; activate whitespace-mode to view all whitespace characters
|
|
||||||
(global-set-key (kbd "C-c w") 'whitespace-mode)
|
|
||||||
|
|
||||||
(set-terminal-coding-system 'utf-8)
|
|
||||||
(set-keyboard-coding-system 'utf-8)
|
|
||||||
(set-language-environment "UTF-8")
|
|
||||||
(prefer-coding-system 'utf-8)
|
|
||||||
|
|
||||||
;; use space to indent by default
|
|
||||||
(setq-default indent-tabs-mode nil)
|
|
||||||
(delete-selection-mode)
|
|
||||||
(global-set-key (kbd "RET") 'newline-and-indent)
|
|
||||||
|
|
||||||
;; GROUP: Editing -> Killing
|
|
||||||
(setq kill-ring-max 5000 ; increase kill-ring capacity
|
(setq kill-ring-max 5000 ; increase kill-ring capacity
|
||||||
kill-whole-line t ; if NIL, kill whole line and move the next line up
|
kill-whole-line t ; if NIL, kill whole line and move the next line up
|
||||||
)
|
)
|
||||||
|
|
||||||
|
;; set appearance of a tab that is represented by 4 spaces
|
||||||
|
(setq-default tab-width 4)
|
||||||
|
|
||||||
|
;; automatically indent when press RET
|
||||||
|
(global-set-key (kbd "RET") 'newline-and-indent)
|
||||||
|
|
||||||
;; show whitespace in diff-mode
|
;; show whitespace in diff-mode
|
||||||
(add-hook 'diff-mode-hook (lambda ()
|
(add-hook 'diff-mode-hook (lambda ()
|
||||||
(setq-local whitespace-style
|
(setq-local whitespace-style
|
||||||
|
|
@ -44,257 +28,58 @@
|
||||||
newline-mark))
|
newline-mark))
|
||||||
(whitespace-mode 1)))
|
(whitespace-mode 1)))
|
||||||
|
|
||||||
|
;; Package: undo-tree -- saner, imo, undo with C-/
|
||||||
|
(require 'undo-tree)
|
||||||
|
(global-undo-tree-mode)
|
||||||
|
|
||||||
;; Package: volatile-highlights --- show changes by "undo/yanks/..."
|
;; Package: volatile-highlights --- show changes by "undo/yanks/..."
|
||||||
;; GROUP: Editing -> Volatile Highlights
|
|
||||||
(require 'volatile-highlights)
|
(require 'volatile-highlights)
|
||||||
(volatile-highlights-mode t)
|
(volatile-highlights-mode t)
|
||||||
|
|
||||||
;; Package: clean-aindent-mode
|
;; Package: ws-butler --- trim spaces from eol
|
||||||
;; GROUP: Editing -> Indent -> Clean Aindent
|
|
||||||
(require 'clean-aindent-mode)
|
|
||||||
(add-hook 'prog-mode-hook 'clean-aindent-mode)
|
|
||||||
|
|
||||||
|
|
||||||
;; PACKAGE: dtrt-indent
|
|
||||||
(require 'dtrt-indent)
|
|
||||||
(dtrt-indent-mode 1)
|
|
||||||
(setq dtrt-indent-verbosity 0)
|
|
||||||
|
|
||||||
;; PACKAGE: ws-butler
|
|
||||||
(require 'ws-butler)
|
(require 'ws-butler)
|
||||||
(add-hook 'c-mode-common-hook 'ws-butler-mode)
|
(add-hook 'c-mode-common-hook 'ws-butler-mode)
|
||||||
(add-hook 'text-mode 'ws-butler-mode)
|
(add-hook 'text-mode 'ws-butler-mode)
|
||||||
(add-hook 'fundamental-mode 'ws-butler-mode)
|
(add-hook 'fundamental-mode 'ws-butler-mode)
|
||||||
|
(add-hook 'prog-mode-hook 'ws-butler-mode)
|
||||||
|
|
||||||
;; Package: undo-tree
|
;;; Package: iedit --- Replace occurences of symbol and highlight them
|
||||||
;; GROUP: Editing -> Undo -> Undo Tree
|
(require 'iedit)
|
||||||
(require 'undo-tree)
|
|
||||||
(global-undo-tree-mode)
|
|
||||||
|
|
||||||
;; Package: yasnippet
|
;; Package: smartparens --- smart way to handle (), {}, ...
|
||||||
;; GROUP: Editing -> Yasnippet
|
(require 'smartparens-config)
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; keybinding management smartparens ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(define-key smartparens-mode-map (kbd "C-M-f") 'sp-forward-sexp)
|
||||||
|
(define-key smartparens-mode-map (kbd "C-M-b") 'sp-backward-sexp)
|
||||||
|
|
||||||
|
;; TODO: in manjaro this selects keyboard-layout or something
|
||||||
|
;;(define-key smartparens-mode-map (kbd "C-M-k") 'sp-kill-sexp)
|
||||||
|
(define-key smartparens-mode-map (kbd "C-M-w") 'sp-copy-sexp)
|
||||||
|
|
||||||
|
(define-key smartparens-mode-map (kbd "C-M-n") 'sp-next-sexp)
|
||||||
|
(define-key smartparens-mode-map (kbd "C-M-p") 'sp-previous-sexp)
|
||||||
|
|
||||||
|
;; TODO: these don't work for some reason
|
||||||
|
(define-key smartparens-mode-map (kbd "C-M-d") 'sp-beginning-of-sexp)
|
||||||
|
(define-key smartparens-mode-map (kbd "C-M-a") 'sp-end-of-sexp)
|
||||||
|
|
||||||
|
(smartparens-global-mode t)
|
||||||
|
|
||||||
|
|
||||||
|
;; Package: comment-dwim-2 --- replacement for built-in comment-dwim, more comment features
|
||||||
|
(require 'comment-dwim-2)
|
||||||
|
(global-set-key (kbd "M-;") 'comment-dwim-2)
|
||||||
|
|
||||||
|
|
||||||
|
;; Package: yasnippet --- code template system
|
||||||
(require 'yasnippet)
|
(require 'yasnippet)
|
||||||
(yas-global-mode 1)
|
(yas-global-mode 1)
|
||||||
|
|
||||||
;; PACKAGE: smartparens
|
|
||||||
(require 'smartparens-config)
|
|
||||||
(setq sp-base-key-bindings 'paredit)
|
|
||||||
(setq sp-autoskip-closing-pair 'always)
|
|
||||||
(setq sp-hybrid-kill-entire-symbol nil)
|
|
||||||
(sp-use-paredit-bindings)
|
|
||||||
|
|
||||||
(show-smartparens-global-mode +1)
|
|
||||||
(smartparens-global-mode 1)
|
|
||||||
|
|
||||||
;; PACKAGE: comment-dwim-2
|
|
||||||
(global-set-key (kbd "M-;") 'comment-dwim-2)
|
|
||||||
|
|
||||||
;; Jump to end of snippet definition
|
|
||||||
(define-key yas-keymap (kbd "<return>") 'yas/exit-all-snippets)
|
|
||||||
|
|
||||||
;; Inter-field navigation
|
|
||||||
(defun yas/goto-end-of-active-field ()
|
|
||||||
(interactive)
|
|
||||||
(let* ((snippet (car (yas--snippets-at-point)))
|
|
||||||
(position (yas--field-end (yas--snippet-active-field snippet))))
|
|
||||||
(if (= (point) position)
|
|
||||||
(move-end-of-line 1)
|
|
||||||
(goto-char position))))
|
|
||||||
|
|
||||||
(defun yas/goto-start-of-active-field ()
|
|
||||||
(interactive)
|
|
||||||
(let* ((snippet (car (yas--snippets-at-point)))
|
|
||||||
(position (yas--field-start (yas--snippet-active-field snippet))))
|
|
||||||
(if (= (point) position)
|
|
||||||
(move-beginning-of-line 1)
|
|
||||||
(goto-char position))))
|
|
||||||
|
|
||||||
(define-key yas-keymap (kbd "C-e") 'yas/goto-end-of-active-field)
|
|
||||||
(define-key yas-keymap (kbd "C-a") 'yas/goto-start-of-active-field)
|
|
||||||
;; (define-key yas-minor-mode-map [(tab)] nil)
|
|
||||||
;; (define-key yas-minor-mode-map (kbd "TAB") nil)
|
|
||||||
;; (define-key yas-minor-mode-map (kbd "C-<tab>") 'yas-expand)
|
|
||||||
;; No dropdowns please, yas
|
|
||||||
(setq yas-prompt-functions '(yas/ido-prompt yas/completing-prompt))
|
|
||||||
|
|
||||||
;; No need to be so verbose
|
|
||||||
(setq yas-verbosity 1)
|
|
||||||
|
|
||||||
;; Wrap around region
|
|
||||||
(setq yas-wrap-around-region t)
|
|
||||||
|
|
||||||
(add-hook 'term-mode-hook (lambda() (setq yas-dont-activate t)))
|
|
||||||
|
|
||||||
;; PACKAGE: anzu
|
|
||||||
;; GROUP: Editing -> Matching -> Isearch -> Anzu
|
|
||||||
(require 'anzu)
|
|
||||||
(global-anzu-mode)
|
|
||||||
(global-set-key (kbd "M-%") 'anzu-query-replace)
|
|
||||||
(global-set-key (kbd "C-M-%") 'anzu-query-replace-regexp)
|
|
||||||
|
|
||||||
;; PACKAGE: iedit
|
|
||||||
(setq iedit-toggle-key-default nil)
|
|
||||||
(require 'iedit)
|
|
||||||
(global-set-key (kbd "C-;") 'iedit-mode)
|
|
||||||
|
|
||||||
;; Customized functions
|
|
||||||
(defun prelude-move-beginning-of-line (arg)
|
|
||||||
"Move point back to indentation of beginning of line.
|
|
||||||
|
|
||||||
Move point to the first non-whitespace character on this line.
|
|
||||||
If point is already there, move to the beginning of the line.
|
|
||||||
Effectively toggle between the first non-whitespace character and
|
|
||||||
the beginning of the line.
|
|
||||||
|
|
||||||
If ARG is not nil or 1, move forward ARG - 1 lines first. If
|
|
||||||
point reaches the beginning or end of the buffer, stop there."
|
|
||||||
(interactive "^p")
|
|
||||||
(setq arg (or arg 1))
|
|
||||||
|
|
||||||
;; Move lines first
|
|
||||||
(when (/= arg 1)
|
|
||||||
(let ((line-move-visual nil))
|
|
||||||
(forward-line (1- arg))))
|
|
||||||
|
|
||||||
(let ((orig-point (point)))
|
|
||||||
(back-to-indentation)
|
|
||||||
(when (= orig-point (point))
|
|
||||||
(move-beginning-of-line 1))))
|
|
||||||
|
|
||||||
(global-set-key (kbd "C-a") 'prelude-move-beginning-of-line)
|
|
||||||
|
|
||||||
(defadvice kill-ring-save (before slick-copy activate compile)
|
|
||||||
"When called interactively with no active region, copy a single
|
|
||||||
line instead."
|
|
||||||
(interactive
|
|
||||||
(if mark-active (list (region-beginning) (region-end))
|
|
||||||
(message "Copied line")
|
|
||||||
(list (line-beginning-position)
|
|
||||||
(line-beginning-position 2)))))
|
|
||||||
|
|
||||||
(defadvice kill-region (before slick-cut activate compile)
|
|
||||||
"When called interactively with no active region, kill a single
|
|
||||||
line instead."
|
|
||||||
(interactive
|
|
||||||
(if mark-active (list (region-beginning) (region-end))
|
|
||||||
(list (line-beginning-position)
|
|
||||||
(line-beginning-position 2)))))
|
|
||||||
|
|
||||||
;; kill a line, including whitespace characters until next non-whiepsace character
|
|
||||||
;; of next line
|
|
||||||
(defadvice kill-line (before check-position activate)
|
|
||||||
(if (member major-mode
|
|
||||||
'(emacs-lisp-mode scheme-mode lisp-mode
|
|
||||||
c-mode c++-mode objc-mode
|
|
||||||
latex-mode plain-tex-mode))
|
|
||||||
(if (and (eolp) (not (bolp)))
|
|
||||||
(progn (forward-char 1)
|
|
||||||
(just-one-space 0)
|
|
||||||
(backward-char 1)))))
|
|
||||||
|
|
||||||
;; taken from prelude-editor.el
|
|
||||||
;; automatically indenting yanked text if in programming-modes
|
|
||||||
(defvar yank-indent-modes
|
|
||||||
'(LaTeX-mode TeX-mode)
|
|
||||||
"Modes in which to indent regions that are yanked (or yank-popped).
|
|
||||||
Only modes that don't derive from `prog-mode' should be listed here.")
|
|
||||||
|
|
||||||
(defvar yank-indent-blacklisted-modes
|
|
||||||
'(python-mode slim-mode haml-mode)
|
|
||||||
"Modes for which auto-indenting is suppressed.")
|
|
||||||
|
|
||||||
(defvar yank-advised-indent-threshold 1000
|
|
||||||
"Threshold (# chars) over which indentation does not automatically occur.")
|
|
||||||
|
|
||||||
(defun yank-advised-indent-function (beg end)
|
|
||||||
"Do indentation, as long as the region isn't too large."
|
|
||||||
(if (<= (- end beg) yank-advised-indent-threshold)
|
|
||||||
(indent-region beg end nil)))
|
|
||||||
|
|
||||||
(defadvice yank (after yank-indent activate)
|
|
||||||
"If current mode is one of 'yank-indent-modes,
|
|
||||||
indent yanked text (with prefix arg don't indent)."
|
|
||||||
(if (and (not (ad-get-arg 0))
|
|
||||||
(not (member major-mode yank-indent-blacklisted-modes))
|
|
||||||
(or (derived-mode-p 'prog-mode)
|
|
||||||
(member major-mode yank-indent-modes)))
|
|
||||||
(let ((transient-mark-mode nil))
|
|
||||||
(yank-advised-indent-function (region-beginning) (region-end)))))
|
|
||||||
|
|
||||||
(defadvice yank-pop (after yank-pop-indent activate)
|
|
||||||
"If current mode is one of `yank-indent-modes',
|
|
||||||
indent yanked text (with prefix arg don't indent)."
|
|
||||||
(when (and (not (ad-get-arg 0))
|
|
||||||
(not (member major-mode yank-indent-blacklisted-modes))
|
|
||||||
(or (derived-mode-p 'prog-mode)
|
|
||||||
(member major-mode yank-indent-modes)))
|
|
||||||
(let ((transient-mark-mode nil))
|
|
||||||
(yank-advised-indent-function (region-beginning) (region-end)))))
|
|
||||||
|
|
||||||
;; prelude-core.el
|
|
||||||
(defun indent-buffer ()
|
|
||||||
"Indent the currently visited buffer."
|
|
||||||
(interactive)
|
|
||||||
(indent-region (point-min) (point-max)))
|
|
||||||
|
|
||||||
;; prelude-editing.el
|
|
||||||
(defcustom prelude-indent-sensitive-modes
|
|
||||||
'(coffee-mode python-mode slim-mode haml-mode yaml-mode)
|
|
||||||
"Modes for which auto-indenting is suppressed."
|
|
||||||
:type 'list)
|
|
||||||
|
|
||||||
(defun indent-region-or-buffer ()
|
|
||||||
"Indent a region if selected, otherwise the whole buffer."
|
|
||||||
(interactive)
|
|
||||||
(unless (member major-mode prelude-indent-sensitive-modes)
|
|
||||||
(save-excursion
|
|
||||||
(if (region-active-p)
|
|
||||||
(progn
|
|
||||||
(indent-region (region-beginning) (region-end))
|
|
||||||
(message "Indented selected region."))
|
|
||||||
(progn
|
|
||||||
(indent-buffer)
|
|
||||||
(message "Indented buffer.")))
|
|
||||||
(whitespace-cleanup))))
|
|
||||||
|
|
||||||
(global-set-key (kbd "C-c i") 'indent-region-or-buffer)
|
|
||||||
|
|
||||||
;; add duplicate line function from Prelude
|
|
||||||
;; taken from prelude-core.el
|
|
||||||
(defun prelude-get-positions-of-line-or-region ()
|
|
||||||
"Return positions (beg . end) of the current line
|
|
||||||
or region."
|
|
||||||
(let (beg end)
|
|
||||||
(if (and mark-active (> (point) (mark)))
|
|
||||||
(exchange-point-and-mark))
|
|
||||||
(setq beg (line-beginning-position))
|
|
||||||
(if mark-active
|
|
||||||
(exchange-point-and-mark))
|
|
||||||
(setq end (line-end-position))
|
|
||||||
(cons beg end)))
|
|
||||||
|
|
||||||
;; smart openline
|
|
||||||
(defun prelude-smart-open-line (arg)
|
|
||||||
"Insert an empty line after the current line.
|
|
||||||
Position the cursor at its beginning, according to the current mode.
|
|
||||||
With a prefix ARG open line above the current line."
|
|
||||||
(interactive "P")
|
|
||||||
(if arg
|
|
||||||
(prelude-smart-open-line-above)
|
|
||||||
(progn
|
|
||||||
(move-end-of-line nil)
|
|
||||||
(newline-and-indent))))
|
|
||||||
|
|
||||||
(defun prelude-smart-open-line-above ()
|
|
||||||
"Insert an empty line above the current line.
|
|
||||||
Position the cursor at it's beginning, according to the current mode."
|
|
||||||
(interactive)
|
|
||||||
(move-beginning-of-line nil)
|
|
||||||
(newline-and-indent)
|
|
||||||
(forward-line -1)
|
|
||||||
(indent-according-to-mode))
|
|
||||||
|
|
||||||
(global-set-key (kbd "M-o") 'prelude-smart-open-line)
|
|
||||||
(global-set-key (kbd "M-o") 'open-line)
|
|
||||||
|
|
||||||
(provide 'setup-editing)
|
(provide 'setup-editing)
|
||||||
|
|
||||||
|
|
|
||||||
33
custom/setup-gtags.el
Normal file
33
custom/setup-gtags.el
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Incremental updates to GTAGS table ;;
|
||||||
|
;; To keep the changes we did in source code synchronized ;;
|
||||||
|
;; in the gtags database ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(defun gtags-root-dir ()
|
||||||
|
"Returns GTAGS root directory or nil if doesn't exist."
|
||||||
|
(with-temp-buffer
|
||||||
|
(if (zerop (call-process "global" nil t nil "-pr"))
|
||||||
|
(buffer-substring (point-min) (1- (point-max)))
|
||||||
|
nil)))
|
||||||
|
|
||||||
|
(defun gtags-update-single(filename)
|
||||||
|
"Update Gtags database for changes in a single file"
|
||||||
|
(interactive)
|
||||||
|
(start-process "update-gtags" "update-gtags" "bash" "-c" (concat "cd " (gtags-root-dir) " ; gtags --single-update " filename )))
|
||||||
|
|
||||||
|
(defun gtags-update-current-file()
|
||||||
|
(interactive)
|
||||||
|
(defvar filename)
|
||||||
|
(setq filename (replace-regexp-in-string (gtags-root-dir) "." (buffer-file-name (current-buffer))))
|
||||||
|
(gtags-update-single filename)
|
||||||
|
(message "Gtags updated for %s" filename))
|
||||||
|
|
||||||
|
(defun gtags-update-hook()
|
||||||
|
"Update GTAGS file incrementally upon saving a file"
|
||||||
|
(when (gtags-root-dir)
|
||||||
|
(gtags-update-current-file)))
|
||||||
|
|
||||||
|
(add-hook 'after-save-hook 'gtags-update-hook)
|
||||||
|
|
||||||
|
(provide 'setup-gtags)
|
||||||
23
custom/setup-helm-gtags.el
Executable file → Normal file
23
custom/setup-helm-gtags.el
Executable file → Normal file
|
|
@ -1,33 +1,18 @@
|
||||||
(require 'helm-gtags)
|
(require 'helm-gtags)
|
||||||
|
|
||||||
(setq
|
|
||||||
helm-gtags-ignore-case t
|
|
||||||
helm-gtags-auto-update t
|
|
||||||
helm-gtags-use-input-at-cursor t
|
|
||||||
helm-gtags-pulse-at-cursor t
|
|
||||||
helm-gtags-prefix-key "\C-cg"
|
|
||||||
helm-gtags-suggested-key-mapping t
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Enable helm-gtags-mode in Dired so you can jump to any tag
|
|
||||||
;; when navigate project tree with Dired
|
|
||||||
(add-hook 'dired-mode-hook 'helm-gtags-mode)
|
|
||||||
|
|
||||||
;; Enable helm-gtags-mode in Eshell for the same reason as above
|
|
||||||
(add-hook 'eshell-mode-hook 'helm-gtags-mode)
|
|
||||||
|
|
||||||
;; Enable helm-gtags-mode in languages that GNU Global supports
|
;; Enable helm-gtags-mode in languages that GNU Global supports
|
||||||
(add-hook 'c-mode-hook 'helm-gtags-mode)
|
(add-hook 'c-mode-hook 'helm-gtags-mode)
|
||||||
(add-hook 'c++-mode-hook 'helm-gtags-mode)
|
(add-hook 'c++-mode-hook 'helm-gtags-mode)
|
||||||
|
(add-hook 'python-mode-hook 'helm-gtags-mode)
|
||||||
(add-hook 'java-mode-hook 'helm-gtags-mode)
|
(add-hook 'java-mode-hook 'helm-gtags-mode)
|
||||||
(add-hook 'asm-mode-hook 'helm-gtags-mode)
|
(add-hook 'asm-mode-hook 'helm-gtags-mode)
|
||||||
|
|
||||||
;; key bindings
|
;; key bindings
|
||||||
(define-key helm-gtags-mode-map (kbd "C-c g a") 'helm-gtags-tags-in-this-function)
|
(define-key helm-gtags-mode-map (kbd "C-j") 'helm-gtags-select) ; Find tag from here
|
||||||
(define-key helm-gtags-mode-map (kbd "C-j") 'helm-gtags-select)
|
(define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-dwim) ; Find by context (inc, ...)
|
||||||
(define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-dwim)
|
|
||||||
(define-key helm-gtags-mode-map (kbd "M-,") 'helm-gtags-pop-stack)
|
(define-key helm-gtags-mode-map (kbd "M-,") 'helm-gtags-pop-stack)
|
||||||
(define-key helm-gtags-mode-map (kbd "C-c <") 'helm-gtags-previous-history)
|
(define-key helm-gtags-mode-map (kbd "C-c <") 'helm-gtags-previous-history)
|
||||||
(define-key helm-gtags-mode-map (kbd "C-c >") 'helm-gtags-next-history)
|
(define-key helm-gtags-mode-map (kbd "C-c >") 'helm-gtags-next-history)
|
||||||
|
|
||||||
|
|
||||||
(provide 'setup-helm-gtags)
|
(provide 'setup-helm-gtags)
|
||||||
|
|
|
||||||
95
custom/setup-helm.el
Executable file → Normal file
95
custom/setup-helm.el
Executable file → Normal file
|
|
@ -1,73 +1,26 @@
|
||||||
|
(require 'helm)
|
||||||
(require 'helm-config)
|
(require 'helm-config)
|
||||||
(require 'helm-grep)
|
|
||||||
|
|
||||||
;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs.
|
|
||||||
;; Changed to "C-c h". Note: We must set "C-c h" globally, because we
|
|
||||||
;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.
|
|
||||||
(global-set-key (kbd "C-c h") 'helm-command-prefix)
|
|
||||||
|
|
||||||
(global-set-key (kbd "C-x C-f") 'helm-find-files)
|
|
||||||
|
|
||||||
(global-set-key (kbd "C-c h c") 'helm-calcul-expression)
|
|
||||||
|
|
||||||
(global-unset-key (kbd "C-x c"))
|
|
||||||
|
|
||||||
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to do persistent action
|
|
||||||
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
|
|
||||||
(define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z
|
|
||||||
|
|
||||||
(define-key helm-grep-mode-map (kbd "<return>") 'helm-grep-mode-jump-other-window)
|
|
||||||
(define-key helm-grep-mode-map (kbd "n") 'helm-grep-mode-jump-other-window-forward)
|
|
||||||
(define-key helm-grep-mode-map (kbd "p") 'helm-grep-mode-jump-other-window-backward)
|
|
||||||
|
|
||||||
(when (executable-find "curl")
|
|
||||||
(setq helm-google-suggest-use-curl-p t))
|
|
||||||
|
|
||||||
(setq
|
|
||||||
helm-scroll-amount 4 ; scroll 4 lines other window using M-<next>/M-<prior>
|
|
||||||
helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
|
|
||||||
helm-split-window-in-side-p t ;; open helm buffer inside current window, not occupy whole other window
|
|
||||||
helm-candidate-number-limit 500 ; limit the number of displayed canidates
|
|
||||||
helm-ff-file-name-history-use-recentf t
|
|
||||||
helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.
|
|
||||||
helm-buffers-fuzzy-matching t ; fuzzy matching buffer names when non-nil
|
|
||||||
; useful in helm-mini that lists buffers
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
(add-to-list 'helm-sources-using-default-as-input 'helm-source-man-pages)
|
|
||||||
|
|
||||||
|
;; replace vanilla commands with helm commands
|
||||||
(global-set-key (kbd "M-x") 'helm-M-x)
|
(global-set-key (kbd "M-x") 'helm-M-x)
|
||||||
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
|
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
|
||||||
(global-set-key (kbd "C-x b") 'helm-mini)
|
(global-set-key (kbd "C-x b") 'helm-mini)
|
||||||
(global-set-key (kbd "C-x C-f") 'helm-find-files)
|
(global-set-key (kbd "C-x C-f") 'helm-find-files)
|
||||||
(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings)
|
|
||||||
(global-set-key (kbd "C-c h o") 'helm-occur)
|
|
||||||
|
|
||||||
(global-set-key (kbd "C-c h C-c w") 'helm-wikipedia-suggest)
|
;; rebind tab to do persistent action
|
||||||
|
;; we use helm-execute-persistent-action more than helm-select-action (default for <tab>)
|
||||||
|
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
|
||||||
|
;; make TAB work in terminal
|
||||||
|
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action)
|
||||||
|
;; remap helm-select-action: lists actions
|
||||||
|
(define-key helm-map (kbd "C-z") 'helm-select-action)
|
||||||
|
|
||||||
(global-set-key (kbd "C-c h x") 'helm-register)
|
;; remap calculator
|
||||||
;; (global-set-key (kbd "C-x r j") 'jump-to-register)
|
(global-set-key (kbd "C-c C-c") 'helm-calcul-expression)
|
||||||
|
|
||||||
(define-key 'help-command (kbd "C-f") 'helm-apropos)
|
;; TODO: experiment with mark ring (breadcrumbs something?)
|
||||||
(define-key 'help-command (kbd "r") 'helm-info-emacs)
|
;; TODO: experiment with helm-regexp (build and test regexes)
|
||||||
(define-key 'help-command (kbd "C-l") 'helm-locate-library)
|
;; TODO: remember helm-top (helm interface for top program)
|
||||||
|
|
||||||
;; use helm to list eshell history
|
|
||||||
(add-hook 'eshell-mode-hook
|
|
||||||
#'(lambda ()
|
|
||||||
(define-key eshell-mode-map (kbd "M-l") 'helm-eshell-history)))
|
|
||||||
|
|
||||||
;;; Save current position to mark ring
|
|
||||||
(add-hook 'helm-goto-line-before-hook 'helm-save-current-pos-to-mark-ring)
|
|
||||||
|
|
||||||
;; show minibuffer history with Helm
|
|
||||||
(define-key minibuffer-local-map (kbd "M-p") 'helm-minibuffer-history)
|
|
||||||
(define-key minibuffer-local-map (kbd "M-n") 'helm-minibuffer-history)
|
|
||||||
|
|
||||||
(define-key global-map [remap find-tag] 'helm-etags-select)
|
|
||||||
|
|
||||||
(define-key global-map [remap list-buffers] 'helm-buffers-list)
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; PACKAGE: helm-swoop ;;
|
;; PACKAGE: helm-swoop ;;
|
||||||
|
|
@ -75,27 +28,21 @@
|
||||||
;; Locate the helm-swoop folder to your path
|
;; Locate the helm-swoop folder to your path
|
||||||
(require 'helm-swoop)
|
(require 'helm-swoop)
|
||||||
|
|
||||||
;; Change the keybinds to whatever you like :)
|
;; replace vanilla I-search with helm-swoop
|
||||||
(global-set-key (kbd "C-s") 'helm-swoop)
|
(global-set-key (kbd "C-s") 'helm-swoop)
|
||||||
|
|
||||||
;; When doing isearch, hand the word over to helm-swoop
|
|
||||||
(define-key isearch-mode-map (kbd "M-i") 'helm-swoop-from-isearch)
|
|
||||||
|
|
||||||
;; From helm-swoop to helm-multi-swoop-all
|
;; From helm-swoop to helm-multi-swoop-all
|
||||||
(define-key helm-swoop-map (kbd "M-i") 'helm-multi-swoop-all-from-helm-swoop)
|
;;(define-key helm-swoop-map (kbd "M-s") 'helm-multi-swoop-all-from-helm-swoop)
|
||||||
|
(define-key helm-swoop-map (kbd "C-s") 'helm-multi-swoop-all-from-helm-swoop)
|
||||||
;; Save buffer when helm-multi-swoop-edit complete
|
;; TODO: find out how to switch from multi-swoop to swoop back again
|
||||||
(setq helm-multi-swoop-edit-save t)
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Next 2 lines make sure when using helm-swoop only the current window/buffer is affected ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; If this value is t, split window inside the current window
|
;; If this value is t, split window inside the current window
|
||||||
(setq helm-swoop-split-with-multiple-windows t)
|
(setq helm-swoop-split-with-multiple-windows t)
|
||||||
|
|
||||||
;; Split direcion. 'split-window-vertically or 'split-window-horizontally
|
;; Split direcion. 'split-window-vertically or 'split-window-horizontally
|
||||||
(setq helm-swoop-split-direction 'split-window-vertically)
|
(setq helm-swoop-split-direction 'split-window-vertically)
|
||||||
|
|
||||||
;; If nil, you can slightly boost invoke speed in exchange for text color
|
|
||||||
(setq helm-swoop-speed-or-color t)
|
|
||||||
|
|
||||||
(helm-mode 1)
|
|
||||||
|
|
||||||
(provide 'setup-helm)
|
(provide 'setup-helm)
|
||||||
|
|
|
||||||
167
init.el
Executable file → Normal file
167
init.el
Executable file → Normal file
|
|
@ -1,42 +1,50 @@
|
||||||
;;; packages
|
;; hide the welcome screen
|
||||||
(require 'package)
|
(setq inhibit-startup-message t)
|
||||||
(add-to-list 'package-archives
|
|
||||||
'("melpa" . "http://melpa.milkbox.net/packages/") t)
|
|
||||||
(package-initialize)
|
|
||||||
|
|
||||||
(require 'package)
|
|
||||||
(add-to-list 'package-archives
|
|
||||||
'("melpa" . "http://melpa.org/packages/") t)
|
|
||||||
(package-initialize)
|
|
||||||
|
|
||||||
;; set garbage collection to higher value
|
;; set garbage collection to higher value
|
||||||
;; see http://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/
|
;; see http://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/
|
||||||
(setq gc-cons-threshold 100000000)
|
(setq gc-cons-threshold 100000000)
|
||||||
|
|
||||||
;; hide the welcome screen
|
|
||||||
(setq inhibit-startup-message t)
|
|
||||||
|
|
||||||
;; important yes-or-no questions can be answered with y-or-n
|
;; important yes-or-no questions can be answered with y-or-n
|
||||||
(defalias 'yes-or-no-p 'y-or-n-p)
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
||||||
|
|
||||||
|
;; set my theme
|
||||||
|
(load-theme 'wombat)
|
||||||
|
|
||||||
|
;; maximize Emacs at startup
|
||||||
|
(add-to-list 'default-frame-alist '(fullscreen . maximized))
|
||||||
|
|
||||||
|
;; Save Emacs session
|
||||||
|
(desktop-save-mode 1)
|
||||||
|
|
||||||
|
;; add the custom dir to our load path
|
||||||
|
(add-to-list 'load-path "~/.emacs.d/custom")
|
||||||
|
|
||||||
|
;; add melpa-stable to package-archives
|
||||||
|
;; IMPORTANT: add (require 'package), else package-archives is not declared (void-variable)
|
||||||
|
(require 'package)
|
||||||
|
(add-to-list 'package-archives
|
||||||
|
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
|
||||||
|
|
||||||
|
;; MUST be called after package-archives is updated
|
||||||
|
;; Else the automated installation logic is not able to install missing packages
|
||||||
|
(package-initialize)
|
||||||
|
|
||||||
;; my required packages
|
;; my required packages
|
||||||
(defconst my-packages
|
(defconst my-packages
|
||||||
'(
|
'(
|
||||||
anzu
|
undo-tree
|
||||||
company
|
volatile-highlights
|
||||||
|
ws-butler
|
||||||
|
smartparens
|
||||||
|
iedit
|
||||||
|
zygospore
|
||||||
|
comment-dwim-2
|
||||||
|
yasnippet
|
||||||
helm
|
helm
|
||||||
helm-gtags
|
helm-gtags
|
||||||
helm-swoop
|
helm-swoop
|
||||||
undo-tree
|
))
|
||||||
clean-aindent-mode
|
|
||||||
comment-dwim-2
|
|
||||||
dtrt-indent
|
|
||||||
ws-butler
|
|
||||||
iedit
|
|
||||||
yasnippet
|
|
||||||
smartparens
|
|
||||||
volatile-highlights
|
|
||||||
zygospore))
|
|
||||||
|
|
||||||
;; function to install new packages
|
;; function to install new packages
|
||||||
(defun install-packages ()
|
(defun install-packages ()
|
||||||
|
|
@ -51,88 +59,30 @@
|
||||||
;; install packages if not yet installed
|
;; install packages if not yet installed
|
||||||
(install-packages)
|
(install-packages)
|
||||||
|
|
||||||
;; set my c-style
|
;; setup gtags
|
||||||
(setq c-default-style "linux")
|
(require 'setup-gtags)
|
||||||
|
(require 'setup-editing)
|
||||||
;; hs-minor-mode for folding source code
|
|
||||||
(add-hook 'c-mode-common-hook 'hs-minor-mode)
|
|
||||||
|
|
||||||
;; set my indentation level
|
|
||||||
(setq c-basic-offset 2)
|
|
||||||
|
|
||||||
;; this variables must be set before load helm-gtags
|
|
||||||
;; you can change to any prefix key of your choice
|
|
||||||
(setq helm-gtags-prefix-key "\C-cg")
|
|
||||||
|
|
||||||
;; add the custom dire to our load path
|
|
||||||
(add-to-list 'load-path "~/.emacs.d/custom")
|
|
||||||
|
|
||||||
;; setup helm
|
;; setup helm
|
||||||
(require 'setup-helm)
|
(require 'setup-helm)
|
||||||
(require 'setup-helm-gtags)
|
(require 'setup-helm-gtags)
|
||||||
|
|
||||||
(require 'setup-cedet)
|
|
||||||
(require 'setup-editing)
|
|
||||||
|
|
||||||
;; use the default window move library keybindings (shift and arrow keys)
|
|
||||||
(windmove-default-keybindings)
|
|
||||||
|
|
||||||
;; show unnecessary whitespace that can mess up your diff
|
|
||||||
(add-hook 'prog-mode-hook (lambda () (interactive) (setq show-trailing-whitespace 1)))
|
|
||||||
|
|
||||||
;; Compilation
|
|
||||||
(global-set-key (kbd "<f5>") (lambda ()
|
|
||||||
(interactive)
|
|
||||||
(setq-local compilation-read-command nil)
|
|
||||||
(call-interactively 'compile)))
|
|
||||||
|
|
||||||
;; setup GDB
|
|
||||||
(setq
|
|
||||||
;; use gdb-many-windows by default
|
|
||||||
gdb-many-windows t
|
|
||||||
|
|
||||||
;; Non-nil means display source file containing the main routine at startup
|
|
||||||
gdb-show-main t
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Package: clean-aindent-mode --- clean auto-indent and backspace unindent
|
|
||||||
(require 'clean-aindent-mode)
|
|
||||||
(add-hook 'prog-mode-hook 'clean-aindent-mode)
|
|
||||||
|
|
||||||
;; Package: dtrt-indent --- guess the indentation offset and use it (for editing foreign files)
|
|
||||||
(require 'dtrt-indent)
|
|
||||||
(dtrt-indent-mode 1)
|
|
||||||
|
|
||||||
;; Package: ws-butler --- trim spaces from eol
|
|
||||||
(require 'ws-butler)
|
|
||||||
(add-hook 'prog-mode-hook 'ws-butler-mode)
|
|
||||||
|
|
||||||
;; Package: yasnippet
|
|
||||||
(require 'yasnippet)
|
|
||||||
(yas-global-mode 1)
|
|
||||||
|
|
||||||
;; Package: smartparens --- smart way to handle (), {}, ...
|
|
||||||
(require 'smartparens-config)
|
|
||||||
(setq sp-base-key-bindings 'paredit)
|
|
||||||
(setq sp-autoskip-closing-pair 'always)
|
|
||||||
(setq sp-hybrid-kill-entire-symbol nil)
|
|
||||||
(sp-use-paredit-bindings)
|
|
||||||
|
|
||||||
(show-smartparens-global-mode +1)
|
|
||||||
(smartparens-global-mode 1)
|
|
||||||
|
|
||||||
;; Package zygospore --- revert C-x 1 by pressing C-x 1 again
|
;; Package zygospore --- revert C-x 1 by pressing C-x 1 again
|
||||||
(global-set-key (kbd "C-x 1") 'zygospore-toggle-delete-other-windows)
|
(global-set-key (kbd "C-x 1") 'zygospore-toggle-delete-other-windows)
|
||||||
|
|
||||||
|
;; Set 'M-g' to 'goto-line', it's faster and what we usually want
|
||||||
|
(global-set-key (kbd "M-g") 'goto-line)
|
||||||
|
|
||||||
|
;; Set 'C-x r i' to 'string-insert-rectangle'
|
||||||
|
;; Easier than using 'M-x' and searching for it.
|
||||||
|
(global-set-key (kbd "C-x r i") 'string-insert-rectangle)
|
||||||
|
|
||||||
(custom-set-variables
|
(custom-set-variables
|
||||||
;; custom-set-variables was added by Custom.
|
;; custom-set-variables was added by Custom.
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
;; Your init file should contain only one such instance.
|
;; Your init file should contain only one such instance.
|
||||||
;; If there is more than one, they won't work right.
|
;; If there is more than one, they won't work right.
|
||||||
'(ansi-color-faces-vector
|
'(package-selected-packages (quote (helm-swoop helm))))
|
||||||
[default default default italic underline success warning error])
|
|
||||||
'(ansi-color-names-vector
|
|
||||||
["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
|
|
||||||
'(custom-enabled-themes (quote (wheatgrass))))
|
|
||||||
(custom-set-faces
|
(custom-set-faces
|
||||||
;; custom-set-faces was added by Custom.
|
;; custom-set-faces was added by Custom.
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
|
|
@ -140,32 +90,5 @@
|
||||||
;; If there is more than one, they won't work right.
|
;; If there is more than one, they won't work right.
|
||||||
)
|
)
|
||||||
|
|
||||||
;; Package: org - personal info manager
|
|
||||||
(require 'org)
|
|
||||||
(define-key global-map "\C-cl" 'org-store-link)
|
|
||||||
(define-key global-map "\C-ca" 'org-agenda)
|
|
||||||
(define-key global-map "\C-cp" 'org-priority)
|
|
||||||
;; when ending TODO (C-C C-t) end with a note + timestamp
|
|
||||||
(setq org-log-done 'note)
|
|
||||||
;; Specify root dir to search for agenda files, TODOs, ...
|
|
||||||
(setq org-agenda-files '("~/org"))
|
|
||||||
;; Add extra states for keywords
|
|
||||||
(setq org-todo-keywords
|
|
||||||
'((sequence "TODO" "IN-PROGRESS" "WAITING" "DONE")))
|
|
||||||
|
|
||||||
;; Set 'M-g' to 'goto-line'
|
|
||||||
(global-set-key (kbd "M-g") 'goto-line)
|
|
||||||
|
|
||||||
;; Set 'C-x r i' to 'string-insert-rectangle'
|
|
||||||
;; Easier than using 'M-x' and searching for it.
|
|
||||||
(global-set-key (kbd "C-x r i") 'string-insert-rectangle)
|
|
||||||
|
|
||||||
|
|
||||||
;; use company-mode in all buffers
|
|
||||||
(add-hook 'after-init-hook 'global-company-mode)
|
|
||||||
|
|
||||||
;; set my theme
|
|
||||||
(load-theme 'wombat)
|
|
||||||
|
|
||||||
(provide 'init)
|
(provide 'init)
|
||||||
;;; init.el ends here
|
;;; init.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue