Simplify goto-speedbar function
This commit is contained in:
parent
35fb803dec
commit
0cf085f2dd
@ -130,18 +130,22 @@
|
|||||||
(global-set-key (kbd "M-o") 'other-window)
|
(global-set-key (kbd "M-o") 'other-window)
|
||||||
|
|
||||||
;; Scroll up/down, but keep point in place.
|
;; Scroll up/down, but keep point in place.
|
||||||
(global-set-key (kbd "C-<") (lambda() (interactive)
|
(global-set-key (kbd "C-<") (lambda()
|
||||||
|
(interactive)
|
||||||
(let ((scroll-preserve-screen-position nil))
|
(let ((scroll-preserve-screen-position nil))
|
||||||
(scroll-down 1))))
|
(scroll-down 1))))
|
||||||
(global-set-key (kbd "C->") (lambda() (interactive)
|
(global-set-key (kbd "C->") (lambda()
|
||||||
|
(interactive)
|
||||||
(let ((scroll-preserve-screen-position nil))
|
(let ((scroll-preserve-screen-position nil))
|
||||||
(scroll-up 1))))
|
(scroll-up 1))))
|
||||||
|
|
||||||
;; Setup key-bindings for switching between themes.
|
;; Setup key-bindings for switching between themes.
|
||||||
(global-set-key (kbd "C-x t l") '(lambda () (interactive)
|
(global-set-key (kbd "C-x t l") (lambda ()
|
||||||
|
(interactive)
|
||||||
(load-theme 'havoc-light t)
|
(load-theme 'havoc-light t)
|
||||||
(refresh-non-face-colours)))
|
(refresh-non-face-colours)))
|
||||||
(global-set-key (kbd "C-x t d") '(lambda () (interactive)
|
(global-set-key (kbd "C-x t d") (lambda ()
|
||||||
|
(interactive)
|
||||||
(load-theme 'havoc-dark t)
|
(load-theme 'havoc-dark t)
|
||||||
(refresh-non-face-colours)))
|
(refresh-non-face-colours)))
|
||||||
|
|
||||||
|
@ -139,7 +139,8 @@
|
|||||||
(add-hook 'racer-mode-hook #'eldoc-mode)
|
(add-hook 'racer-mode-hook #'eldoc-mode)
|
||||||
:config
|
:config
|
||||||
(setq-default
|
(setq-default
|
||||||
racer-rust-src-path "~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/")
|
racer-rust-src-path
|
||||||
|
"~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/")
|
||||||
|
|
||||||
(require 'rust-mode)
|
(require 'rust-mode)
|
||||||
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
|
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
|
||||||
@ -157,54 +158,17 @@
|
|||||||
(setq-default
|
(setq-default
|
||||||
sr-speedbar-skip-other-window-p t
|
sr-speedbar-skip-other-window-p t
|
||||||
sr-speedbar-right-side nil
|
sr-speedbar-right-side nil
|
||||||
speedbar-show-unknown-files t)
|
speedbar-show-unknown-files t
|
||||||
|
sr-speedbar-delete-windows t)
|
||||||
(defun x-before-save-selected-window ()
|
|
||||||
(cons (selected-window)
|
|
||||||
;; We save and restore all frames' selected windows, because
|
|
||||||
;; `select-window' can change the frame-selected-window of
|
|
||||||
;; whatever frame that window is in. Each text terminal's
|
|
||||||
;; top-frame is preserved by putting it last in the list.
|
|
||||||
(apply #'append
|
|
||||||
(mapcar (lambda (terminal)
|
|
||||||
(let ((frames (frames-on-display-list terminal))
|
|
||||||
(top-frame (tty-top-frame terminal))
|
|
||||||
alist)
|
|
||||||
(if top-frame
|
|
||||||
(setq frames
|
|
||||||
(cons top-frame
|
|
||||||
(delq top-frame frames))))
|
|
||||||
(dolist (f frames)
|
|
||||||
(push (cons f (frame-selected-window f))
|
|
||||||
alist))
|
|
||||||
alist))
|
|
||||||
(terminal-list)))))
|
|
||||||
|
|
||||||
(defun x-after-save-selected-window (state)
|
|
||||||
(dolist (elt (cdr state))
|
|
||||||
(and (frame-live-p (car elt))
|
|
||||||
(window-live-p (cdr elt))
|
|
||||||
(set-frame-selected-window (car elt) (cdr elt) 'norecord)))
|
|
||||||
(when (window-live-p (car state))
|
|
||||||
(select-window (car state) 'norecord)))
|
|
||||||
|
|
||||||
(defun goto-speedbar ()
|
(defun goto-speedbar ()
|
||||||
"Change window to speedbar's window.
|
"Set the speedbar window as the active window."
|
||||||
This function assumes that the speedbar is either the left-
|
|
||||||
or right-most window"
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((selected-window (x-before-save-selected-window)))
|
(if (window-live-p sr-speedbar-window)
|
||||||
(loop
|
(set-frame-selected-window (window-frame) sr-speedbar-window)
|
||||||
(condition-case nil
|
(user-error "Speedbar window is not live")))
|
||||||
(if sr-speedbar-right-side
|
|
||||||
(windmove-right)
|
|
||||||
(windmove-left))
|
|
||||||
(user-error (progn
|
|
||||||
(unless (string= major-mode "speedbar-mode")
|
|
||||||
(x-after-save-selected-window selected-window))
|
|
||||||
(return)))))))
|
|
||||||
|
|
||||||
(global-set-key (kbd "M-m") #'goto-speedbar))
|
(global-set-key (kbd "M-m") #'goto-speedbar)
|
||||||
|
|
||||||
;; --------------------------------------------------------------------------
|
;; --------------------------------------------------------------------------
|
||||||
;; Enable yasnippet.
|
;; Enable yasnippet.
|
||||||
@ -312,7 +276,7 @@
|
|||||||
(propertize " " 'face 'mode-line-inactive)))
|
(propertize " " 'face 'mode-line-inactive)))
|
||||||
|
|
||||||
(setq-default linum-format 'linum-format-func)
|
(setq-default linum-format 'linum-format-func)
|
||||||
(add-hook 'prog-mode-hook '(lambda ()
|
(add-hook 'prog-mode-hook (lambda ()
|
||||||
(unless (> (count-lines (point-min) (point-max))
|
(unless (> (count-lines (point-min) (point-max))
|
||||||
9999)
|
9999)
|
||||||
(linum-mode))))
|
(linum-mode))))
|
||||||
|
Reference in New Issue
Block a user