comparison lisp/isearch-mode.el @ 5855:0bddb59072b6

Look for cased character classes when deciding on case-fold-search, #'isearch lisp/ChangeLog addition: 2015-03-11 Aidan Kehoe <kehoea@parhasard.net> * isearch-mode.el: * isearch-mode.el (isearch-fix-case): Use the new #'no-case-regexp-p function if treating ISEARCH-STRING as a regular expression; otherwise, use the [[:upper:]] character class. * isearch-mode.el (isearch-no-upper-case-p): Removed. * isearch-mode.el (with-caps-disable-folding): Removed. These two haven't been used since 1998. * occur.el (occur-1): Use #'no-case-regexp-p here. * replace.el (perform-replace): Don't use #'no-upper-case-p, use #'no-case-regexp-p or (string-match "[[:upper:]]" ...) as appropriate. * simple.el: * simple.el (no-upper-case-p): Removed. This did two different things, and its secondary function (examining regular expressions) just became much more complicated; move the regular expression functionality to its own function, use character classes when examining non-regular-expressions instead. The code to look for character classes, and the design decision that this should be done, are from GNU, thank you Stefan Monnier. * simple.el (no-case-regexp-p): New. Given a REGEXP, return non-nil if it has nothing to suggest an interactive user wants a case-sensitive search. * simple.el (with-search-caps-disable-folding): * simple.el (with-interactive-search-caps-disable-folding): Update both these macros to use #'no-case-regexp-p.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 11 Mar 2015 18:06:15 +0000
parents 2b8edd304c2b
children
comparison
equal deleted inserted replaced
5854:ccb0cff115d2 5855:0bddb59072b6
1066 (and case-fold-search 1066 (and case-fold-search
1067 ;; Make sure isearch-toggle-case-fold works. 1067 ;; Make sure isearch-toggle-case-fold works.
1068 (not isearch-fixed-case) 1068 (not isearch-fixed-case)
1069 search-caps-disable-folding) 1069 search-caps-disable-folding)
1070 (setq isearch-case-fold-search 1070 (setq isearch-case-fold-search
1071 (no-upper-case-p isearch-string isearch-regexp))) 1071 (if isearch-regexp
1072 (no-case-regexp-p isearch-string)
1073 (save-match-data
1074 (let (case-fold-search)
1075 (not (string-match "[[:upper:]]" isearch-string)))))))
1072 (setq isearch-mode (if case-fold-search 1076 (setq isearch-mode (if case-fold-search
1073 (if isearch-case-fold-search 1077 (if isearch-case-fold-search
1074 " Isearch" ;As God Intended Mode 1078 " Isearch" ;As God Intended Mode
1075 " ISeARch") ;Warn about evil case via StuDLYcAps. 1079 " ISeARch") ;Warn about evil case via StuDLYcAps.
1076 " Isearch"))) 1080 " Isearch")))
1854 'all-extents-closed) 1858 'all-extents-closed)
1855 (isearch-restore-extent extent) 1859 (isearch-restore-extent extent)
1856 t)) 1860 t))
1857 isearch-unhidden-extents))))) 1861 isearch-unhidden-extents)))))
1858 1862
1859 (defun isearch-no-upper-case-p (string)
1860 "Return t if there are no upper case chars in string.
1861 But upper case chars preceded by \\ do not count since they
1862 have special meaning in a regexp."
1863 ;; this incorrectly returns t for "\\\\A"
1864 (let ((case-fold-search nil))
1865 (not (string-match "\\(^\\|[^\\]\\)[A-Z]" string))))
1866 (make-obsolete 'isearch-no-upper-case-p 'no-upper-case-p)
1867
1868 ;; Portability functions to support various Emacs versions. 1863 ;; Portability functions to support various Emacs versions.
1869 1864
1870 (defun isearch-char-to-string (c) 1865 (defun isearch-char-to-string (c)
1871 (if (eventp c) 1866 (if (eventp c)
1872 (make-string 1 (event-to-character c)) 1867 (make-string 1 (event-to-character c))
1874 1869
1875 ;(defun isearch-text-char-description (c) 1870 ;(defun isearch-text-char-description (c)
1876 ; (isearch-char-to-string c)) 1871 ; (isearch-char-to-string c))
1877 1872
1878 (define-function 'isearch-text-char-description 'text-char-description) 1873 (define-function 'isearch-text-char-description 'text-char-description)
1879
1880 ;; Used by etags.el and info.el
1881 (defmacro with-caps-disable-folding (string &rest body) "\
1882 Eval BODY with `case-fold-search' let to nil if STRING contains
1883 uppercase letters and `search-caps-disable-folding' is t."
1884 `(let ((case-fold-search
1885 (if (and case-fold-search search-caps-disable-folding)
1886 (isearch-no-upper-case-p ,string)
1887 case-fold-search)))
1888 ,@body))
1889 (make-obsolete 'with-caps-disable-folding 'with-search-caps-disable-folding)
1890 (put 'with-caps-disable-folding 'lisp-indent-function 1)
1891 (put 'with-caps-disable-folding 'edebug-form-spec '(form body))
1892
1893 1874
1894 ;;;======================================================== 1875 ;;;========================================================
1895 ;;; Advanced highlighting 1876 ;;; Advanced highlighting
1896 1877
1897 ;; When active, *every* visible match for the current search string is 1878 ;; When active, *every* visible match for the current search string is