[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 341f8f1 2/6: Uses the active region, is any.

From: Alexey Veretennikov
Subject: [elpa] master 341f8f1 2/6: Uses the active region, is any.
Date: Mon, 26 Dec 2016 14:14:36 +0000 (UTC)

branch: master
commit 341f8f1fed7d36c0a35265c70c5594d52332f07e
Author: mookid <address@hidden>
Commit: mookid <address@hidden>

    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
-   (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))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]