'cycle-spacing' and their order can now be customized via the user
option 'cycle-spacing-actions'.
+---
+** 'zap-to-char' and 'zap-up-to-char' are case-sensitive for upper-case chars.
+These commands now behave as case-sensitive for interactive calls when
+are invoked with an uppercase argument, regardless of the
+`case-fold-search' value.
+
---
** 'scroll-other-window' and 'scroll-other-window-down' now respect remapping.
These commands (bound to 'C-M-v' and 'C-M-V') used to scroll the other
;; Variation of `zap-to-char'.
;;;###autoload
-(defun zap-up-to-char (arg char)
+(defun zap-up-to-char (arg char &optional interactive)
"Kill up to, but not including ARGth occurrence of CHAR.
+When run interactively, the argument INTERACTIVE is non-nil.
Case is ignored if `case-fold-search' is non-nil in the current buffer.
Goes backward if ARG is negative; error if CHAR not found.
-Ignores CHAR at point."
+Ignores CHAR at point.
+If called interactively, do a case sensitive search if CHAR
+is an upper-case character."
(interactive (list (prefix-numeric-value current-prefix-arg)
(read-char-from-minibuffer "Zap up to char: "
- nil 'read-char-history)))
- (let ((direction (if (>= arg 0) 1 -1)))
+ nil 'read-char-history)
+ t))
+ (let ((direction (if (>= arg 0) 1 -1))
+ (case-fold-search (if (and interactive (char-uppercase-p char))
+ nil
+ case-fold-search)))
(kill-region (point)
(progn
(forward-char direction)
(characterp (get-char-code-property char 'lowercase)))
((and (>= char ?A) (<= char ?Z)))))
-(defun zap-to-char (arg char)
+(defun zap-to-char (arg char &optional interactive)
"Kill up to and including ARGth occurrence of CHAR.
+When run interactively, the argument INTERACTIVE is non-nil.
Case is ignored if `case-fold-search' is non-nil in the current buffer.
Goes backward if ARG is negative; error if CHAR not found.
-See also `zap-up-to-char'."
+See also `zap-up-to-char'.
+If called interactively, do a case sensitive search if CHAR
+is an upper-case character."
(interactive (list (prefix-numeric-value current-prefix-arg)
(read-char-from-minibuffer "Zap to char: "
- nil 'read-char-history)))
+ nil 'read-char-history))
+ t)
;; Avoid "obsolete" warnings for translation-table-for-input.
(with-no-warnings
(if (char-table-p translation-table-for-input)
(setq char (or (aref translation-table-for-input char) char))))
- (kill-region (point) (progn
- (search-forward (char-to-string char) nil nil arg)
- (point))))
+ (let ((case-fold-search (if (and interactive (char-uppercase-p char))
+ nil
+ case-fold-search)))
+ (kill-region (point) (search-forward (char-to-string char) nil nil arg))))
;; kill-line and its subroutines.
(zap-up-to-char 1 ?c))
(with-misc-test "abcde abc123" "c123"
(goto-char (point-min))
- (zap-up-to-char 2 ?c)))
+ (zap-up-to-char 2 ?c))
+ (let ((case-fold-search t))
+ (with-misc-test "abcdeCXYZ" "cdeCXYZ"
+ (goto-char (point-min))
+ (zap-up-to-char 1 ?C))
+ (with-misc-test "abcdeCXYZ" "CXYZ"
+ (goto-char (point-min))
+ (zap-up-to-char 1 ?C 'interactive))))
(ert-deftest misc-test-upcase-char ()
(with-misc-test "abcde" "aBCDe"
(yank-in-context)
(buffer-string))
"echo 'f'\\''bar'\\''oo'")))
+\f
+;;; Tests for `zap-to-char'
+
+(defmacro with-zap-to-char-test (original result &rest body)
+ (declare (indent 2) (debug (stringp stringp body)))
+ `(with-temp-buffer
+ (insert ,original)
+ (goto-char (point-min))
+ ,@body
+ (should (equal (buffer-string) ,result))))
+
+(ert-deftest simple-tests-zap-to-char ()
+ (with-zap-to-char-test "abcde" "de"
+ (zap-to-char 1 ?c))
+ (with-zap-to-char-test "abcde abc123" "123"
+ (zap-to-char 2 ?c))
+ (let ((case-fold-search t))
+ (with-zap-to-char-test "abcdeCXYZ" "deCXYZ"
+ (zap-to-char 1 ?C))
+ (with-zap-to-char-test "abcdeCXYZ" "XYZ"
+ (zap-to-char 1 ?C 'interactive))))
(provide 'simple-test)
;;; simple-tests.el ends here