summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2023-01-12 16:39:31 -0600
committerCase Duckworth2023-01-12 16:39:31 -0600
commitb13e8f87a92c34abb7168a812523f395151afcc7 (patch)
tree9cbb709acf9b366d54d6d41201292b2f9d17ceeb /lisp
parentMove faces definition to init.el (diff)
downloademacs-b13e8f87a92c34abb7168a812523f395151afcc7.tar.gz
emacs-b13e8f87a92c34abb7168a812523f395151afcc7.zip
Meh
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw.el50
1 files changed, 50 insertions, 0 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index f16a679..6729759 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -35,5 +35,55 @@ enables passing arguments to a calling function."
35 (executable-find (car (ensure-list x)))) 35 (executable-find (car (ensure-list x))))
36 programs)) 36 programs))
37 37
38(defun file-string (file)
39 "Return the contents of FILE as a string."
40 (with-current-buffer (find-file-noselect file)
41 (buffer-string)))
42
43(defun unsmartify-region (begin end)
44 "Replace \"smart\" punctuation with \"dumb\" counterparts."
45 (interactive "*r")
46 (save-excursion
47 (goto-char begin)
48 (while (re-search-forward "[“”‘’–—]" end t)
49 (let ((replace (pcase (match-string 0)
50 ((or "“" "”") "\"")
51 ((or "‘" "’") "'")
52 ("–" "--")
53 ("—" "---"))))
54 (replace-match replace nil nil)))))
55
56(defun ++concat (func strings)
57 "Concat STRINGS processed by FUNC.
58Each of STRINGS can be a bare string or a list. Strings are
59passed through as-is, but lists are passed to FUNC first as
60arguments. Finally, all the resulting strings are `mapconcat'-ed
61together.
62
63As a special case, if `:separator' is the first of STRINGS, the
64string following will be used as a separator. Otherwise, a
65newline will be used."
66 (let (separator)
67 (when (eq (car strings) :separator)
68 (setq separator (cadr strings)
69 strings (cddr strings)))
70 (mapconcat (lambda (s)
71 (cond
72 ((listp s) (apply func s))
73 ((stringp s) s)
74 (t (user-error "Bad argument: %S" s))))
75 strings
76 (or separator "\n"))))
77
78(defun format-concat (&rest strings)
79 "Concatenate formatted STRINGS.
80Each of STRINGS can be a bare string or a list. Bare strings are passed as-is
81to `mapconcat' for concatenation and separation. Lists, however, are passed to
82`format' first.
83
84If `:separator' is the first of STRINGS, the next string will be
85used as a separator."
86 (++concat #'format strings))
87
38(provide 'acdw) 88(provide 'acdw)
39;;; acdw.el ends here 89;;; acdw.el ends here