Created
January 11, 2018 13:16
-
-
Save arielshaqed/5f31850039fa62b7eda6603b24cd0bf6 to your computer and use it in GitHub Desktop.
Emacs: helm commands with other-window defaults
This file contains 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
;;; Versions of helm commands that usefully replace `find-file-other-window' | |
;;; and `switch-to-buffer-other-window'. They work by replacing the default | |
;;; action and calling the actual helm functions. | |
(defun as-alist-move-cdr-first (alist cdr-value) | |
"Returns a copy of alist, but with the (first) element with CDR cdr-value at its head." | |
(let ((first (rassoc cdr-value alist))) | |
(if first | |
(cons first (map-remove #'(lambda (key value) (equal value cdr-value)) alist)) | |
alist))) | |
;; Bind this to [C-x 4 C-f]. | |
(defun as-helm-ff-other-window (arg) | |
"`helm-find-files' with a default action for `find-file-other-window'." | |
(interactive "P") | |
(let ((helm-find-files-actions | |
(as-alist-move-cdr-first helm-find-files-actions 'helm-find-files-other-window))) | |
(helm-find-files arg))) | |
;; Bind this to [C-x 4 b] | |
(defun as-helm-mini-other-window nil | |
"`helm-mini' with a default action for buffers to use other window." | |
(interactive) | |
(let ((helm-type-buffer-actions | |
(as-alist-move-cdr-first helm-type-buffer-actions 'helm-buffer-switch-buffers-other-window))) | |
(helm-mini))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New to helm?
Keep on hitting
C-x 4 f
,C-x 4 b
?Me too! Instead of training my fingers, I decided to train Emacs. After binding keys to these 2 commands, I get to
...-other-window
whenever I like. It just works...