summaryrefslogtreecommitdiff
path: root/helm-regexp.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2015-03-08 20:16:54 +0100
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2015-03-08 20:16:54 +0100
commit765bf36d9e85376fe763c6ecb724462fae0802c6 (patch)
treea201b03def0463d7f5495b57f38626c5a7ae2939 /helm-regexp.el
parentac7fdc08b22004c7c20886956c1989c7ff6df6c7 (diff)
Allow searching empty lines in moccur.
* helm.el (helm-search-from-candidate-buffer-internal): Adding a newline at bob and eof seems unneeded, fix it. * helm-regexp.el (helm-moccur-get-line): Forward char when hitting an empty line. Return EMPTY-LINE when hitting such a line. (helm-moccur--next-or-previous-char): new, search the buffer-name in the feeded lines around.
Diffstat (limited to 'helm-regexp.el')
-rw-r--r--helm-regexp.el32
1 files changed, 23 insertions, 9 deletions
diff --git a/helm-regexp.el b/helm-regexp.el
index cc919aa0..3046571a 100644
--- a/helm-regexp.el
+++ b/helm-regexp.el
@@ -190,17 +190,31 @@ i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b."
bufstr)
concat bufstr)))
+(defun helm-moccur--next-or-previous-char ()
+ (save-excursion
+ (or (re-search-forward "^." nil t)
+ (re-search-backward "^." nil t))))
+
(defun helm-moccur-get-line (beg end)
"Format line for `helm-source-moccur'."
- (format "%s:%d:%s"
- (get-text-property beg 'buffer-name)
- (save-restriction
- (narrow-to-region (previous-single-property-change
- (point) 'buffer-name)
- (next-single-property-change
- (point) 'buffer-name))
- (line-number-at-pos beg))
- (buffer-substring beg end)))
+ (prog1
+ (format "%s:%d:%s"
+ (get-text-property (if (= beg end)
+ (helm-moccur--next-or-previous-char)
+ beg)
+ 'buffer-name)
+ (save-restriction
+ (narrow-to-region (or (previous-single-property-change
+ (point) 'buffer-name) 1)
+ (or (next-single-property-change
+ (if (= beg end)
+ (helm-moccur--next-or-previous-char)
+ (point))
+ 'buffer-name)
+ (point-max)))
+ (line-number-at-pos beg))
+ (if (= beg end) "EMPTY LINE" (buffer-substring beg end)))
+ (if (= beg end) (forward-char 1))))
(cl-defun helm-moccur-action (candidate
&optional (method (quote buffer)) mark)