mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
I've set `lexical-binding` to `nil` in all Emacs Lisp files to suppress the warnings introduced in Emacs 31 requiring all elisp files to have a `lexical-binding` comment. This retains the default behavior of dynamic binding when no `lexical-binding` comment is present. With it set to `t` across the board, various things break, and fixing those is a task for another day.
34 lines
1.0 KiB
EmacsLisp
34 lines
1.0 KiB
EmacsLisp
;;; siren-safe-change-case.el --- jimeh's Emacs Siren: change-case -*- lexical-binding: nil; -*-
|
|
|
|
;;; Commentary:
|
|
|
|
;; Set strict/safer case changing functions to C-x C-u and C-x C-l which ONLY
|
|
;; perform case modifications when region is active.
|
|
|
|
;;; Code:
|
|
|
|
(defun downcase-region-only (beg end &rest args)
|
|
"Only downcase if region (BEG END) is active.
|
|
|
|
Avoids accidental downcase when region is not active. Passes all
|
|
additional ARGS passed along to `downcase-region'."
|
|
(interactive "r")
|
|
(when (region-active-p)
|
|
(apply #'downcase-region beg end args)))
|
|
|
|
(defun upcase-region-only (beg end &rest args)
|
|
"Only upcase if region (BEG END) is active.
|
|
|
|
Avoids accidental upcase when region is not active. Passes all
|
|
additional ARGS passed along to `upcase-region'."
|
|
(interactive "r")
|
|
(when (region-active-p)
|
|
(apply #'upcase-region beg end args)))
|
|
|
|
(siren-general-define-key
|
|
"C-x C-l" 'downcase-region-only
|
|
"C-x C-u" 'upcase-region-only)
|
|
|
|
(provide 'siren-safe-change-case)
|
|
;;; siren-safe-change-case.el ends here
|