emacs-lisp

Table of Contents

1. stuff I see a lot in functions

1.1. (pcase EXP &rest CASES)

elisp equivvalent of switch in java and match in python.

cases
each case is (PATTERN CODE)
patterns
  • _ -> anything
  • ’VAL -> symbol ’VAL
  • (pred FUN) (pred (not FUN)) -> if (FUN EXP) return nil or non-nil
  • (app FUN PAT) -> if (FUN EXP) return PAT
  • (guard BOOLEXP) -> if BOOLEXP return non-nil
  • (and PAT …), (or PAT …)

1.2. #'a-symbol

the same as (function a-symbol). It’s difference with ' = (qoute a-symbol):

  • compiler use #' to find compile time warning like function not defined
  • signify that this is a function
  • when used with lambda:
    • #'(lambda ...), (lambda ...), evaluates to a function.
    • '(lambda ...) evaluates to a list.

2. getting help

self-documentation in info
C-h i g (elisp) Anonymous Functions RET is a link to a info page

3. related

  • stores some snippets I wrote.

Backlinks

(2024 > 03 - March > <2024-03-06 Wed>)

old index

(Tools, skills and cheatsheets > programming languages)

Author: Linfeng He

Created: 2024-04-05 Fri 02:23