------------------------------------------------------------ revno: 243 committer: thierry volpiatto <thierry.volpia...@gmail.com branch nick: elpa timestamp: Tue 2012-07-24 06:53:30 +0200 message: (ioccur-case-fold-search): Provide smart case-fold-search in ioccur. modified: packages/ioccur/ioccur.el
=== modified file 'packages/ioccur/ioccur.el' --- a/packages/ioccur/ioccur.el 2012-03-25 02:46:27 +0000 +++ b/packages/ioccur/ioccur.el 2012-07-24 04:53:30 +0000 @@ -3,7 +3,7 @@ ;; Copyright (C) 2010-2012 Free Software Foundation, Inc. ;; Author: Thierry Volpiatto <thierry dot volpiatto at gmail dot com> -;; X-URL: http://mercurial.intuxication.org/hg/ioccur +;; X-URL: https://github.com/thierryvolpiatto/ioccur ;; Version: 2.4 ;; Compatibility: GNU Emacs >=22.3 @@ -140,9 +140,20 @@ :group 'ioccur :type 'boolean) +(defcustom ioccur-case-fold-search 'smart + "Add 'smart' option to `case-fold-search'. +When smart is enabled, Ignore case in the search strings +if pattern contains no uppercase characters. +Otherwise, with a nil or t value, the behavior is same as +`case-fold-search'. +Default value is smart, other possible values are nil and t." + :group 'ioccur + :type 'symbol) + (defvar ioccur-read-char-or-event-skip-read-key nil "Force not using `read-key' to read input in minibuffer even if bounded. -Set it to non--nil if menu disapear or if keys are echoing in minibuffer.") +Set it to non--nil if menu disapear or if keys are echoing in minibuffer. +Deprecated, should be used only in old Emacs versions.") ;;; Faces. (defface ioccur-overlay-face @@ -297,21 +308,24 @@ "Print in `ioccur-buffer' lines matching REGEXP in `ioccur-current-buffer'." (setq ioccur-count-occurences 0) (with-current-buffer ioccur-current-buffer - (save-excursion - (goto-char (point-min)) - (loop - while (not (eobp)) - ;; We need to read also C-g from here - ;; Because when loop is started `ioccur-read-search-input' - ;; will read key only when loop is finished - ;; and we have no chance to exit loop. - when quit-flag do (setq ioccur-quit-flag t) and return nil - for count from 0 - when (funcall ioccur-search-function regexp (point-at-eol) t) - do (ioccur-print-line - (buffer-substring (point-at-bol) (point-at-eol)) - count (match-string 0) regexp) - do (forward-line 1))))) + (let ((case-fold-search (case ioccur-case-fold-search + (smart (if (string-match "[A-Z]" regexp) nil t)) + (t ioccur-case-fold-search)))) + (save-excursion + (goto-char (point-min)) + (loop + while (not (eobp)) + ;; We need to read also C-g from here + ;; Because when loop is started `ioccur-read-search-input' + ;; will read key only when loop is finished + ;; and we have no chance to exit loop. + when quit-flag do (setq ioccur-quit-flag t) and return nil + for count from 0 + when (funcall ioccur-search-function regexp (point-at-eol) t) + do (ioccur-print-line + (buffer-substring (point-at-bol) (point-at-eol)) + count (match-string 0) regexp) + do (forward-line 1)))))) (defun ioccur-print-match (str &optional all)