branch: master
commit 341f8f1fed7d36c0a35265c70c5594d52332f07e
Author: mookid <nathan.mor...@m4x.org>
Commit: mookid <nathan.mor...@m4x.org>

    Uses the active region, is any.
---
 loccur.el |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/loccur.el b/loccur.el
index e1008ab..c48ce3e 100644
--- a/loccur.el
+++ b/loccur.el
@@ -168,11 +168,18 @@ REGEX is regexp to search"
 
 This command hides all lines from the current buffer except those
 containing the regular expression REGEX.  A second call of the function
-unhides lines again"
+unhides lines again.
+
+When called interactively, either prompts the user for REGEXP or,
+when called with an active region, uses the content of the
+region."
   (interactive
-   (if loccur-mode
-       (list nil)
-     (list (read-string "Loccur: " (loccur-prompt) 'loccur-history))))
+   (if (region-active-p)
+       (list (buffer-substring (mark) (point)))
+     (if loccur-mode
+         (list nil)
+       (list (read-string "Loccur: " (loccur-prompt) 'loccur-history)))))
+  (when (region-active-p) (deactivate-mark))
   (if (or loccur-mode
           (= (length regex) 0))
       (progn

Reply via email to