diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-02-21 22:06:07 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-02-28 00:29:49 -0500 |
commit | 405a2beebbb2695efb2de6462242b1b46fb98fc6 (patch) | |
tree | 559b28583711a18fbbf5f0106e8c01ab6323c782 /lisp | |
parent | 17a61e65d5a12e0649dfe427855131478d575e3f (diff) | |
download | emacs.d-405a2beebbb2695efb2de6462242b1b46fb98fc6.tar.gz |
Move abbrev customization to separate file
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/init-abbrev.el | 43 | ||||
-rw-r--r-- | lisp/init-general.el | 41 |
2 files changed, 43 insertions, 41 deletions
diff --git a/lisp/init-abbrev.el b/lisp/init-abbrev.el new file mode 100644 index 0000000..22cfd0b --- /dev/null +++ b/lisp/init-abbrev.el @@ -0,0 +1,43 @@ + +(setq save-abbrevs 'silently) + +(defun km/abbrev-add-case-global () + "Define lower abbreviation for the word before point. +Like `add-global-abbrev', but always make the abbreviation the +lower case variant of the word before point." + (interactive) + ;; Modified from `add-abbrev'. + (let* ((table global-abbrev-table) + (exp (buffer-substring-no-properties + (point) + (save-excursion (forward-word -1) (point)))) + (name (downcase exp))) + (when (or (not (abbrev-expansion name table)) + (y-or-n-p (format "%s expands to \"%s\"; redefine? " + name (abbrev-expansion name table)))) + (define-abbrev table name exp)))) + +(defun km/abbrev-inverse-add-uppercase-global () + "Define uppercase expansion for the word before point. +Like `inverse-add-global-abbrev', but always use the lower case +version of the word before point as the abbreviation and the +upper case version as the expansion." + (interactive) + ;; Modified from `inverse-add-abbrev'. + (let* ((table global-abbrev-table) + (end (point)) + (start (save-excursion (forward-word -1) (point))) + (name (downcase (buffer-substring-no-properties start end))) + (exp (upcase name))) + (when (or (not (abbrev-expansion name table)) + (y-or-n-p (format "%s expands to \"%s\"; redefine? " + name (abbrev-expansion name table)))) + (define-abbrev table name exp) + (save-excursion + (goto-char end) + (expand-abbrev))))) + +(define-key abbrev-map "c" 'km/abbrev-add-case-global) +(define-key abbrev-map "iu" 'km/abbrev-inverse-add-uppercase-global) + +(provide 'init-abbrev) diff --git a/lisp/init-general.el b/lisp/init-general.el index d24b877..c1206f3 100644 --- a/lisp/init-general.el +++ b/lisp/init-general.el @@ -14,8 +14,6 @@ (setq custom-file "~/.emacs.d/custom.el") (load custom-file) -(setq save-abbrevs 'silently) - (defalias 'yes-or-no-p 'y-or-n-p) (put 'narrow-to-region 'disabled nil) @@ -46,42 +44,6 @@ `(eval-after-load ,mode '(progn ,@body))) -(defun km/abbrev-add-case-global () - "Define lower abbreviation for the word before point. -Like `add-global-abbrev', but always make the abbreviation the -lower case variant of the word before point." - (interactive) - ;; Modified from `add-abbrev'. - (let* ((table global-abbrev-table) - (exp (buffer-substring-no-properties - (point) - (save-excursion (forward-word -1) (point)))) - (name (downcase exp))) - (when (or (not (abbrev-expansion name table)) - (y-or-n-p (format "%s expands to \"%s\"; redefine? " - name (abbrev-expansion name table)))) - (define-abbrev table name exp)))) - -(defun km/abbrev-inverse-add-uppercase-global () - "Define uppercase expansion for the word before point. -Like `inverse-add-global-abbrev', but always use the lower case -version of the word before point as the abbreviation and the -upper case version as the expansion." - (interactive) - ;; Modified from `inverse-add-abbrev'. - (let* ((table global-abbrev-table) - (end (point)) - (start (save-excursion (forward-word -1) (point))) - (name (downcase (buffer-substring-no-properties start end))) - (exp (upcase name))) - (when (or (not (abbrev-expansion name table)) - (y-or-n-p (format "%s expands to \"%s\"; redefine? " - name (abbrev-expansion name table)))) - (define-abbrev table name exp) - (save-excursion - (goto-char end) - (expand-abbrev))))) - (global-set-key (kbd "C-h ;") 'find-function) (global-set-key (kbd "C-c l") 'km/imenu) @@ -98,9 +60,6 @@ upper case version as the expansion." (define-key occur-mode-map "n" 'next-line) (define-key occur-mode-map "p" 'previous-line) -(define-key abbrev-map "c" 'km/abbrev-add-case-global) -(define-key abbrev-map "iu" 'km/abbrev-inverse-add-uppercase-global) - (show-paren-mode) (global-auto-revert-mode) (transient-mark-mode -1) |