From 7b4a464f024e709194921c2716b27007b33837da Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 29 Jul 2018 19:35:59 +0200 Subject: [PATCH] Move functions from text-manip to the Org config --- configuration.org | 60 ++++++++++++++++++++++++++++++++++++ init.el | 1 - lisp/text-manip.el | 76 ---------------------------------------------- 3 files changed, 60 insertions(+), 77 deletions(-) delete mode 100644 lisp/text-manip.el diff --git a/configuration.org b/configuration.org index 3efc8e1..8228614 100644 --- a/configuration.org +++ b/configuration.org @@ -211,6 +211,66 @@ If the prefix argument ARG is non-nil, convert the text to uppercase." (unless had-initial-underscore (delete-char 1))))) #+END_SRC +*** Insert two spaces after specific characters + +#+BEGIN_SRC emacs-lisp +(defun org-space-key (&optional arg) + "Insert two spaces after a period. + +ARG will be passed down verbatim to `self-insert-command'" + (interactive "p") + + (when (looking-back "[.!?…]" nil) + (call-interactively 'self-insert-command arg)) + (call-interactively 'self-insert-command arg)) +#+END_SRC + +*** Fill or unfill a paragraph + +From http://pages.sachachua.com/.emacs.d/Sacha.html + +#+BEGIN_SRC emacs-lisp +(defun sachachua/fill-or-unfill-paragraph (&optional unfill region) + "Fill (or unfill, if UNFILL is non-nil) paragraph (or REGION)." + (interactive (progn + (barf-if-buffer-read-only) + (list (if current-prefix-arg 'unfill) t))) + (let ((fill-column (if unfill (point-max) fill-column))) + (fill-paragraph nil region))) +#+END_SRC + +*** Swap occurences of strings + +Copied from http://emacs.stackexchange.com/a/27170/507 + +#+BEGIN_SRC emacs-lisp +(defun so/query-swap-strings (from-string + to-string + &optional delimited start end) + "Swap occurrences of FROM-STRING and TO-STRING. + +DELIMITED, START, and END are passed down verbatim to `perform-replace'." + (interactive + (let ((common + (query-replace-read-args + (concat "Query swap" + (if current-prefix-arg + (if (eq current-prefix-arg '-) " backward" " word") + "") + (if (use-region-p) " in region" "")) + nil))) + (list (nth 0 common) (nth 1 common) (nth 2 common) + (if (use-region-p) (region-beginning)) + (if (use-region-p) (region-end))))) + (perform-replace + (concat "\\(" (regexp-quote from-string) "\\)\\|" (regexp-quote to-string)) + `(replace-eval-replacement replace-quote + (if (match-string 1) + ,to-string + ,from-string)) + t t delimited nil nil start end)) +#+END_SRC + ** Navigation *** Move to different beginnings of the current line diff --git a/init.el b/init.el index dfef719..d504a10 100644 --- a/init.el +++ b/init.el @@ -29,7 +29,6 @@ (load "gnu-c-header") (load "round-number-to-decimals") (load "zim") -(load "text-manip") (load "window-manip") (load "xdg-paths") (load "utils") diff --git a/lisp/text-manip.el b/lisp/text-manip.el deleted file mode 100644 index 66f1fc3..0000000 --- a/lisp/text-manip.el +++ /dev/null @@ -1,76 +0,0 @@ -;;; package --- Summary - -;;; Commentary: - -;;; Code: -(defun org-space-key (&optional arg) - "Insert two spaces after a period. - -ARG will be passed down verbatim to `self-insert-command'" - (interactive "p") - - (when (looking-back "[.!?…]" nil) - (call-interactively 'self-insert-command arg)) - (call-interactively 'self-insert-command arg)) - -;; From http://pages.sachachua.com/.emacs.d/Sacha.html -(defun sachachua/fill-or-unfill-paragraph (&optional unfill region) - "Fill (or unfill, if UNFILL is non-nil) paragraph (or REGION)." - (interactive (progn - (barf-if-buffer-read-only) - (list (if current-prefix-arg 'unfill) t))) - (let ((fill-column (if unfill (point-max) fill-column))) - (fill-paragraph nil region))) - -;; Copied from http://emacs.stackexchange.com/a/27170/507 -(defun so/query-swap-strings (from-string - to-string - &optional delimited start end) - "Swap occurrences of FROM-STRING and TO-STRING. - -DELIMITED, START, and END are passed down verbatim to `perform-replace'." - (interactive - (let ((common - (query-replace-read-args - (concat "Query swap" - (if current-prefix-arg - (if (eq current-prefix-arg '-) " backward" " word") - "") - (if (use-region-p) " in region" "")) - nil))) - (list (nth 0 common) (nth 1 common) (nth 2 common) - (if (use-region-p) (region-beginning)) - (if (use-region-p) (region-end))))) - (perform-replace - (concat "\\(" (regexp-quote from-string) "\\)\\|" (regexp-quote to-string)) - `(replace-eval-replacement replace-quote - (if (match-string 1) - ,to-string - ,from-string)) - t t delimited nil nil start end)) - -;; From https://emacs.stackexchange.com/a/27170/507 -(defun query-swap-strings (from-string to-string &optional delimited start end) - "Swap occurrences of FROM-STRING and TO-STRING. - -DELIMITED, START, and END are passed to `replace-eval-replacement' verbatim." - (interactive - (let ((common - (query-replace-read-args - (concat "Query swap" - (if current-prefix-arg - (if (eq current-prefix-arg '-) " backward" " word") - "") - (if (use-region-p) " in region" "")) - nil))) - (list (nth 0 common) (nth 1 common) (nth 2 common) - (if (use-region-p) (region-beginning)) - (if (use-region-p) (region-end))))) - (perform-replace - (concat "\\(" (regexp-quote from-string) "\\)\\|" (regexp-quote to-string)) - `(replace-eval-replacement replace-quote (if (match-string 1) ,to-string ,from-string)) - t t delimited nil nil start end)) - -(provide 'text-manip) - -;;; text-manip.el ends here