-;;; ioccur.el --- Incremental occur.
+;;; ioccur.el --- Incremental occur
;; 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
;;; Commentary:
;;
-;; This package provide similar functionality as occur but is incremental.
+;; This package provides the command M-x ioccur, which is similar to
+;; M-x occur, except that it is incremental.
;;
-;; You can jump and quit to an occurence or jump
-;; and save the search buffer (ioccur-buffer) for further use.
-;; It is possible to toggle literal and regexp searching while running.
-;; It is auto documented both in mode-line and tooltip.
-;; It have its own history `ioccur-history' which is a real ring.
-;; etc...
+;; You can jump and quit to an occurrence, or jump and save the search
+;; buffer (ioccur-buffer) for further use. You can toggle literal and
+;; regexp searching while running. It is auto documented both in
+;; mode-line and tooltip. It has its own history, `ioccur-history',
+;; which is a real ring.
;;
-;; To save `ioccur-history', use desktop, adding that to your .emacs:
-;; (add-to-list 'desktop-globals-to-save 'ioccur-history)
+;; To save `ioccur-history' via the Desktop package, add this to your
+;; init file (see (info "(emacs) Saving Emacs Sessions") for details):
;;
-;; For more info See:
-;; [EVAL] (info "(emacs) Saving Emacs Sessions")
+;; (add-to-list 'desktop-globals-to-save 'ioccur-history)
;;; Code:
(require 'derived)
: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
"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 (let ((case-fold-search nil))
+ (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)
"Highlight in string STR all occurences matching `ioccur-pattern'.
(setq cur-hist-elm (ioccur-iter-next it))
(setq tmp-list nil)
(loop for char across cur-hist-elm
- do (push char tmp-list))
+ do (push char tmp-list))
(setq ioccur-pattern cur-hist-elm)))
;; First call use car of history ring.
(setq tmp-list nil)
(loop for char across cur-hist-elm
- do (push char tmp-list))
+ do (push char tmp-list))
(setq ioccur-pattern cur-hist-elm)
(setq start-hist t)))
(message "No history available.") (sit-for 2) t))
(insert-initial-input ()
(unless (string= initial-input "")
(loop for char across initial-input
- do (push char tmp-list))))
+ do (push char (nthcdr index tmp-list)))))
;; Maybe start timer.
;;
(start-timer ()
(with-current-buffer ioccur-current-buffer
(goto-char start-point)
(setq yank-point start-point))
- (kill-new (substring str (- (1- (length tmp-list)) index)))
+ (kill-new (substring str (- (length tmp-list) index)))
(setq tmp-list (nthcdr index tmp-list)))
;; Add cursor in minibuffer
;;