Emacs Lisp Programming

use org-struct mode for emacs-lisp.

(add-hook 'emacs-lisp-mode-hook '(lambda ()
                              (turn-on-orgstruct)
                              (setq-local orgstruct-heading-prefix-regexp ";;;; ")))

(rep “a” 3) –> “aaa”

(defun yt/lisp-rep (arg n)
  (apply 'concat (make-list n arg)))

Org-Mode API

Get the link to current headline as an external link.

(defun yt/org-get-heading-link ()
  (interactive)
  (let* ((file-name (file-truename buffer-file-name))
         (headline (org-heading-components))
         (level (nth 0 headline))
         (title (nth 4 headline))
         (link (concat file-name
                       "::"
                       "*" ;; (yt/lisp-rep "*" level)
                       title)))
    (kill-new (concat "[["
                      link
                      "]["
                      title
                      "]]"))))