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
;; predicates... I'm not sure yet how to call it. I don't want the | |
;; -p suffix, because that's used internally and there migth be | |
;; some clashes. I think sp-pred- is a good indicator, at least | |
;; for the built-in stuff. | |
(defun sp-pred-in-string (id action context) | |
"Return t if point is inside string or comment, nil otherwise." | |
(eq context :string)) | |
(defun sp-pred-in-code (id action context) |
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 -slice (list &optional from to) | |
"Return copy of LIST, starting from index FROM to index TO. | |
FROM or TO may be negative" | |
(setq from (or from 0)) | |
(setq to (or to 0)) | |
(let ((from-list list) | |
(result-list nil) | |
(index 0) | |
(len 0)) | |
(cond |
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
(defcustom sp-base-key-bindings nil | |
"A default set of key bindings for commands provided by smartparens. | |
Paredit binding adds the paredit bindings to the corresponding | |
smartparens commands. It does not add bindings to any other | |
commands, or commands that do not have a paredit counterpart. | |
Smartparens binding adds bindings to most common smartparens | |
commands. These are somewhat inspired by paredit, but in many | |
cases differ. |
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 |
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
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-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
(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
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
;; 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 |
OlderNewer