8

When programing emacs (or common) lisp, how to discover (standard) function names (using emacs and working offline)?

Example: Let's say you want to shift bits of an integer, but you don't now the name of the function, which can do this (hint: the name is ash, but you don't know, yet).
apropos isn't helping you, because it does not list ash when asking for shift.

Drew
  • 75,699
  • 9
  • 109
  • 225
jue
  • 4,476
  • 8
  • 20

1 Answers1

10

Apropos help in Emacs is by no means limited to function apropos.

  1. M-x apropos documentation. It lets you match keywords or a regexp against doc strings. Very helpful when you don't know how the function might be named but you might be able to guess some words used in its doc.

    For example, M-x apropos-documentation RET shift bit RET shows you the names and doc for just the functions lsh and ash. Simple, effective.

    lsh
    Function: Return VALUE with its bits shifted left by COUNT.
    If COUNT is negative, shifting is actually to the right.
    In this case, zeros are shifted in on the left.
    
    (fn VALUE COUNT)
    
    ----------------
    ash
    Function: Return VALUE with its bits shifted left by COUNT.
    If COUNT is negative, shifting is actually to the right.
    In this case, the sign bit is duplicated.
    
    (fn VALUE COUNT)
    
  2. There are also these other Apropos commands:

    apropos-command
    apropos-follow
    apropos-function 
    apropos-library
    apropos-local-value
    apropos-local-variable
    apropos-option
    apropos-value
    apropos-variable
    

    See also apropos-fn+var.el.

  3. The Emacs manual (C-h r), i, is your friend. Likewise, the Elisp manual (C-h i, choose Elisp).

  4. Icicles apropos support -- including documentation-apropos commands, which provide the functionality of apropos-documentation, but which let you match against both the function name (e.g. parts of it) and the doc string.

In answer to your question in the comments, I don't really know how to find similar info for Common Lisp. Perhaps someone else will have a good answer about that. But:

  • You can certainly use i in the CL Info manual provided by Emacs.
  • Googling "common lisp docstring" turned up this StackOverflow question as the first hit. Perhaps it will help.
Drew
  • 75,699
  • 9
  • 109
  • 225
  • Thank you! Any idea how to do this for common lisp with slime and hyperspec installed? ;) – jue Sep 20 '19 at 16:57