Function: edt-change-case

edt-change-case is an interactive and byte-compiled function defined in edt.el.gz.

Signature

(edt-change-case NUM)

Documentation

Change the case of specified characters.

If text selection IS active, then characters between the cursor and mark are changed. If text selection is NOT active, there are two cases. First, if the current direction is ADVANCE, then the prefix number of character(s) under and following cursor are changed. Second, if the current direction is BACKUP, then the prefix number of character(s) before the cursor are changed. Accepts a positive prefix for the number of characters to change, but the prefix is ignored if text selection is active. Argument NUM is the numbers of consecutive characters to change.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/edt.el.gz
;;;
;;; CHNGCASE
;;;
;; This function is based upon Jeff Kowalski's case-flip function in his
;; tpu.el.

(defun edt-change-case (num)
  "Change the case of specified characters.
If text selection IS active, then characters between the cursor and mark are
changed.  If text selection is NOT active, there are two cases.  First, if the
current direction is ADVANCE, then the prefix number of character(s) under and
following cursor are changed.  Second, if the current direction is BACKUP, then
the prefix number of character(s) before the cursor are changed.  Accepts a
positive prefix for the number of characters to change, but the prefix is
ignored if text selection is active.
Argument NUM is the numbers of consecutive characters to change."
  (interactive "*p")
  (edt-check-prefix num)
  (if edt-select-mode
      (let ((end (max (mark) (point)))
            (point-save (point)))
        (goto-char (min (point) (mark)))
        (while (not (eq (point) end))
          (funcall (if (<= ?a (following-char))
                       'upcase-region 'downcase-region)
                   (point) (1+ (point)))
          (forward-char 1))
        (goto-char point-save))
    (progn
      (if (string= edt-direction-string edt-backward-string)
	  (backward-char num))
      (while (> num 0)
	(funcall (if (<= ?a (following-char))
		     'upcase-region 'downcase-region)
		 (point) (1+ (point)))
	(forward-char 1)
	(setq num (1- num))))))