Emacs
Table of Contents
1. documentation
- The Craft of Text Editing, or Emacs for the Modern World, by Craig A. Finseth.
2. native compiler
4. org-mode
4.1. adding link types
- Org-mode custom youtube link syntax
https://emacs.stackexchange.com/questions/38098
5. persistence
;; creating a hashtable (setq myhash (make-hash-table :test 'equal)) ;; putting things in it (puthash "joe" 20 myhash) (puthash "john" 200 myhash) ;; printing it (print myhash) ;; #s(hash-table size 65 ;; test equal ;; rehash-size 1.5 ;; rehash-threshold 0.8125 ;; data ("joe" 20 "john" 200)) ;; #<hash-table equal 2/65 0x156e97c17f11> ;; writing it as a string (prin1-to-string myhash) "#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (\"joe\" 20 \"john\" 200))" ;; reading back from string and querying it (gethash "joe" (read-from-string "#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (\"joe\" 20 \"john\" 200))")) ;; → 20 (#o24, #x14, ?\C-t) ;; writing to a file (with-temp-file "~/shalala.el" (insert (prin1-to-string myhash))) ;; reading back from it, a helper function: ;; https://stackoverflow.com/a/20747279/1091982 (defun slurp-file (f) "Give me a file, and for thee I shall regurgitate its content as a string." (with-temp-buffer (insert-file-contents f) (buffer-substring-no-properties (point-min) (point-max)))) ;; get it back: (setq myhash (car (read-from-string (slurp-file "/medha/lalala.el"))))
6. insert colored text
(insert (let ((tmp "lalala")) (put-text-property 0 (length tmp) 'font-lock-face '(:foreground "orange" :weight bold :slant italic) tmp) tmp))
To find in which character the cursor currently is: (what-cursor-position)
To find the text properties of a character: (text-properties-at 1)
To apply a face to a string:
(insert (let ((tmp "lalala")) (put-text-property 0 (length tmp) 'font-lock-face 'diff-error tmp) tmp))
Or, with my function: (insert (add-properties-to-string "lalala" 'dired-broken-symlink))
7. variables
Files may define local variables, since ancient times, on the first
line using this form: -*- mode:lisp; base:8 -*
. There are functions
for manipulating this:
add-file-local-variable-prop-line
Another way is putting them at the end of the file. Check the link above.
8. command list
9. zmacs
9.1. commands
COM-VARIOUS-QUANTITIES
did much more than whatC-q
does today. I’ve found very few mentions around: