2025-03-05 11:47:46 +01:00

26 lines
661 B
EmacsLisp

;; Eksempel på elisp-kode.
(defun show-kill-ring ()
"Shows the contents of the kill ring in another window."
(interactive)
(let ((buf (get-buffer-create "*kill ring*"))
(i 0))
(save-excursion
(set-buffer buf)
(delete-region (point-min) (point-max))
(dolist (item kill-ring)
(setq i (1+ i))
(insert (format "%d: %s\n" i
(replace-regexp-in-string
"\n" "\\\\n"
(cut-string item 70 "..."))))))
(display-buffer buf)))
(defun cut-string (str len ellipsis)
(if (> (length str) len)
(concat (substring str 0 (- len (length ellipsis)))
ellipsis)
str))
(global-set-key (kbd "C-x C-y") 'show-kill-ring)