[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e89f250 072/348: Add option for swiper line number to be s
From: |
Oleh Krehel |
Subject: |
[elpa] master e89f250 072/348: Add option for swiper line number to be searchable |
Date: |
Sat, 8 Apr 2017 11:03:29 -0400 (EDT) |
branch: master
commit e89f250176ca9442a0ed3aa56c4403fc2f37e461
Author: justbur <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add option for swiper line number to be searchable
* swiper.el (swiper-include-line-number-in-search): Add option
* swiper.el: Use swiper-line-number to store candidate line number
* ivy.el: Same
Store swiper line number in new text property swiper-line-number,
reserving the display property for the display of text. When the option
is enabled the only change is that the line number is included as text
in the candidates instead of in the display property.
Fixes #562
---
ivy.el | 2 +-
swiper.el | 27 ++++++++++++++++++---------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/ivy.el b/ivy.el
index d882999..6c067b3 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2408,7 +2408,7 @@ Prefix matches to NAME are put ahead of the list."
(res 0)
(i 0))
(dolist (c cands)
- (when (eq n (read (get-text-property 0 'display c)))
+ (when (eq n (read (get-text-property 0 'swiper-line-number c)))
(setq res i))
(cl-incf i))
res)))))
diff --git a/swiper.el b/swiper.el
index ad587c6..101bc2d 100644
--- a/swiper.el
+++ b/swiper.el
@@ -77,6 +77,11 @@
"Only highlight matches for regexps at least this long."
:type 'integer)
+(defcustom swiper-include-line-number-in-search nil
+ "Include line number in text of search candidates."
+ :type 'boolean
+ :group 'swiper)
+
(defvar swiper-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "M-q") 'swiper-query-replace)
@@ -305,10 +310,14 @@ numbers; replaces calculating the width from buffer line
count."
(point)
(line-end-position)))))))
(remove-text-properties 0 (length str) '(field) str)
- (put-text-property 0 1 'display
- (format swiper--format-spec
- (cl-incf line-number))
- str)
+ (let ((line-number-str
+ (format swiper--format-spec (cl-incf line-number))))
+ (if swiper-include-line-number-in-search
+ (setq str (concat line-number-str str))
+ (put-text-property
+ 0 1 'display line-number-str str))
+ (put-text-property
+ 0 1 'swiper-line-number line-number-str str))
(push str candidates))
(funcall advancer 1))
(nreverse candidates))))))
@@ -344,7 +353,7 @@ When REVERT is non-nil, regenerate the current *ivy-occur*
buffer."
fname
(propertize
(string-trim-right
- (get-text-property 0 'display s))
+ (get-text-property 0 'swiper-line-number s))
'face 'compilation-line-number)
(substring s 1)))
(if (null revert)
@@ -502,7 +511,7 @@ Matched candidates should have `swiper-invocation-face'."
" " "\t"
(funcall ivy--regex-function ivy-text)))
(re (if (stringp re) re (caar re)))
- (str (get-text-property 0 'display ivy--current))
+ (str (get-text-property 0 'swiper-line-number ivy--current))
(num (if (string-match "^[0-9]+" str)
(string-to-number (match-string 0 str))
0)))
@@ -589,7 +598,7 @@ WND, when specified is the window."
(defun swiper--action (x)
"Goto line X."
- (let ((ln (1- (read (or (get-text-property 0 'display x)
+ (let ((ln (1- (read (or (get-text-property 0 'swiper-line-number x)
(and (string-match ":\\([0-9]+\\):.*\\'" x)
(match-string-no-properties 1 x))))))
(re (ivy--regex ivy-text)))
@@ -715,12 +724,12 @@ Run `swiper' for those buffers."
(delete-minibuffer-contents))))
(defun swiper-multi-action-2 (x)
- (let ((buf-space (get-text-property (1- (length x)) 'display x)))
+ (let ((buf-space (get-text-property (1- (length x)) 'swiper-line-number x)))
(with-ivy-window
(when (string-match "\\` *\\([^ ]+\\)\\'" buf-space)
(switch-to-buffer (match-string 1 buf-space))
(goto-char (point-min))
- (forward-line (1- (read (get-text-property 0 'display x))))
+ (forward-line (1- (read (get-text-property 0 'swiper-line-number x))))
(re-search-forward
(ivy--regex ivy-text)
(line-end-position) t)
- [elpa] master 6cf7feb 282/348: ivy.el: Allow toggling of sorting in ivy-read, (continued)
- [elpa] master 6cf7feb 282/348: ivy.el: Allow toggling of sorting in ivy-read, Oleh Krehel, 2017/04/08
- [elpa] master dbcee94 288/348: counsel.el: support universal argument for counsel-unicode-char, Oleh Krehel, 2017/04/08
- [elpa] master 0507841 285/348: Use customizable list of directories when looking for linux apps., Oleh Krehel, 2017/04/08
- [elpa] master 7c73f71 293/348: Allow users to find libraries from counsel-load-library, Oleh Krehel, 2017/04/08
- [elpa] master 07813be 094/348: Spelling fixes, Oleh Krehel, 2017/04/08
- [elpa] master 22623aa 101/348: swiper.el (swiper-avy): Require avy, Oleh Krehel, 2017/04/08
- [elpa] master 9118fa1 093/348: Separate readme into distinct ivy/counsel/swiper sections, Oleh Krehel, 2017/04/08
- [elpa] master 64b385d 107/348: Don't quit counsel-linux-app on bad data, Oleh Krehel, 2017/04/08
- [elpa] master 2be454c 104/348: Remove ivy-height from the example configuration., Oleh Krehel, 2017/04/08
- [elpa] master d83567e 073/348: counsel.el (counsel-locate-options): Remove obsolete var, Oleh Krehel, 2017/04/08
- [elpa] master e89f250 072/348: Add option for swiper line number to be searchable,
Oleh Krehel <=
- [elpa] master 06d5cf5 078/348: counsel.el (counsel-rhythmbox): Require dbus, Oleh Krehel, 2017/04/08
- [elpa] master 469a4ab 081/348: Add ivy-push-view and ivy-pop-view, Oleh Krehel, 2017/04/08
- [elpa] master c009b28 080/348: ivy.el: Breaking change for alist type collection actions, Oleh Krehel, 2017/04/08
- [elpa] master 8df5a67 089/348: counsel.el (counsel-semantic): New command, Oleh Krehel, 2017/04/08
- [elpa] master af5d2c1 097/348: Don't crash if default-directory is nil., Oleh Krehel, 2017/04/08
- [elpa] master 874632e 098/348: Name bookmarked directories using the bookmark name, Oleh Krehel, 2017/04/08
- [elpa] master 9e6bf2d 112/348: Makefile (plain): Fix target, Oleh Krehel, 2017/04/08
- [elpa] master c43de47 120/348: counsel.el (counsel-dired-jump): Fix up, Oleh Krehel, 2017/04/08
- [elpa] master 5fe3cef 122/348: counsel.el (counsel-file-jump): Allow spaces in path, Oleh Krehel, 2017/04/08
- [elpa] master f27a1f0 124/348: swiper.el (swiper-all-function): Add a ">0 cands -> 0 cands" fix, Oleh Krehel, 2017/04/08