This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; TODO: package this? | |
(defadvice basic-save-buffer-2 (around fix-unwritable-save-with-sudo activate) | |
"When we save a buffer which is write-protected, try to sudo-save it. | |
When the buffer is write-protected it is usually opened in | |
read-only mode. Use \\[read-only-mode] to toggle | |
`read-only-mode', make your changes and \\[save-buffer] to save. | |
Emacs will warn you that the buffer is write-protected and asks | |
you to confirm if you really want to save. If you answer yes, | |
Emacs will use sudo tramp method to save the file and then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defadvice org-archive-subtree (around fix-hierarchy activate) | |
(let* ((fix-archive-p (and (not current-prefix-arg) | |
(not (use-region-p)))) | |
(afile (org-extract-archive-file (org-get-local-archive-location))) | |
(buffer (or (find-buffer-visiting afile) (find-file-noselect afile)))) | |
ad-do-it | |
(when fix-archive-p | |
(with-current-buffer buffer | |
(goto-char (point-max)) | |
(while (org-up-heading-safe)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Variable G : Set. | |
Variable e : G. | |
Variable inv : G -> G. | |
Variable mult : G -> G -> G. | |
Infix "*" := mult. | |
Axiom left_id : forall x : G, e * x = x. | |
Axiom left_inv : forall x : G, inv x * x = e. | |
Axiom assoc : forall x y z : G, x * (y * z) = (x * y) * z. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Practical cooperative threading in emacs 25 using generators. | |
;; Requires generator.el library of emacs 25 (can be used stand-alone | |
;; on anything 24.3+) | |
;; Eval the next three forms. To start the computation, run the | |
;; timer. | |
(fset 'foo | |
(iter-lambda () | |
(let ((i 0)) | |
;; limit to 3 interupts for demo purposes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
All these operations are very natural for buffer objects as well as | |
strings, which leads me to the conclusion we should provide two | |
flavours for each function, for buffers and for strings. The way | |
emacs does it is by specifying an =object= argument. I find this | |
suboptimal, but it is also possible solution (and would reduce the | |
number of functions in half). /Note that there are also different | |
indexing conventions, see the Question below./ | |
All functions come in buffer and string flavours. The "current | |
position" is called =point= in buffer versions and =offset= in string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let* ((plist1 '(:a 1 :b 2)) | |
(plist2 '(:b 3 :c 4)) | |
(both (-concat plist1 plist2)) | |
(-compare-fn (-on 'equal 'car))) | |
(-flatten-n 1 (-distinct (-partition 2 both)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-dired-insert-git-ls-files (path) | |
(let* ((full-path (file-truename path)) | |
(default-directory path) | |
(buf (with-current-buffer (get-buffer-create " git-ls-files") | |
(erase-buffer) | |
(current-buffer)))) | |
(call-process "git" | |
nil | |
buf | |
nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cl--foo | |
cl-loop | |
(setq hide-prefix-last-point (cl-remove-if foo bar)) | |
("\\_<\\(cl--\\)\\(\\(\\sw\\|\\s_\\)+\\)" | |
(1 (progn (my-hide-prefix (match-beginning 1) (match-end 1)) nil)) | |
(2 font-lock-constant-face)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-let-to-let* () | |
(interactive) | |
(save-excursion | |
(while (and (sp-beginning-of-sexp '(4)) (not (string-prefix-p (or (word-at-point) "x") "let")))) | |
(sp-forward-sexp) | |
(if (looking-back "\\*") | |
(delete-backward-char 1) | |
(insert "*")))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-find-function-subs-arguments (form) | |
;; first thing in form is the function name | |
(let ((name (symbol-name (car form))) | |
(cur-param-index 1) | |
args cur-param-name) | |
(save-excursion | |
(goto-char 1) | |
(re-search-forward (concat "(defun " name)) | |
;; replace the arguments. The next form is the argument form |