diff --git a/lib/extensions/development.el b/lib/extensions/development.el index 66d7329..a85a519 100644 --- a/lib/extensions/development.el +++ b/lib/extensions/development.el @@ -7,7 +7,6 @@ (depends-on 'company) (depends-on 'company-statistics) (depends-on 'projectile) -(depends-on 'flyspell) (depends-on 'diff-hl) (depends-on 'magit) (depends-on 'indent-guide) @@ -17,6 +16,8 @@ (depends-on 'ag) (depends-on 'smart-mode-line) +(with-ability spell + (depends-on 'flyspell)) ;; TODO: Add flycheck-color-modebar ;; TODO Add flycheck-tip diff --git a/lib/extensions/development/init.el b/lib/extensions/development/init.el index 5f2d6b1..22c765a 100644 --- a/lib/extensions/development/init.el +++ b/lib/extensions/development/init.el @@ -63,7 +63,7 @@ (ability spell () "Check spell of any word using ispell." - (require 'flyspell) + (global-set-key (kbd "") 'ispell-word) (setq flyspell-issue-message-flg nil)) (ability diff-highlight () diff --git a/lib/extensions/editor/init.el b/lib/extensions/editor/init.el index 3ec0a58..d718116 100644 --- a/lib/extensions/editor/init.el +++ b/lib/extensions/editor/init.el @@ -10,7 +10,7 @@ "Base plugin initialization." (message "Initializing 'editor' extension.") - (require 'color-theme) + (require 'extensions/editor/utils) ;; Remove splash screen (setq inhibit-splash-screen t) @@ -116,22 +116,23 @@ ;; Helm ----------------------------------------------------- (with-ability helm - (require 'helm) - (global-set-key (kbd "C-c h") 'helm-command-prefix) (global-unset-key (kbd "C-x c")) - (define-key helm-map (kbd "") 'helm-execute-persistent-action) ; rebind tab to run 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-map (kbd "") + 'helm-execute-persistent-action) + (define-key helm-map (kbd "C-i") + 'helm-execute-persistent-action) + (define-key helm-map (kbd "C-z") + 'helm-select-action) (when (executable-find "curl") (setq helm-google-suggest-use-curl-p t)) - (setq helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window - helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source. - helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp. - helm-scroll-amount 8 ; scroll 8 lines other window using M-/M- + (setq helm-split-window-in-side-p t + helm-move-to-line-cycle-in-source t + helm-ff-search-library-in-sexp t + helm-scroll-amount 8 helm-ff-file-name-history-use-recentf t) (helm-mode 1)) @@ -140,11 +141,14 @@ (ability swiper () "Replace default isearch with swiper" (ivy-mode 1) + (setq ivy-use-virtual-buffers t) (global-set-key "\C-s" 'swiper) (global-set-key "\C-r" 'swiper) (global-set-key (kbd "C-c C-r") 'ivy-resume) - (global-set-key [f6] 'ivy-resume)) + (global-set-key [f6] 'ivy-resume) + (with-ability ido + (global-set-key (kbd "C-x b") 'ido-switch-buffer))) ;; Session Management --------------------------------------- (desktop-save-mode 1) @@ -164,10 +168,13 @@ ;; get rid of yes-or-no questions - y or n is enough (defalias 'yes-or-no-p 'y-or-n-p) + (setup-utils) + (setq my-path (file-name-directory load-file-name)) ;; Load about submenu (require 'extensions/editor/version) (require 'extensions/editor/about) (require 'extensions/editor/custom) (require 'extensions/editor/session-management)) + (provide 'extensions/editor/init) diff --git a/lib/extensions/editor/utils.el b/lib/extensions/editor/utils.el new file mode 100644 index 0000000..809652d --- /dev/null +++ b/lib/extensions/editor/utils.el @@ -0,0 +1,48 @@ +;; Functions ----------------------------- + +;;;###autoload +(defun comment-dwim-line (&optional arg) + "Replacement for the comment-dwim command. +If no region is selected and current line is +not blank and we are not at the end of the line, +then comment current line. +Replaces default behaviour of comment-dwim, when +it inserts comment at the end of the line." + + ;; Original idea from + ;; http://www.opensubscriber.com/message/emacs-devel@gnu.org/10971693.html + + (interactive "*P") + (comment-normalize-vars) + (if (and (not (region-active-p)) + (not (looking-at "[ \t]*$"))) + (comment-or-uncomment-region (line-beginning-position) + (line-end-position)) + (comment-dwim arg))) + + +;;;###autoload +(defun kill-and-join-forward (&optional arg) + "If at end of line, join with following; otherwise kill line. + Deletes whitespace at join. + http://www.emacswiki.org/emacs/AutoIndentation" + (interactive "P") + (if (and (eolp) (not (bolp))) + (progn (forward-char 1) + (just-one-space 0) + (backward-char 1) + (kill-line arg)) + (kill-line arg))) + +;;;###autoload +(defun setup-utils () + "Setup several utitlies for FG42" + (global-set-key (kbd "C-k") 'kill-and-join-forward) + (global-set-key (kbd "C-") 'other-window) + (global-set-key (kbd "M-;") 'comment-dwim-line) + (global-set-key (kbd "M-j") (lambda () + (interactive) (join-line -1)))) + + + +(provide 'extensions/editor/utils)