@alvaro
sign in · lmno.lol

Learning Emacs lisp

(setq-local my-clever-var)
(add-hook 'write-file-hooks
          (lambda ()
            (message "about to save!")))
(make-comint NAME PROGRAM &optional STARTFILE &rest SWITCHES)
(setq my-marker (copy-marker (point)))
  #<marker at 10251 in *ielm*>

(marker-buffer my-marker)
  #<buffer *ielm*>

(marker-position my-marker)
  10251 (#o24013, #x280b, ?⠋)
(org-get-heading 'no-tags 'no-todo)

(substring-no-properties STRING &optional FROM TO)

Return a substring of STRING, without text properties. It starts at index FROM and ends before TO. TO may be nil or omitted; then the substring runs to the end of STRING. If FROM is nil or omitted, the substring starts at the beginning of STRING. If FROM or TO is negative, it counts from the end.

(org-end-of-meta-data-and-drawers)
(org-open-link-from-string "[[#%exciting-custom-id]]")
(let ((my-var (list "val1"
                    "val2"
                    "val3")))
  (pp-to-string my-var))
(re-search-forward "needle"
                   nil t)
(match-beginning 0) ;; Start location of match from last search.
(match-end 0) ;; End location of match from last search.
(replace-match "love")

;; needle-in-haystack
(narrow-to-region (point)
                  (point-max))
(save-restriction (narrow-to-region (point)
                                    (point-max))
(save-excursion (goto-char (point-max))
                (insert "Hello elisp."))
(concat "Hello " "elisp " "world.")
(thing-at-point 'word)
(thing-at-point 'symbol)
(thing-at-point 'line)
(dolist (v '("a" "b" "c"))
  (print v))
(with-current-buffer (get-buffer-create "*some buffer*")
  (princ '(some list to print)
         (current-buffer)))
(with-temp-buffer
  (insert "abc")
  (point))
(string-match-p REGEXP STRING &optional START)
(setq haystack "Always click [[http://reddit.com/r/emacs][here]].")
(setq needle-re "\\[\\[\\(.*\\)]\\[\\(.*\\)]]")
  "\\[\\[\\(.*\\)]\\[\\(.*\\)]]"

(string-match needle-re haystack)
  13 (#o15, #xd, ?\C-m)

(match-string 0 haystack)
  "[[http://reddit.com/r/emacs][here]]"

(match-string 1 haystack)
  "http://reddit.com/r/emacs"

(match-string 2 haystack)
  "here"
(identity ARG)
(org-insert-time-stamp (current-time))
(car LIST)
(cdr LIST)
(push NEWELT PLACE)
(mapcar FUNCTION SEQUENCE)
(while (search-forward "Hello")
  (replace-match "Bonjour"))