2 ms·
Also here's a emacs lisp snippet for window switching that I never managed to publish but I just can't use emacs without it. With it I press super+left and supe
by nextaccountic 4y ago
Also here's a emacs lisp snippet for window switching that I never managed to publish but I just can't use emacs without it. With it I press super+left and super+right to cycle windows such that if I'm on a non-asterisk buffer, it cycles only through such kind of buffer (and scratch), but if I'm on an asterisk* buffer (except scratch), it cycles only through asterisk buffers, skipping some bad buffers. And super+up goes to a non-asterisk buffer, and super+down goes to an asterisk buffer:
https://github.com/dlight/dotemacs/blob/master/bindings.el#L274 https://github.com/dlight/dotemacs/blob/master/bindings.el#L...
This is brittle-looking but I didn't know how to test if a buffer is special other than checking the buffer name (I'm sure there's a better way). Anyway I kept looking if emacs already had this, but apparently not
Maybe someone will think it is useful so:
(defun keys (a)
(when a
(global-set-key (read-kbd-macro (nth 0 a)) (nth 1 a))
(keys (cddr a))))
(keys '(
"<s-left>" my-previous-buffer
"<s-right>" my-next-buffer
"<s-up>" next-regular-buffer
"<s-down>" previous-star-buffer
))
(defun switch-to-previous-buffer ()
(interactive)
(switch-to-buffer (other-buffer)))
(defun matching-buffer ()
;(string-match "^\\*.*\\*$" (buffer-name)))
(string-match "^\\*.*$" (buffer-name)))
(defun my-next-buffer ()
(interactive)
(if (matching-buffer)
(next-star-buffer)
(next-regular-buffer)))
(defun my-previous-buffer ()
(interactive)
(if (matching-buffer)
(previous-star-buffer)
(previous-regular-buffer)))
(defun next-regular-buffer ()
(interactive)
(next-buffer)
(if (matching-buffer)
(next-regular-buffer)))
(defun next-regular-buffer-or-scratch ()
(interactive)
(next-buffer)
(if (and (matching-buffer)
(not (equal "*scratch*" (buffer-name))))
(next-regular-buffer-or-scratch)))
(defun previous-regular-buffer ()
(interactive)
(previous-buffer)
(if (matching-buffer)
(previous-regular-buffer)))
(defun bad-buffer (a)
(member a '("*Backtrace*"
"*Completions*"
"*Messages*"
"*Help*"
"*Egg:Select Action*")))
(defun next-star-buffer ()
(interactive)
(next-buffer)
(if (or (not (matching-buffer))
(bad-buffer (buffer-name)))
(next-star-buffer)))
(defun previous-star-buffer ()
(interactive)
(previous-buffer)
(if (or (not (matching-buffer))
(bad-buffer (buffer-name)))
(previous-star-buffer)))