[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/crux c79985f 077/112: Saner functions for modifying cases
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/crux c79985f 077/112: Saner functions for modifying cases on region for humans |
Date: |
Wed, 11 Aug 2021 09:57:57 -0400 (EDT) |
branch: elpa/crux
commit c79985f69b7cd96edb505199bd751f71ce6d4e58
Author: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Saner functions for modifying cases on region for humans
By default `upcase-region` `downcase-region` and `captialize-region`
commands
are disabled in emacs, and for good reason because they are insane. Whenever
you've placed a mark anywhere in the document, inadventently pressing one
of the
assigned keybinding will change the cases for all the words in half a
document. These commands resurrect these potentially useful functions in a
much
saner way by wrapping them around `use-region-p`, so they are only activated
when `transient-mark-mode` is one.
---
README.md | 3 +++
crux.el | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/README.md b/README.md
index 8d5b373..763d37c 100644
--- a/README.md
+++ b/README.md
@@ -67,6 +67,9 @@ Command |
Suggested Keybinding(s)
`crux-kill-whole-line` | <kbd>Super-k</kbd> |
Kill whole line
`crux-kill-line-backwards` | <kbd>C-Backspace</kbd> |
Kill line backwards
`crux-ispell-word-then-abbrev` | <kbd>C-c i</kbd> | Fix
word using `ispell` and then save to `abbrev`.
+`crux-upcase-region` | <kbd>C-x C-u</kbd> |
`upcase-region` when `transient-mark-mode` is on and region is active.
+`crux-downcase-region` | <kbd>C-x C-l</kbd> |
`downcase-region` when `transient-mark-mode` is on and region is active.
+`crux-capitalize-region` | <kbd>C-x M-c</kbd> |
`capitalize-region` when `transient-mark-mode` is on and region is active.
Here's how you'd bind some of the commands to keycombos:
diff --git a/crux.el b/crux.el
index 1886e30..bb46f31 100644
--- a/crux.el
+++ b/crux.el
@@ -590,6 +590,27 @@ Doesn't mess with special buffers."
(find-file-other-window (completing-read "Choose shell init file: "
candidates))
(find-file-other-window (car candidates)))))
+;;;###autoload
+(defun crux-upcase-region (beg end)
+ "`upcase-region' when `transient-mark-mode' is on and region is active."
+ (interactive "*r")
+ (when (use-region-p)
+ (upcase-region beg end)))
+
+;;;###autoload
+(defun crux-downcase-region (beg end)
+ "`downcase-region' when `transient-mark-mode' is on and region is active."
+ (interactive "*r")
+ (when (use-region-p)
+ (downcase-region beg end)))
+
+;;;###autoload
+(defun crux-capitalize-region (beg end)
+ "`capitalize-region' when `transient-mark-mode' is on and region is active."
+ (interactive "*r")
+ (when (use-region-p)
+ (capitalize-region beg end)))
+
;;
http://endlessparentheses.com/ispell-and-abbrev-the-perfect-auto-correct.html
;;;###autoload
(defun crux-ispell-word-then-abbrev (p)
- [nongnu] elpa/crux bb5a133 090/112: Simplify a bit of code, (continued)
- [nongnu] elpa/crux bb5a133 090/112: Simplify a bit of code, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 1fa7162 091/112: Optionally move visually in `move-to-mode-line-start', ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux dcd693c 093/112: Rename move-to-mode-line-start to crux-move-to-mode-line-start, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e805ab7 057/112: Use synchronous process for crux-open-with, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 4f5c8fe 059/112: [Fix #46] Address two issues with crux-move-beginning-line (#48), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 49dc7d7 067/112: Remove unused prefix argument from crux-smart-kill-line, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 903db7b 080/112: Add history on crux and links to emacsredux blog posts, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux ba4a1f3 098/112: Restructure the README a bit, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux a0a34d1 100/112: Fix defcustom types, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux acaaa00e 065/112: Bump the copyright years, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux c79985f 077/112: Saner functions for modifying cases on region for humans,
ELPA Syncer <=
- [nongnu] elpa/crux 308f17d 079/112: Bump the copyright years, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux b923d61 082/112: Support creating shells and terminal buffers, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux de603e9 088/112: Add function other-window-or-switch-buffer, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 96d4faa 097/112: Silence byte-compiler warnings, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 501a43c 105/112: Placate byte-compiler, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux d989f2a 110/112: Bump copyright years, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e0457f6 103/112: Fix a major mode check, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e3e16c1 066/112: Add a missing space, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux fa064d7 068/112: Remove a bunch of redundant progn usages, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 3e07035 073/112: Add missing autoloads, ELPA Syncer, 2021/08/11