### Start Emacs with -Q -D options Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Simple-Extension.html Command line options to start Emacs with a clean configuration. ```bash emacs -Q -D ``` -------------------------------- ### Installation list for print-Y-axis test Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/print_002dY_002daxis-Penultimate.html Lists the functions to install before testing print-Y-axis. ```emacs-lisp Y-axis-label-spacing Y-axis-tic Y-axis-element Y-axis-column print-Y-axis ``` -------------------------------- ### Usage examples of nth Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/nth.html Examples demonstrating how to retrieve elements from a list using zero-based indexing with nth. ```emacs-lisp (nth 0 '("one" "two" "three")) ⇒ "one" (nth 1 '("one" "two" "three")) ⇒ "two" ``` -------------------------------- ### Setup for count-words-in-defun Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/count_002dwords_002din_002ddefun.html Initial setup code that moves to the beginning of the definition and initializes local variables for counting and boundary tracking. ```elisp (beginning-of-defun) (let ((count 0) (end (save-excursion (end-of-defun) (point)))) ``` -------------------------------- ### Install emacs2 keymap with install-keymap Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Miscellaneous.html Installs the emacs2 keymap using install-keymap in a boot script as an alternative to loadkeys. ```shell install-keymap emacs2 ``` -------------------------------- ### Modulo arithmetic examples with mod Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Determining-the-Element.html Examples showing how the mod function returns the remainder of a division. ```elisp (mod 12 4) ⇒ 0 ;; because there is no remainder (mod 13 4) ⇒ 1 ``` -------------------------------- ### Conceptual if example Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/if-_0026-or.html A conceptual example illustrating the logic of checking a condition and performing an action. ```elisp (if (not (holding-on-to-guest)) (find-and-take-arm-of-guest)) ``` -------------------------------- ### Start Emacs without loading init files Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Simple-Extension.html Command line options to start Emacs without loading site or user initialization files, with specific evaluation. ```bash emacs -q --no-site-file -eval '(blink-cursor-mode nil)' ``` -------------------------------- ### Basic concat usage Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/kill_002dappend-function.html A simple example demonstrating how the concat function joins two strings. ```elisp (concat "abc" "def") ⇒ "abcdef" ``` -------------------------------- ### Lisp List Syntax Example Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Lisp-Lists.html A basic example of a Lisp list containing four flower names, demonstrating that lists can be formatted across multiple lines. ```lisp '(rose violet daisy buttercup) ``` -------------------------------- ### Initial while loop structure Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Loop-Example.html Shows the start of a while loop testing the animals list. ```elisp (while animals ... ``` -------------------------------- ### Set start and goto-char expressions Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/fwd_002dpara-while.html These two expressions set the variable start to the beginning of the matched text and move point to that location. ```emacs-lisp (setq start (match-beginning 0)) (goto-char start) ``` -------------------------------- ### Example calculation for next multiple Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Compute-a-Remainder.html Evaluating the next multiple calculation with a height of 12. ```elisp (* (1+ (/ 12 5)) 5) ``` -------------------------------- ### Start building X-tic string Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/X-Axis-Tic-Marks.html Begins constructing the X-tic string using concat and make-string. ```emacs-lisp (X-tic (concat (make-string ``` -------------------------------- ### Compute remainders with % Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Compute-a-Remainder.html Examples of using the % function to find the remainder of division. ```elisp (% 7 5) (% 10 5) ``` -------------------------------- ### Execute square-each Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Every.html Example usage of the square-each function showing the input list and the resulting squared list. ```elisp (square-each '(1 2 3)) ⇒ (1 4 9) ``` -------------------------------- ### Test column-of-graph prototype Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Columns-of-a-graph.html Example usage and expected output for the initial column-of-graph function. ```elisp (column-of-graph 5 3) ``` ```elisp (" " " " "*" "*" "*") ``` -------------------------------- ### Construct a list with cons Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/cons.html This example demonstrates using cons to create a four-element list from an existing three-element list. ```elisp (cons 'pine '(fir oak maple)) ``` ```elisp (pine fir oak maple) ``` -------------------------------- ### let expression structure in append-to-buffer Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/append_002dto_002dbuffer-body.html An example showing the nested parentheses required for the let expression and its varlist. ```elisp (let ((oldbuf (current-buffer))) ... ) ``` -------------------------------- ### Insert (debug) in code to start debugger Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/debug_002don_002dquit.html Place (debug) in your code where you want the debugger to start. The example shows it inside a while loop before a deliberate error (1= number). ```emacs-lisp (defun triangle-bugged (number) "Return sum of numbers 1 through NUMBER inclusive." (let ((total 0)) (while (> number 0) (setq total (+ total number)) (debug) ; Start debugger. (setq number (1= number))) ; Error here. total)) ``` -------------------------------- ### Forward motion while loop in forward-paragraph Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/fwd_002dpara-while.html This while loop searches forward for sp-parstart, moves point to the start of the match, and continues until the end of the paragraph. It uses match-beginning to get the start of the matched text. ```emacs-lisp (while (and (re-search-forward sp-parstart nil 1) (progn (setq start (match-beginning 0)) (goto-char start) (not (eobp))) (progn (move-to-left-margin) (not (looking-at parsep))) (or (not (looking-at parstart)) (and use-hard-newlines (not (get-text-property (1- start) 'hard))))) (forward-char 1)) ``` -------------------------------- ### Call lengths-list-file on debug.el Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/lengths_002dlist_002dfile.html Example invocation of lengths-list-file on the debug.el file in the default GNU Emacs 30.2 installation tree. Place cursor after the expression and type C-x C-e to evaluate. ```emacs-lisp (lengths-list-file "/usr/local/share/emacs/30.2/lisp/emacs-lisp/debug.el") ``` -------------------------------- ### Example: setq creates a two-element list Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/kill_002dnew-function.html Sets example-list to a list of two strings. Evaluating this with C-x C-e and then evaluating example-list shows the list value. ```emacs-lisp (setq example-list '("here is a clause" "another clause")) ``` ```emacs-lisp example-list ⇒ ("here is a clause" "another clause") ``` -------------------------------- ### Global key binding for count-words-example Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Whitespace-Bug.html A command to bind the count-words-example function to the C-c = key sequence. ```elisp (keymap-global-set "C-c =" 'count-words-example) ``` -------------------------------- ### Evaluated message expression example Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/multiply_002dby_002dseven-in-detail.html An example of how the message expression is evaluated when a prefix argument of 5 is provided. ```elisp (message "The result is %d" (* 7 5)) ``` -------------------------------- ### Sample mode line display Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Mode-Line.html Shows the resulting mode line format after applying the custom configuration. It displays the file name, machine, directory, line number, mode, and buffer position. ```text -:-- foo.texi rattlesnake:/home/bob/ Line 1 (Texinfo Fill) Top ``` -------------------------------- ### Start Emacs without initialization file Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Mode-Line.html Use this command to launch a plain, default Emacs instance that does not load your ~/.emacs initialization file. ```bash emacs -q ``` -------------------------------- ### Documentation for goto-char Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/simplified_002dbeginning_002dof_002dbuffer.html The documentation string for `goto-char` as shown by `describe-function`. It explains that the function sets point to a position, with the beginning of the buffer at `point-min` and the end at `point-max`. ```text Set point to POSITION, a number or marker. Beginning of buffer is position (point-min), end is (point-max). ``` -------------------------------- ### defun example: multiply-by-seven Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/defun.html Example function definition that multiplies its argument by 7. It is not interactive; see the section on Making a Function Interactive for that information. ```lisp (defun multiply-by-seven (number) "Multiply NUMBER by seven." (* 7 number)) ``` -------------------------------- ### Implementation of count-words-example using let Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/recursive_002dcount_002dwords.html The complete implementation of the interactive function, using a let expression to capture the result of the recursive call and display it to the user. ```elisp (defun count-words-example (beginning end) "Print number of words in the region." (interactive "r") ``` ```elisp ;;; 1. Set up appropriate conditions. (message "Counting words in region ... ") (save-excursion (goto-char beginning) ``` ```elisp ;;; 2. Count the words. (let ((count (recursive-count-words end))) ``` ```elisp ;;; 3. Send a message to the user. (cond ((zerop count) (message "The region does NOT have any words.")) ((= 1 count) (message "The region has 1 word.")) (t (message "The region has %d words." count)))))) ``` -------------------------------- ### Using let* for sequential variable binding Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Regexp-Review.html Demonstrates let* which binds variables locally and allows subsequent bindings to reference previously bound variables. ```emacs-lisp (let* ((foo 7) (bar (* 3 foo))) (message "`bar' is %d." bar)) ⇒ ‘bar’ is 21. ``` -------------------------------- ### Lisp String Atom Example Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Lisp-Atoms.html An example of a list containing a string atom, which is treated as a single unit including its internal punctuation and spaces. ```Lisp '(this list includes "text between quotation marks.") ``` -------------------------------- ### Construct a list using dotimes Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/dotimes.html This example binds the numbers 0, 1, and 2 to the variable 'number' and constructs a list of these three numbers. ```elisp (let (value) ; otherwise a value is a void variable (dotimes (number 3) (setq value (cons number value))) value) ⇒ (2 1 0) ``` -------------------------------- ### Example list argument for insert-rectangle Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Columns-of-a-graph.html An example of a list argument passed to insert-rectangle to represent a column of height 3 in a graph with a maximum height of 5. ```elisp (" " " " "*" "*" "*") ``` -------------------------------- ### List Construction with cons Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/cons-_0026-search_002dfwd-Review.html Shows how to prepend an element to the front of an existing list. ```elisp (cons 1 '(2 3 4)) ⇒ (1 2 3 4) ``` -------------------------------- ### Example invocations of triangle function Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Inc-Example-altogether.html Two example calls to the triangle function: (triangle 4) and (triangle 7). The first returns 10 and the second returns 28. ```emacs-lisp (triangle 4) ``` ```emacs-lisp (triangle 7) ``` -------------------------------- ### First version of count-words-example (with bugs) Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Design-count_002dwords_002dexample.html This is the initial implementation of the count-words-example function. It uses interactive "r" to get the region, and prints a message. The function is known to have bugs and does not work in all circumstances. ```emacs-lisp ;;; First version; has bugs! (defun count-words-example (beginning end) "Print number of words in the region. Words are defined as at least one word-constituent character followed by at least one character that is not a word-constituent. The buffer's syntax table determines which characters these are." (interactive "r") (message "Counting words in region ... ") ``` ```emacs-lisp ``` ```emacs-lisp ;;; 1. Set up appropriate conditions. (save-excursion (goto-char beginning) (let ((count 0)) ``` ```emacs-lisp ``` ```emacs-lisp ;;; 2. Run the while loop. (while (< (point) end) (re-search-forward "\\w+\\W*") (setq count (1+ count))) ``` ```emacs-lisp ``` ```emacs-lisp ;;; 3. Send a message to the user. (cond ((zerop count) (message "The region does NOT have any words.")) ((= 1 count) (message "The region has 1 word.")) (t (message "The region has %d words." count)))))) ``` -------------------------------- ### Call add-elements with example list Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Accumulate.html Invokes add-elements with the list (1 2 3 4) and shows the result 10. ```emacs-lisp (add-elements '(1 2 3 4)) ⇒ 10 ``` -------------------------------- ### Example output for print-graph Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Test-print_002dgraph.html The visual output generated by the print-graph function. ```text 10 - * ** * 5 - **** * **** *** * ********* ************ 1 - ************* | | | | 1 5 10 15 ``` -------------------------------- ### Evaluate multiply-by-seven Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Effect-of-installation.html Evaluates the multiply-by-seven function with the argument 3 to verify its installation. ```elisp (multiply-by-seven 3) ``` -------------------------------- ### Edebug result display Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/edebug.html Example of a value displayed in the echo area during debugging. ```text Result: 3 (#o3, #x3, ?\C-c) ``` -------------------------------- ### Updating set-buffer to use bound variables Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/append-save_002dexcursion.html Demonstrates the transition from using a function call directly to using a variable bound in a let* expression. ```elisp (set-buffer (get-buffer-create buffer)) ``` ```elisp (set-buffer append-to) ``` -------------------------------- ### Example of a nested Lisp list Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Numbers-Lists.html A list containing words and an interior list. ```lisp '(this list has (a list inside of it)) ``` -------------------------------- ### Evaluate addition Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Making-Errors.html An example of a successful evaluation where the symbol '+' has a defined function. ```elisp (+ 2 2) ``` -------------------------------- ### Evaluate functions with three arguments Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Variable-Number-of-Arguments.html Demonstrates evaluating the addition and multiplication functions with three arguments. ```elisp (+ 3 4 5) ⇒ 12 (* 3 4 5) ⇒ 60 ``` -------------------------------- ### Example of a text storage list Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/Storing-Text.html A representation of how successive pieces of text are stored in a list. ```elisp ("a piece of text" "previous piece") ``` -------------------------------- ### Display a message with multiple arguments Source: https://www.gnu.org/software/emacs/manual/html_node/eintr/message.html Demonstrates using both %d and %s placeholders with multiple arguments. ```elisp (message "There are %d %s in the office!" (- fill-column 14) "pink elephants") ```