branch: master commit 78e24b7b3aa61680d3142cb6c670fc7dc96121ce Merge: 5402f35 0b85b60 Author: Alexey Veretennikov <alexey.veretenni...@gmail.com> Commit: Alexey Veretennikov <alexey.veretenni...@gmail.com>
Updated to version 1.2.3 - Removed empty line in the beginning of the buffer - Using active region as default suggestion (trivial change accepted without signing FSF papers, confirmed to be trivial enough by johnw) Merge commit '0b85b6001a42dfce2906cd5ff66b849c44ed1aa1' --- packages/loccur/README.md | 13 +++++++++++++ packages/loccur/loccur.el | 32 ++++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/packages/loccur/README.md b/packages/loccur/README.md index cea09cd..bfb9acd 100644 --- a/packages/loccur/README.md +++ b/packages/loccur/README.md @@ -48,3 +48,16 @@ Below is the list of interactive commands available for user: * `loccur-jump-beginning-of-line` variable specifies if move the cursor to the beginning of the matching line. Default `nil` * `loccur-highlight-matching-regexp` variable whenever `loccur` should highlight matching words. Default `t`. * `loccur-face` face to be used while highlighting. Default points to `isearch` face. + +### Tips and tricks +To combine **Loccur** and **isearch** functionality (narrowing-search) one can use the following hooks: +```lisp +(add-hook 'isearch-update-post-hook + (lambda () + (let ((loccur-mode nil)) + (loccur (regexp-quote isearch-string))))) + +(add-hook 'isearch-mode-end-hook + (lambda () + (loccur nil))) +``` diff --git a/packages/loccur/loccur.el b/packages/loccur/loccur.el index 2921ba0..2cd7bee 100644 --- a/packages/loccur/loccur.el +++ b/packages/loccur/loccur.el @@ -5,7 +5,7 @@ ;; Author: Alexey Veretennikov <alexey.veretenni...@gmail.com> ;; ;; Created: 2009-09-08 -;; Version: 1.2.2 +;; Version: 1.2.3 ;; Package-Requires: ((cl-lib "0")) ;; Keywords: matching ;; URL: https://github.com/fourier/loccur @@ -29,7 +29,7 @@ ;;; Commentary: ;; ;; Add the following to your .emacs file: -;; +;; ;; (require 'loccur) ;; ;; defines shortcut for loccur of the current word ;; (define-key global-map [(control o)] 'loccur-current) @@ -43,14 +43,17 @@ ;; gives unexpected jumps in loccur mode ;; ;;; TODO: -;; +;; ;;; Change Log: ;; +;; 2016-12-26 (1.2.3) +;; + Removed empty line in the beginning of the buffer. +;; + Added 'Tips and tricks' session to the README.md file ;; 2015-12-27 (1.2.2) ;; + Preparation for GNU ELPA submission. Removed contributions ;; without signed papers ;; + added loccur-face - face to highlight text, by default isearch -;; +;; ;; 2013-10-22 (1.2.1) ;; + Added custom option loccur-jump-beginning-of-line; removed some ;; of cl dependencies @@ -168,11 +171,19 @@ 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)))) + (cond ((region-active-p) + (list (buffer-substring (mark) (point)))) + (loccur-mode + (list nil)) + (t + (list (read-string "Loccur: " (loccur-prompt) 'loccur-history))))) + (when (region-active-p) (deactivate-mark)) (if (or loccur-mode (= (length regex) 0)) (progn @@ -271,6 +282,7 @@ REGEX is an argument to `loccur'." (let ((prev-end (point-min)) (overlays (list))) (when buffer-matches + (push (list 1 (caar buffer-matches)) overlays) (mapc (lambda (line) (let ((beginning (car line))) (unless ( = (- beginning prev-end) 1) @@ -315,8 +327,8 @@ containing match" (forward-line 1)) (setq lines (nreverse lines))))) - - + + (provide 'loccur)