summaryrefslogtreecommitdiff
path: root/lisp/simple.el
diff options
context:
space:
mode:
authorZachary Kanfer <zkanfer@gmail.com>2015-09-26 11:09:19 +0300
committerEli Zaretskii <eliz@gnu.org>2015-09-26 11:09:19 +0300
commit80cc5d13d4ceee0fae75e28ee75f351425ada1a9 (patch)
tree1ce8bc3f13c40ca53ac910d1006fd6c3cfca72e2 /lisp/simple.el
parent7b532d3e26197e5d4d65d1442c34ce7e27cf9d0b (diff)
downloademacs-80cc5d13d4ceee0fae75e28ee75f351425ada1a9.tar.gz
New DWIM commands for changing letter-case
* lisp/simple.el (upcase-dwim, downcase-dwim, capitalize-dwim): New functions. (Bug#21501) Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp/simple.el')
-rw-r--r--lisp/simple.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index f80faae80d8..8acb6839744 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8424,6 +8424,38 @@ contains the list of implementations currently supported for this command."
command-name)))))))
+;;; Functions for changing capitalization that Do What I Mean
+(defun upcase-dwim (arg)
+ "Upcase words in the region, if active; if not, upcase word at point.
+If the region is active, this function calls `upcase-region'.
+Otherwise, it calls `upcase-word', with prefix argument passed to it
+to upcase ARG words."
+ (interactive "*p")
+ (if (use-region-p)
+ (upcase-region (region-beginning) (region-end))
+ (upcase-word arg)))
+
+(defun downcase-dwim (arg)
+ "Downcase words in the region, if active; if not, downcase word at point.
+If the region is active, this function calls `downcase-region'.
+Otherwise, it calls `downcase-word', with prefix argument passed to it
+to downcase ARG words."
+ (interactive "*p")
+ (if (use-region-p)
+ (downcase-region (region-beginning) (region-end))
+ (downcase-word arg)))
+
+(defun capitalize-dwim (arg)
+ "Capitalize words in the region, if active; if not, capitalize word at point.
+If the region is active, this function calls `capitalize-region'.
+Otherwise, it calls `capitalize-word', with prefix argument passed to it
+to capitalize ARG words."
+ (interactive "*p")
+ (if (use-region-p)
+ (capitalize-region (region-beginning) (region-end))
+ (capitalize-word arg)))
+
+
(provide 'simple)