diff options
author | Case Duckworth | 2021-08-11 22:03:54 -0500 |
---|---|---|
committer | Case Duckworth | 2021-08-11 22:04:05 -0500 |
commit | d187b2b8cbf19ec387c800df37d2669a9d520448 (patch) | |
tree | 8286f37c3a595800ababd7f804ac65259fa3b5fc | |
parent | Enable `crux-reopen-as-root-mode' (diff) | |
download | emacs-d187b2b8cbf19ec387c800df37d2669a9d520448.tar.gz emacs-d187b2b8cbf19ec387c800df37d2669a9d520448.zip |
Add acdw-compat.el
-rw-r--r-- | init.el | 3 | ||||
-rw-r--r-- | lisp/acdw-compat.el | 71 |
2 files changed, 74 insertions, 0 deletions
diff --git a/init.el b/init.el index bfc736d..733de04 100644 --- a/init.el +++ b/init.el | |||
@@ -48,6 +48,9 @@ | |||
48 | ;;;; Private stuff | 48 | ;;;; Private stuff |
49 | (acdw/require-private) | 49 | (acdw/require-private) |
50 | 50 | ||
51 | ;;;; Compatibility with older versions | ||
52 | (require 'acdw-compat) | ||
53 | |||
51 | 54 | ||
52 | ;;;; Utility functions and variables | 55 | ;;;; Utility functions and variables |
53 | ;; see also: `acdw' and friends. Functions here aren't big enough, or they're | 56 | ;; see also: `acdw' and friends. Functions here aren't big enough, or they're |
diff --git a/lisp/acdw-compat.el b/lisp/acdw-compat.el new file mode 100644 index 0000000..b77527c --- /dev/null +++ b/lisp/acdw-compat.el | |||
@@ -0,0 +1,71 @@ | |||
1 | ;;; acdw-compat.el -*- lexical-binding: t; coding: utf-8-unix -*- | ||
2 | |||
3 | ;; Author: Case Duckworth <acdw@acdw.net> | ||
4 | ;; Created: 2021-08-11 | ||
5 | ;; Keywords: configuration | ||
6 | ;; URL: https://tildegit.org/acdw/emacs | ||
7 | |||
8 | ;; This file is NOT part of GNU Emacs. | ||
9 | |||
10 | ;;; License: | ||
11 | ;; Everyone is permitted to do whatever with this software, without | ||
12 | ;; limitation. This software comes without any warranty whatsoever, | ||
13 | ;; but with two pieces of advice: | ||
14 | ;; - Don't hurt yourself. | ||
15 | ;; - Make good choices. | ||
16 | |||
17 | ;;; Commentary: | ||
18 | |||
19 | ;; This file contains functions, variables, and other code that might not be in | ||
20 | ;; every version of Emacs I use. | ||
21 | |||
22 | ;;; Code: | ||
23 | |||
24 | ;; Convenience macro | ||
25 | (defmacro safe-defun (name arglist &optional docstring &rest body) | ||
26 | "Like `defun', but only if the function doesn't already exist. | ||
27 | |||
28 | Is it necessary? Who knows! | ||
29 | |||
30 | \(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)" | ||
31 | (declare (doc-string 3) | ||
32 | (indent 2)) | ||
33 | `(unless (fboundp (function ,name)) | ||
34 | (defun ,name ,@body))) | ||
35 | |||
36 | |||
37 | ;;; Functions for changing capitalization that Do What I Mean | ||
38 | ;; Defined in /usr/share/emacs/28.0.50/lisp/simple.el | ||
39 | |||
40 | (safe-defun upcase-dwim (arg) | ||
41 | "Upcase words in the region, if active; if not, upcase word at point. | ||
42 | If the region is active, this function calls `upcase-region'. | ||
43 | Otherwise, it calls `upcase-word', with prefix argument passed to it | ||
44 | to upcase ARG words." | ||
45 | (interactive "*p") | ||
46 | (if (use-region-p) | ||
47 | (upcase-region (region-beginning) (region-end) (region-noncontiguous-p)) | ||
48 | (upcase-word arg))) | ||
49 | |||
50 | (safe-defun downcase-dwim (arg) | ||
51 | "Downcase words in the region, if active; if not, downcase word at point. | ||
52 | If the region is active, this function calls `downcase-region'. | ||
53 | Otherwise, it calls `downcase-word', with prefix argument passed to it | ||
54 | to downcase ARG words." | ||
55 | (interactive "*p") | ||
56 | (if (use-region-p) | ||
57 | (downcase-region (region-beginning) (region-end) (region-noncontiguous-p)) | ||
58 | (downcase-word arg))) | ||
59 | |||
60 | (safe-defun capitalize-dwim (arg) | ||
61 | "Capitalize words in the region, if active; if not, capitalize word at point. | ||
62 | If the region is active, this function calls `capitalize-region'. | ||
63 | Otherwise, it calls `capitalize-word', with prefix argument passed to it | ||
64 | to capitalize ARG words." | ||
65 | (interactive "*p") | ||
66 | (if (use-region-p) | ||
67 | (capitalize-region (region-beginning) (region-end) (region-noncontiguous-p)) | ||
68 | (capitalize-word arg))) | ||
69 | |||
70 | (provide 'acdw-compat) | ||
71 | ;;; acdw-compat.el ends here | ||