[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Convenient ways to search the web

Emacs-w3m comes with advanced features related to search engines, they are accessible through three interfaces:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.1 How to search with emacs-w3m

You can fire up the regular search interface by using the S key (the s key for the ‘Info-like’ keymap) in an emacs-w3m buffer. You will see a prompt in the minibuffer, asking for a search term. Type one or several words at the prompt, then hit <RET>. The result page of your search in the engine appears, you can then browse the results, just as if you had used the normal web based entry point to the engine.

You probably noticed that you have not been given a chance to choose which engine you want to search with. By default, emacs-w3m will use the Google search engine, you can change this behavior by customizing the w3m-search-default-engine variable (see Customizable variables), or you can specify the search engine each time you use the command.

To specify which engine to use, you have to give the command a prefix argument (usually, this means hitting C-u before the command, e.g. C-u S (C-u s for the ‘Info-like’ keymap). Emacs-w3m will prompt you for an engine, you can choose one by typing its name (completion is also available with the <TAB> key). Once you have made your choice, hit the <RET> key. You can then type your search term, hit <RET>, and you will see the search results.

S (Lynx-like keymap)
s (Info-like keymap)

Begin a new search. If called with a prefix argument, prompt for the engine to use (w3m-search).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.2 An alternative (and fast) way to search the web

If you’re a “Web Power User” (and since you’re reading this, you probably are), you need a quick and efficient way to perform searches. The Quick Searching feature is one.

What does it do? It lets you launch web searches by simply going to a special URL such as gg:emacs. The advantages of this mode of operation are:

Using it is very simple: suppose you want to search for the word “gnu” on Google and get a list of results. Hit g to go to a new URL, and type “gg:gnu”. The first part of this expression, “gg” indicates that we want to use the Google search engine. The second term is the word we will be searching for. The prefix and the search term must be separated by a colon. Hit <RET>, and you will see the results of your search. Note that you can input several words by separating them with spaces. <SPC> is a self-inserting key in the minibuffer if the “Feeling Searchy” feature is enabled (it is by default; see w3m-enable-feeling-searchy). If it’s disabled, then hit C-q first, i.e. C-q <SPC>.

The default configuration of emacs-w3m includes several prefixes you can use, they are defined in the w3m-uri-replace-alist variable. There’s for example “gg” for Google, “ggg” for Google Groups, “ya” for Yahoo!, “al” for Altavista, “alc” for Eijirou on the web to name a few. You can also add prefixes for the search engines you define, See section Using your favorite engines.

Instead of prefixes, you can also use full engine names in Quicksearch URLs, such as “google” or “yahoo”. These names are defined in the w3m-search-engine-alist variable.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.3 Using your favorite engines

Emacs-w3m has a number of built-in search engines you can use. What if you want to use your favorite search engine and it’s not listed in the known search engines? You have to add it to the list of search engines, and it’s quite easy:

  1. First, you have to find what’s the entry point of the search engine you want to add, for example:

    http://my.searchengine.com/?query=foobar

    where foobar is the term you want to search for.

  2. Once you have this information, add this to your ‘~/.emacs-w3m’ file:
     
    (eval-after-load "w3m-search"
      '(add-to-list 'w3m-search-engine-alist
                    '("My engine"
                      "http://my.searchengine.com/?query=%s"
                      nil)))
    

    Replace the first field “My engine” with the description of your engine, the second field with the entry point (the ‘%s’ is important, it will be replaced by the search term when you issue the search), and the third field is the encoding to use, nil or omitting this field means to use the value of w3m-default-coding-system as a regular encoding.

    For English search engines, you rarely have to worry about this. However, for some Japanese search engines, you may need to specify something (e.g. euc-japan) there.

  3. You can now use this engine to search, using the normal S key (the s key for the ‘Info-like’ keymap) in emacs-w3m. If you use this engine often, you can also add it to the Quicksearch (see An alternative (and fast) way to search the web) engines and give it a small prefix, by adding this to your ‘~/.emacs-w3m’ file instead:
     
    (eval-after-load "w3m-search"
      '(progn
         (add-to-list 'w3m-search-engine-alist
                      '("My engine"
                        "http://my.searchengine.com/?query=%s"
                        nil))
         (add-to-list 'w3m-uri-replace-alist
                      '("\\`my:" w3m-search-uri-replace "My engine"))))
    

    This way you can also use a URL like my:foobar to search for the term “foobar” with your engine.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by TSUCHIYA Masatoshi on January 30, 2019 using texi2html 1.82.