2018-03-19 11:08:01 +00:00
|
|
|
;;; package --- Summary
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; Code:
|
2016-10-21 21:02:22 +00:00
|
|
|
(defun org-space-key (&optional arg)
|
2018-03-19 11:08:01 +00:00
|
|
|
"Insert two spaces after a period.
|
|
|
|
|
|
|
|
ARG will be passed down verbatim to `self-insert-command'"
|
2016-10-21 21:02:22 +00:00
|
|
|
(interactive "p")
|
|
|
|
|
2018-03-19 11:08:01 +00:00
|
|
|
(when (looking-back "[.!?…]" nil)
|
2016-10-21 21:02:22 +00:00
|
|
|
(call-interactively 'self-insert-command arg))
|
|
|
|
(call-interactively 'self-insert-command arg))
|
2016-11-28 04:23:11 +00:00
|
|
|
|
|
|
|
;; From http://pages.sachachua.com/.emacs.d/Sacha.html
|
|
|
|
(defun sachachua/fill-or-unfill-paragraph (&optional unfill region)
|
2018-03-19 11:08:01 +00:00
|
|
|
"Fill (or unfill, if UNFILL is non-nil) paragraph (or REGION)."
|
2016-11-28 04:23:11 +00:00
|
|
|
(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)))
|
2016-12-02 07:34:50 +00:00
|
|
|
|
|
|
|
;; Copied from http://emacs.stackexchange.com/a/27170/507
|
|
|
|
(defun so/query-swap-strings (from-string
|
|
|
|
to-string
|
|
|
|
&optional delimited start end)
|
2018-03-19 11:08:01 +00:00
|
|
|
"Swap occurrences of FROM-STRING and TO-STRING.
|
|
|
|
|
|
|
|
DELIMITED, START, and END are passed down verbatim to `perform-replace'."
|
2016-12-02 07:34:50 +00:00
|
|
|
(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))
|
2018-03-19 11:08:01 +00:00
|
|
|
|
2018-03-19 11:12:52 +00:00
|
|
|
;; 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))
|
|
|
|
|
2018-03-19 11:08:01 +00:00
|
|
|
(provide 'text-manip)
|
|
|
|
|
|
|
|
;;; text-manip.el ends here
|