Skip to content

Instantly share code, notes, and snippets.

@PHAredes
Created October 23, 2024 21:34
Show Gist options
  • Save PHAredes/b3f986648fa31120fa2997e27dde4475 to your computer and use it in GitHub Desktop.
Save PHAredes/b3f986648fa31120fa2997e27dde4475 to your computer and use it in GitHub Desktop.

User

Can you explain the difference between sexp hyperlinks and eepitch blocks?

Please show 4 examples of executable logs using eev emacs library, explaining their relation with sexp and eepitch

Enumerate these examples one by one as a list using Github Markdown Syntax

Llama-3.2-90b

Difference between sexp hyperlinks and eepitch blocks:

In Emacs, sexp stands for "symbolic expression," which is a basic data structure in Emacs Lisp. A sexp hyperlink is a clickable link that represents a sexp, which when clicked, usually evaluates the expression.

eepitch (or eev) blocks, on the other hand, are interactive blocks of Emacs Lisp code that can be executed directly from a text file or a buffer. These blocks are usually used for documentation or tutorials, allowing the user to see the code and its output simultaneously.

Examples of executable logs using eepitch (eev) and sexp:

Here are four examples of executable logs using the eev Emacs library, along with their relation to sexp and eepitch:

1. Simple math calculation

«eepitch-eg» 
  (message "The result is: %s" (+ 2 3)) 
  «eepitch-end» 
«sexp» 
  (+ 2 3) 
«sexp-end» 

In this example, the eepitch block evaluates the expression (message "The result is: %s" (+ 2 3)), which adds 2 and 3 and prints the result. The sexp hyperlink represents the same expression (+ 2 3).

2. Extracting text from a buffer

«eepitch-eg» 
  (setq toto "a b c") 
  (message "Last two characters: %s" (substring toto 1 4)) 
  «eepitch-end» 
«sexp» 
  (substring toto 1 4) 
«sexp-end» 

Here, the eepitch block defines a variable toto and extracts its last two characters using (substring toto 1 4). The sexp hyperlink represents the same expression.

3. Showing the current Emacs version

«eepitch-eg» 
  (message "Emacs version: %s" emacs-version) 
  «eepitch-end» 
«sexp» 
  emacs-version 
«sexp-end» 

In this example, the eepitch block displays the current Emacs version using (message "Emacs version: %s" emacs-version). The sexp hyperlink simply represents the emacs-version variable.

4. Evaluating a Lisp expression

«eepitch-eg» 
  (message "The result is: %s" (1+ 4)) 
  «eepitch-end» 
«sexp» 
  (1+ 4) 
«sexp-end» 

Here, the eepitch block evaluates the expression (message "The result is: %s" (1+ 4)), which increments the number 4 and prints the result. The sexp hyperlink represents the same expression (1+ 4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment