summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-abbrev.el43
-rw-r--r--lisp/init-general.el41
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)