2022-05-22 20:42:53 +02:00
|
|
|
#+title: Random Notes on Emacs
|
2019-12-19 10:46:15 +01:00
|
|
|
#+author: Various
|
2019-12-22 21:57:50 +01:00
|
|
|
#+filetags: NOTE
|
2019-02-09 17:53:53 +01:00
|
|
|
|
2019-02-09 18:23:54 +01:00
|
|
|
#+options: toc:t
|
|
|
|
|
2019-12-19 11:04:49 +01:00
|
|
|
This is a small collection of Emacs related posts and documentation by other
|
|
|
|
authors that I find useful.
|
|
|
|
|
2022-05-22 20:42:53 +02:00
|
|
|
* Fractals in Emacs
|
2019-12-30 13:35:58 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:CREATED: [2018-08-04 Sat 13:01]
|
|
|
|
:END:
|
2019-12-19 10:53:43 +01:00
|
|
|
|
2019-12-30 13:35:58 +01:00
|
|
|
From https://nullprogram.com/blog/2012/09/14/
|
2019-12-19 10:53:43 +01:00
|
|
|
|
2019-12-30 13:35:58 +01:00
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(defun sierpinski (s)
|
|
|
|
(pop-to-buffer (get-buffer-create "*sierpinski*"))
|
|
|
|
(fundamental-mode) (erase-buffer)
|
|
|
|
(labels ((fill-p (x y)
|
|
|
|
(cond ((or (zerop x) (zerop y)) "0")
|
|
|
|
((and (= 1 (mod x 3)) (= 1 (mod y 3))) "1")
|
|
|
|
(t (fill-p (/ x 3) (/ y 3))))))
|
|
|
|
(insert (format "P1\n%d %d\n" s s))
|
|
|
|
(dotimes (y s) (dotimes (x s) (insert (fill-p x y) " "))))
|
|
|
|
(image-mode))
|
2019-12-19 10:53:43 +01:00
|
|
|
|
2019-12-30 13:35:58 +01:00
|
|
|
(defun mandelbrot ()
|
|
|
|
(pop-to-buffer (get-buffer-create "*mandelbrot*"))
|
|
|
|
(let ((w 400) (h 300) (d 32))
|
|
|
|
(fundamental-mode) (erase-buffer)
|
|
|
|
(set-buffer-multibyte nil)
|
|
|
|
(insert (format "P6\n%d %d\n255\n" w h))
|
|
|
|
(dotimes (y h)
|
|
|
|
(dotimes (x w)
|
|
|
|
(let* ((cx (* 1.5 (/ (- x (/ w 1.45)) w 0.45)))
|
|
|
|
(cy (* 1.5 (/ (- y (/ h 2.0)) h 0.5)))
|
|
|
|
(zr 0) (zi 0)
|
|
|
|
(v (dotimes (i d d)
|
|
|
|
(if (> (+ (* zr zr) (* zi zi)) 4) (return i)
|
|
|
|
(psetq zr (+ (* zr zr) (- (* zi zi)) cx)
|
|
|
|
zi (+ (* (* zr zi) 2) cy))))))
|
|
|
|
(insert-char (floor (* 256 (/ v 1.0 d))) 3))))
|
|
|
|
(image-mode)))
|
|
|
|
#+end_src
|
2019-02-09 18:03:39 +01:00
|
|
|
|
2022-05-22 20:42:53 +02:00
|
|
|
* Emacs reencode buffers with other encoding
|
2019-02-09 18:03:39 +01:00
|
|
|
|
2019-12-30 13:35:58 +01:00
|
|
|
- Use the function =revert-buffer-with-coding-system= to re-open a buffer in
|
|
|
|
another encoding.
|
2019-02-09 18:03:39 +01:00
|
|
|
|
2019-12-30 13:35:58 +01:00
|
|
|
- Customize the variable =file-coding-system-alist= to control whether certain
|
|
|
|
files should always be opened with a specific encoding.
|
2019-02-09 18:03:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-30 13:19:18 +01:00
|
|
|
|
|
|
|
|