XEmacs 21.2.28 "Hermes".
[chise/xemacs-chise.git.1] / lisp / simple.el
index be9f8d2..19a6eec 100644 (file)
@@ -62,7 +62,7 @@
 ;; Mule-2.3, and could probably use some feature additions (like additional wrap
 ;; styles, etc)
 
-;; 97/06/11 Steve Baur (steve@altair.xemacs.org) Convert use of
+;; 97/06/11 Steve Baur (steve@xemacs.org) Convert use of
 ;;  (preceding|following)-char to char-(after|before).
 
 ;;; Code:
   :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.
@@ -623,7 +670,7 @@ BUFFER defaults to the current buffer."
       cnt)))
 
 ;;; Modified by Bob Weiner, 8/24/95, to print narrowed line number also.
-;;; Expanded by Bob Weiner, Altrasoft, on 02/12/1997
+;;; Expanded by Bob Weiner, BeOpen, on 02/12/1997
 (defun what-line ()
   "Print the following variants of the line number of point:
      Region line     - displayed line within the active region
@@ -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.
@@ -2545,7 +2592,8 @@ indicating whether soft newlines should be inserted.")
                       bounce
                       ;; 97/3/14 jhod: Kinsoku
                       (re-break-point (if (featurep 'mule)
-                                           (concat "[ \t\n]\\|" word-across-newline)
+                                           (concat "[ \t\n]\\|" word-across-newline
+                                                   ".\\|." word-across-newline)
                                        "[ \t\n]"))
                       ;; end patch
                       (first t))
@@ -2608,20 +2656,23 @@ indicating whether soft newlines should be inserted.")
                  (if (save-excursion
                        (skip-chars-backward " \t")
                        (= (point) fill-point))
+                     ;; 1999-09-17 hniksic: turn off Kinsoku until
+                     ;; it's debugged.
+                     (indent-new-comment-line)
                      ;; 97/3/14 jhod: Kinsoku processing
-                     ;(indent-new-comment-line)
-                     (let ((spacep (memq (char-before (point)) '(?\  ?\t))))
-                       (funcall comment-line-break-function)
-                       ;; if user type space explicitly, leave SPC
-                       ;; even if there is no WAN.
-                       (if spacep
-                           (save-excursion
-                             (goto-char fill-point)
-                             ;; put SPC except that there is SPC
-                             ;; already or there is sentence end.
-                             (or (memq (char-after (point)) '(?\  ?\t))
-                                 (fill-end-of-sentence-p)
-                                 (insert ?\ )))))
+;                    ;(indent-new-comment-line)
+;                    (let ((spacep (memq (char-before (point)) '(?\  ?\t))))
+;                      (funcall comment-line-break-function)
+;                      ;; if user type space explicitly, leave SPC
+;                      ;; even if there is no WAN.
+;                      (if spacep
+;                          (save-excursion
+;                            (goto-char fill-point)
+;                            ;; put SPC except that there is SPC
+;                            ;; already or there is sentence end.
+;                            (or (memq (char-after (point)) '(?\  ?\t))
+;                                (fill-end-of-sentence-p)
+;                                (insert ?\ )))))
                    (save-excursion
                      (goto-char fill-point)
                      (funcall comment-line-break-function)))
@@ -2842,6 +2893,7 @@ unless optional argument SOFT is non-nil."
       (if (and comcol (not fill-prefix))  ; XEmacs - (ENE) from fa-extras.
          (let ((comment-column comcol)
                (comment-start comstart)
+               (block-comment-start comstart)
                (comment-end comment-end))
            (and comment-end (not (equal comment-end ""))
   ;           (if (not comment-multi-line)
@@ -3578,7 +3630,7 @@ as the second argument.")
 ;;                                            --hniksic
 (defcustom log-message-ignore-regexps
   '(;; Note: adding entries to this list slows down messaging
-    ;; significantly.  Wherever possible, use message lables.
+    ;; significantly.  Wherever possible, use message labels.
 
     ;; Often-seen messages
     "\\`\\'"                           ; empty message