Skip to content

Commit

Permalink
remove attempt to use perspective aware prev/next buffer switcher
Browse files Browse the repository at this point in the history
fix from nex3/perspective-el#63
does not work correctly, it switches by alphabetical sort and
not chronologically
  • Loading branch information
kakulo83 committed Sep 29, 2022
1 parent 414d3c5 commit 8f55952
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
25 changes: 0 additions & 25 deletions config/functions.el
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,3 @@
(split-window-horizontally)
(find-file "~/.zshrc")))
vterm-eval-cmds)

;; next-buffer and prev-buffer will violate the scope of the current perspective
;; and show buffers from other perspectives
;; The following functions attempt to remediate this.
;; Taken from (https://github.com/nex3/perspective-el/issues/63)
(defun my/persp-get-buffers-list ()
"Get filtered list of buffers, sorted alphabetically."
(sort
(cl-remove-if '(lambda (b) (if (stringp b) (string-match "^\[* \]" b) t))
(mapcar 'buffer-name (persp-buffers (persp-curr))))
'string<))

(defun my/persp-next-buffer ()
"My own version of `next-buffer'. Don't show internal buffers."
(interactive)
(let ((buffername (buffer-name (current-buffer)))
(bufferlist (my/persp-get-buffers-list)))
(switch-to-buffer (or (cadr (member buffername bufferlist)) (car bufferlist)))))

(defun my/persp-previous-buffer ()
"My own version of `next-buffer'. Don't show internal buffers"
(interactive)
(let ((buffername (buffer-name (current-buffer)))
(bufferlist (reverse (my/persp-get-buffers-list))))
(switch-to-buffer (or (cadr (member buffername bufferlist)) (car bufferlist)))))
4 changes: 2 additions & 2 deletions config/keybindings.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

(define-key evil-normal-state-map (kbd "n") 'isearch-repeat-forward)
(define-key evil-normal-state-map (kbd "N") 'isearch-repeat-backward)
(define-key evil-normal-state-map (kbd "C-o") 'my/persp-previous-buffer)
(define-key evil-normal-state-map (kbd "C-i") 'my/persp-next-buffer)
(define-key evil-normal-state-map (kbd "C-o") 'switch-to-prev-buffer)
(define-key evil-normal-state-map (kbd "C-i") 'switch-to-next-buffer)
(define-key evil-normal-state-map "zc" nil)
(define-key evil-normal-state-map "zo" nil)
(define-key evil-normal-state-map "zM" nil)
Expand Down

0 comments on commit 8f55952

Please sign in to comment.