This commit was generated by cvs2svn to compensate for changes in r242,
[chise/xemacs-chise.git.1] / lisp / simple.el
index be9f8d2..74daf55 100644 (file)
   :group 'minibuffer)
 
 
+(defcustom search-caps-disable-folding t
+  "*If non-nil, upper case chars disable case fold searching.
+This does not apply to \"yanked\" strings."
+  :type 'boolean
+  :group 'editing-basics)
+
+;; This is stolen (and slightly modified) from FSF emacs's
+;; `isearch-no-upper-case-p'.
+(defun no-upper-case-p (string &optional regexp-flag)
+  "Return t if there are no upper case chars in STRING.
+If REGEXP-FLAG is non-nil, disregard letters preceded by `\\' (but not `\\\\')
+since they have special meaning in a regexp."
+  (let ((case-fold-search nil))
+    (not (string-match (if regexp-flag 
+                          "\\(^\\|\\\\\\\\\\|[^\\]\\)[A-Z]"
+                        "[A-Z]")
+                      string))
+    ))
+
+(defmacro with-search-caps-disable-folding (string regexp-flag &rest body) "\
+Eval BODY with `case-fold-search' let to nil if `search-caps-disable-folding' 
+is non-nil, and if STRING (either a string or a regular expression according
+to REGEXP-FLAG) contains uppercase letters."
+  `(let ((case-fold-search
+          (if (and case-fold-search search-caps-disable-folding)
+              (no-upper-case-p ,string ,regexp-flag)
+            case-fold-search)))
+     ,@body))
+(put 'with-search-caps-disable-folding 'lisp-indent-function 2)
+(put 'with-search-caps-disable-folding 'edebug-form-spec 
+     '(sexp sexp &rest form))
+
+(defmacro with-interactive-search-caps-disable-folding (string regexp-flag 
+                                                              &rest body)
+  "Same as `with-search-caps-disable-folding', but only in the case of a
+function called interactively."
+  `(let ((case-fold-search
+         (if (and (interactive-p) 
+                  case-fold-search search-caps-disable-folding)
+              (no-upper-case-p ,string ,regexp-flag)
+            case-fold-search)))
+     ,@body))
+(put 'with-interactive-search-caps-disable-folding 'lisp-indent-function 2)
+(put 'with-interactive-search-caps-disable-folding 'edebug-form-spec 
+     '(sexp sexp &rest form))
+
 (defun newline (&optional arg)
   "Insert a newline, and move to left margin of the new line if it's blank.
 The newline is marked with the text-property `hard'.
@@ -387,7 +433,7 @@ and KILLP is t if a prefix arg was specified."
   (and overwrite-mode (not (eolp))
        (save-excursion (insert-char ?\  arg))))
 
-(defcustom delete-key-deletes-forward nil
+(defcustom delete-key-deletes-forward t
   "*If non-nil, the DEL key will erase one character forwards.
 If nil, the DEL key will erase one character backwards."
   :type 'boolean
@@ -456,19 +502,20 @@ backwards."
   "Kill up to and including ARG'th occurrence of CHAR.
 Goes backward if ARG is negative; error if CHAR not found."
   (interactive "*p\ncZap to char: ")
-  (kill-region (point) (progn
+  (kill-region (point) (with-interactive-search-caps-disable-folding
+                          (char-to-string char) nil
                         (search-forward (char-to-string char) nil nil arg)
-;                       (goto-char (if (> arg 0) (1- (point)) (1+ (point))))
                         (point))))
 
 (defun zap-up-to-char (arg char)
   "Kill up to ARG'th occurrence of CHAR.
 Goes backward if ARG is negative; error if CHAR not found."
   (interactive "*p\ncZap up to char: ")
-  (kill-region (point) (progn
-                       (search-forward (char-to-string char) nil nil arg)
-                       (goto-char (if (> arg 0) (1- (point)) (1+ (point))))
-                       (point))))
+  (kill-region (point) (with-interactive-search-caps-disable-folding
+                          (char-to-string char) nil
+                        (search-forward (char-to-string char) nil nil arg)
+                        (goto-char (if (> arg 0) (1- (point)) (1+ (point))))
+                        (point))))
 
 (defun beginning-of-buffer (&optional arg)
   "Move point to the beginning of the buffer; leave mark at previous position.
@@ -2322,7 +2369,7 @@ With any other arg, set comment column to indentation of the previous comment
 (defun kill-comment (arg)
   "Kill the comment on this line, if any.
 With argument, kill comments on that many lines starting with this one."
-  ;; this function loses in a lot of situations.  it incorrectly recognises
+  ;; this function loses in a lot of situations.  it incorrectly recognizes
   ;; comment delimiters sometimes (ergo, inside a string), doesn't work
   ;; with multi-line comments, can kill extra whitespace if comment wasn't
   ;; through end-of-line, et cetera.