Giter VIP home page Giter VIP logo

Comments (10)

sergei-dyshel avatar sergei-dyshel commented on July 18, 2024

Makes sense. Had to move to another plugin just because of this option.

from ferret.

cpixl avatar cpixl commented on July 18, 2024

Recently I switched to CtrlSF. It gives me more options and Edit Mode (which is more user-friendly in most of the cases).

from ferret.

wincent avatar wincent commented on July 18, 2024

Wow, CtrlSF is pretty impressive.

I'm going to close this for now as it's not a pain point that I feel. If anybody wants to fix it, I think these are the options:

  • Use dispatch.vim, which doesn't jump to the first match by default (this is what I do).
  • If you don't want to use dispatch.vim, you could patch the cexpr call in Ferret to be cgetexpr instead (make it a configuration option if you want), and then use g:FerretQFHandler to implement any custom behavior that you want (like copen | wincmd p or whatever).

I'd be open to pull requests.

from ferret.

ntnn avatar ntnn commented on July 18, 2024

I don't remember the code well, but I guess you set 'grepprg' and 'grepformat' - if so you'd just have to put an exclamation mark after the final grep.

from ferret.

wincent avatar wincent commented on July 18, 2024

Yeah @ntnn, something like that. I quickly hacked a sample up in 47ca7cd to show one way of doing it (too flakey to actually merge). We're using cexpr under the covers but switching to :grep would indeed enable a pretty straightforward switch to :grep!.

from ferret.

sergei-dyshel avatar sergei-dyshel commented on July 18, 2024

Thanks for quick response!

from ferret.

kriansa avatar kriansa commented on July 18, 2024

Hello @wincent,

Sorry to bump this closed issue, but is there something we could do to help to get 47ca7cd merged? Sometimes it's annoying to close the current buffer every time I do an :Ack and the result is not the first one listed.

Thanks for this great project.

from ferret.

wincent avatar wincent commented on July 18, 2024

@kriansa: yeah, I think we can merge something like that (will need to redo it it no longer applies cleanly). Lots of edge cases to deal with, but it will have to be something like this:

diff --git a/autoload/ferret/private/shared.vim b/autoload/ferret/private/shared.vim
index 14ad5a1..ff1d929 100644
--- a/autoload/ferret/private/shared.vim
+++ b/autoload/ferret/private/shared.vim
@@ -1,19 +1,43 @@
 " Copyright 2015-present Greg Hurrell. All rights reserved.
 " Licensed under the terms of the BSD 2-clause license.
 
+" Convenience function to get/sanitize the current g:FerretAutojump setting.
+function! s:autojump()
+  let l:autojump=get(g:, 'FerretAutojump', 1)
+  if l:autojump != 0 && l:autojump != 1 && l:autojump != 2
+    let l:autojump=0
+  endif
+  return l:autojump
+endfunction
+
 function! ferret#private#shared#finalize_search(output, ack)
   let l:original_errorformat=&errorformat
+  let l:autojump=s:autojump()
+  if a:ack
+    let l:prefix='c' " Will use cexpr, cgetexpr.
+    let l:handler=get(g:, 'FerretQFHandler', 'botright copen')
+    let l:post='qf'
+  else
+    let l:prefix='l' " Will use lexpr, lgetexpr.
+    let l:handler=get(g:, 'FerretLLHandler', 'lopen')
+    let l:post='location'
+  endif
   try
     let &errorformat=g:FerretFormat
-    if a:ack
-      call s:swallow('cexpr a:1', a:output)
-      execute get(g:, 'FerretQFHandler', 'botright cwindow')
-      call ferret#private#post('qf')
+    if l:autojump == 2 " Show listing and jump to first result.
+      call s:swallow(l:prefix . 'expr a:1', a:output)
     else
-      call s:swallow('lexpr a:1', a:output)
-      execute get(g:, 'FerretLLHandler', 'lwindow')
-      call ferret#private#post('location')
+      call s:swallow(l:prefix . 'getexpr a:1', a:output)
     endif
+    let l:before=winnr()
+    execute l:handler
+    if l:autojump != 1 " Show listing, but don't jump anywhere.
+      let l:after=winnr()
+      if l:before != l:after
+        execute l:before . 'wincmd w'
+      end
+    endif
+    call ferret#private#post(l:post)
   finally
     let &errorformat=l:original_errorformat
   endtry

from ferret.

wincent avatar wincent commented on July 18, 2024

Ok, so I pushed something to the "next" branch. Will let it bake there for a while before merging to master.

from ferret.

kriansa avatar kriansa commented on July 18, 2024

Thank you for your quick response!

from ferret.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.