Skip to content

Instantly share code, notes, and snippets.

(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)
(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)
;; -*- lexical-binding: t; -*-
(defun test9 ()
(let ((a '(10)))
(setcar a (* 2 (car a)))
a))
(test9) ; 20
(test9) ; 40
(test9) ; 80
(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)")
(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)")
(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)))
(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]
(pp '(current-active-maps :aaaaaaaaaa
bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb adasd :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :aaaaaaaaaa bbbbbbbbbb :AAAAAAAAAA BBBBBBBBBB))
qq
(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)
"
(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))))))))