Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can these quicklinks/bangs be put in a lua table or written in a way to avoid the bangs namespacing? #939

Open
jgarte opened this issue Jul 5, 2021 · 3 comments

Comments

@jgarte
Copy link
Contributor

jgarte commented Jul 5, 2021

Can these quicklinks/bangs be put in a lua table or written in a way to avoid the bangs. repetitions namespace?

local bangs = settings.window.search_engines

bangs.d = "https://duckduckgo.com/?q=%s"
bangs.s = "https://startpage.com/do/metasearch.pl?query=%s"
bangs.gh = "https://github.com/search?q=%s"
bangs.w = "https://en.wikipedia.org/wiki/Special:Search?search=%s"
bangs.pu = "https://pursuit.purescript.org/search?q=%s"
bangs.lm = "https://search.libremiami.org/searx/search?q=%s"
bangs.mint = "https://www.mint-lang.com/api/modules/Array#%s"
bangs.n = "https://search.nixos.org/packages?query=%s"
bangs.i = "http://issues.guix.gnu.org/search?query=%s"
bangs.l = "https://logs.guix.gnu.org/guix/search?query=%s"
bangs.sr = "https://sr.ht/projects?search=%s&sort=recently-updated"
bangs.ns = "https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&query=%s"
bangs.fun = "https://www.funtoo.org/index.php?search=%s&title=Special%3ASearch&profile=default&fulltext=1"
bangs.rkt = "https://docs.racket-lang.org/search/index.html?q=%s"
bangs.v = "https://invidious.silkky.cloud/search?q=%s"
bangs.git = "https://git-scm.com/search/results?search=%s"
@taobert
Copy link
Contributor

taobert commented Jul 6, 2021

Well, they are in a table.
You could also assign a single table to settings.window.search_engines if the variable name is distressing you.
Note that this will throw away all values already set in settings.window.search_engines, whereas what you currently have will add to this table (overwriting values if their index is reused).
My list is:


settings = require "settings"
settings.window.search_engines = 
{
    luakit      = "https://github.com/luakit/luakit/issues?q=%s",
    duckduckgo  = "http://duckduckgo.com/?q=%s&t=debian",
    github      = "https://github.com/search?q=%s",
    google      = "http://google.com/search?q=%s",
    GoogleMaps  = "https://www.google.com.au/maps/place/%s",
    -- google	= "http://www.google.com.au/?cx=013269018370076798483%%3A8eec3papwpi&nojs=1&q=%s",
    -- http://www.google.com/cse?cx=013269018370076798483%3A8eec3papwpi&ie=UTF-8&q=foo&sa=Search&nojs=1
    scholar     = "http://scholar.google.com/scholar?q=%s",
    imdb        = "http://www.imdb.com/find?s=all&q=%s",
    piratebay   = "http://thepiratebay.org/search/%s",
    wikipedia   = "http://en.wikipedia.org/wiki/Special:Search?search=%s",
    AliExpress  = "https://www.aliexpress.com/wholesale?SearchText=%s",
    debbugs     = "http://bugs.debian.org/%s",
    sourceforge = "http://sf.net/search/?words=%s",
    OpenWetWare = "http://openwetware.org/wiki/Special:Search?search=%s",
    netflix     = "http://dvd.netflix.com/Search?v1=%s",
    journal     = "http://primo-direct-apac.hosted.exlibrisgroup.com/primo_library/libweb/action/dlSearch.do?vid=LATROBE&institution=LATROBE&search_scope=All&query=any,contains,%s",
    doi         = "http://misshie.jp/doi2bibtex/doi2bibtex.cgi?id=%s",
    ldoi        = "http://0-dx.doi.org.alpha2.latrobe.edu.au/%s",

    default     = "https://google.com/search?q=%s",
}

@jgarte
Copy link
Contributor Author

jgarte commented Jul 6, 2021

Well, they are in a table.
You could also assign a single table to settings.window.search_engines if the variable name is distressing you.
Note that this will throw away all values already set in settings.window.search_engines, whereas what you currently have will add to this table (overwriting values if their index is reused).

How can I see what is in settings.window.search_engines by default? Do you use the lua repl to introspect it?

@taobert
Copy link
Contributor

taobert commented Jul 6, 2021

The current (as opposed to the default) contents of settings.window.search_engines are at the bottom of luakit://settings (:settings). The default value is set in window.lua.

You could iterate through it to print the contents. I am lazier and use penlight: :lua require('pl.pretty').dump(<table>) which prints to the console. (inspect.lua has also been mentioned for printing tables, but i've not played with it yet; neither of these ship with luakit by default and would need to be installed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants