X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fsimple.el;h=74daf55dbca6e00ad68b7d71eacc94bf6d9d129c;hb=c9a63e1a342578bd9c9ad8c2292d527557910faf;hp=be9f8d221d3bc580f5212b850c9deb78cfdab85b;hpb=6883ee56ec887c2c48abe5b06b5e66aa74031910;p=chise%2Fxemacs-chise.git diff --git a/lisp/simple.el b/lisp/simple.el index be9f8d2..74daf55 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -94,6 +94,52 @@ :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.