simple useful functions from Tak Ota
[elbb.git] / elbb-example-page.org
blobf0e0702334c1aa98dea32ad1f420324143562d9b
1 #+TITLE:    ELBB - Example of page with code
2 #+STARTUP:  odd hidestars unfold
3 #+AUTHOR:   Emacs Community
4 #+EMAIL:    bzg AT gnu DOT org
5 #+LANGUAGE: en
6 #+OPTIONS:  skip:nil toc:nil
8 [Back to the [[file:index.org][index]] page.]
10 This page contain some blocks of code and some samples of Org-mode's syntax.
12 * Fixed-width sections of code
14 : (substring "abcdefg" 0 3)
15 :   ==> "abc"
16 : (substring "abcdefg" -3 -1)
17 :   ==> "ef"
19 * BEGIN_EXAMPLE
21 #+BEGIN_EXAMPLE
22 (substring "abcdefg" 0 3)
23   ==> "abc"
24 (substring "abcdefg" -3 -1)
25   ==> "ef"
26 #+END_EXAMPLE
28 * BEGIN_SRC
30 #+BEGIN_SRC emacs-lisp
31 (defun chomp (str)
32   "..."
33   (let ((s (if (symbolp str)(symbol-name str) str)))
34     (save-excursion
35       (while (and
36               (not (null (string-match "^\\( \\|\f\\|\t\\|\n\\)" s)))
37               (> (length s) (string-match "^\\( \\|\f\\|\t\\|\n\\)" s)))
38         (setq s (replace-match "" t nil s)))
39       (while (and
40               (not (null (string-match "\\( \\|\f\\|\t\\|\n\\)$" s)))
41               (> (length s) (string-match "\\( \\|\f\\|\t\\|\n\\)$" s)))
42         (setq s (replace-match "" t nil s))))
43     s))
44 #+END_SRC
47 Read more on [[http://orgmode.org/manual/Literal-examples.html][Org's manual]].