From d52a110acb207d09dc5e3fe3f72e39e4a07064a1 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 29 Jul 2018 19:00:38 +0200 Subject: [PATCH] =?UTF-8?q?Move=20=C3=A6-enclose-region=20to=20the=20Org?= =?UTF-8?q?=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configuration.org | 39 +++++++++++++++++++++++++++++++++++++++ init.el | 1 - lisp/enclose-string.el | 34 ---------------------------------- 3 files changed, 39 insertions(+), 35 deletions(-) delete mode 100644 lisp/enclose-string.el diff --git a/configuration.org b/configuration.org index bfef215..40b5c78 100644 --- a/configuration.org +++ b/configuration.org @@ -147,6 +147,45 @@ copied to the kill ring." (copy-region-as-kill beginning end)))) #+END_SRC +*** Enclose region in a specific character + +#+BEGIN_SRC emacs-lisp +(defun æ-enclose-region (character &optional start end) + "Enclose region in CHARACTER. If region is empty, simply inserts + CHARACTER two times and moves point between them. + + If character is present in `insert-pair-alist', this function + will enclose region in the corresponding pair. In this case, + CHARACTER must be the opening member of the pair." + + (interactive "cWhat character? \nr") + + (setq open character close character) + + (let ((pair (assq character insert-pair-alist))) + (if pair + (if (nth 2 pair) + (setq open (nth 1 pair) close (nth 2 pair)) + (setq open (nth 0 pair) close (nth 1 pair))))) + + (unless (and open close) + (setq open character) + (setq close character)) + + (unless (use-region-p) + (setq start (point) end (point))) + + (save-excursion + (goto-char end) + (insert-char close) + + (goto-char start) + (insert-char open)) + + (unless (use-region-p) + (forward-char))) +#+END_SRC + ** Navigation *** Move to different beginnings of the current line diff --git a/init.el b/init.el index 89f13cb..83a9af1 100644 --- a/init.el +++ b/init.el @@ -29,7 +29,6 @@ (load "gnu-c-header") (load "round-number-to-decimals") (load "zim") -(load "enclose-string") (load "text-manip") (load "frame-manip") (load "file-manip") diff --git a/lisp/enclose-string.el b/lisp/enclose-string.el deleted file mode 100644 index ee59d6c..0000000 --- a/lisp/enclose-string.el +++ /dev/null @@ -1,34 +0,0 @@ -(defun æ-enclose-region (character &optional start end) - "Enclose region in CHARACTER. If region is empty, simply inserts - CHARACTER two times and moves point between them. - - If character is present in `insert-pair-alist', this function - will enclose region in the corresponding pair. In this case, - CHARACTER must be the opening member of the pair." - - (interactive "cWhat character? \nr") - - (setq open character close character) - - (let ((pair (assq character insert-pair-alist))) - (if pair - (if (nth 2 pair) - (setq open (nth 1 pair) close (nth 2 pair)) - (setq open (nth 0 pair) close (nth 1 pair))))) - - (unless (and open close) - (setq open character) - (setq close character)) - - (unless (use-region-p) - (setq start (point) end (point))) - - (save-excursion - (goto-char end) - (insert-char close) - - (goto-char start) - (insert-char open)) - - (unless (use-region-p) - (forward-char)))