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 display-buffer-above-selected (buffer alist) | |
"Try displaying BUFFER in a window below the selected window. | |
This either splits the selected window or reuses the window below | |
the selected one." | |
(let (window) | |
(or (and (setq window (window-in-direction 'above)) | |
(eq buffer (window-buffer window)) | |
(window--display-buffer buffer window 'reuse alist)) | |
(and (not (frame-parameter nil 'unsplittable)) | |
(let ((split-height-threshold 0) |
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 display-buffer-above-selected (buffer alist) | |
"Try displaying BUFFER in a window below the selected window. | |
This either splits the selected window or reuses the window below | |
the selected one." | |
(let (window) | |
(or (and (setq window (window-in-direction 'above)) | |
(eq buffer (window-buffer window)) | |
(window--display-buffer buffer window 'reuse alist)) | |
(and (not (frame-parameter nil 'unsplittable)) | |
(let ((split-height-threshold 0) |
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
;; -*- lexical-binding: t; -*- | |
(defun test9 () | |
(let ((a '(10))) | |
(setcar a (* 2 (car a))) | |
a)) | |
(test9) ; 20 | |
(test9) ; 40 | |
(test9) ; 80 |
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-defun test (&key bar) | |
(message "bar: %s" bar)) | |
(test :bar 'qwe) | |
;; "bar: qwe" | |
(cl-defun test (&rest foo &key bar) | |
(message "foo: %s bar: %s" foo bar)) | |
(test 'qwe :bar 'asd) | |
;; (error "Keyword argument qwe not one of (:bar)") |
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-defun test (&key bar) | |
(message "bar: %s" bar)) | |
(test :bar 'qwe) | |
;; "bar: qwe" | |
(cl-defun test (&rest foo &key bar) | |
(message "foo: %s bar: %s" foo bar)) | |
(test 'qwe :bar 'asd) | |
;; (error "Keyword argument qwe not one of (:bar)") |
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-defun transient-map (command &rest bindings &key keep-pred | |
on-exit &allow-other-keys) | |
(unless (commandp command) (push command bindings) | |
(setq command nil)) | |
(let* ((keymap (-map (-applify 'cons) (-partition 2 bindings)))) | |
(set-transient-map (easy-mmode-define-keymap keymap) keep-pred on-exit)) | |
(when command (call-interactively command))) |
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
(setq-default scroll-up-aggressively 0.0) | |
(add-hook 'post-command-hook | |
(defun recenter+ () | |
(unless (and (symbolp this-command) (get this-command 'scroll-command)) | |
(with-current-buffer (window-buffer) | |
(recenter (- (1+ (save-excursion | |
(vertical-motion (floor (window-screen-lines) 2)))))))))) | |
(define-key global-map [remap scroll-down-command] | |
(defun move-to-top-line () (interactive) (move-to-window-line 1))) | |
(define-key global-map [remap scroll-up-command] |
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
(pp '(current-active-maps :aaaaaaaaaa | |
bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb adasd :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :AAAAAAAAAA BBBBBBBBBB)) | |
(current-active-maps :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb adasd :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :AAAAAAAAAA BBBBBBBBBB) | |
"(current-active-maps :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb adasd :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :AAAAAAAAAA BBBBBBBBBB) | |
" |
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
M-x |
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
(advice-add 'describe-prefix-bindings :after | |
(defun another-chance? (&rest args) | |
(unless (key-binding (this-command-keys)) | |
(let ((path (listify-key-sequence (this-command-keys-vector)))) | |
(set-transient-map (key-binding (vconcat (butlast path)))))))) |