[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to run a elisp-function

From: Jean Louis
Subject: Re: how to run a elisp-function
Date: Tue, 11 May 2021 10:26:53 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

Dear Dr. Ruff,

> 2) How can I - without using the GUI-emacs option-system - in .emacs
> programmatically add entries to:

I recommend reading the Emacs Lisp manual by evaluating the following:
(info "(elisp) Association Lists") <--- evaluate here with C-x C-e

> hyperbole-web-search-alist
> programmtically, that is in elisp?

The info page above, tells about this:

 -- Function: alist-get key alist &optional default remove testfn
     This function is similar to ‘assq’.  It finds the first association
     ‘(KEY . VALUE)’ by comparing KEY with ALIST elements, and, if
     found, returns the VALUE of that association.  If no association is
     found, the function returns DEFAULT.  Comparison of KEY against
     ALIST elements uses the function specified by TESTFN, defaulting to

     This is a generalized variable (*note Generalized Variables::) that
     can be used to change a value with ‘setf’.  When using it to set a
     value, optional argument REMOVE non-‘nil’ means to remove KEY’s
     association from ALIST if the new value is ‘eql’ to DEFAULT.

I also recommend using {C-h f} on the function or {C-h v} on the
variable for which you wish to get more information.

As `hyperbole-web-search-alist' is variable you would do:
{C-h v hyperbole-web-search-alist RET}

then it gives similar result as this down:
hyperbole-web-search-alist is a variable defined in ‘hsettings.el’.

Its value is shown below.

  You can customize this variable.

*Alist of (web-service-name . url-with-%s-parameter) elements.
The first character of each web-service-name must be unique.
This custom option is used in the Hyperbole Find/Web menu where
the %s in the url-with-%s-parameter is replaced with an interactively
obtained search string.

(("Amazon" . "http://www.amazon.com/s/field-keywords=%s";)
 ("Bing" . "http://www.bing.com/search?q=%s";)

Now, provided you understood:

- how to reach to Emacs Lisp info manual
- how to change the alist with `setf' 
- and how to format the value for hyperbole-web-search-alist

Now you can add to the alist by using:

(setf (alist-get "Leo" hyperbole-web-search-alist) 

While this worked, I see that following does not work:

(alist-get "Leo" hyperbole-web-search-alist) ⇒ nil

As that is because we use the key with quotes "Leo" instead a
symbol 'Leo, which means that function `alist-get' requires
different "test" function, to test also for strings.

Then this works:

(alist-get "Leo" hyperbole-web-search-alist nil nil 'equal) ⇒ 

Then I think this would be more proper to do:

(setf (alist-get "Leo" hyperbole-web-search-alist nil nil 'equal) 

In general, alist has unique keys, but it is a list, and if you
start using other non intended functions with alist, it may
behave randomly.

That is why you should use only the alist related functions.


Take action in Free Software Foundation campaigns:

Sign an open letter in support of Richard M. Stallman

reply via email to

[Prev in Thread] Current Thread [Next in Thread]